nus-yam/ex-repair huggingface dataset:
Program: 19442
Project: 19442
Buggy source:
private void processConstructor(final Node function){
  final String className=getClassName(function);
  if (className == null) {
    return;
  }
  final Node insertionPoint=NodeUtil.getEnclosingStatement(function);
  NodeTraversal.traverseEs6(compiler,function.getLastChild(),new AbstractShallowStatementCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isExprResult()) {
        Node expr=n.getFirstChild();
        Node name=expr.isAssign() ? expr.getFirstChild() : expr;
        if (!name.isGetProp() || !name.getFirstChild().isThis()) {
          return;
        }
        JSType type=name.getJSType();
        String pname=name.getLastChild().getString();
        JSDocInfo jsdoc=NodeUtil.getBestJSDocInfo(name);
        Node initializer=null;
        if (type == null) {
          initializer=NodeUtil.getRValueOfLValue(name).detachFromParent();
        }
 else         if (isInferrableConst(jsdoc,name)) {
          jsdoc=maybeUpdateJSDocInfoWithType(jsdoc,name);
        }
        Node newProtoAssignStmt=NodeUtil.newQNameDeclaration(compiler,className + "String_Node_Str" + pname,initializer,jsdoc);
        newProtoAssignStmt.useSourceInfoIfMissingFromForTree(expr);
        insertionPoint.getParent().addChildAfter(newProtoAssignStmt,insertionPoint);
        compiler.reportCodeChange();
      }
    }
  }
);
}

Fixed version (ground truth):
private void processConstructor(final Node function){
  final String className=getClassName(function);
  if (className == null) {
    return;
  }
  final Node insertionPoint=NodeUtil.getEnclosingStatement(function);
  NodeTraversal.traverseEs6(compiler,function.getLastChild(),new AbstractShallowStatementCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isExprResult()) {
        Node expr=n.getFirstChild();
        Node name=expr.isAssign() ? expr.getFirstChild() : expr;
        if (!name.isGetProp() || !name.getFirstChild().isThis()) {
          return;
        }
        String pname=name.getLastChild().getString();
        String fullyQualifiedName=className + "String_Node_Str" + pname;
        if (seenNames.contains(fullyQualifiedName)) {
          return;
        }
        JSType type=name.getJSType();
        JSDocInfo jsdoc=NodeUtil.getBestJSDocInfo(name);
        if (jsdoc == null) {
          jsdoc=getAllTypeJSDoc();
        }
 else         if (isInferrableConst(jsdoc,name)) {
          jsdoc=maybeUpdateJSDocInfoWithType(jsdoc,name);
          if (type == null) {
            compiler.report(JSError.make(name,CONSTANT_WITHOUT_EXPLICIT_TYPE));
            return;
          }
        }
        Node newProtoAssignStmt=NodeUtil.newQNameDeclaration(compiler,fullyQualifiedName,null,jsdoc);
        newProtoAssignStmt.useSourceInfoIfMissingFromForTree(expr);
        insertionPoint.getParent().addChildAfter(newProtoAssignStmt,insertionPoint);
        compiler.reportCodeChange();
        seenNames.add(fullyQualifiedName);
      }
    }
  }
);
}
Program: 19443
Project: 19443
Buggy source:
private static boolean isUnknownType(JSType jsType){
  return jsType == null || jsType.isUnknownType() || jsType.isNoType();
}

Fixed version (ground truth):
private static boolean isUnknownType(JSType jsType){
  return jsType == null || jsType.isUnknownType() || jsType.isNoType() || jsType.isAllType();
}
Program: 19444
Project: 19444
Buggy source:
private static boolean isObjectType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  jsType=jsType.restrictByNotNullOrUndefined();
  return !jsType.isUnknownType() && !jsType.isNoType() && jsType.isObject();
}

Fixed version (ground truth):
private static boolean isObjectType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  jsType=jsType.restrictByNotNullOrUndefined();
  return !jsType.isUnknownType() && !jsType.isNoType() && !jsType.isAllType()&& jsType.isObject();
}
Program: 19445
Project: 19445
Buggy source:
private static boolean isNumberType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  return !jsType.isUnknownType() && !jsType.isNoType() && jsType.isNumberValueType();
}

Fixed version (ground truth):
private static boolean isNumberType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  return !jsType.isUnknownType() && !jsType.isNoType() && !jsType.isAllType()&& jsType.isNumberValueType();
}
Program: 19447
Project: 19447
Buggy source:
public JSType getProp(QualifiedName qname){
  if (isBottom() || isUnknown()) {
    return UNKNOWN;
  }
  Preconditions.checkState(!getObjs().isEmpty() || !getEnums().isEmpty(),"String_Node_Str",this);
  return nullAcceptingJoin(TypeWithPropertiesStatics.getProp(getObjs(),qname),TypeWithPropertiesStatics.getProp(getEnums(),qname));
}

Fixed version (ground truth):
public JSType getProp(QualifiedName qname){
  if (isBottom() || isUnknown() || hasTruthyMask()) {
    return UNKNOWN;
  }
  Preconditions.checkState(!getObjs().isEmpty() || !getEnums().isEmpty(),"String_Node_Str",qname,this);
  return nullAcceptingJoin(TypeWithPropertiesStatics.getProp(getObjs(),qname),TypeWithPropertiesStatics.getProp(getEnums(),qname));
}
Program: 19448
Project: 19448
Buggy source:
private static JSType meetHelper(JSType lhs,JSType rhs){
  if (lhs.isTop()) {
    return rhs;
  }
 else   if (rhs.isTop()) {
    return lhs;
  }
 else   if (lhs.isUnknown()) {
    return rhs;
  }
 else   if (rhs.isUnknown()) {
    return lhs;
  }
 else   if (lhs.isBottom() || rhs.isBottom()) {
    return BOTTOM;
  }
  int newMask=lhs.getMask() & rhs.getMask();
  String newTypevar;
  if (Objects.equals(lhs.getTypeVar(),rhs.getTypeVar())) {
    newTypevar=lhs.getTypeVar();
  }
 else {
    newTypevar=null;
    newMask=newMask & ~TYPEVAR_MASK;
  }
  return meetEnums(newMask,lhs.getMask() | rhs.getMask(),ObjectType.meetSets(lhs.getObjs(),rhs.getObjs()),newTypevar,lhs.getObjs(),rhs.getObjs(),lhs.getEnums(),rhs.getEnums());
}

Fixed version (ground truth):
private static JSType meetHelper(JSType lhs,JSType rhs){
  if (lhs.isTop()) {
    return rhs;
  }
  if (rhs.isTop()) {
    return lhs;
  }
  if (lhs.isUnknown()) {
    return rhs;
  }
  if (rhs.isUnknown()) {
    return lhs;
  }
  if (lhs.isBottom() || rhs.isBottom()) {
    return BOTTOM;
  }
  if (lhs.hasTruthyMask()) {
    return rhs.makeTruthy();
  }
  if (lhs.hasFalsyMask()) {
    return rhs.makeFalsy();
  }
  if (rhs.hasTruthyMask()) {
    return lhs.makeTruthy();
  }
  if (rhs.hasFalsyMask()) {
    return lhs.makeFalsy();
  }
  int newMask=lhs.getMask() & rhs.getMask();
  String newTypevar;
  if (Objects.equals(lhs.getTypeVar(),rhs.getTypeVar())) {
    newTypevar=lhs.getTypeVar();
  }
 else {
    newTypevar=null;
    newMask=newMask & ~TYPEVAR_MASK;
  }
  return meetEnums(newMask,lhs.getMask() | rhs.getMask(),ObjectType.meetSets(lhs.getObjs(),rhs.getObjs()),newTypevar,lhs.getObjs(),rhs.getObjs(),lhs.getEnums(),rhs.getEnums());
}
Program: 19449
Project: 19449
Buggy source:
/** 
 * Tries to apply our various peephole minimizations on the passed in node.
 */
@Override @SuppressWarnings("String_Node_Str") public Node optimizeSubtree(Node node){
switch (node.getType()) {
case THROW:
case RETURN:
{
      Node result=tryRemoveRedundantExit(node);
      if (result != node) {
        return result;
      }
      return tryReplaceExitWithBreak(node);
    }
case NOT:
  tryMinimizeCondition(node.getFirstChild());
return tryMinimizeNot(node);
case IF:
performCoercionSubstitutions(node.getFirstChild());
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeIf(node);
case EXPR_RESULT:
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeExprResult(node);
case HOOK:
performCoercionSubstitutions(node.getFirstChild());
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeHook(node);
case WHILE:
case DO:
tryMinimizeCondition(NodeUtil.getConditionExpression(node));
return node;
case FOR:
if (!NodeUtil.isForIn(node)) {
tryJoinForCondition(node);
tryMinimizeCondition(NodeUtil.getConditionExpression(node));
}
return node;
case BLOCK:
return tryReplaceIf(node);
default :
return node;
}
}

Fixed version (ground truth):
/** 
 * Tries to apply our various peephole minimizations on the passed in node.
 */
@Override @SuppressWarnings("String_Node_Str") public Node optimizeSubtree(Node node){
switch (node.getType()) {
case THROW:
case RETURN:
{
      Node result=tryRemoveRedundantExit(node);
      if (result != node) {
        return result;
      }
      return tryReplaceExitWithBreak(node);
    }
case NOT:
  tryMinimizeCondition(node.getFirstChild());
return tryMinimizeNot(node);
case IF:
performCoercionSubstitutions(node.getFirstChild());
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeIf(node);
case EXPR_RESULT:
performCoercionSubstitutions(node.getFirstChild());
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeExprResult(node);
case HOOK:
performCoercionSubstitutions(node.getFirstChild());
performConditionSubstitutions(node.getFirstChild());
return tryMinimizeHook(node);
case WHILE:
case DO:
tryMinimizeCondition(NodeUtil.getConditionExpression(node));
return node;
case FOR:
if (!NodeUtil.isForIn(node)) {
tryJoinForCondition(node);
tryMinimizeCondition(NodeUtil.getConditionExpression(node));
}
return node;
case BLOCK:
return tryReplaceIf(node);
default :
return node;
}
}
Program: 19450
Project: 19450
Buggy source:
private static boolean isObjectType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  return !jsType.isUnknownType() && jsType.isObject();
}

Fixed version (ground truth):
private static boolean isObjectType(Node n){
  JSType jsType=n.getJSType();
  if (jsType == null) {
    return false;
  }
  jsType=jsType.restrictByNotNullOrUndefined();
  return !jsType.isUnknownType() && !jsType.isNoType() && jsType.isObject();
}
Program: 19451
Project: 19451
Buggy source:
/** 
 * Given a source file, line, and column, return the reverse mapping (source --> target). A collection is returned as in some cases (like a function being inlined), one source line may map to more then one target location. An empty collection is returned if there were no matches.
 * @param originalFile the source file
 * @param line the source line
 * @param column the source column
 * @return the reverse mapping (source --> target)
 */
public Collection<OriginalMapping> getReverseMapping(String originalFile,int line,int column);

Fixed version (ground truth):
/** 
 * Given a source file, line, and column, return the reverse mapping (source → target). A collection is returned as in some cases (like a function being inlined), one source line may map to more then one target location. An empty collection is returned if there were no matches.
 * @param originalFile the source file
 * @param line the source line
 * @param column the source column
 * @return the reverse mapping (source → target)
 */
public Collection<OriginalMapping> getReverseMapping(String originalFile,int line,int column);
Program: 19452
Project: 19452
Buggy source:
/** 
 * Prefix for filenames of compiled JS modules. <module-name>.js will be appended to this prefix. Directories will be created as needed. Use with --module
 */
public CommandLineConfig setModuleOutputPathPrefix(String moduleOutputPathPrefix){
  this.moduleOutputPathPrefix=moduleOutputPathPrefix;
  return this;
}

Fixed version (ground truth):
/** 
 * Prefix for filenames of compiled JS modules.  {@code <module-name>.js} will be appended to this prefix. Directorieswill be created as needed. Use with --module
 */
public CommandLineConfig setModuleOutputPathPrefix(String moduleOutputPathPrefix){
  this.moduleOutputPathPrefix=moduleOutputPathPrefix;
  return this;
}
Program: 19453
Project: 19453
Buggy source:
/** 
 * Decodes an encoded string from the JS Compiler ReplaceStrings pass. <p>An original string with args might look like this: <pre>  Error('Some ' + arg1 + ' error ' + arg2 + ' message.');</pre> Which gets replaced with: <pre>  Error('key' + '`' + arg1 + '`' + arg2);</pre> Where ` is the argument place holder. The replacement mapping would be: <pre>  key -> 'Some ` error ` message.'</pre> Where key is some arbitrary replacement string. An encoded string, with args, from the client will look like: <pre>  'key`arg1`arg2'</pre>
 * @param encodedStr An encoded string.
 * @return The decoded string, or the encoded string if it fails to decode.
 * @see com.google.javascript.jscomp.ReplaceStrings
 */
public String decode(String encodedStr){
  String[] suppliedBits=encodedStr.split(ARGUMENT_PLACE_HOLDER,-1);
  String originalStr=originalToNewNameMap.get(suppliedBits[0]);
  if (originalStr == null) {
    return encodedStr;
  }
  String[] originalBits=originalStr.split(ARGUMENT_PLACE_HOLDER,-1);
  StringBuilder sb=new StringBuilder(originalBits[0]);
  for (int i=1; i < Math.max(originalBits.length,suppliedBits.length); i++) {
    sb.append(i < suppliedBits.length ? suppliedBits[i] : "String_Node_Str");
    sb.append(i < originalBits.length ? originalBits[i] : "String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Decodes an encoded string from the JS Compiler ReplaceStrings pass. <p>An original string with args might look like this: <pre>  Error('Some ' + arg1 + ' error ' + arg2 + ' message.');</pre> Which gets replaced with: <pre>  Error('key' + '`' + arg1 + '`' + arg2);</pre> Where ` is the argument place holder. The replacement mapping would be: <pre>  key → 'Some ` error ` message.'</pre> Where key is some arbitrary replacement string. An encoded string, with args, from the client will look like: <pre>  'key`arg1`arg2'</pre>
 * @param encodedStr An encoded string.
 * @return The decoded string, or the encoded string if it fails to decode.
 * @see com.google.javascript.jscomp.ReplaceStrings
 */
public String decode(String encodedStr){
  String[] suppliedBits=encodedStr.split(ARGUMENT_PLACE_HOLDER,-1);
  String originalStr=originalToNewNameMap.get(suppliedBits[0]);
  if (originalStr == null) {
    return encodedStr;
  }
  String[] originalBits=originalStr.split(ARGUMENT_PLACE_HOLDER,-1);
  StringBuilder sb=new StringBuilder(originalBits[0]);
  for (int i=1; i < Math.max(originalBits.length,suppliedBits.length); i++) {
    sb.append(i < suppliedBits.length ? suppliedBits[i] : "String_Node_Str");
    sb.append(i < originalBits.length ? originalBits[i] : "String_Node_Str");
  }
  return sb.toString();
}
Program: 19454
Project: 19454
Buggy source:
/** 
 * Adds a <path/> entry.
 */
public void addPath(Path list){
  this.sourcePaths.add(list);
}

Fixed version (ground truth):
/** 
 * Adds a   {@code <path/>} entry.
 */
public void addPath(Path list){
  this.sourcePaths.add(list);
}
Program: 19455
Project: 19455
Buggy source:
@Override public void process(Node externs,Node root){
  NodeTraversal.traverseEs6(compiler,root,this);
}

Fixed version (ground truth):
@Override public void process(Node externs,Node root){
  GetterSetterCollector getterSetterCollector=new GetterSetterCollector();
  NodeTraversal.traverseEs6(compiler,root,getterSetterCollector);
  NodeTraversal.traverseEs6(compiler,root,new FunctionVisitor(compiler,getterSetterCollector.propNames));
}
Program: 19456
Project: 19456
Buggy source:
private boolean visitNode(Node n,Node parent){
switch (n.getType()) {
case Token.GETPROP:
    if (NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n) {
      return false;
    }
  Property property=getOrCreateProperty(n);
if (property != null) {
  property.markLastWriteRead();
  property.markChildrenRead();
}
return true;
case Token.CALL:
if (ASSUME_CONSTRUCTORS_HAVENT_ESCAPED && isConstructor && !NodeUtil.referencesThis(n)&& NodeUtil.getEnclosingType(n,Token.TRY) == null) {
markAllPropsReadExceptThisProps();
}
 else {
markAllPropsRead();
}
return false;
case Token.THIS:
case Token.NAME:
Property nameProp=Preconditions.checkNotNull(getOrCreateProperty(n));
nameProp.markLastWriteRead();
nameProp.markChildrenRead();
return true;
case Token.THROW:
case Token.FOR:
case Token.SWITCH:
markAllPropsRead();
return false;
case Token.BLOCK:
visitBlock(n);
return true;
default :
if (isConditionalExpression(n)) {
markAllPropsRead();
return false;
}
return true;
}
}

Fixed version (ground truth):
private boolean visitNode(Node n,Node parent){
switch (n.getType()) {
case Token.GETPROP:
    if (n.isGetProp() && n.getLastChild().isString() && getterSetterNames.contains(n.getLastChild().getString())) {
      markAllPropsRead();
      return true;
    }
  if (NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n) {
    return false;
  }
Property property=getOrCreateProperty(n);
if (property != null) {
property.markLastWriteRead();
if (!parent.isGetProp()) {
  property.markChildrenRead();
}
}
return true;
case Token.CALL:
if (ASSUME_CONSTRUCTORS_HAVENT_ESCAPED && isConstructor && !NodeUtil.referencesThis(n)&& NodeUtil.getEnclosingType(n,Token.TRY) == null) {
markAllPropsReadExceptThisProps();
}
 else {
markAllPropsRead();
}
return false;
case Token.THIS:
case Token.NAME:
Property nameProp=Preconditions.checkNotNull(getOrCreateProperty(n));
nameProp.markLastWriteRead();
if (!parent.isGetProp()) {
nameProp.markChildrenRead();
}
return true;
case Token.THROW:
case Token.FOR:
case Token.SWITCH:
markAllPropsRead();
return false;
case Token.BLOCK:
visitBlock(n);
return true;
default :
if (isConditionalExpression(n)) {
markAllPropsRead();
return false;
}
return true;
}
}
Program: 19457
Project: 19457
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (NodeUtil.isAssignmentOp(n)) {
    visitAssignmentLhs(n.getFirstChild());
  }
  if (n.isBlock()) {
    visitBlock(n);
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (NodeUtil.isGetterOrSetter(n)) {
    Node grandparent=parent.getParent();
    if (NodeUtil.isGetOrSetKey(n) && n.getString() != null) {
      propNames.add(n.getString());
    }
 else     if (NodeUtil.isObjectDefinePropertyDefinition(grandparent)) {
      Node propNode=grandparent.getChildAtIndex(2);
      if (propNode.isString()) {
        propNames.add(propNode.getString());
      }
    }
 else     if (grandparent.isStringKey() && NodeUtil.isObjectDefinePropertiesDefinition(grandparent.getParent().getParent())) {
      propNames.add(grandparent.getString());
    }
  }
}
Program: 19458
Project: 19458
Buggy source:
FindCandidateAssignmentTraversal(boolean isConstructor){
  this.isConstructor=isConstructor;
}

Fixed version (ground truth):
FindCandidateAssignmentTraversal(Set<String> getterSetterNames,boolean isConstructor){
  this.getterSetterNames=getterSetterNames;
  this.isConstructor=isConstructor;
}
Program: 19459
Project: 19459
Buggy source:
static boolean isNegativeZero(double x){
  return x == 0.0 && Math.copySign(1,x) == -1.0;
}

Fixed version (ground truth):
static boolean isNegativeZero(double x){
  return x == 0.0 && 1 / x < 0;
}
Program: 19460
Project: 19460
Buggy source:
private EnvTypePair analyzeAssignFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  if (expr.getBooleanProp(Node.ANALYZED_DURING_GTI)) {
    expr.removeProp(Node.ANALYZED_DURING_GTI);
    return new EnvTypePair(inEnv,requiredType);
  }
  mayWarnAboutConst(expr);
  Node lhs=expr.getFirstChild();
  Node rhs=expr.getLastChild();
  if (lhs.getBooleanProp(Node.ANALYZED_DURING_GTI)) {
    lhs.removeProp(Node.ANALYZED_DURING_GTI);
    JSType declType=markAndGetTypeOfPreanalyzedNode(lhs,inEnv,true);
    if (rhs.matchesQualifiedName(ABSTRACT_METHOD_NAME)) {
      return new EnvTypePair(inEnv,requiredType);
    }
    EnvTypePair rhsPair=analyzeExprFwd(rhs,inEnv,declType);
    if (!rhsPair.type.isSubtypeOf(declType) && !NodeUtil.isPrototypeAssignment(lhs)) {
      warnings.add(JSError.make(expr,MISTYPED_ASSIGN_RHS,declType.toString(),rhsPair.type.toString()));
    }
    return rhsPair;
  }
  LValueResultFwd lvalue=analyzeLValueFwd(lhs,inEnv,requiredType);
  JSType declType=lvalue.declType;
  EnvTypePair rhsPair=analyzeExprFwd(rhs,lvalue.env,requiredType,specializedType);
  if (declType != null && !rhsPair.type.isSubtypeOf(declType)) {
    warnings.add(JSError.make(expr,MISTYPED_ASSIGN_RHS,declType.toString(),rhsPair.type.toString()));
  }
 else {
    rhsPair.env=updateLvalueTypeInEnv(rhsPair.env,lhs,lvalue.ptr,rhsPair.type);
  }
  return rhsPair;
}

Fixed version (ground truth):
private EnvTypePair analyzeAssignFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  if (expr.getBooleanProp(Node.ANALYZED_DURING_GTI)) {
    expr.removeProp(Node.ANALYZED_DURING_GTI);
    return new EnvTypePair(inEnv,requiredType);
  }
  mayWarnAboutConst(expr);
  Node lhs=expr.getFirstChild();
  Node rhs=expr.getLastChild();
  if (lhs.getBooleanProp(Node.ANALYZED_DURING_GTI)) {
    lhs.removeProp(Node.ANALYZED_DURING_GTI);
    JSType declType=markAndGetTypeOfPreanalyzedNode(lhs,inEnv,true);
    if (rhs.matchesQualifiedName(ABSTRACT_METHOD_NAME)) {
      return new EnvTypePair(inEnv,requiredType);
    }
    EnvTypePair rhsPair=analyzeExprFwd(rhs,inEnv,declType);
    if (!rhsPair.type.isSubtypeOf(declType) && !NodeUtil.isPrototypeAssignment(lhs)) {
      warnings.add(JSError.make(expr,MISTYPED_ASSIGN_RHS,errorMsgWithTypeDiff(declType,rhsPair.type)));
    }
    return rhsPair;
  }
  LValueResultFwd lvalue=analyzeLValueFwd(lhs,inEnv,requiredType);
  JSType declType=lvalue.declType;
  EnvTypePair rhsPair=analyzeExprFwd(rhs,lvalue.env,requiredType,specializedType);
  if (declType != null && !rhsPair.type.isSubtypeOf(declType)) {
    warnings.add(JSError.make(expr,MISTYPED_ASSIGN_RHS,errorMsgWithTypeDiff(declType,rhsPair.type)));
  }
 else {
    rhsPair.env=updateLvalueTypeInEnv(rhsPair.env,lhs,lvalue.ptr,rhsPair.type);
  }
  return rhsPair;
}
Program: 19462
Project: 19462
Buggy source:
private EnvTypePair analyzeAssertionCall(Node callNode,TypeEnv env,AssertionFunctionSpec assertionFunctionSpec){
  Node firstParam=callNode.getSecondChild();
  if (firstParam == null) {
    return new EnvTypePair(env,JSType.UNKNOWN);
  }
  Node assertedNode=assertionFunctionSpec.getAssertedParam(firstParam);
  if (assertedNode == null) {
    return new EnvTypePair(env,JSType.UNKNOWN);
  }
  JSType assertedType=assertionFunctionSpec.getAssertedNewType(callNode,currentScope);
  if (assertedType.isUnknown()) {
    warnings.add(JSError.make(callNode,NewTypeInference.UNKNOWN_ASSERTION_TYPE));
  }
  EnvTypePair pair=analyzeExprFwd(assertedNode,env,JSType.UNKNOWN,assertedType);
  if (pair.type.isBottom()) {
    JSType t=analyzeExprFwd(assertedNode,env).type.substituteGenericsWithUnknown();
    if (t.isSubtypeOf(assertedType)) {
      pair.type=t;
    }
 else {
      warnings.add(JSError.make(assertedNode,NewTypeInference.ASSERT_FALSE));
      pair.type=JSType.UNKNOWN;
      pair.env=env;
    }
  }
  return pair;
}

Fixed version (ground truth):
private EnvTypePair analyzeAssertionCall(Node callNode,TypeEnv env,AssertionFunctionSpec assertionFunctionSpec){
  Node firstParam=callNode.getSecondChild();
  if (firstParam == null) {
    return new EnvTypePair(env,JSType.UNKNOWN);
  }
  Node assertedNode=assertionFunctionSpec.getAssertedParam(firstParam);
  if (assertedNode == null) {
    return new EnvTypePair(env,JSType.UNKNOWN);
  }
  JSType assertedType=assertionFunctionSpec.getAssertedNewType(callNode,currentScope);
  if (assertedType.isUnknown()) {
    warnings.add(JSError.make(callNode,NewTypeInference.UNKNOWN_ASSERTION_TYPE));
  }
  EnvTypePair pair=analyzeExprFwd(assertedNode,env,JSType.UNKNOWN,assertedType);
  if (!pair.type.isSubtypeOf(assertedType) && JSType.haveCommonSubtype(assertedType,pair.type)) {
    pair.type=assertedType;
  }
  if (pair.type.isBottom()) {
    JSType t=analyzeExprFwd(assertedNode,env).type.substituteGenericsWithUnknown();
    if (t.isSubtypeOf(assertedType)) {
      pair.type=t;
    }
 else {
      warnings.add(JSError.make(assertedNode,NewTypeInference.ASSERT_FALSE));
      pair.type=JSType.UNKNOWN;
      pair.env=env;
    }
  }
  return pair;
}
Program: 19463
Project: 19463
Buggy source:
public void testAsserts(){
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"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","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"));
  typeCheck(LINE_JOINER.join("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"));
}

Fixed version (ground truth):
public void testAsserts(){
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck(LINE_JOINER.join(CLOSURE_BASE,"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","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"));
  typeCheck(LINE_JOINER.join("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"));
  typeCheck(LINE_JOINER.join("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"),NewTypeInference.MISTYPED_ASSIGN_RHS);
}
Program: 19464
Project: 19464
Buggy source:
void fillPropertyScopes(){
  List<Symbol> types=new ArrayList<>();
  for (  Symbol sym : getAllSymbols()) {
    if (needsPropertyScope(sym)) {
      types.add(sym);
    }
  }
  Collections.sort(types,getNaturalSymbolOrdering().reverse());
  for (  Symbol s : types) {
    createPropertyScopeFor(s);
  }
  pruneOrphanedNames();
}

Fixed version (ground truth):
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();
}
Program: 19465
Project: 19465
Buggy source:
@Override public void enterScope(NodeTraversal t){
  Scope scope=t.getScope();
  if (!shouldOptimizeScope(scope)) {
    return;
  }
  Preconditions.checkState(scope.isFunctionScope(),scope);
  ControlFlowGraph<Node> cfg=t.getControlFlowGraph();
  LiveVariablesAnalysis liveness=new LiveVariablesAnalysis(cfg,scope,compiler);
  if (NodeUtil.getFunctionParameters(scope.getRootNode()).getChildCount() == 2) {
    liveness.markAllParametersEscaped();
  }
  liveness.analyze();
  UndiGraph<Var,Void> interferenceGraph=computeVariableNamesInterferenceGraph(t,cfg,(Set<Var>)liveness.getEscapedLocals());
  GraphColoring<Var,Void> coloring=new GreedyGraphColoring<>(interferenceGraph,coloringTieBreaker);
  coloring.color();
  colorings.push(coloring);
}

Fixed version (ground truth):
@Override public void enterScope(NodeTraversal t){
  Scope scope=t.getScope();
  if (!shouldOptimizeScope(scope)) {
    return;
  }
  Preconditions.checkState(scope.isFunctionScope(),scope);
  ControlFlowGraph<Node> cfg=t.getControlFlowGraph();
  LiveVariablesAnalysis liveness=new LiveVariablesAnalysis(cfg,scope,compiler);
  if (compiler.getOptions().getLanguageOut() == CompilerOptions.LanguageMode.ECMASCRIPT3) {
    if (NodeUtil.getFunctionParameters(scope.getRootNode()).getChildCount() == 2) {
      liveness.markAllParametersEscaped();
    }
  }
  liveness.analyze();
  UndiGraph<Var,Void> interferenceGraph=computeVariableNamesInterferenceGraph(t,cfg,(Set<Var>)liveness.getEscapedLocals());
  GraphColoring<Var,Void> coloring=new GreedyGraphColoring<>(interferenceGraph,coloringTieBreaker);
  coloring.color();
  colorings.push(coloring);
}
Program: 19466
Project: 19466
Buggy source:
public void testParameter4b(){
  test("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testParameter4b(){
  setLanguageOut(LanguageMode.ECMASCRIPT5);
  test("String_Node_Str","String_Node_Str");
}
Program: 19468
Project: 19468
Buggy source:
/** 
 * Appends the exported function and all paths necessary for the path to be declared. For example, for a property "a.b.c", the initializers for paths "a", "a.b" will be appended (if they have not already) and a.b.c will be initialized with the exported version of the function: <pre> var a = {}; a.b = {}; a.b.c = function(x,y) { } </pre>
 */
void appendExtern(String path,Node valueToExport){
  List<String> pathPrefixes=computePathPrefixes(path);
  for (int i=0; i < pathPrefixes.size(); ++i) {
    String pathPrefix=pathPrefixes.get(i);
    boolean isCompletePathPrefix=(i == pathPrefixes.size() - 1);
    boolean skipPathPrefix=pathPrefix.endsWith("String_Node_Str") || (alreadyExportedPaths.contains(pathPrefix) && !isCompletePathPrefix);
    if (!skipPathPrefix) {
      Node initializer;
      if (isCompletePathPrefix && valueToExport != null) {
        if (valueToExport.isFunction()) {
          initializer=createExternFunction(valueToExport);
        }
 else {
          Preconditions.checkState(valueToExport.isObjectLit());
          initializer=createExternObjectLit(valueToExport);
        }
      }
 else {
        initializer=IR.empty();
      }
      appendPathDefinition(pathPrefix,initializer);
    }
  }
}

Fixed version (ground truth):
/** 
 * Appends the exported function and all paths necessary for the path to be declared. For example, for a property "a.b.c", the initializers for paths "a", "a.b" will be appended (if they have not already) and a.b.c will be initialized with the exported version of the function: <pre> var a = {}; a.b = {}; a.b.c = function(x,y) { } </pre>
 */
void appendExtern(String path,Node valueToExport){
  List<String> pathPrefixes=computePathPrefixes(path);
  for (int i=0; i < pathPrefixes.size(); ++i) {
    String pathPrefix=pathPrefixes.get(i);
    boolean isCompletePathPrefix=(i == pathPrefixes.size() - 1);
    boolean skipPathPrefix=pathPrefix.endsWith("String_Node_Str") || (alreadyExportedPaths.contains(pathPrefix) && !isCompletePathPrefix);
    boolean exportedValueDefinesNewType=false;
    if (valueToExport != null) {
      JSDocInfo jsdoc=NodeUtil.getBestJSDocInfo(valueToExport);
      if (jsdoc != null && jsdoc.containsTypeDefinition()) {
        exportedValueDefinesNewType=true;
      }
    }
    if (!skipPathPrefix) {
      Node initializer;
      JSDocInfo jsdoc=null;
      if (isCompletePathPrefix && valueToExport != null) {
        if (valueToExport.isFunction()) {
          initializer=createExternFunction(valueToExport);
        }
 else {
          Preconditions.checkState(valueToExport.isObjectLit());
          initializer=createExternObjectLit(valueToExport);
        }
      }
 else       if (!isCompletePathPrefix && exportedValueDefinesNewType) {
        jsdoc=buildNamespaceJSDoc();
        initializer=createExternObjectLit(IR.objectlit());
        initializer.setJSDocInfo(null);
      }
 else {
        initializer=IR.empty();
      }
      appendPathDefinition(pathPrefix,initializer,jsdoc);
    }
  }
}
Program: 19469
Project: 19469
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());
  externFunction.setJSType(exportedFunction.getJSType());
  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.getJSType() != null) {
    externFunction.setJSType(exportedFunction.getJSType());
    deleteInlineJsdocs(externFunction);
  }
  return externFunction;
}
Program: 19470
Project: 19470
Buggy source:
private void appendPathDefinition(String path,Node initializer){
  Node pathDefinition;
  if (!path.contains("String_Node_Str")) {
    if (initializer.isEmpty()) {
      pathDefinition=IR.var(IR.name(path));
    }
 else {
      pathDefinition=NodeUtil.newVarNode(path,initializer);
    }
  }
 else {
    Node qualifiedPath=NodeUtil.newQName(compiler,path);
    if (initializer.isEmpty()) {
      pathDefinition=NodeUtil.newExpr(qualifiedPath);
    }
 else {
      pathDefinition=NodeUtil.newExpr(IR.assign(qualifiedPath,initializer));
    }
  }
  externsRoot.addChildToBack(pathDefinition);
  alreadyExportedPaths.add(path);
}

Fixed version (ground truth):
private void appendPathDefinition(String path,Node initializer,JSDocInfo jsdoc){
  Node pathDefinition;
  if (!path.contains("String_Node_Str")) {
    if (initializer.isEmpty()) {
      pathDefinition=IR.var(IR.name(path));
    }
 else {
      pathDefinition=NodeUtil.newVarNode(path,initializer);
    }
  }
 else {
    Node qualifiedPath=NodeUtil.newQName(compiler,path);
    if (initializer.isEmpty()) {
      pathDefinition=NodeUtil.newExpr(qualifiedPath);
    }
 else {
      pathDefinition=NodeUtil.newExpr(IR.assign(qualifiedPath,initializer));
    }
  }
  if (jsdoc != null) {
    if (pathDefinition.isExprResult()) {
      pathDefinition.getFirstChild().setJSDocInfo(jsdoc);
    }
 else {
      Preconditions.checkState(pathDefinition.isVar());
      pathDefinition.setJSDocInfo(jsdoc);
    }
  }
  externsRoot.addChildToBack(pathDefinition);
  alreadyExportedPaths.add(path);
}
Program: 19472
Project: 19472
Buggy source:
@Override void add(Node n,Context context){
  Node parent=n.getParent();
  if (parent != null && (parent.isBlock() || parent.isScript())) {
    if (n.isFunction()) {
      add(getFunctionAnnotation(n));
    }
 else     if (n.isExprResult() && n.getFirstChild().isAssign()) {
      Node rhs=n.getFirstChild().getLastChild();
      add(getTypeAnnotation(rhs));
    }
 else     if (n.isVar() && n.getFirstFirstChild() != null) {
      add(getTypeAnnotation(n.getFirstFirstChild()));
    }
  }
  super.add(n,context);
}

Fixed version (ground truth):
@Override void add(Node n,Context context){
  Node parent=n.getParent();
  if (parent != null && (parent.isBlock() || parent.isScript())) {
    if (n.isFunction()) {
      add(getFunctionAnnotation(n));
    }
 else     if (n.isExprResult() && n.getFirstChild().isAssign()) {
      Node assign=n.getFirstChild();
      if (NodeUtil.isNamespaceDecl(assign.getFirstChild())) {
        add(JSDocInfoPrinter.print(assign.getJSDocInfo()));
      }
 else {
        Node rhs=assign.getLastChild();
        add(getTypeAnnotation(rhs));
      }
    }
 else     if (n.isVar() && n.getFirstFirstChild() != null) {
      if (NodeUtil.isNamespaceDecl(n.getFirstChild())) {
        add(JSDocInfoPrinter.print(n.getJSDocInfo()));
      }
 else {
        add(getTypeAnnotation(n.getFirstFirstChild()));
      }
    }
  }
  super.add(n,context);
}
Program: 19473
Project: 19473
Buggy source:
void recordPassStart(String passName,boolean isOneTime){
  currentPass.push(new Stats(passName,isOneTime));
  codeChange.reset();
}

Fixed version (ground truth):
void recordPassStart(String passName,boolean isOneTime){
  currentPass.push(new Stats(passName,isOneTime));
  if (!passName.equals("String_Node_Str")) {
    codeChange.reset();
  }
}
Program: 19474
Project: 19474
Buggy source:
/** 
 * Gets the r-value (or intializer) of a node returned by getBestLValue. 
 */
static Node getRValueOfLValue(Node n){
  Node parent=n.getParent();
switch (parent.getType()) {
case Token.ASSIGN:
    return n.getNext();
case Token.VAR:
case Token.LET:
case Token.CONST:
case Token.OBJECTLIT:
  return n.getFirstChild();
case Token.FUNCTION:
case Token.CLASS:
return parent;
}
return null;
}

Fixed version (ground truth):
/** 
 * Gets the r-value (or intializer) of a node returned by getBestLValue. 
 */
static Node getRValueOfLValue(Node n){
  Node parent=n.getParent();
switch (parent.getType()) {
case Token.ASSIGN:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_LSH:
case Token.ASSIGN_RSH:
case Token.ASSIGN_URSH:
case Token.ASSIGN_ADD:
case Token.ASSIGN_SUB:
case Token.ASSIGN_MUL:
case Token.ASSIGN_DIV:
case Token.ASSIGN_MOD:
    return n.getNext();
case Token.VAR:
case Token.LET:
case Token.CONST:
case Token.OBJECTLIT:
  return n.getFirstChild();
case Token.FUNCTION:
case Token.CLASS:
return parent;
}
return null;
}
Program: 19476
Project: 19476
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case Token.CALL:
    Node callee=n.getFirstChild();
  if (callee.matchesQualifiedName("String_Node_Str")) {
    if (currentModuleName == null) {
      currentModuleName=extractFirstArgumentName(n);
    }
 else {
      t.report(n,MULTIPLE_MODULES_IN_FILE);
    }
  }
 else   if (callee.matchesQualifiedName("String_Node_Str")) {
    t.report(n,MODULE_AND_PROVIDES);
  }
 else   if (callee.matchesQualifiedName("String_Node_Str")) {
    checkRequireCall(t,n,parent);
  }
break;
case Token.THIS:
if (t.inGlobalHoistScope()) {
t.report(n,GOOG_MODULE_REFERENCES_THIS);
}
break;
case Token.THROW:
if (t.inGlobalHoistScope()) {
t.report(n,GOOG_MODULE_USES_THROW);
}
break;
case Token.GETPROP:
if (currentModuleName != null && n.matchesQualifiedName(currentModuleName)) {
t.report(n,REFERENCE_TO_MODULE_GLOBAL_NAME);
}
 else if (shortRequiredNamespaces.contains(n.getQualifiedName())) {
t.report(n,REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME);
}
break;
case Token.SCRIPT:
currentModuleName=null;
shortRequiredNamespaces.clear();
break;
}
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case Token.CALL:
    Node callee=n.getFirstChild();
  if (callee.matchesQualifiedName("String_Node_Str")) {
    if (currentModuleName == null) {
      currentModuleName=extractFirstArgumentName(n);
    }
 else {
      t.report(n,MULTIPLE_MODULES_IN_FILE);
    }
  }
 else   if (callee.matchesQualifiedName("String_Node_Str")) {
    t.report(n,MODULE_AND_PROVIDES);
  }
 else   if (callee.matchesQualifiedName("String_Node_Str")) {
    checkRequireCall(t,n,parent);
  }
break;
case Token.THIS:
if (t.inGlobalHoistScope()) {
t.report(n,GOOG_MODULE_REFERENCES_THIS);
}
break;
case Token.THROW:
if (t.inGlobalHoistScope()) {
t.report(n,GOOG_MODULE_USES_THROW);
}
break;
case Token.GETPROP:
if (currentModuleName != null && n.matchesQualifiedName(currentModuleName)) {
t.report(n,REFERENCE_TO_MODULE_GLOBAL_NAME);
}
 else if (shortRequiredNamespaces.contains(n.getQualifiedName())) {
t.report(n,REFERENCE_TO_SHORT_IMPORT_BY_LONG_NAME,n.getQualifiedName());
}
break;
case Token.SCRIPT:
currentModuleName=null;
shortRequiredNamespaces.clear();
break;
}
}
Program: 19478
Project: 19478
Buggy source:
public void testForIn(){
  enableUnusedLocalAssignmentCheck=true;
  assertNoWarning("String_Node_Str");
}

Fixed version (ground truth):
public void testForIn(){
  enableUnusedLocalAssignmentCheck=true;
  assertNoWarning("String_Node_Str");
  assertNoWarning("String_Node_Str");
  assertNoWarning("String_Node_Str");
}
Program: 19479
Project: 19479
Buggy source:
public void testTestTypes(){
  try {
    testTypes("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  AssertionError expected) {
  }
}

Fixed version (ground truth):
public void testTestTypes(){
  try {
    testTypes("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    throw new Error("String_Node_Str");
  }
 catch (  AssertionError expected) {
  }
}
Program: 19480
Project: 19480
Buggy source:
private static void lint(Path path,boolean fix) throws IOException {
  SourceFile file=SourceFile.fromFile(path.toString());
  Compiler compiler=new Compiler(System.out);
  CompilerOptions options=new CompilerOptions();
  options.setLanguage(LanguageMode.ECMASCRIPT6_STRICT);
  options.setSkipTranspilationAndCrash(true);
  options.setIdeMode(true);
  options.setCodingConvention(new GoogleCodingConvention());
  options.setWarningLevel(DiagnosticGroups.CHECK_TYPES,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.LINT_CHECKS,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.MISSING_REQUIRE,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE,CheckLevel.WARNING);
  compiler.setPassConfig(new LintPassConfig(options));
  compiler.disableThreads();
  SourceFile externs=SourceFile.fromCode("String_Node_Str","String_Node_Str");
  compiler.compile(ImmutableList.<SourceFile>of(externs),ImmutableList.of(file),options);
  if (fix) {
    List<SuggestedFix> fixes=new ArrayList<>();
    for (    JSError warning : compiler.getWarnings()) {
      SuggestedFix suggestedFix=ErrorToFixMapper.getFixForJsError(warning,compiler);
      if (suggestedFix != null) {
        fixes.add(suggestedFix);
      }
    }
    ApplySuggestedFixes.applySuggestedFixesToFiles(fixes);
  }
}

Fixed version (ground truth):
private static void lint(Path path,boolean fix) throws IOException {
  SourceFile file=SourceFile.fromFile(path.toString());
  Compiler compiler=new Compiler(System.out);
  CompilerOptions options=new CompilerOptions();
  options.setLanguage(LanguageMode.ECMASCRIPT6_STRICT);
  options.setSkipTranspilationAndCrash(true);
  options.setIdeMode(true);
  options.setCodingConvention(new GoogleCodingConvention());
  options.setWarningLevel(DiagnosticGroups.CHECK_TYPES,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.LINT_CHECKS,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.MISSING_REQUIRE,CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE,CheckLevel.WARNING);
  compiler.setPassConfig(new LintPassConfig(options));
  compiler.disableThreads();
  SourceFile externs=SourceFile.fromCode("String_Node_Str","String_Node_Str");
  compiler.compile(ImmutableList.<SourceFile>of(externs),ImmutableList.of(file),options);
  if (fix) {
    List<SuggestedFix> fixes=new ArrayList<>();
    for (    JSError warning : concat(compiler.getErrors(),compiler.getWarnings(),JSError.class)) {
      SuggestedFix suggestedFix=ErrorToFixMapper.getFixForJsError(warning,compiler);
      if (suggestedFix != null) {
        fixes.add(suggestedFix);
      }
    }
    ApplySuggestedFixes.applySuggestedFixesToFiles(fixes);
  }
}
Program: 19481
Project: 19481
Buggy source:
@Override public JSType caseTemplateType(TemplateType type){
  if (replacements.hasTemplateKey(type)) {
    if (hasVisitedType(type) || !replacements.hasTemplateType(type)) {
      return type;
    }
 else {
      JSType replacement=replacements.getUnresolvedOriginalTemplateType(type);
      JSType restrictedReplacement=replacement.restrictByNotNullOrUndefined();
      if (restrictedReplacement.isTemplatizedType() && restrictedReplacement.toMaybeTemplatizedType().getTemplateTypes().contains(type)) {
        return type;
      }
      visitedTypes.push(type);
      JSType visitedReplacement=replacement.visit(this);
      visitedTypes.pop();
      return visitedReplacement;
    }
  }
 else {
    return type;
  }
}

Fixed version (ground truth):
@Override public JSType caseTemplateType(TemplateType type){
  if (replacements.hasTemplateKey(type)) {
    if (hasVisitedType(type) || !replacements.hasTemplateType(type)) {
      return type;
    }
 else {
      JSType replacement=replacements.getUnresolvedOriginalTemplateType(type);
      JSType restrictedReplacement=replacement.restrictByNotNullOrUndefined();
      if (restrictedReplacement.isTemplatizedType()) {
        Iterable<JSType> replacementTemplateTypes=restrictedReplacement.toMaybeTemplatizedType().getTemplateTypes();
        for (        JSType replacementTemplateType : replacementTemplateTypes) {
          if (!replacementTemplateType.differsFrom(type)) {
            return type;
          }
        }
      }
      visitedTypes.push(type);
      JSType visitedReplacement=replacement.visit(this);
      visitedTypes.pop();
      return visitedReplacement;
    }
  }
 else {
    return type;
  }
}
Program: 19482
Project: 19482
Buggy source:
@Override public JSType caseTemplateType(TemplateType type){
  if (replacements.hasTemplateKey(type)) {
    if (hasVisitedType(type) || !replacements.hasTemplateType(type)) {
      return type;
    }
 else {
      JSType replacement=replacements.getUnresolvedOriginalTemplateType(type);
      visitedTypes.push(type);
      JSType visitedReplacement=replacement.visit(this);
      visitedTypes.pop();
      return visitedReplacement;
    }
  }
 else {
    return type;
  }
}

Fixed version (ground truth):
@Override public JSType caseTemplateType(TemplateType type){
  if (replacements.hasTemplateKey(type)) {
    if (hasVisitedType(type) || !replacements.hasTemplateType(type)) {
      return type;
    }
 else {
      JSType replacement=replacements.getUnresolvedOriginalTemplateType(type);
      JSType restrictedReplacement=replacement.restrictByNotNullOrUndefined();
      if (restrictedReplacement.isTemplatizedType() && restrictedReplacement.toMaybeTemplatizedType().getTemplateTypes().contains(type)) {
        return type;
      }
      visitedTypes.push(type);
      JSType visitedReplacement=replacement.visit(this);
      visitedTypes.pop();
      return visitedReplacement;
    }
  }
 else {
    return type;
  }
}