nus-yam/ex-repair huggingface dataset:
Program: 27361
Project: 27361
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case FUNCTION:
    Node grandparent=parent.getParent();
  if (grandparent == null || (!isPrototypePropertyDeclaration(grandparent) && !isClassPropertyDeclaration(parent.getFirstChild(),currentScope))) {
    RawNominalType ownerType=maybeGetOwnerType(n,parent);
    visitFunctionLate(n,ownerType);
  }
break;
case NAME:
{
String name=n.getString();
if (name == null || parent.isFunction()) {
  return;
}
if (parent.isVar() || parent.isCatch()) {
  visitVar(n,parent);
}
 else if (currentScope.isOuterVarEarly(name)) {
  currentScope.addOuterVar(name);
}
 else if (currentScope.getTypedef(name) != null || !name.equals(currentScope.getName()) && !currentScope.isDefinedLocally(name,false)) {
}
break;
}
case GETPROP:
if (NodeUtil.isPropertyTest(compiler,n) || isPropertyAbsentTest(n)) {
allPropertyNames.add(n.getLastChild().getString());
}
if (parent.isExprResult() && n.isQualifiedName()) {
visitPropertyDeclaration(n);
}
break;
case ASSIGN:
{
Node lvalue=n.getFirstChild();
if (lvalue.isGetProp() && lvalue.isQualifiedName() && parent.isExprResult()) {
visitPropertyDeclaration(lvalue);
}
break;
}
case CAST:
castTypes.put(n,getDeclaredTypeOfNode(n.getJSDocInfo(),currentScope));
break;
case OBJECTLIT:
visitObjectLit(n,parent);
break;
case CALL:
visitCall(n);
break;
default :
break;
}
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case FUNCTION:
    Node grandparent=parent.getParent();
  if (grandparent == null || (!isPrototypePropertyDeclaration(grandparent) && !isClassPropertyDeclaration(parent.getFirstChild(),currentScope))) {
    RawNominalType ownerType=maybeGetOwnerType(n,parent);
    visitFunctionLate(n,ownerType);
  }
break;
case NAME:
{
String name=n.getString();
if (name == null || parent.isFunction()) {
  return;
}
if (parent.isVar() || parent.isCatch()) {
  visitVar(n,parent);
}
 else if (currentScope.isOuterVarEarly(name)) {
  currentScope.addOuterVar(name);
}
 else if (currentScope.getTypedef(name) != null || !name.equals(currentScope.getName()) && !currentScope.isDefinedLocally(name,false)) {
}
break;
}
case GETPROP:
if (NodeUtil.isPropertyTest(compiler,n) || isPropertyAbsentTest(n)) {
allPropertyNames.add(n.getLastChild().getString());
}
if (parent.isExprResult() && n.isQualifiedName()) {
visitPropertyDeclaration(n);
}
break;
case ASSIGN:
{
Node lvalue=n.getFirstChild();
if (lvalue.isGetProp() && lvalue.isQualifiedName()) {
visitPropertyDeclaration(lvalue);
}
break;
}
case CAST:
castTypes.put(n,getDeclaredTypeOfNode(n.getJSDocInfo(),currentScope));
break;
case OBJECTLIT:
visitObjectLit(n,parent);
break;
case CALL:
visitCall(n);
break;
default :
break;
}
}
Program: 27362
Project: 27362
Buggy source:
boolean isPropDefinedOnSubtype(QualifiedName pname){
  Preconditions.checkArgument(pname.isIdentifier());
  return this.rawType.isPropDefinedOnSubtype(this,pname);
}

Fixed version (ground truth):
boolean isPropDefinedOnSubtype(QualifiedName pname){
  Preconditions.checkArgument(pname.isIdentifier());
  return this.rawType.isPropDefinedOnSubtype(pname.getLeftmostName());
}
Program: 27363
Project: 27363
Buggy source:
boolean isPropDefinedOnSubtype(QualifiedName pname){
  Preconditions.checkArgument(pname.isIdentifier());
  NominalType nt=getNominalType();
  Preconditions.checkState(!nt.isBuiltinObject());
  return nt.isPropDefinedOnSubtype(pname);
}

Fixed version (ground truth):
boolean isPropDefinedOnSubtype(QualifiedName pname){
  Preconditions.checkArgument(pname.isIdentifier());
  NominalType nt=getNominalType();
  return nt.isBuiltinObject() ? false : nt.isPropDefinedOnSubtype(pname);
}
Program: 27364
Project: 27364
Buggy source:
/** 
 * @return Whether the superclass can be added without creating a cycle. 
 */
public boolean addSuperClass(NominalType superclass){
  Preconditions.checkState(!this.isFinalized);
  Preconditions.checkState(this.superclass == null);
  if (superclass.hasAncestorClass(this)) {
    return false;
  }
  this.superclass=superclass;
  addSubtypeTo(superclass,this);
  return true;
}

Fixed version (ground truth):
/** 
 * @return Whether the superclass can be added without creating a cycle. 
 */
public boolean addSuperClass(NominalType superclass){
  Preconditions.checkState(!this.isFinalized);
  Preconditions.checkState(this.superclass == null);
  if (superclass.hasAncestorClass(this)) {
    return false;
  }
  this.superclass=superclass;
  superclass.getRawNominalType().addSubtype(this);
  return true;
}
Program: 27365
Project: 27365
Buggy source:
/** 
 * @return Whether the interface can be added without creating a cycle. 
 */
public boolean addInterfaces(ImmutableSet<NominalType> interfaces){
  Preconditions.checkState(!this.isFinalized);
  Preconditions.checkState(this.interfaces == null);
  Preconditions.checkNotNull(interfaces);
  if (this.isInterface()) {
    for (    NominalType interf : interfaces) {
      if (interf.hasAncestorInterface(this)) {
        this.interfaces=ImmutableSet.of();
        return false;
      }
    }
  }
  for (  NominalType interf : interfaces) {
    if (interf.getRawNominalType().inheritsFromIObjectReflexive()) {
      this.objectKind=ObjectKind.UNRESTRICTED;
    }
    addSubtypeTo(interf,this);
  }
  this.interfaces=interfaces;
  return true;
}

Fixed version (ground truth):
/** 
 * @return Whether the interface can be added without creating a cycle. 
 */
public boolean addInterfaces(ImmutableSet<NominalType> interfaces){
  Preconditions.checkState(!this.isFinalized);
  Preconditions.checkState(this.interfaces == null);
  Preconditions.checkNotNull(interfaces);
  if (this.isInterface()) {
    for (    NominalType interf : interfaces) {
      if (interf.hasAncestorInterface(this)) {
        this.interfaces=ImmutableSet.of();
        return false;
      }
    }
  }
  for (  NominalType interf : interfaces) {
    if (interf.getRawNominalType().inheritsFromIObjectReflexive()) {
      this.objectKind=ObjectKind.UNRESTRICTED;
    }
    interf.getRawNominalType().addSubtype(this);
  }
  this.interfaces=interfaces;
  return true;
}
Program: 27366
Project: 27366
Buggy source:
boolean isPropDefinedOnSubtype(NominalType thisAsNominal,QualifiedName qname){
  Preconditions.checkArgument(qname.isIdentifier());
  String pname=qname.getLeftmostName();
  for (  RawNominalType subtype : this.subtypes.get(thisAsNominal)) {
    if (subtype.mayHaveProp(pname)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean isPropDefinedOnSubtype(String pname){
  if (mayHaveProp(pname)) {
    return true;
  }
  for (  RawNominalType subtype : this.subtypes) {
    if (subtype.isPropDefinedOnSubtype(pname)) {
      return true;
    }
  }
  return false;
}
Program: 27368
Project: 27368
Buggy source:
/** 
 * Creates a SuggestedFix for the given error. Note that some errors have multiple fixes so getFixesForJsError should often be used instead of this.
 */
public static SuggestedFix getFixForJsError(JSError error,AbstractCompiler compiler){
switch (error.getType().key) {
case "String_Node_Str":
    return getFixForMissingSemicolon(error,compiler);
case "String_Node_Str":
  return getFixForUnsortedRequiresOrProvides("String_Node_Str",error,compiler);
case "String_Node_Str":
return getFixForUnsortedRequiresOrProvides("String_Node_Str",error,compiler);
case "String_Node_Str":
case "String_Node_Str":
return removeNode(error,compiler);
case "String_Node_Str":
return getFixForInexistentProperty(error,compiler);
case "String_Node_Str":
return getFixForMissingSuper(error,compiler);
case "String_Node_Str":
return getFixForInvalidSuper(error,compiler);
case "String_Node_Str":
case "String_Node_Str":
return getFixForMissingRequire(error,compiler);
case "String_Node_Str":
return getFixForExtraRequire(error,compiler,DUPLICATE_REQUIRE);
case "String_Node_Str":
return getFixForExtraRequire(error,compiler,EXTRA_REQUIRE);
default :
return null;
}
}

Fixed version (ground truth):
/** 
 * Creates a SuggestedFix for the given error. Note that some errors have multiple fixes so getFixesForJsError should often be used instead of this.
 */
public static SuggestedFix getFixForJsError(JSError error,AbstractCompiler compiler){
switch (error.getType().key) {
case "String_Node_Str":
    return getFixForMissingSemicolon(error,compiler);
case "String_Node_Str":
  return getFixForUnsortedRequiresOrProvides("String_Node_Str",error,compiler);
case "String_Node_Str":
return getFixForUnsortedRequiresOrProvides("String_Node_Str",error,compiler);
case "String_Node_Str":
case "String_Node_Str":
return removeNode(error,compiler);
case "String_Node_Str":
return getFixForInexistentProperty(error,compiler);
case "String_Node_Str":
return getFixForMissingSuper(error,compiler);
case "String_Node_Str":
return getFixForInvalidSuper(error,compiler);
case "String_Node_Str":
case "String_Node_Str":
return getFixForMissingRequire(error,compiler);
case "String_Node_Str":
return getFixForExtraRequire(error,compiler,DUPLICATE_REQUIRE);
case "String_Node_Str":
return getFixForExtraRequire(error,compiler,EXTRA_REQUIRE);
case "String_Node_Str":
return getFixForReferenceToShortImportByLongName(error,compiler);
default :
return null;
}
}
Program: 27371
Project: 27371
Buggy source:
void collectPropertyNames(Set<String> props){
  Set<PropertyMap> identitySet=Sets.newIdentityHashSet();
  collectPropertyNamesHelper(props,identitySet);
}

Fixed version (ground truth):
void collectPropertyNames(Set<String> props){
  props.addAll(properties.keySet());
  PropertyMap primaryParent=getPrimaryParent();
  if (primaryParent != null) {
    primaryParent.collectPropertyNames(props);
  }
  for (  PropertyMap p : getSecondaryParents()) {
    if (p != null) {
      p.collectPropertyNames(props);
    }
  }
}
Program: 27372
Project: 27372
Buggy source:
public void testInterfaceExtendsLoop2(){
  testClosureTypes(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInterfaceExtendsLoop2(){
  testClosureTypesMultipleWarnings(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ImmutableList.of("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str"));
}
Program: 27373
Project: 27373
Buggy source:
void collectPropertyNames(Set<String> props){
  props.addAll(properties.keySet());
  PropertyMap primaryParent=getPrimaryParent();
  if (primaryParent != null) {
    primaryParent.collectPropertyNames(props);
  }
  for (  PropertyMap p : getSecondaryParents()) {
    if (p != null) {
      p.collectPropertyNames(props);
    }
  }
}

Fixed version (ground truth):
void collectPropertyNames(Set<String> props){
  Set<PropertyMap> identitySet=Sets.newIdentityHashSet();
  collectPropertyNamesHelper(props,identitySet);
}
Program: 27374
Project: 27374
Buggy source:
public void testInterfaceExtendsLoop2(){
  testClosureTypesMultipleWarnings(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ImmutableList.of("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str"));
}

Fixed version (ground truth):
public void testInterfaceExtendsLoop2(){
  testClosureTypes(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str");
}
Program: 27375
Project: 27375
Buggy source:
@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):
@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: 27376
Project: 27376
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: 27377
Project: 27377
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: 27378
Project: 27378
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: 27379
Project: 27379
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: 27381
Project: 27381
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: 27382
Project: 27382
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: 27383
Project: 27383
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: 27384
Project: 27384
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: 27385
Project: 27385
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: 27386
Project: 27386
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: 27387
Project: 27387
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: 27388
Project: 27388
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: 27389
Project: 27389
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: 27390
Project: 27390
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: 27391
Project: 27391
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: 27392
Project: 27392
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: 27393
Project: 27393
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: 27394
Project: 27394
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: 27396
Project: 27396
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: 27397
Project: 27397
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: 27398
Project: 27398
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: 27399
Project: 27399
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: 27400
Project: 27400
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: 27402
Project: 27402
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: 27403
Project: 27403
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;
}