nus-yam/ex-repair huggingface dataset:
Program: 27751
Project: 27751
Buggy source:
public void testInstanceof(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str",VarCheck.UNDEFINED_VAR_ERROR);
  typeCheck("String_Node_Str" + "String_Node_Str",ImmutableList.of(NewTypeInference.INVALID_OPERAND_TYPE,NewTypeInference.PROPERTY_ACCESS_ON_NONOBJECT));
}

Fixed version (ground truth):
public void testInstanceof(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str",VarCheck.UNDEFINED_VAR_ERROR);
  typeCheck("String_Node_Str" + "String_Node_Str",ImmutableList.of(NewTypeInference.INVALID_OPERAND_TYPE,NewTypeInference.PROPERTY_ACCESS_ON_NONOBJECT));
}
Program: 27754
Project: 27754
Buggy source:
/** 
 * Runs the sanity check if it is available.
 */
private void maybeSanityCheck(Node externs,Node root){
  if (sanityCheck != null) {
    sanityCheck.create(compiler).process(externs,root);
    if (inLoop) {
      NodeUtil.verifyScopeChanges(mtoc,jsRoot,true,compiler);
      setSanityCheckState();
    }
  }
}

Fixed version (ground truth):
/** 
 * Runs the sanity check if it is available.
 */
private void maybeSanityCheck(Node externs,Node root){
  if (sanityCheck != null) {
    sanityCheck.create(compiler).process(externs,root);
    if (inLoop) {
      NodeUtil.verifyScopeChanges(mtoc,jsRoot,true,compiler);
    }
  }
}
Program: 27755
Project: 27755
Buggy source:
private void setSanityCheckState(){
  lastAst=jsRoot.cloneTree();
  mtoc=NodeUtil.mapMainToClone(jsRoot,lastAst);
}

Fixed version (ground truth):
private void setSanityCheckState(){
  if (inLoop) {
    lastAst=jsRoot.cloneTree();
    mtoc=NodeUtil.mapMainToClone(jsRoot,lastAst);
  }
}
Program: 27756
Project: 27756
Buggy source:
@Override protected CompilerPass create(AbstractCompiler compiler){
  return new RemoveUnusedVars(compiler,false,false,false);
}

Fixed version (ground truth):
@Override protected CompilerPass create(final AbstractCompiler compiler){
  return new CompilerPass(){
    @Override public void process(    Node externs,    Node root){
      NameAnalyzer na=new NameAnalyzer(compiler,false);
      na.process(externs,root);
      na.removeUnreferenced();
    }
  }
;
}
Program: 27758
Project: 27758
Buggy source:
public JSType negate(){
  if (isTop() || isUnknown() || objs != null || typeVar != null) {
    return this;
  }
  if (isTruthy()) {
    return FALSY;
  }
 else   if (isFalsy()) {
    return TRUTHY;
  }
  return new JSType(TOP_SCALAR_MASK & ~mask);
}

Fixed version (ground truth):
public JSType negate(){
  if (isTop() || isUnknown()) {
    return this;
  }
  if (isTruthy()) {
    return FALSY;
  }
 else   if (isFalsy()) {
    return TRUTHY;
  }
 else   if (objs == null && typeVar == null) {
    return new JSType(TOP_SCALAR_MASK & ~mask);
  }
  return UNKNOWN;
}
Program: 27760
Project: 27760
Buggy source:
private ObjectType(NominalType nominalType,PersistentMap<String,Property> props,FunctionType fn,boolean isLoose,ObjectKind objectKind){
  this.nominalType=nominalType;
  this.props=props;
  this.fn=fn;
  this.isLoose=isLoose;
  this.objectKind=objectKind;
}

Fixed version (ground truth):
private ObjectType(NominalType nominalType,PersistentMap<String,Property> props,FunctionType fn,boolean isLoose,ObjectKind objectKind){
  Preconditions.checkState(nominalType == null || !isLoose);
  this.nominalType=nominalType;
  this.props=props;
  this.fn=fn;
  this.isLoose=isLoose;
  this.objectKind=objectKind;
}
Program: 27761
Project: 27761
Buggy source:
boolean isLooseSubtypeOf(ObjectType obj2){
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  for (  String pname : obj2.props.keySet()) {
    if (props.containsKey(pname)) {
      if (!props.get(pname).getType().isSubtypeOf(obj2.props.get(pname).getType())) {
        return false;
      }
    }
  }
  if (obj2.fn == null) {
    return true;
  }
 else   if (this.fn == null) {
    return false;
  }
  return fn.isLooseSubtypeOf(obj2.fn);
}

Fixed version (ground truth):
boolean isLooseSubtypeOf(ObjectType obj2){
  Preconditions.checkState(isLoose || obj2.isLoose);
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  if (!isLoose) {
    if (!objectKind.isSubtypeOf(obj2.objectKind)) {
      return false;
    }
    for (    String pname : obj2.props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (!mayHaveProp(qname) || !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
 else {
    for (    String pname : props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (obj2.mayHaveProp(qname) && !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
  if (obj2.fn == null) {
    return true;
  }
 else   if (this.fn == null) {
    return false;
  }
  return fn.isLooseSubtypeOf(obj2.fn);
}
Program: 27762
Project: 27762
Buggy source:
/** 
 * Required properties are acceptable where an optional is required, but not vice versa. Optional properties create cycles in the type lattice, eg, { } \le { p: num= }  and also   { p: num= } \le { }.
 */
boolean isSubtypeOf(ObjectType obj2){
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  if (!objectKind.isSubtypeOf(obj2.objectKind)) {
    return false;
  }
  if (this.isLoose || obj2.isLoose) {
    return this.isLooseSubtypeOf(obj2);
  }
  for (  String pname : obj2.props.keySet()) {
    Property prop2=obj2.props.get(pname);
    Property prop1=this.getLeftmostProp(new QualifiedName(pname));
    if (prop2.isOptional()) {
      if (prop1 != null && !prop1.getType().isSubtypeOf(prop2.getType())) {
        return false;
      }
    }
 else {
      if (prop1 == null || prop1.isOptional() || !prop1.getType().isSubtypeOf(prop2.getType())) {
        return false;
      }
    }
  }
  if ((this.nominalType == null && obj2.nominalType != null) || this.nominalType != null && obj2.nominalType != null && !this.nominalType.isSubclassOf(obj2.nominalType)) {
    return false;
  }
  if (obj2.fn == null) {
    return true;
  }
 else   if (this.fn == null) {
    return false;
  }
  return this.fn.isSubtypeOf(obj2.fn);
}

Fixed version (ground truth):
/** 
 * Required properties are acceptable where an optional is required, but not vice versa. Optional properties create cycles in the type lattice, eg, { } \le { p: num= }  and also   { p: num= } \le { }.
 */
boolean isSubtypeOf(ObjectType obj2){
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  if (this.isLoose || obj2.isLoose) {
    return this.isLooseSubtypeOf(obj2);
  }
  if (!objectKind.isSubtypeOf(obj2.objectKind)) {
    return false;
  }
  for (  String pname : obj2.props.keySet()) {
    Property prop2=obj2.props.get(pname);
    Property prop1=this.getLeftmostProp(new QualifiedName(pname));
    if (prop2.isOptional()) {
      if (prop1 != null && !prop1.getType().isSubtypeOf(prop2.getType())) {
        return false;
      }
    }
 else {
      if (prop1 == null || prop1.isOptional() || !prop1.getType().isSubtypeOf(prop2.getType())) {
        return false;
      }
    }
  }
  if ((this.nominalType == null && obj2.nominalType != null) || this.nominalType != null && obj2.nominalType != null && !this.nominalType.isSubclassOf(obj2.nominalType)) {
    return false;
  }
  if (obj2.fn == null) {
    return true;
  }
 else   if (this.fn == null) {
    return false;
  }
  return this.fn.isSubtypeOf(obj2.fn);
}
Program: 27763
Project: 27763
Buggy source:
ObjectType specialize(ObjectType other){
  Preconditions.checkState(areRelatedClasses(this.nominalType,other.nominalType));
  NominalType resultNominalType=NominalType.pickSubclass(this.nominalType,other.nominalType);
  return ObjectType.makeObjectType(resultNominalType,meetPropsHelper(true,resultNominalType,this.props,other.props),(fn == null) ? null : fn.specialize(other.fn),this.isLoose || other.isLoose,ObjectKind.meet(this.objectKind,other.objectKind));
}

Fixed version (ground truth):
ObjectType specialize(ObjectType other){
  Preconditions.checkState(areRelatedClasses(this.nominalType,other.nominalType));
  NominalType resultNominalType=NominalType.pickSubclass(this.nominalType,other.nominalType);
  return ObjectType.makeObjectType(resultNominalType,meetPropsHelper(true,resultNominalType,this.props,other.props),(fn == null) ? null : fn.specialize(other.fn),resultNominalType == null && this.isLoose,ObjectKind.meet(this.objectKind,other.objectKind));
}
Program: 27764
Project: 27764
Buggy source:
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  call=(ArrowType)safeResolve(call,t,scope);
  if (prototypeSlot != null) {
    prototypeSlot.setType(safeResolve(prototypeSlot.getType(),t,scope));
  }
  JSType maybeTypeOfThis=safeResolve(typeOfThis,t,scope);
  if (maybeTypeOfThis != null) {
    if (maybeTypeOfThis.isNullType() || maybeTypeOfThis.isVoidType()) {
      typeOfThis=maybeTypeOfThis;
    }
 else {
      maybeTypeOfThis=ObjectType.cast(maybeTypeOfThis.restrictByNotNullOrUndefined());
      if (maybeTypeOfThis != null) {
        typeOfThis=maybeTypeOfThis;
      }
    }
  }
  boolean changed=false;
  ImmutableList.Builder<ObjectType> resolvedInterfaces=ImmutableList.builder();
  for (  ObjectType iface : implementedInterfaces) {
    ObjectType resolvedIface=(ObjectType)iface.resolve(t,scope);
    resolvedInterfaces.add(resolvedIface);
    changed|=(resolvedIface != iface);
  }
  if (changed) {
    implementedInterfaces=resolvedInterfaces.build();
  }
  if (subTypes != null) {
    for (int i=0; i < subTypes.size(); i++) {
      subTypes.set(i,JSType.toMaybeFunctionType(subTypes.get(i).resolve(t,scope)));
    }
  }
  return super.resolveInternal(t,scope);
}

Fixed version (ground truth):
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  call=(ArrowType)safeResolve(call,t,scope);
  if (prototypeSlot != null) {
    prototypeSlot.setType(safeResolve(prototypeSlot.getType(),t,scope));
  }
  JSType maybeTypeOfThis=safeResolve(typeOfThis,t,scope);
  if (maybeTypeOfThis != null) {
    if (maybeTypeOfThis.isNullType() || maybeTypeOfThis.isVoidType()) {
      typeOfThis=maybeTypeOfThis;
    }
 else {
      maybeTypeOfThis=ObjectType.cast(maybeTypeOfThis.restrictByNotNullOrUndefined());
      if (maybeTypeOfThis != null) {
        typeOfThis=maybeTypeOfThis;
      }
    }
  }
  ImmutableList<ObjectType> resolvedImplemented=resolveTypeListHelper(implementedInterfaces,t,scope);
  if (resolvedImplemented != null) {
    implementedInterfaces=resolvedImplemented;
  }
  ImmutableList<ObjectType> resolvedExtended=resolveTypeListHelper(extendedInterfaces,t,scope);
  if (resolvedExtended != null) {
    extendedInterfaces=resolvedExtended;
  }
  if (subTypes != null) {
    for (int i=0; i < subTypes.size(); i++) {
      subTypes.set(i,JSType.toMaybeFunctionType(subTypes.get(i).resolve(t,scope)));
    }
  }
  return super.resolveInternal(t,scope);
}
Program: 27765
Project: 27765
Buggy source:
private void addRelatedInterfaces(ObjectType instance,Set<ObjectType> set){
  FunctionType constructor=instance.getConstructor();
  if (constructor != null) {
    if (!constructor.isInterface()) {
      return;
    }
    set.add(instance);
    for (    ObjectType interfaceType : instance.getCtorExtendedInterfaces()) {
      addRelatedInterfaces(interfaceType,set);
    }
  }
}

Fixed version (ground truth):
private void addRelatedInterfaces(ObjectType instance,Set<ObjectType> set){
  FunctionType constructor=instance.getConstructor();
  if (constructor != null) {
    if (!constructor.isInterface()) {
      return;
    }
    if (!set.add(instance)) {
      return;
    }
    for (    ObjectType interfaceType : instance.getCtorExtendedInterfaces()) {
      addRelatedInterfaces(interfaceType,set);
    }
  }
}
Program: 27766
Project: 27766
Buggy source:
private void addRelatedExtendedInterfaces(ObjectType instance,Set<ObjectType> set){
  FunctionType constructor=instance.getConstructor();
  if (constructor != null) {
    set.add(instance);
    for (    ObjectType interfaceType : constructor.getExtendedInterfaces()) {
      addRelatedExtendedInterfaces(interfaceType,set);
    }
  }
}

Fixed version (ground truth):
private void addRelatedExtendedInterfaces(ObjectType instance,Set<ObjectType> set){
  FunctionType constructor=instance.getConstructor();
  if (constructor != null) {
    if (!set.add(instance)) {
      return;
    }
    for (    ObjectType interfaceType : constructor.getExtendedInterfaces()) {
      addRelatedExtendedInterfaces(interfaceType,set);
    }
  }
}
Program: 27767
Project: 27767
Buggy source:
public void testInterfaceExtendsLoop() throws Exception {
  testClosureTypesMultipleWarnings(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str",Lists.newArrayList("String_Node_Str"));
}

Fixed version (ground truth):
public void testInterfaceExtendsLoop() throws Exception {
  testClosureTypesMultipleWarnings(suppressMissingProperty("String_Node_Str") + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",Lists.<String>newArrayList());
}
Program: 27768
Project: 27768
Buggy source:
/** 
 * Returns whether a node corresponds to a simple or a qualified name, such as <code>x</code> or <code>a.b.c</code> or <code>this.a</code>.
 */
public boolean isQualifiedName(){
switch (getType()) {
case Token.NAME:
    return getString().isEmpty() ? false : true;
case Token.THIS:
  return true;
case Token.GETPROP:
return getFirstChild().isQualifiedName();
default :
return false;
}
}

Fixed version (ground truth):
/** 
 * Returns whether a node corresponds to a simple or a qualified name, such as <code>x</code> or <code>a.b.c</code> or <code>this.a</code>.
 */
public boolean isQualifiedName(){
switch (getType()) {
case Token.NAME:
    return !getString().isEmpty();
case Token.THIS:
  return true;
case Token.GETPROP:
return getFirstChild().isQualifiedName();
default :
return false;
}
}
Program: 27769
Project: 27769
Buggy source:
/** 
 * Returns whether a node corresponds to a simple or a qualified name without a "this" reference, such as <code>a.b.c</code>, but not <code>this.a</code> .
 */
public boolean isUnscopedQualifiedName(){
switch (getType()) {
case Token.NAME:
    return getString().isEmpty() ? false : true;
case Token.GETPROP:
  return getFirstChild().isUnscopedQualifiedName();
default :
return false;
}
}

Fixed version (ground truth):
/** 
 * Returns whether a node corresponds to a simple or a qualified name without a "this" reference, such as <code>a.b.c</code>, but not <code>this.a</code> .
 */
public boolean isUnscopedQualifiedName(){
switch (getType()) {
case Token.NAME:
    return !getString().isEmpty();
case Token.GETPROP:
  return getFirstChild().isUnscopedQualifiedName();
default :
return false;
}
}
Program: 27770
Project: 27770
Buggy source:
private boolean inlineAliasIfPossible(Ref alias,GlobalNamespace namespace){
  Node aliasParent=alias.node.getParent();
  if (aliasParent.isName()) {
    Scope scope=alias.scope;
    Var aliasVar=scope.getVar(aliasParent.getString());
    ReferenceCollectingCallback collector=new ReferenceCollectingCallback(compiler,ReferenceCollectingCallback.DO_NOTHING_BEHAVIOR,Predicates.<Var>equalTo(aliasVar));
    (new NodeTraversal(compiler,collector)).traverseAtScope(scope);
    ReferenceCollection aliasRefs=collector.getReferences(aliasVar);
    List<AstChange> newNodes=Lists.newArrayList();
    if (aliasRefs.isWellDefined() && aliasRefs.firstReferenceIsAssigningDeclaration() && aliasRefs.isAssignedOnceInLifetime()) {
      int size=aliasRefs.references.size();
      for (int i=1; i < size; i++) {
        ReferenceCollectingCallback.Reference aliasRef=aliasRefs.references.get(i);
        Node newNode=alias.node.cloneTree();
        aliasRef.getParent().replaceChild(aliasRef.getNode(),newNode);
        newNodes.add(new AstChange(getRefModule(aliasRef),aliasRef.getScope(),newNode));
      }
      aliasParent.replaceChild(alias.node,IR.nullNode());
      compiler.reportCodeChange();
      namespace.scanNewNodes(newNodes);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean inlineAliasIfPossible(Ref alias,GlobalNamespace namespace){
  Node aliasParent=alias.node.getParent();
  if (aliasParent.isName()) {
    Scope scope=alias.scope;
    Var aliasVar=scope.getVar(aliasParent.getString());
    ReferenceCollectingCallback collector=new ReferenceCollectingCallback(compiler,ReferenceCollectingCallback.DO_NOTHING_BEHAVIOR,Predicates.<Var>equalTo(aliasVar));
    collector.processScope(scope);
    ReferenceCollection aliasRefs=collector.getReferences(aliasVar);
    List<AstChange> newNodes=Lists.newArrayList();
    if (aliasRefs.isWellDefined() && aliasRefs.firstReferenceIsAssigningDeclaration() && aliasRefs.isAssignedOnceInLifetime()) {
      int size=aliasRefs.references.size();
      for (int i=1; i < size; i++) {
        ReferenceCollectingCallback.Reference aliasRef=aliasRefs.references.get(i);
        Node newNode=alias.node.cloneTree();
        aliasRef.getParent().replaceChild(aliasRef.getNode(),newNode);
        newNodes.add(new AstChange(getRefModule(aliasRef),aliasRef.getScope(),newNode));
      }
      aliasParent.replaceChild(alias.node,IR.nullNode());
      compiler.reportCodeChange();
      namespace.scanNewNodes(newNodes);
      return true;
    }
  }
  return false;
}
Program: 27771
Project: 27771
Buggy source:
/** 
 * Traverses an inner node recursively with a refined scope. An inner node may be any node with a non   {@code null} parent (i.e. all nodes except theroot).
 * @param node the node to traverse
 * @param parent the node's parent, it may not be {@code null}
 * @param refinedScope the refined scope of the scope currently at the top ofthe scope stack or in trivial cases that very scope or  {@code null}
 */
protected void traverseInnerNode(Node node,Node parent,Scope refinedScope){
  Preconditions.checkNotNull(parent);
  if (refinedScope != null && getScope() != refinedScope) {
    curNode=node;
    pushScope(refinedScope);
    traverseBranch(node,parent);
    popScope();
  }
 else {
    traverseBranch(node,parent);
  }
}

Fixed version (ground truth):
/** 
 * Traverses an inner node recursively with a refined scope. An inner node may be any node with a non   {@code null} parent (i.e. all nodes except theroot).
 * @param node the node to traverse
 * @param parent the node's parent, it may not be {@code null}
 * @param refinedScope the refined scope of the scope currently at the top ofthe scope stack or in trivial cases that very scope or  {@code null}
 */
protected void traverseInnerNode(Node node,Node parent,Scope refinedScope){
  Preconditions.checkNotNull(parent);
  if (inputId == null) {
    inputId=NodeUtil.getInputId(node);
  }
  if (refinedScope != null && getScope() != refinedScope) {
    curNode=node;
    pushScope(refinedScope);
    traverseBranch(node,parent);
    popScope();
  }
 else {
    traverseBranch(node,parent);
  }
}
Program: 27772
Project: 27772
Buggy source:
/** 
 * Creates a new scope (e.g. when entering a function). 
 */
private void pushScope(Scope s){
  Preconditions.checkState(curNode != null);
  compiler.setScope(s.getRootNode());
  scopes.push(s);
  cfgs.push(null);
  if (scopeCallback != null) {
    scopeCallback.enterScope(this);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new scope (e.g. when entering a function).
 * @param quietly Don't fire an enterScope callback.
 */
private void pushScope(Scope s,boolean quietly){
  Preconditions.checkState(curNode != null);
  compiler.setScope(s.getRootNode());
  scopes.push(s);
  cfgs.push(null);
  if (!quietly && scopeCallback != null) {
    scopeCallback.enterScope(this);
  }
}
Program: 27773
Project: 27773
Buggy source:
/** 
 * Pops back to the previous scope (e.g. when leaving a function). 
 */
private void popScope(){
  if (scopeCallback != null) {
    scopeCallback.exitScope(this);
  }
  if (scopeRoots.isEmpty()) {
    scopes.pop();
  }
 else {
    scopeRoots.pop();
  }
  cfgs.pop();
  if (hasScope()) {
    compiler.setScope(getScopeRoot());
  }
}

Fixed version (ground truth):
/** 
 * Pops back to the previous scope (e.g. when leaving a function).
 * @param quietly Don't fire the exitScope callback.
 */
private void popScope(boolean quietly){
  if (!quietly && scopeCallback != null) {
    scopeCallback.exitScope(this);
  }
  if (scopeRoots.isEmpty()) {
    scopes.pop();
  }
 else {
    scopeRoots.pop();
  }
  cfgs.pop();
  if (hasScope()) {
    compiler.setScope(getScopeRoot());
  }
}
Program: 27774
Project: 27774
Buggy source:
/** 
 * Updates block stack and invokes any additional behavior.
 */
@Override public void enterScope(NodeTraversal t){
  Node n=t.getScope().getRootNode();
  BasicBlock parent=blockStack.isEmpty() ? null : blockStack.peek();
  blockStack.push(new BasicBlock(parent,n));
}

Fixed version (ground truth):
/** 
 * Updates block stack and invokes any additional behavior.
 */
@Override public void enterScope(NodeTraversal t){
  Node n=t.getScope().getRootNode();
  BasicBlock parent=blockStack.isEmpty() ? null : peek(blockStack);
  blockStack.add(new BasicBlock(parent,n));
}
Program: 27775
Project: 27775
Buggy source:
/** 
 * Creates a new block.
 * @param parent The containing block.
 * @param root The root node of the block.
 */
BasicBlock(BasicBlock parent,Node root){
  this.parent=parent;
  this.isHoisted=NodeUtil.isHoistedFunctionDeclaration(root);
  this.isFunction=root.isFunction();
  if (root.getParent() != null) {
    int pType=root.getParent().getType();
    this.isLoop=pType == Token.DO || pType == Token.WHILE || pType == Token.FOR;
  }
 else {
    this.isLoop=false;
  }
}

Fixed version (ground truth):
/** 
 * Creates a new block.
 * @param parent The containing block.
 * @param root The root node of the block.
 */
BasicBlock(BasicBlock parent,Node root){
  this.parent=parent;
  this.root=root;
  this.isFunction=root.isFunction();
  if (root.getParent() != null) {
    int pType=root.getParent().getType();
    this.isLoop=pType == Token.DO || pType == Token.WHILE || pType == Token.FOR;
  }
 else {
    this.isLoop=false;
  }
}
Program: 27776
Project: 27776
Buggy source:
/** 
 * Updates block stack.
 */
@Override public boolean shouldTraverse(NodeTraversal nodeTraversal,Node n,Node parent){
  if (isBlockBoundary(n,parent)) {
    blockStack.push(new BasicBlock(blockStack.peek(),n));
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Updates block stack.
 */
@Override public boolean shouldTraverse(NodeTraversal nodeTraversal,Node n,Node parent){
  if (NodeUtil.isHoistedFunctionDeclaration(n)) {
    Node nameNode=n.getFirstChild();
    Var functionVar=nodeTraversal.getScope().getVar(nameNode.getString());
    if (functionVar != null) {
      if (finishedFunctionTraverse.contains(functionVar)) {
        return false;
      }
      startedFunctionTraverse.add(functionVar);
    }
  }
  if (isBlockBoundary(n,parent)) {
    blockStack.add(new BasicBlock(peek(blockStack),n));
  }
  return true;
}
Program: 27777
Project: 27777
Buggy source:
/** 
 * For each node, update the block stack and reference collection as appropriate.
 */
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName()) {
    Var v;
    if (n.getString().equals("String_Node_Str")) {
      v=t.getScope().getArgumentsVar();
    }
 else {
      v=t.getScope().getVar(n.getString());
    }
    if (v != null && varFilter.apply(v)) {
      addReference(v,new Reference(n,t,blockStack.peek()));
    }
  }
  if (isBlockBoundary(n,parent)) {
    blockStack.pop();
  }
}

Fixed version (ground truth):
/** 
 * For each node, update the block stack and reference collection as appropriate.
 */
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName()) {
    Var v;
    if (n.getString().equals("String_Node_Str")) {
      v=t.getScope().getArgumentsVar();
    }
 else {
      v=t.getScope().getVar(n.getString());
    }
    if (v != null) {
      if (varFilter.apply(v)) {
        addReference(v,new Reference(n,t,peek(blockStack)));
      }
      if (v.getParentNode() != null && NodeUtil.isHoistedFunctionDeclaration(v.getParentNode()) && (narrowScope == null || narrowScope.getDepth() <= v.getScope().getDepth())) {
        outOfBandTraversal(v);
      }
    }
  }
  if (isBlockBoundary(n,parent)) {
    pop(blockStack);
  }
}
Program: 27778
Project: 27778
Buggy source:
/** 
 * Updates block stack and invokes any additional behavior.
 */
@Override public void exitScope(NodeTraversal t){
  blockStack.pop();
  if (t.getScope().isGlobal()) {
    compiler.updateGlobalVarReferences(referenceMap,t.getScopeRoot());
    behavior.afterExitScope(t,compiler.getGlobalVarReferences());
  }
 else {
    behavior.afterExitScope(t,new ReferenceMapWrapper(referenceMap));
  }
}

Fixed version (ground truth):
/** 
 * Updates block stack and invokes any additional behavior.
 */
@Override public void exitScope(NodeTraversal t){
  pop(blockStack);
  if (t.getScope().isGlobal()) {
    compiler.updateGlobalVarReferences(referenceMap,t.getScopeRoot());
    behavior.afterExitScope(t,compiler.getGlobalVarReferences());
  }
 else {
    behavior.afterExitScope(t,new ReferenceMapWrapper(referenceMap));
  }
}
Program: 27779
Project: 27779
Buggy source:
/** 
 * Determines whether this block is guaranteed to begin executing before the given block does.
 */
boolean provablyExecutesBefore(BasicBlock thatBlock){
  BasicBlock currentBlock;
  for (currentBlock=thatBlock; currentBlock != null && currentBlock != this; currentBlock=currentBlock.getParent()) {
    if (currentBlock.isHoisted) {
      return false;
    }
  }
  if (currentBlock == this) {
    return true;
  }
  if (isGlobalScopeBlock() && thatBlock.isGlobalScopeBlock()) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Determines whether this block is guaranteed to begin executing before the given block does.
 */
boolean provablyExecutesBefore(BasicBlock thatBlock){
  BasicBlock currentBlock;
  for (currentBlock=thatBlock; currentBlock != null && currentBlock != this; currentBlock=currentBlock.getParent()) {
  }
  if (currentBlock == this) {
    return true;
  }
  if (isGlobalScopeBlock() && thatBlock.isGlobalScopeBlock()) {
    return true;
  }
  return false;
}
Program: 27780
Project: 27780
Buggy source:
/** 
 * Visits a CALL node.
 * @param t The node traversal object that supplies context, such as thescope chain to use in name lookups as well as error reporting.
 * @param n The node being visited.
 */
private void visitCall(NodeTraversal t,Node n){
  Node child=n.getFirstChild();
  JSType childType=getJSType(child).restrictByNotNullOrUndefined();
  if (!childType.canBeCalled()) {
    report(t,n,NOT_CALLABLE,childType.toString());
    ensureTyped(t,n);
    return;
  }
  if (childType.isFunctionType()) {
    FunctionType functionType=childType.toMaybeFunctionType();
    if (functionType.isConstructor() && !functionType.isNativeObjectType() && (functionType.getReturnType().isUnknownType() || functionType.getReturnType().isVoidType())) {
      report(t,n,CONSTRUCTOR_NOT_CALLABLE,childType.toString());
    }
    if (functionType.isOrdinaryFunction() && !functionType.getTypeOfThis().isUnknownType() && !(functionType.getTypeOfThis().toObjectType() != null && functionType.getTypeOfThis().toObjectType().isNativeObjectType())&& !(child.isGetElem() || child.isGetProp())) {
      report(t,n,EXPECTED_THIS_TYPE,functionType.toString());
    }
    visitParameterList(t,n,functionType);
    ensureTyped(t,n,functionType.getReturnType());
  }
 else {
    ensureTyped(t,n);
  }
}

Fixed version (ground truth):
/** 
 * Visits a CALL node.
 * @param t The node traversal object that supplies context, such as thescope chain to use in name lookups as well as error reporting.
 * @param n The node being visited.
 */
private void visitCall(NodeTraversal t,Node n){
  checkCallConventions(t,n);
  Node child=n.getFirstChild();
  JSType childType=getJSType(child).restrictByNotNullOrUndefined();
  if (!childType.canBeCalled()) {
    report(t,n,NOT_CALLABLE,childType.toString());
    ensureTyped(t,n);
    return;
  }
  if (childType.isFunctionType()) {
    FunctionType functionType=childType.toMaybeFunctionType();
    if (functionType.isConstructor() && !functionType.isNativeObjectType() && (functionType.getReturnType().isUnknownType() || functionType.getReturnType().isVoidType())) {
      report(t,n,CONSTRUCTOR_NOT_CALLABLE,childType.toString());
    }
    if (functionType.isOrdinaryFunction() && !functionType.getTypeOfThis().isUnknownType() && !(functionType.getTypeOfThis().toObjectType() != null && functionType.getTypeOfThis().toObjectType().isNativeObjectType())&& !(child.isGetElem() || child.isGetProp())) {
      report(t,n,EXPECTED_THIS_TYPE,functionType.toString());
    }
    visitParameterList(t,n,functionType);
    ensureTyped(t,n,functionType.getReturnType());
  }
 else {
    ensureTyped(t,n);
  }
}
Program: 27783
Project: 27783
Buggy source:
private void maybeCollectMember(Node member,Node nodeWithJsDocInfo,@Nullable Node value){
  JSDocInfo info=nodeWithJsDocInfo.getJSDocInfo();
  if (info == null || !member.isGetProp() || !member.getFirstChild().isThis()) {
    return;
  }
  member.getFirstChild().setJSType(thisType);
  JSType thisObjectType=thisType.toObjectType();
  if (thisObjectType != null) {
    ImmutableList<TemplateType> keys=thisObjectType.getTemplateTypeMap().getTemplateKeys();
    typeRegistry.setTemplateTypeNames(keys);
  }
  JSType jsType=getDeclaredType(info,member,value);
  if (thisObjectType != null) {
    typeRegistry.clearTemplateTypeNames();
  }
  Node name=member.getLastChild();
  if (jsType != null && (name.isName() || name.isString()) && thisType.toObjectType() != null) {
    thisType.toObjectType().defineDeclaredProperty(name.getString(),jsType,member);
  }
}

Fixed version (ground truth):
private void maybeCollectMember(Node member,Node nodeWithJsDocInfo,@Nullable Node value){
  JSDocInfo info=nodeWithJsDocInfo.getJSDocInfo();
  if (info == null || !member.isGetProp() || !member.getFirstChild().isThis()) {
    return;
  }
  JSType jsType=getDeclaredType(info,member,value);
  Node name=member.getLastChild();
  if (jsType != null) {
    thisTypeForProperties.defineDeclaredProperty(name.getString(),jsType,member);
  }
}
Program: 27784
Project: 27784
Buggy source:
/** 
 * Look for a type declaration on a property assignment (in an ASSIGN or an object literal key).
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,or  {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(JSDocInfo info,Node lValue,@Nullable Node rValue){
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(lValue,info);
  }
 else   if (rValue != null && rValue.isFunction() && shouldUseFunctionLiteralType(JSType.toMaybeFunctionType(rValue.getJSType()),info,lValue)) {
    return rValue.getJSType();
  }
 else   if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      }
 else {
        return createEnumTypeFromNodes(rValue,lValue.getQualifiedName(),info,lValue);
      }
    }
 else     if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(rValue,lValue.getQualifiedName(),info,lValue);
    }
  }
  if (isConstantSymbol(info,lValue)) {
    if (rValue != null) {
      JSType rValueType=getDeclaredRValueType(lValue,rValue);
      if (rValueType != null) {
        return rValueType;
      }
    }
  }
  return getDeclaredTypeInAnnotation(lValue,info);
}

Fixed version (ground truth):
/** 
 * Look for a type declaration on a property assignment (in an ASSIGN or an object literal key).
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,or  {@code null} if this is a stub declaration.
 */
JSType getDeclaredType(JSDocInfo info,Node lValue,@Nullable Node rValue){
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(lValue,info);
  }
 else   if (rValue != null && rValue.isFunction() && shouldUseFunctionLiteralType(JSType.toMaybeFunctionType(rValue.getJSType()),info,lValue)) {
    return rValue.getJSType();
  }
 else   if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      }
 else {
        return createEnumTypeFromNodes(rValue,lValue.getQualifiedName(),info,lValue);
      }
    }
 else     if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(rValue,lValue.getQualifiedName(),info,lValue);
    }
  }
  if (isConstantSymbol(info,lValue)) {
    if (rValue != null) {
      JSType rValueType=getDeclaredRValueType(lValue,rValue);
      if (rValueType != null) {
        return rValueType;
      }
    }
  }
  return getDeclaredTypeInAnnotation(lValue,info);
}
Program: 27785
Project: 27785
Buggy source:
/** 
 * Creates a scope with all types declared. Declares newly discovered types and type properties in the type registry.
 */
@Override public Scope createScope(Node root,Scope parent){
  Scope newScope=null;
  AbstractScopeBuilder scopeBuilder=null;
  if (parent == null) {
    JSType globalThis=typeRegistry.getNativeObjectType(JSTypeNative.GLOBAL_THIS);
    root.setJSType(globalThis);
    root.getFirstChild().setJSType(globalThis);
    root.getLastChild().setJSType(globalThis);
    (new FirstOrderFunctionAnalyzer(compiler,functionAnalysisResults)).process(root.getFirstChild(),root.getLastChild());
    newScope=createInitialScope(root);
    GlobalScopeBuilder globalScopeBuilder=new GlobalScopeBuilder(newScope);
    scopeBuilder=globalScopeBuilder;
    NodeTraversal.traverse(compiler,root,scopeBuilder);
  }
 else {
    newScope=new Scope(parent,root);
    LocalScopeBuilder localScopeBuilder=new LocalScopeBuilder(newScope);
    scopeBuilder=localScopeBuilder;
    localScopeBuilder.build();
  }
  scopeBuilder.resolveStubDeclarations();
  for (  Node functionNode : scopeBuilder.nonExternFunctions) {
    JSType type=functionNode.getJSType();
    if (type != null && type.isFunctionType()) {
      FunctionType fnType=type.toMaybeFunctionType();
      JSType fnThisType=fnType.getTypeOfThis();
      if (!fnThisType.isUnknownType()) {
        NodeTraversal.traverse(compiler,functionNode.getLastChild(),scopeBuilder.new CollectProperties(fnThisType));
      }
    }
  }
  if (parent == null) {
    codingConvention.defineDelegateProxyPrototypeProperties(typeRegistry,newScope,delegateProxyPrototypes,delegateCallingConventions);
  }
  newScope.setTypeResolver(scopeBuilder);
  return newScope;
}

Fixed version (ground truth):
/** 
 * Creates a scope with all types declared. Declares newly discovered types and type properties in the type registry.
 */
@Override public Scope createScope(Node root,Scope parent){
  Scope newScope=null;
  AbstractScopeBuilder scopeBuilder=null;
  if (parent == null) {
    JSType globalThis=typeRegistry.getNativeObjectType(JSTypeNative.GLOBAL_THIS);
    root.setJSType(globalThis);
    root.getFirstChild().setJSType(globalThis);
    root.getLastChild().setJSType(globalThis);
    (new FirstOrderFunctionAnalyzer(compiler,functionAnalysisResults)).process(root.getFirstChild(),root.getLastChild());
    newScope=createInitialScope(root);
    GlobalScopeBuilder globalScopeBuilder=new GlobalScopeBuilder(newScope);
    scopeBuilder=globalScopeBuilder;
    NodeTraversal.traverse(compiler,root,scopeBuilder);
  }
 else {
    newScope=new Scope(parent,root);
    LocalScopeBuilder localScopeBuilder=new LocalScopeBuilder(newScope);
    scopeBuilder=localScopeBuilder;
    localScopeBuilder.build();
  }
  scopeBuilder.resolveStubDeclarations();
  if (parent == null) {
    codingConvention.defineDelegateProxyPrototypeProperties(typeRegistry,newScope,delegateProxyPrototypes,delegateCallingConventions);
  }
  newScope.setTypeResolver(scopeBuilder);
  return newScope;
}
Program: 27786
Project: 27786
Buggy source:
/** 
 * @param scope The scope that we're building.
 */
private LocalScopeBuilder(Scope scope){
  super(scope);
}

Fixed version (ground truth):
/** 
 * @param scope The scope that we're building.
 */
private LocalScopeBuilder(Scope scope){
  super(scope);
  thisTypeForProperties=getThisTypeForCollectingProperties();
}
Program: 27787
Project: 27787
Buggy source:
public void testClassTemplateInheritance3(){
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertEquals("String_Node_Str",findNameType("String_Node_Str",globalScope).toString());
  assertEquals("String_Node_Str",findNameType("String_Node_Str",globalScope).toString());
}

Fixed version (ground truth):
public void testClassTemplateInheritance3(){
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertEquals("String_Node_Str",findNameType("String_Node_Str",globalScope).toString());
}
Program: 27788
Project: 27788
Buggy source:
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  call=(ArrowType)safeResolve(call,t,scope);
  if (prototypeSlot != null) {
    prototypeSlot.setType(safeResolve(prototypeSlot.getType(),t,scope));
  }
  JSType maybeTypeOfThis=safeResolve(typeOfThis,t,scope);
  if (maybeTypeOfThis != null) {
    maybeTypeOfThis=maybeTypeOfThis.restrictByNotNullOrUndefined();
  }
  if (maybeTypeOfThis instanceof ObjectType) {
    typeOfThis=maybeTypeOfThis;
  }
  boolean changed=false;
  ImmutableList.Builder<ObjectType> resolvedInterfaces=ImmutableList.builder();
  for (  ObjectType iface : implementedInterfaces) {
    ObjectType resolvedIface=(ObjectType)iface.resolve(t,scope);
    resolvedInterfaces.add(resolvedIface);
    changed|=(resolvedIface != iface);
  }
  if (changed) {
    implementedInterfaces=resolvedInterfaces.build();
  }
  if (subTypes != null) {
    for (int i=0; i < subTypes.size(); i++) {
      subTypes.set(i,JSType.toMaybeFunctionType(subTypes.get(i).resolve(t,scope)));
    }
  }
  return super.resolveInternal(t,scope);
}

Fixed version (ground truth):
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  call=(ArrowType)safeResolve(call,t,scope);
  if (prototypeSlot != null) {
    prototypeSlot.setType(safeResolve(prototypeSlot.getType(),t,scope));
  }
  JSType maybeTypeOfThis=safeResolve(typeOfThis,t,scope);
  if (maybeTypeOfThis != null) {
    if (maybeTypeOfThis.isNullType() || maybeTypeOfThis.isVoidType()) {
      typeOfThis=maybeTypeOfThis;
    }
 else {
      maybeTypeOfThis=ObjectType.cast(maybeTypeOfThis.restrictByNotNullOrUndefined());
      if (maybeTypeOfThis != null) {
        typeOfThis=maybeTypeOfThis;
      }
    }
  }
  boolean changed=false;
  ImmutableList.Builder<ObjectType> resolvedInterfaces=ImmutableList.builder();
  for (  ObjectType iface : implementedInterfaces) {
    ObjectType resolvedIface=(ObjectType)iface.resolve(t,scope);
    resolvedInterfaces.add(resolvedIface);
    changed|=(resolvedIface != iface);
  }
  if (changed) {
    implementedInterfaces=resolvedInterfaces.build();
  }
  if (subTypes != null) {
    for (int i=0; i < subTypes.size(); i++) {
      subTypes.set(i,JSType.toMaybeFunctionType(subTypes.get(i).resolve(t,scope)));
    }
  }
  return super.resolveInternal(t,scope);
}
Program: 27790
Project: 27790
Buggy source:
/** 
 * Records the assignment of a value to a global name.
 * @param name Fully qualified name
 * @param node The top node representing the name (GETPROP, NAME, or STRING[objlit key])
 */
private void recordSet(String name,Node node){
  JsName jsn=getName(name,true);
  JsNameRefNode nameRefNode=new JsNameRefNode(jsn,node);
  refNodes.add(nameRefNode);
  if (node.isGetElem()) {
    recordWriteOnProperties(name);
  }
 else   if (name.indexOf('.') != -1) {
    recordWriteOnProperties(name.substring(0,name.lastIndexOf('.')));
  }
}

Fixed version (ground truth):
/** 
 * Records the assignment of a value to a global name.
 * @param name Fully qualified name
 * @param node The top node representing the name (GETPROP, NAME, or STRING[objlit key])
 */
private void recordSet(String name,Node node){
  JsName jsn=getName(name,true);
  JsNameRefNode nameRefNode=new JsNameRefNode(jsn,node);
  refNodes.add(nameRefNode);
  jsn.hasSetterReference=true;
  if (node.isGetElem()) {
    recordWriteOnProperties(name);
  }
 else   if (name.indexOf('.') != -1) {
    recordWriteOnProperties(name.substring(0,name.lastIndexOf('.')));
  }
}
Program: 27791
Project: 27791
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (!(n.isName() || (NodeUtil.isGet(n) && !parent.isGetProp()))) {
    return;
  }
  NameInformation nameInfo=createNameInformation(t,n);
  if (nameInfo == null) {
    return;
  }
  if (nameInfo.onlyAffectsClassDef) {
    if (nameInfo.superclass != null) {
      recordReference(nameInfo.name,nameInfo.superclass,RefType.INHERITANCE);
    }
    String nodeName=n.getQualifiedName();
    if (nodeName != null) {
      recordReference(nameInfo.name,nodeName,RefType.REGULAR);
    }
    return;
  }
  if (parent.isInstanceOf() && parent.getLastChild() == n && n.isQualifiedName()) {
    JsName checkedClass=getName(nameInfo.name,true);
    refNodes.add(new InstanceOfCheckNode(checkedClass,n));
    checkedClass.hasInstanceOfReference=true;
    return;
  }
  List<NameInformation> referers=getDependencyScope(n);
  if (referers.isEmpty()) {
    maybeRecordReferenceOrAlias(t,n,parent,nameInfo,null);
  }
 else {
    for (    NameInformation referring : referers) {
      maybeRecordReferenceOrAlias(t,n,parent,nameInfo,referring);
    }
    recordAliases(referers);
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (!(n.isName() || (NodeUtil.isGet(n) && !parent.isGetProp()))) {
    return;
  }
  NameInformation nameInfo=createNameInformation(t,n);
  if (nameInfo == null) {
    return;
  }
  if (nameInfo.onlyAffectsClassDef) {
    if (nameInfo.superclass != null) {
      recordReference(nameInfo.name,nameInfo.superclass,RefType.INHERITANCE);
    }
    String nodeName=n.getQualifiedName();
    if (nodeName != null) {
      recordReference(nameInfo.name,nodeName,RefType.REGULAR);
    }
    return;
  }
  boolean isInstanceOfCheck=parent.isInstanceOf() && parent.getLastChild() == n;
  if (isInstanceOfCheck) {
    JsName checkedClass=getName(nameInfo.name,true);
    if (checkedClass.hasSetterReference && !nameInfo.isExternallyReferenceable && n.isQualifiedName()) {
      refNodes.add(new InstanceOfCheckNode(checkedClass,n));
      checkedClass.hasInstanceOfReference=true;
      return;
    }
  }
  List<NameInformation> referers=getDependencyScope(n);
  if (referers.isEmpty()) {
    maybeRecordReferenceOrAlias(t,n,parent,nameInfo,null);
  }
 else {
    for (    NameInformation referring : referers) {
      maybeRecordReferenceOrAlias(t,n,parent,nameInfo,referring);
    }
    recordAliases(referers);
  }
}
Program: 27792
Project: 27792
Buggy source:
@Override public void process(Node externs,Node root){
  logger.fine("String_Node_Str");
  if (graph != null && graph.getModuleCount() > 1) {
    NodeTraversal.traverse(compiler,root,this);
    if (parentModuleCanSeeSymbolsDeclaredInChildren) {
      makeInstanceOfCodeOrderIndependent();
    }
    moveCode();
  }
}

Fixed version (ground truth):
@Override public void process(Node externs,Node root){
  logger.fine("String_Node_Str");
  if (graph != null && graph.getModuleCount() > 1) {
    collectReferences(root);
    if (parentModuleCanSeeSymbolsDeclaredInChildren) {
      makeInstanceOfCodeOrderIndependent();
    }
    moveCode();
  }
}
Program: 27793
Project: 27793
Buggy source:
/** 
 * Process the references to named variables
 */
private void processReference(NodeTraversal t,NamedInfo info,String name){
  boolean recursive=false;
  Node rootNode=t.getScope().getRootNode();
  if (rootNode.isFunction()) {
    String scopeFuncName=rootNode.getFirstChild().getString();
    Node scopeFuncParent=rootNode.getParent();
    if (scopeFuncName.equals(name)) {
      recursive=true;
    }
 else     if (scopeFuncParent.isName() && scopeFuncParent.getString().equals(name)) {
      recursive=true;
    }
 else {
      for (Scope s=t.getScope(); s.getParent() != null; s=s.getParent()) {
        Node curRoot=s.getRootNode();
        if (curRoot.getParent().isAssign()) {
          Node owner=curRoot.getParent().getFirstChild();
          while (owner.isGetProp()) {
            owner=owner.getFirstChild();
          }
          if (owner.isName() && owner.getString().equals(name)) {
            recursive=true;
            break;
          }
        }
      }
    }
  }
  if (!recursive) {
    info.addUsedModule(t.getModule());
  }
}

Fixed version (ground truth):
private void processReference(ReferenceCollectingCallback collector,Reference ref,NamedInfo info){
  Node n=ref.getNode();
  Node parent=n.getParent();
  if (info.allowMove) {
    if (maybeProcessDeclaration(collector,ref,info)) {
      if (hasConditionalAncestor(parent.getParent())) {
        info.allowMove=false;
      }
    }
 else {
      if (parentModuleCanSeeSymbolsDeclaredInChildren && parent.isInstanceOf() && parent.getLastChild() == n) {
        instanceofNodes.put(parent,new InstanceofInfo(getModule(ref),info));
      }
 else {
        processRead(ref,info);
      }
    }
  }
}