nus-yam/ex-repair huggingface dataset:
Program: 27221
Project: 27221
Buggy source:
public final void addChildToBack(Node child){
  checkArgument(child.parent == null,"String_Node_Str",child,parent,this);
  checkArgument(child.next == null);
  checkArgument(child.previous == null);
  if (first == null) {
    child.previous=child;
    first=child;
  }
 else {
    Node last=first.previous;
    last.next=child;
    child.previous=last;
    first.previous=child;
  }
  child.parent=this;
}

Fixed version (ground truth):
public final void addChildToBack(Node child){
  checkArgument(child.parent == null,"String_Node_Str",child,child.parent,this);
  checkArgument(child.next == null);
  checkArgument(child.previous == null);
  if (first == null) {
    child.previous=child;
    first=child;
  }
 else {
    Node last=first.previous;
    last.next=child;
    child.previous=last;
    first.previous=child;
  }
  child.parent=this;
}
Program: 27222
Project: 27222
Buggy source:
/** 
 * @param fnNode The function to inspect.
 * @return Whether the function has parameters, var, or function declarations.
 */
private static boolean hasLocalNames(Node fnNode){
  Node block=NodeUtil.getFunctionBody(fnNode);
  return NodeUtil.getFunctionParameters(fnNode).hasChildren() || NodeUtil.has(block,new NodeUtil.MatchDeclaration(),new NodeUtil.MatchShallowStatement());
}

Fixed version (ground truth):
/** 
 * @param fnNode The function to inspect.
 * @return Whether the function has parameters, var/const/let, class, or function declarations.
 */
private static boolean hasLocalNames(Node fnNode){
  Node block=NodeUtil.getFunctionBody(fnNode);
  return NodeUtil.getFunctionParameters(fnNode).hasChildren() || NodeUtil.has(block,new NodeUtil.MatchDeclaration(),new NodeUtil.MatchShallowStatement());
}
Program: 27223
Project: 27223
Buggy source:
/** 
 * see   {@link #isClassDeclaration}
 */
public static boolean isClassDeclaration(Node n){
  return n.isClass() && isDeclarationParent(n.getParent());
}

Fixed version (ground truth):
/** 
 * see   {@link #isClassDeclaration}
 */
public static boolean isClassDeclaration(Node n){
  return n.isClass() && isDeclarationParent(n.getParent()) && isNamedClass(n);
}
Program: 27224
Project: 27224
Buggy source:
private static boolean isDeclarationParent(Node parent){
switch (parent.getToken()) {
case DECLARE:
    return true;
case EXPORT:
  return !parent.getBooleanProp(Node.EXPORT_DEFAULT);
default :
return isStatementParent(parent);
}
}

Fixed version (ground truth):
private static boolean isDeclarationParent(Node parent){
switch (parent.getToken()) {
case DECLARE:
case EXPORT:
    return true;
default :
  return isStatementParent(parent);
}
}
Program: 27225
Project: 27225
Buggy source:
/** 
 * Is this node a function declaration? A function declaration is a function that has a name that is added to the current scope (i.e. a function that is not part of a expression; see   {@link #isFunctionExpression}).
 */
public static boolean isFunctionDeclaration(Node n){
  return n.isFunction() && isDeclarationParent(n.getParent());
}

Fixed version (ground truth):
/** 
 * Is this node a function declaration? A function declaration is a function that has a name that is added to the current scope (i.e. a function that is not part of a expression; see   {@link #isFunctionExpression}).
 */
public static boolean isFunctionDeclaration(Node n){
  return n.isFunction() && isDeclarationParent(n.getParent()) && isNamedFunction(n);
}
Program: 27226
Project: 27226
Buggy source:
/** 
 * Splits ES6 export combined with a variable or function declaration.
 */
private void splitExportDeclaration(Node n){
  Node c=n.getFirstChild();
  if (NodeUtil.isNameDeclaration(c) || c.isClass()) {
    n.removeChild(c);
    Node exportSpecs=new Node(Token.EXPORT_SPECS).srcref(n);
    n.addChildToFront(exportSpecs);
    Iterable<Node> names;
    if (c.isClass()) {
      names=Collections.singleton(c.getFirstChild());
      n.getParent().addChildBefore(c,n);
      n.getParent().addChildBefore(new Node(Token.EMPTY).srcref(n),n);
    }
 else {
      names=NodeUtil.getLhsNodesOfDeclaration(c);
      for (      Node child : c.children()) {
        c.removeChild(child);
        Node newDeclaration=new Node(c.getToken(),child).srcref(n);
        n.getParent().addChildBefore(newDeclaration,n);
      }
    }
    for (    Node name : names) {
      Node exportSpec=new Node(Token.EXPORT_SPEC).srcref(name);
      exportSpec.addChildToFront(name.cloneNode());
      exportSpec.addChildToFront(name.cloneNode());
      exportSpecs.addChildToBack(exportSpec);
    }
    compiler.reportChangeToEnclosingScope(n.getParent());
  }
}

Fixed version (ground truth):
/** 
 * Splits ES6 export combined with a variable or function declaration.
 */
private void splitExportDeclaration(Node n){
  if (n.getBooleanProp(Node.EXPORT_DEFAULT)) {
    return;
  }
  Node c=n.getFirstChild();
  if (NodeUtil.isDeclaration(c)) {
    n.removeChild(c);
    Node exportSpecs=new Node(Token.EXPORT_SPECS).srcref(n);
    n.addChildToFront(exportSpecs);
    Iterable<Node> names;
    if (c.isClass() || c.isFunction()) {
      names=Collections.singleton(c.getFirstChild());
      n.getParent().addChildBefore(c,n);
      if (c.isClass()) {
        n.getParent().addChildBefore(new Node(Token.EMPTY).srcref(n),n);
      }
    }
 else {
      names=NodeUtil.getLhsNodesOfDeclaration(c);
      for (      Node child : c.children()) {
        c.removeChild(child);
        Node newDeclaration=new Node(c.getToken(),child).srcref(n);
        n.getParent().addChildBefore(newDeclaration,n);
      }
    }
    for (    Node name : names) {
      Node exportSpec=new Node(Token.EXPORT_SPEC).srcref(name);
      exportSpec.addChildToFront(name.cloneNode());
      exportSpec.addChildToFront(name.cloneNode());
      exportSpecs.addChildToBack(exportSpec);
    }
    compiler.reportChangeToEnclosingScope(n.getParent());
  }
}
Program: 27227
Project: 27227
Buggy source:
/** 
 * Rewrite named unhoisted functions declarations to a known consistent behavior so we don't to different logic paths for the same code. From: function f() {} to: var f = function () {}; and move it to the top of the block. This actually breaks semantics, but the semantics are also not well-defined cross-browser.
 * @see https://github.com/google/closure-compiler/pull/429
 */
static boolean visitFunction(Node n,AbstractCompiler compiler){
  checkState(n.isFunction(),n);
  if (NodeUtil.isFunctionDeclaration(n) && !NodeUtil.isHoistedFunctionDeclaration(n)) {
    rewriteFunctionDeclaration(n,compiler);
    return true;
  }
 else   if (n.isFunction() && !NodeUtil.getFunctionBody(n).isNormalBlock()) {
    Node returnValue=NodeUtil.getFunctionBody(n);
    Node body=IR.block(IR.returnNode(returnValue.detach()));
    body.useSourceInfoIfMissingFromForTree(returnValue);
    n.addChildToBack(body);
    compiler.reportChangeToEnclosingScope(body);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Rewrite named unhoisted functions declarations to a known consistent behavior so we don't to different logic paths for the same code. From: function f() {} to: var f = function () {}; and move it to the top of the block. This actually breaks semantics, but the semantics are also not well-defined cross-browser.
 * @see https://github.com/google/closure-compiler/pull/429
 */
static boolean visitFunction(Node n,AbstractCompiler compiler){
  checkState(n.isFunction(),n);
  if (NodeUtil.isFunctionDeclaration(n) && !NodeUtil.isHoistedFunctionDeclaration(n) && !n.getParent().isExport()) {
    rewriteFunctionDeclaration(n,compiler);
    return true;
  }
 else   if (n.isFunction() && !NodeUtil.getFunctionBody(n).isNormalBlock()) {
    Node returnValue=NodeUtil.getFunctionBody(n);
    Node body=IR.block(IR.returnNode(returnValue.detach()));
    body.useSourceInfoIfMissingFromForTree(returnValue);
    n.addChildToBack(body);
    compiler.reportChangeToEnclosingScope(body);
  }
  return false;
}
Program: 27228
Project: 27228
Buggy source:
public void testIsFunctionDeclaration(){
  assertTrue(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertTrue(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
}

Fixed version (ground truth):
public void testIsFunctionDeclaration(){
  assertTrue(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertTrue(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertTrue(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
  assertFalse(NodeUtil.isFunctionDeclaration(getFunctionNode("String_Node_Str")));
}
Program: 27229
Project: 27229
Buggy source:
public void testIsClassDeclaration(){
  assertTrue(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertTrue(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
}

Fixed version (ground truth):
public void testIsClassDeclaration(){
  assertTrue(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertTrue(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertTrue(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
  assertFalse(NodeUtil.isClassDeclaration(getClassNode("String_Node_Str")));
}
Program: 27230
Project: 27230
Buggy source:
public void testSplitExportDeclarationOfClass(){
  test("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testSplitExportDeclarationOfClass(){
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
}
Program: 27231
Project: 27231
Buggy source:
public void testSplitExportDeclarationOfFunction(){
  test("String_Node_Str",LINE_JOINER.join("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
public void testSplitExportDeclarationOfFunction(){
  test("String_Node_Str",LINE_JOINER.join("String_Node_Str","String_Node_Str"));
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27232
Project: 27232
Buggy source:
/** 
 * Given an object literal to export, create an object lit with all its string properties. We don't care what the values of those properties are because they are not checked.
 */
private Node createExternObjectLit(Node exportedObjectLit){
  Node lit=IR.objectlit();
  lit.setJSType(exportedObjectLit.getJSType());
  lit.setJSDocInfo(buildEmptyJSDoc());
  int index=1;
  for (Node child=exportedObjectLit.getFirstChild(); child != null; child=child.getNext()) {
    if (child.isStringKey()) {
      lit.addChildToBack(IR.propdef(IR.stringKey(child.getString()),IR.number(index++)));
    }
  }
  return lit;
}

Fixed version (ground truth):
/** 
 * Given an object literal to export, create an object lit with all its string properties. We don't care what the values of those properties are because they are not checked.
 */
private Node createExternObjectLit(Node exportedObjectLit){
  Node lit=IR.objectlit();
  lit.setTypeI(exportedObjectLit.getTypeI());
  lit.setJSDocInfo(buildEmptyJSDoc());
  int index=1;
  for (Node child=exportedObjectLit.getFirstChild(); child != null; child=child.getNext()) {
    if (child.isStringKey()) {
      lit.addChildToBack(IR.propdef(IR.stringKey(child.getString()),IR.number(index++)));
    }
  }
  return lit;
}
Program: 27233
Project: 27233
Buggy source:
/** 
 * Given a function to export, create the empty function that will be put in the externs file. This extern function should have the same type as the original function and the same parameter name but no function body. We create a warning here if the the function to export is missing parameter or return types.
 */
private Node createExternFunction(Node exportedFunction){
  Node paramList=NodeUtil.getFunctionParameters(exportedFunction).cloneTree();
  Node param=paramList.getFirstChild();
  while (param != null && param.isName()) {
    String originalName=param.getOriginalName();
    if (originalName != null) {
      param.setString(originalName);
    }
    param=param.getNext();
  }
  Node externFunction=IR.function(IR.name("String_Node_Str"),paramList,IR.block());
  if (exportedFunction.getJSType() != null) {
    externFunction.setJSType(exportedFunction.getJSType());
    deleteInlineJsdocs(externFunction);
  }
  return externFunction;
}

Fixed version (ground truth):
/** 
 * Given a function to export, create the empty function that will be put in the externs file. This extern function should have the same type as the original function and the same parameter name but no function body. We create a warning here if the the function to export is missing parameter or return types.
 */
private Node createExternFunction(Node exportedFunction){
  Node paramList=NodeUtil.getFunctionParameters(exportedFunction).cloneTree();
  Node param=paramList.getFirstChild();
  while (param != null && param.isName()) {
    String originalName=param.getOriginalName();
    if (originalName != null) {
      param.setString(originalName);
    }
    param=param.getNext();
  }
  Node externFunction=IR.function(IR.name("String_Node_Str"),paramList,IR.block());
  if (exportedFunction.getTypeI() != null) {
    externFunction.setTypeI(exportedFunction.getTypeI());
    deleteInlineJsdocs(externFunction);
  }
  return externFunction;
}
Program: 27234
Project: 27234
Buggy source:
StringBuilder appendTo(StringBuilder builder,ToStringContext ctx){
  if (isPrototypeObject()) {
    return builder.append(getOwnerFunction().getThisType()).append("String_Node_Str");
  }
  if (!hasNonPrototypeProperties()) {
    if (fn != null) {
      return fn.appendTo(builder,ctx);
    }
    return this.nominalType.appendTo(builder,ctx);
  }
  if (!nominalType.isFunction() && !nominalType.isBuiltinObject() && !nominalType.isLiteralObject()) {
    nominalType.appendTo(builder,ctx);
  }
 else   if (isStruct()) {
    builder.append("String_Node_Str");
  }
 else   if (isDict()) {
    builder.append("String_Node_Str");
  }
 else   if (this.ns != null) {
    builder.append(this.ns);
  }
  if (this.fn != null) {
    builder.append("String_Node_Str");
    fn.appendTo(builder,ctx);
    builder.append("String_Node_Str");
  }
  if (ns == null || !props.isEmpty()) {
    builder.append('{');
    boolean firstIteration=true;
    for (    String pname : new TreeSet<>(props.keySet())) {
      if (firstIteration) {
        firstIteration=false;
      }
 else {
        builder.append("String_Node_Str");
      }
      builder.append(pname);
      builder.append("String_Node_Str");
      props.get(pname).appendTo(builder,ctx);
    }
    builder.append('}');
  }
  if (isLoose) {
    builder.append("String_Node_Str");
  }
  return builder;
}

Fixed version (ground truth):
StringBuilder appendTo(StringBuilder builder,ToStringContext ctx){
  if (isPrototypeObject()) {
    return builder.append(getOwnerFunction().getThisType()).append("String_Node_Str");
  }
  if (ctx.forAnnotation()) {
    if (fn != null) {
      fn.appendTo(builder,ctx);
    }
 else     if (!props.isEmpty()) {
      appendPropsTo(builder,ctx);
    }
 else     if (nominalType.isLiteralObject()) {
      builder.append("String_Node_Str");
    }
 else {
      nominalType.appendTo(builder,ctx);
    }
    return builder;
  }
  if (!hasNonPrototypeProperties()) {
    if (fn != null) {
      return fn.appendTo(builder,ctx);
    }
    return this.nominalType.appendTo(builder,ctx);
  }
  if (!nominalType.isFunction() && !nominalType.isBuiltinObject() && !nominalType.isLiteralObject()) {
    nominalType.appendTo(builder,ctx);
  }
 else   if (isStruct()) {
    builder.append("String_Node_Str");
  }
 else   if (isDict()) {
    builder.append("String_Node_Str");
  }
 else   if (this.ns != null) {
    builder.append(this.ns);
  }
  if (this.fn != null) {
    builder.append("String_Node_Str");
    fn.appendTo(builder,ctx);
    builder.append("String_Node_Str");
  }
  if (ns == null || !props.isEmpty()) {
    appendPropsTo(builder,ctx);
  }
  if (isLoose) {
    builder.append("String_Node_Str");
  }
  return builder;
}
Program: 27236
Project: 27236
Buggy source:
private void addRetTypeAndWarn(NTIScope fn,TypeEnv exitEnv,DeclaredFunctionType declType,FunctionTypeBuilder builder){
  Node fnRoot=fn.getRoot();
  JSType declRetType=declType.getReturnType();
  JSType actualRetType=checkNotNull(envGetType(exitEnv,RETVAL_ID));
  if (declRetType != null) {
    if (fnRoot.isGeneratorFunction()) {
      JSType generator=this.commonTypes.getGeneratorInstance(UNKNOWN);
      if (!generator.isSubtypeOf(declRetType)) {
        registerMismatchAndWarn(JSError.make(fnRoot,INVALID_DECLARED_RETURN_TYPE_OF_GENERATOR_FUNCTION,errorMsgWithTypeDiff(generator,declRetType)),declRetType,generator);
        builder.addRetType(UNKNOWN);
      }
 else {
        builder.addRetType(declRetType);
      }
    }
 else {
      builder.addRetType(declRetType);
      if (!isAllowedToNotReturn(fn) && !UNDEFINED.isSubtypeOf(declRetType) && hasPathWithNoReturn(this.cfg)) {
        warnings.add(JSError.make(fnRoot,MISSING_RETURN_STATEMENT,declRetType.toString()));
      }
    }
  }
 else   if (fnRoot.isGeneratorFunction()) {
    JSType yieldType=envGetType(exitEnv,YIELDVAL_ID);
    builder.addRetType(this.commonTypes.getGeneratorInstance(firstNonNull(yieldType,UNKNOWN)));
  }
 else   if (declType.getNominalType() == null) {
    builder.addRetType(firstNonBottom(actualRetType,TOP));
  }
 else {
    builder.addRetType(UNDEFINED);
  }
}

Fixed version (ground truth):
private void addRetTypeAndWarn(NTIScope fn,TypeEnv exitEnv,DeclaredFunctionType declType,FunctionTypeBuilder builder){
  Node fnRoot=fn.getRoot();
  JSType declRetType=declType.getReturnType();
  JSType actualRetType=checkNotNull(envGetType(exitEnv,RETVAL_ID));
  if (declRetType != null) {
    if (fnRoot.isGeneratorFunction()) {
      JSType generator=this.commonTypes.getGeneratorInstance(UNKNOWN);
      if (!generator.isSubtypeOf(declRetType)) {
        registerMismatchAndWarn(JSError.make(fnRoot,INVALID_DECLARED_RETURN_TYPE_OF_GENERATOR_FUNCTION,errorMsgWithTypeDiff(generator,declRetType)),declRetType,generator);
        builder.addRetType(UNKNOWN);
      }
 else {
        builder.addRetType(declRetType);
      }
    }
 else {
      builder.addRetType(declRetType);
      if (!isAllowedToNotReturn(fn) && !UNDEFINED.isSubtypeOf(declRetType) && hasPathWithNoReturn(this.cfg)) {
        warnings.add(JSError.make(fnRoot,MISSING_RETURN_STATEMENT,declRetType.toString()));
      }
    }
  }
 else   if (fnRoot.isGeneratorFunction()) {
    JSType yieldType=envGetType(exitEnv,YIELDVAL_ID);
    builder.addRetType(this.commonTypes.getGeneratorInstance(firstNonNull(yieldType,UNKNOWN)));
  }
 else   if (declType.getNominalType() == null) {
    builder.addRetType(firstNonBottom(actualRetType,UNKNOWN));
  }
 else {
    builder.addRetType(UNDEFINED);
  }
}
Program: 27237
Project: 27237
Buggy source:
private TypeEnv getExitTypeEnv(){
  if (!this.cfg.getImplicitReturn().getInEdges().isEmpty()) {
    exitEnvs.add(getInEnv(this.cfg.getImplicitReturn()));
  }
  checkState(!exitEnvs.isEmpty(),"String_Node_Str");
  return TypeEnv.join(exitEnvs);
}

Fixed version (ground truth):
private TypeEnv getExitTypeEnv(){
  for (int i=0; i < exitEnvs.size(); i++) {
    TypeEnv env=exitEnvs.get(i);
    exitEnvs.set(i,envPutType(env,RETVAL_ID,BOTTOM));
  }
  if (!this.cfg.getImplicitReturn().getInEdges().isEmpty()) {
    exitEnvs.add(getInEnv(this.cfg.getImplicitReturn()));
  }
  checkState(!exitEnvs.isEmpty(),"String_Node_Str");
  return TypeEnv.join(exitEnvs);
}
Program: 27238
Project: 27238
Buggy source:
public void testFunctionsWithAbnormalExit(){
  typeCheck("String_Node_Str");
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_ARGUMENT_TYPE);
}

Fixed version (ground truth):
public void testFunctionsWithAbnormalExit(){
  typeCheck("String_Node_Str");
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str"));
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str"));
}
Program: 27239
Project: 27239
Buggy source:
private boolean evalTypePredicate(Node ttlAst,NameResolver nameResolver){
  TypeI[] params=evalTypeParams(ttlAst,nameResolver);
  String name=getCallName(ttlAst);
  Keywords keyword=nameToKeyword(name);
  TypeI type=params[0];
switch (keyword) {
case EQ:
    return type.isEquivalentTo(params[1]);
case SUB:
  return type.isSubtypeOf(params[1]);
case ISCTOR:
return type.isConstructor();
case ISTEMPLATIZED:
return type.isObjectType() && type.toMaybeObjectType().isGenericObjectType() && !type.hasUninstantiatedTypeVariables();
case ISRECORD:
return type.isRecordType();
case ISUNKNOWN:
return type.isSomeUnknownType();
default :
throw new IllegalStateException("String_Node_Str");
}
}

Fixed version (ground truth):
private boolean evalTypePredicate(Node ttlAst,NameResolver nameResolver){
  TypeI[] params=evalTypeParams(ttlAst,nameResolver);
  String name=getCallName(ttlAst);
  Keywords keyword=nameToKeyword(name);
  TypeI type=params[0];
switch (keyword) {
case EQ:
    return type.isEquivalentTo(params[1]);
case SUB:
  return type.isSubtypeOf(params[1]);
case ISCTOR:
return type.isConstructor();
case ISTEMPLATIZED:
return type.isObjectType() && type.toMaybeObjectType().isGenericObjectType();
case ISRECORD:
return type.isRecordType();
case ISUNKNOWN:
return type.isSomeUnknownType();
default :
throw new IllegalStateException("String_Node_Str");
}
}
Program: 27240
Project: 27240
Buggy source:
private TypeI evalTemplatizedType(Node ttlAst,NameResolver nameResolver){
  ImmutableList<Node> params=getCallParams(ttlAst);
  TypeI firstParam=evalInternal(params.get(0),nameResolver);
  if (!firstParam.hasUninstantiatedTypeVariables()) {
    reportWarning(ttlAst,BASETYPE_INVALID,firstParam.toString());
    return getUnknownType();
  }
  TypeI[] templatizedTypes=new TypeI[params.size() - 1];
  for (int i=0; i < templatizedTypes.length; i++) {
    templatizedTypes[i]=evalInternal(params.get(i + 1),nameResolver);
  }
  ObjectTypeI baseType=firstParam.toMaybeObjectType();
  return createTemplatizedType(baseType,templatizedTypes);
}

Fixed version (ground truth):
private TypeI evalTemplatizedType(Node ttlAst,NameResolver nameResolver){
  ImmutableList<Node> params=getCallParams(ttlAst);
  TypeI firstParam=evalInternal(params.get(0),nameResolver);
  if (firstParam.isFullyInstantiated()) {
    reportWarning(ttlAst,BASETYPE_INVALID,firstParam.toString());
    return getUnknownType();
  }
  TypeI[] templatizedTypes=new TypeI[params.size() - 1];
  for (int i=0; i < templatizedTypes.length; i++) {
    templatizedTypes[i]=evalInternal(params.get(i + 1),nameResolver);
  }
  ObjectTypeI baseType=firstParam.toMaybeObjectType();
  return createTemplatizedType(baseType,templatizedTypes);
}
Program: 27241
Project: 27241
Buggy source:
private boolean evalTypePredicate(Node ttlAst,NameResolver nameResolver){
  TypeI[] params=evalTypeParams(ttlAst,nameResolver);
  String name=getCallName(ttlAst);
  Keywords keyword=nameToKeyword(name);
  TypeI type=params[0];
switch (keyword) {
case EQ:
    return type.isEquivalentTo(params[1]);
case SUB:
  return type.isSubtypeOf(params[1]);
case ISCTOR:
return type.isConstructor();
case ISTEMPLATIZED:
return type.isObjectType() && type.toMaybeObjectType().isGenericObjectType();
case ISRECORD:
return type.isRecordType();
case ISUNKNOWN:
return type.isSomeUnknownType();
default :
throw new IllegalStateException("String_Node_Str");
}
}

Fixed version (ground truth):
private boolean evalTypePredicate(Node ttlAst,NameResolver nameResolver){
  TypeI[] params=evalTypeParams(ttlAst,nameResolver);
  String name=getCallName(ttlAst);
  Keywords keyword=nameToKeyword(name);
  TypeI type=params[0];
switch (keyword) {
case EQ:
    return type.isEquivalentTo(params[1]);
case SUB:
  return type.isSubtypeOf(params[1]);
case ISCTOR:
return type.isConstructor();
case ISTEMPLATIZED:
return type.isObjectType() && type.toMaybeObjectType().isGenericObjectType() && type.isPartiallyInstantiated();
case ISRECORD:
return type.isRecordType();
case ISUNKNOWN:
return type.isSomeUnknownType();
default :
throw new IllegalStateException("String_Node_Str");
}
}
Program: 27242
Project: 27242
Buggy source:
private void exportClass(Node scriptNode,Node classNode){
  Node classMembers=classNode.getLastChild();
  for (  Node maybeMemberFunctionDef : classMembers.children()) {
    if (maybeMemberFunctionDef.isMemberFunctionDef()) {
      String methodName=maybeMemberFunctionDef.getString();
      if (TEST_FUNCTIONS_NAME_PATTERN.matcher(methodName).matches()) {
        String functionRef=NodeUtil.getName(classNode) + "String_Node_Str" + methodName;
        String classRef=NodeUtil.getName(classNode) + "String_Node_Str";
        Node exportCallTarget=NodeUtil.newQName(compiler,exportPropertyFunction,maybeMemberFunctionDef,methodName);
        Node call=IR.call(exportCallTarget);
        if (exportCallTarget.isName()) {
          call.putBooleanProp(Node.FREE_CALL,true);
        }
        call.addChildToBack(NodeUtil.newQName(compiler,classRef,maybeMemberFunctionDef,classRef));
        call.addChildToBack(IR.string(methodName));
        call.addChildToBack(NodeUtil.newQName(compiler,functionRef,maybeMemberFunctionDef,functionRef));
        Node expression=IR.exprResult(call);
        scriptNode.addChildAfter(expression,classNode);
        compiler.reportChangeToEnclosingScope(expression);
      }
    }
  }
}

Fixed version (ground truth):
private void exportClass(Node scriptNode,Node classNode,String className,Node baseNode){
  Node classMembers=classNode.getLastChild();
  for (  Node maybeMemberFunctionDef : classMembers.children()) {
    if (maybeMemberFunctionDef.isMemberFunctionDef()) {
      String methodName=maybeMemberFunctionDef.getString();
      if (isTestFunction(methodName)) {
        String functionRef=className + "String_Node_Str" + methodName;
        String classRef=className + "String_Node_Str";
        Node exportCallTarget=NodeUtil.newQName(compiler,exportPropertyFunction,maybeMemberFunctionDef,methodName);
        Node call=IR.call(exportCallTarget);
        if (exportCallTarget.isName()) {
          call.putBooleanProp(Node.FREE_CALL,true);
        }
        call.addChildToBack(NodeUtil.newQName(compiler,classRef,maybeMemberFunctionDef,classRef));
        call.addChildToBack(IR.string(methodName));
        call.addChildToBack(NodeUtil.newQName(compiler,functionRef,maybeMemberFunctionDef,functionRef));
        Node expression=IR.exprResult(call);
        scriptNode.addChildAfter(expression,baseNode);
        compiler.reportChangeToEnclosingScope(expression);
      }
    }
  }
}
Program: 27243
Project: 27243
Buggy source:
/** 
 * Whether node corresponds to a function expression declared with var, let or const which is of the form: <pre> var/let/const functionName = function() { // Implementation }; </pre> This has the AST structure VAR/LET/CONST -> NAME -> FUNCTION
 * @param node
 */
private boolean isNameDeclaredFunction(Node node){
  if (!NodeUtil.isNameDeclaration(node)) {
    return false;
  }
  Node grandchild=node.getFirstFirstChild();
  return grandchild != null && grandchild.isFunction();
}

Fixed version (ground truth):
/** 
 * Whether node corresponds to a function expression declared with var, let or const which is of the form: <pre> var/let/const functionName = function() { // Implementation }; </pre> This has the AST structure VAR/LET/CONST -> NAME -> FUNCTION
 * @param node
 */
private boolean isNameDeclaredFunction(Node node){
  Node grandchild=getNameDeclaredGrandchild(node);
  return grandchild != null && grandchild.isFunction();
}
Program: 27245
Project: 27245
Buggy source:
@Override public void process(Node externs,Node root){
  NodeTraversal.traverseRootsEs6(compiler,new AbstractPostOrderCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isName() && !parent.isFunction() && !parent.isLabel()) {
        assertTrue("String_Node_Str" + n.getString() + "String_Node_Str",t.getScope().isDeclared(n.getString(),true));
      }
    }
  }
,externs,root);
}

Fixed version (ground truth):
@Override public void process(Node externs,Node root){
  NodeTraversal.traverseRootsEs6(compiler,new AbstractPostOrderCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isName() && !parent.isFunction() && !parent.isLabel()) {
        assertWithMessage("String_Node_Str",n).that(t.getScope().isDeclared(n.getString(),true)).isTrue();
      }
    }
  }
,externs,root);
}
Program: 27246
Project: 27246
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName() && !parent.isFunction() && !parent.isLabel()) {
    assertTrue("String_Node_Str" + n.getString() + "String_Node_Str",t.getScope().isDeclared(n.getString(),true));
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName() && !parent.isFunction() && !parent.isLabel()) {
    assertWithMessage("String_Node_Str",n).that(t.getScope().isDeclared(n.getString(),true)).isTrue();
  }
}
Program: 27247
Project: 27247
Buggy source:
void fillPropertyScopes(){
  List<Symbol> types=new ArrayList<>();
  List<Symbol> googModuleExportTypes=new ArrayList<>();
  for (  Symbol sym : getAllSymbols()) {
    if (needsPropertyScope(sym)) {
      if (sym.getName().startsWith("String_Node_Str")) {
        googModuleExportTypes.add(sym);
      }
 else {
        types.add(sym);
      }
    }
  }
  Collections.sort(types,getNaturalSymbolOrdering().reverse());
  Collections.sort(googModuleExportTypes,getNaturalSymbolOrdering().reverse());
  for (  Symbol s : Iterables.concat(googModuleExportTypes,types)) {
    createPropertyScopeFor(s);
  }
  pruneOrphanedNames();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") void fillPropertyScopes(){
  List<Symbol> types=new ArrayList<>();
  List<Symbol> googModuleExportTypes=new ArrayList<>();
  for (  Symbol sym : getAllSymbols()) {
    if (needsPropertyScope(sym)) {
      if (sym.getName().startsWith("String_Node_Str")) {
        googModuleExportTypes.add(sym);
      }
 else {
        types.add(sym);
      }
    }
  }
  Collections.sort(types,getNaturalSymbolOrdering().reverse());
  Collections.sort(googModuleExportTypes,getNaturalSymbolOrdering().reverse());
  Iterable<Symbol> allTypes=Iterables.concat(googModuleExportTypes,types);
  Map<JSType,Symbol> symbolThatDeclaresType=new IdentityHashMap<>();
  for (  Symbol s : allTypes) {
    symbolThatDeclaresType.put(s.getType(),s);
  }
  for (  Symbol s : allTypes) {
    if (s.getType() == null || symbolThatDeclaresType.get(s.getType()).equals(s)) {
      createPropertyScopeFor(s);
    }
  }
  for (  Symbol s : allTypes) {
    if (s.getType() != null) {
      s.propertyScope=symbolThatDeclaresType.get(s.getType()).getPropertyScope();
    }
  }
  pruneOrphanedNames();
}
Program: 27248
Project: 27248
Buggy source:
private void removeSymbol(Symbol s){
  SymbolScope scope=getScope(s);
  if (scope.ownSymbols.remove(s.getName()) != s) {
    throw new IllegalStateException("String_Node_Str" + s);
  }
  if (symbols.remove(s.getDeclaration().getNode(),s.getName()) != s) {
    throw new IllegalStateException("String_Node_Str" + s);
  }
}

Fixed version (ground truth):
private void removeSymbol(Symbol s){
  SymbolScope scope=getScope(s);
  if (!scope.ownSymbols.remove(s.getName()).equals(s)) {
    throw new IllegalStateException("String_Node_Str" + s);
  }
  if (!symbols.remove(s.getDeclaration().getNode(),s.getName()).equals(s)) {
    throw new IllegalStateException("String_Node_Str" + s);
  }
}
Program: 27250
Project: 27250
Buggy source:
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis,JSType other,SubtypeCache subSuperMap,MismatchInfo[] boxedInfo){
  if (isUnknown() || other.isUnknown() || other.isTop()) {
    return true;
  }
  if (isTheTruthyType()) {
    return !other.makeTruthy().isBottom();
  }
  if (isTheFalsyType()) {
    return !other.makeFalsy().isBottom();
  }
  if (!EnumType.areSubtypes(this,other,subSuperMap)) {
    return false;
  }
  int mask=getMask() & ~ENUM_MASK;
  if ((mask | other.getMask()) != other.getMask()) {
    if (boxedInfo != null && isUnion()) {
      whyNotUnionSubtypes(this,other,boxedInfo);
    }
    return false;
  }
  if (getTypeVar() != null && !getTypeVar().equals(other.getTypeVar())) {
    return false;
  }
  if (getObjs().isEmpty()) {
    return true;
  }
  boolean result=ObjectType.isUnionSubtype(keepLoosenessOfThis,getObjs(),other.getObjs(),subSuperMap);
  if (boxedInfo != null) {
    ObjectType.whyNotUnionSubtypes(keepLoosenessOfThis,getObjs(),other.getObjs(),subSuperMap,boxedInfo);
  }
  return result;
}

Fixed version (ground truth):
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis,JSType other,SubtypeCache subSuperMap,MismatchInfo[] boxedInfo){
  if (isUnknown() || other.isUnknown() || other.isTop()) {
    return true;
  }
  if (isTheTruthyType()) {
    return !other.makeTruthy().isBottom();
  }
  if (isTheFalsyType()) {
    return !other.makeFalsy().isBottom();
  }
  if (other.isTheTruthyType()) {
    return isAnyTruthyType();
  }
  if (!EnumType.areSubtypes(this,other,subSuperMap)) {
    return false;
  }
  int mask=getMask() & ~ENUM_MASK;
  if ((mask | other.getMask()) != other.getMask()) {
    if (boxedInfo != null && isUnion()) {
      whyNotUnionSubtypes(this,other,boxedInfo);
    }
    return false;
  }
  if (getTypeVar() != null && !getTypeVar().equals(other.getTypeVar())) {
    return false;
  }
  if (getObjs().isEmpty()) {
    return true;
  }
  boolean result=ObjectType.isUnionSubtype(keepLoosenessOfThis,getObjs(),other.getObjs(),subSuperMap);
  if (boxedInfo != null) {
    ObjectType.whyNotUnionSubtypes(keepLoosenessOfThis,getObjs(),other.getObjs(),subSuperMap,boxedInfo);
  }
  return result;
}
Program: 27252
Project: 27252
Buggy source:
public void testExports(){
  CompilerOptions options=createCompilerOptions();
  CompilationLevel level=CompilationLevel.ADVANCED_OPTIMIZATIONS;
  level.setOptionsForCompilationLevel(options);
  WarningLevel warnings=WarningLevel.DEFAULT;
  warnings.setOptionsForWarningLevel(options);
  options.setRemoveUnusedPrototypePropertiesInExterns(true);
  String code="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  test(options,code,"String_Node_Str" + "String_Node_Str");
  options.setGenerateExports(true);
  test(options,"String_Node_Str" + "String_Node_Str",FindExportableNodes.NON_GLOBAL_ERROR);
  options.exportLocalPropertyDefinitions=true;
  options.setRemoveUnusedPrototypePropertiesInExterns(false);
  test(options,code,"String_Node_Str" + "String_Node_Str");
  test(options,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str");
  options.setCheckTypes(true);
  options.setDisambiguateProperties(true);
  options.setAmbiguateProperties(true);
  options.propertyInvalidationErrors=ImmutableMap.of("String_Node_Str",CheckLevel.ERROR);
  test(options,code,"String_Node_Str" + "String_Node_Str");
  test(options,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testExports(){
  CompilerOptions options=createCompilerOptions();
  CompilationLevel level=CompilationLevel.ADVANCED_OPTIMIZATIONS;
  level.setOptionsForCompilationLevel(options);
  WarningLevel warnings=WarningLevel.DEFAULT;
  warnings.setOptionsForWarningLevel(options);
  options.setRemoveUnusedPrototypePropertiesInExterns(true);
  String code="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  test(options,code,"String_Node_Str" + "String_Node_Str");
  options.setGenerateExports(true);
  test(options,"String_Node_Str" + "String_Node_Str",FindExportableNodes.NON_GLOBAL_ERROR);
  options.exportLocalPropertyDefinitions=true;
  options.setRemoveUnusedPrototypePropertiesInExterns(false);
  test(options,code,"String_Node_Str");
  test(options,LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),"String_Node_Str");
  options.setCheckTypes(true);
  options.setDisambiguateProperties(true);
  options.setAmbiguateProperties(true);
  options.propertyInvalidationErrors=ImmutableMap.of("String_Node_Str",CheckLevel.ERROR);
  test(options,code,"String_Node_Str");
  test(options,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str");
}
Program: 27253
Project: 27253
Buggy source:
public void testIssue724(){
  CompilerOptions options=createCompilerOptions();
  CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
  options.setCheckSymbols(false);
  options.setCheckTypes(false);
  String code="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String result="String_Node_Str" + "String_Node_Str";
  test(options,code,result);
}

Fixed version (ground truth):
public void testIssue724(){
  CompilerOptions options=createCompilerOptions();
  CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
  options.setCheckSymbols(false);
  options.setCheckTypes(false);
  String code=LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  String result="String_Node_Str";
  test(options,code,result);
}
Program: 27254
Project: 27254
Buggy source:
private EnvTypePair analyzeLooseCallNodeBwd(Node callNode,TypeEnv outEnv,JSType retType){
  Preconditions.checkArgument(callNode.isCall() || callNode.isNew());
  Preconditions.checkNotNull(retType);
  Node callee=callNode.getFirstChild();
  TypeEnv tmpEnv=outEnv;
  FunctionTypeBuilder builder=new FunctionTypeBuilder(this.commonTypes);
  for (Node arg=callee.getNext(); arg != null; arg=arg.getNext()) {
    EnvTypePair pair=analyzeExprBwd(arg,tmpEnv);
    JSType argType=pair.type;
    tmpEnv=pair.env;
    builder.addReqFormal(isImpreciseType(argType) ? BOTTOM : argType);
  }
  JSType looseRetType=retType.isUnknown() ? BOTTOM : retType;
  JSType looseFunctionType=commonTypes.fromFunctionType(builder.addRetType(looseRetType).addLoose().buildFunction());
  println("String_Node_Str",looseFunctionType);
  EnvTypePair calleePair=analyzeExprBwd(callee,tmpEnv,looseFunctionType);
  return new EnvTypePair(calleePair.env,retType);
}

Fixed version (ground truth):
private EnvTypePair analyzeLooseCallNodeBwd(Node callNode,TypeEnv outEnv,JSType retType){
  Preconditions.checkArgument(callNode.isCall() || callNode.isNew());
  Preconditions.checkNotNull(retType);
  Node callee=callNode.getFirstChild();
  TypeEnv tmpEnv=outEnv;
  FunctionTypeBuilder builder=new FunctionTypeBuilder(this.commonTypes);
  Node target=callNode.getFirstChild();
  for (Node arg=callNode.getLastChild(); arg != target; arg=arg.getPrevious()) {
    EnvTypePair pair=analyzeExprBwd(arg,tmpEnv);
    JSType argType=pair.type;
    tmpEnv=pair.env;
    builder.addReqFormalToFront(isImpreciseType(argType) ? BOTTOM : argType);
  }
  JSType looseRetType=retType.isUnknown() ? BOTTOM : retType;
  JSType looseFunctionType=commonTypes.fromFunctionType(builder.addRetType(looseRetType).addLoose().buildFunction());
  println("String_Node_Str",looseFunctionType);
  EnvTypePair calleePair=analyzeExprBwd(callee,tmpEnv,looseFunctionType);
  return new EnvTypePair(calleePair.env,retType);
}
Program: 27255
Project: 27255
Buggy source:
public void testBackwardAnalyzedLooseFunctionParametersInRightOrder(){
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
public void testBackwardAnalyzedLooseFunctionParametersInRightOrder(){
  typeCheck(LINE_JOINER.join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
}
Program: 27256
Project: 27256
Buggy source:
private EnvTypePair analyzeThisFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  mayWarnAboutGlobalThis(expr,currentScope);
  if (!this.currentScope.hasThis()) {
    return new EnvTypePair(inEnv,UNKNOWN);
  }
  JSType inferredType=envGetType(inEnv,THIS_ID);
  if (!inferredType.isSubtypeOf(requiredType)) {
    return new EnvTypePair(inEnv,inferredType);
  }
  JSType preciseType=inferredType.specialize(specializedType);
  if (preciseType.isBottom()) {
    preciseType=pickFallbackTypeAfterBottom(THIS_ID,inferredType,specializedType);
  }
  return EnvTypePair.addBinding(inEnv,THIS_ID,preciseType);
}

Fixed version (ground truth):
private EnvTypePair analyzeThisFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  mayWarnAboutGlobalThis(expr);
  if (!this.currentScope.hasThis()) {
    return new EnvTypePair(inEnv,UNKNOWN);
  }
  JSType inferredType=envGetType(inEnv,THIS_ID);
  if (!inferredType.isSubtypeOf(requiredType)) {
    return new EnvTypePair(inEnv,inferredType);
  }
  JSType preciseType=inferredType.specialize(specializedType);
  if (preciseType.isBottom()) {
    preciseType=pickFallbackTypeAfterBottom(THIS_ID,inferredType,specializedType);
  }
  return EnvTypePair.addBinding(inEnv,THIS_ID,preciseType);
}
Program: 27258
Project: 27258
Buggy source:
private EnvTypePair analyzeIncDecFwd(Node expr,TypeEnv inEnv,JSType requiredType){
  mayWarnAboutConst(expr);
  Node ch=expr.getFirstChild();
  if (ch.isGetProp() || ch.isGetElem() && ch.getLastChild().isString()) {
    Node recv=ch.getFirstChild();
    String pname=ch.getLastChild().getString();
    EnvTypePair pair=analyzeExprFwd(recv,inEnv);
    JSType recvType=pair.type;
    if (mayWarnAboutConstProp(ch,recvType,new QualifiedName(pname))) {
      pair.type=requiredType;
      return pair;
    }
  }
  return analyzeUnaryNumFwd(expr,inEnv);
}

Fixed version (ground truth):
private EnvTypePair analyzeIncDecFwd(Node expr,TypeEnv inEnv,JSType requiredType){
  mayWarnAboutConst(expr);
  Node ch=expr.getFirstChild();
  if (ch.isGetProp() || (ch.isGetElem() && ch.getLastChild().isString())) {
    Node recv=ch.getFirstChild();
    String pname=ch.getLastChild().getString();
    EnvTypePair pair=analyzeExprFwd(recv,inEnv);
    JSType recvType=pair.type;
    if (mayWarnAboutConstProp(ch,recvType,new QualifiedName(pname))) {
      pair.type=requiredType;
      return pair;
    }
  }
  return analyzeUnaryNumFwd(expr,inEnv);
}
Program: 27261
Project: 27261
Buggy source:
private boolean mayWarnAboutInexistentProp(Node propAccessNode,JSType recvType,QualifiedName propQname){
  Preconditions.checkState(propAccessNode.isGetProp() || propAccessNode.isGetElem());
  String pname=propQname.toString();
  if (propAccessNode.isGetElem() || !recvType.isLoose() && recvType.hasProp(propQname)) {
    return false;
  }
  if (recvType.isUnknown() || recvType.isTrueOrTruthy() || recvType.isLoose()|| (allowPropertyOnSubtypes && (recvType.mayContainUnknownObject() || recvType.isIObject()))) {
    if (symbolTable.isPropertyDefined(pname)) {
      return false;
    }
    warnings.add(JSError.make(propAccessNode,INEXISTENT_PROPERTY,pname,"String_Node_Str"));
    return true;
  }
  if (allowPropertyOnSubtypes && !recvType.isStruct() && recvType.isPropDefinedOnSubtype(propQname)) {
    return false;
  }
  String recvTypeAsString=recvType.toString();
  Node recv=propAccessNode.getFirstChild();
  String errorMsg;
  if (!recv.isQualifiedName()) {
    errorMsg=recvTypeAsString;
  }
 else   if (recvTypeAsString.length() > 100) {
    errorMsg=recv.getQualifiedName();
  }
 else {
    errorMsg=recv.getQualifiedName() + "String_Node_Str" + recvTypeAsString;
  }
  DiagnosticType warningType=recvType.mayHaveProp(propQname) ? POSSIBLY_INEXISTENT_PROPERTY : INEXISTENT_PROPERTY;
  warnings.add(JSError.make(propAccessNode,warningType,pname,errorMsg));
  return true;
}

Fixed version (ground truth):
private boolean mayWarnAboutInexistentProp(Node propAccessNode,JSType recvType,QualifiedName propQname){
  Preconditions.checkState(propAccessNode.isGetProp() || propAccessNode.isGetElem());
  String pname=propQname.toString();
  if (propAccessNode.isGetElem() || (!recvType.isLoose() && recvType.hasProp(propQname))) {
    return false;
  }
  if (recvType.isUnknown() || recvType.isTrueOrTruthy() || recvType.isLoose()|| (allowPropertyOnSubtypes && (recvType.mayContainUnknownObject() || recvType.isIObject()))) {
    if (symbolTable.isPropertyDefined(pname)) {
      return false;
    }
    warnings.add(JSError.make(propAccessNode,INEXISTENT_PROPERTY,pname,"String_Node_Str"));
    return true;
  }
  if (allowPropertyOnSubtypes && !recvType.isStruct() && recvType.isPropDefinedOnSubtype(propQname)) {
    return false;
  }
  String recvTypeAsString=recvType.toString();
  Node recv=propAccessNode.getFirstChild();
  String errorMsg;
  if (!recv.isQualifiedName()) {
    errorMsg=recvTypeAsString;
  }
 else   if (recvTypeAsString.length() > 100) {
    errorMsg=recv.getQualifiedName();
  }
 else {
    errorMsg=recv.getQualifiedName() + "String_Node_Str" + recvTypeAsString;
  }
  DiagnosticType warningType=recvType.mayHaveProp(propQname) ? POSSIBLY_INEXISTENT_PROPERTY : INEXISTENT_PROPERTY;
  warnings.add(JSError.make(propAccessNode,warningType,pname,errorMsg));
  return true;
}
Program: 27262
Project: 27262
Buggy source:
private void mayWarnAboutGlobalThis(Node thisExpr,NTIScope currentScope){
  Preconditions.checkArgument(thisExpr.isThis());
  if (this.currentScope.isTopLevel() || !this.currentScope.hasThis()) {
    Node parent=thisExpr.getParent();
    if ((parent.isGetProp() || parent.isGetElem()) && !NodeUtil.isCallOrNewArgument(this.currentScope.getRoot())) {
      warnings.add(JSError.make(thisExpr,GLOBAL_THIS));
    }
  }
}

Fixed version (ground truth):
private void mayWarnAboutGlobalThis(Node thisExpr){
  Preconditions.checkArgument(thisExpr.isThis());
  if (this.currentScope.isTopLevel() || !this.currentScope.hasThis()) {
    Node parent=thisExpr.getParent();
    if ((parent.isGetProp() || parent.isGetElem()) && !NodeUtil.isCallOrNewArgument(this.currentScope.getRoot())) {
      warnings.add(JSError.make(thisExpr,GLOBAL_THIS));
    }
  }
}