nus-yam/ex-repair huggingface dataset:
Program: 27848
Project: 27848
Buggy source:
private Node tryRotateAssociativeOperator(Node n){
  if (!late) {
    return n;
  }
  Preconditions.checkArgument(NodeUtil.isAssociative(n.getType()));
  Node rhs=n.getLastChild();
  if (n.getType() == rhs.getType()) {
    Node first=n.getFirstChild().detachFromParent();
    Node second=rhs.getFirstChild().detachFromParent();
    Node third=rhs.getLastChild().detachFromParent();
    Node newLhs=new Node(n.getType(),first,second).copyInformationFrom(n);
    Node newRoot=new Node(rhs.getType(),newLhs,third).copyInformationFrom(rhs);
    n.getParent().replaceChild(n,newRoot);
    reportCodeChange();
    return newRoot;
  }
 else   if (NodeUtil.isCommutative(n.getType()) && !NodeUtil.mayHaveSideEffects(n)) {
    Node lhs=n.getFirstChild();
    int precedence=NodeUtil.precedence(n.getType());
    int lhsPrecedence=NodeUtil.precedence(lhs.getType());
    int rhsPrecedence=NodeUtil.precedence(rhs.getType());
    if (rhsPrecedence == precedence && (lhs.getType() == n.getType() || lhsPrecedence != precedence)) {
      n.removeChild(rhs);
      n.addChildToFront(rhs);
      reportCodeChange();
      return n;
    }
  }
  return n;
}

Fixed version (ground truth):
private Node tryRotateAssociativeOperator(Node n){
  if (!late) {
    return n;
  }
  Preconditions.checkArgument(NodeUtil.isAssociative(n.getType()));
  Node rhs=n.getLastChild();
  if (n.getType() == rhs.getType()) {
    Node first=n.getFirstChild().detachFromParent();
    Node second=rhs.getFirstChild().detachFromParent();
    Node third=rhs.getLastChild().detachFromParent();
    Node newLhs=new Node(n.getType(),first,second).copyInformationFrom(n);
    Node newRoot=new Node(rhs.getType(),newLhs,third).copyInformationFrom(rhs);
    n.getParent().replaceChild(n,newRoot);
    reportCodeChange();
    return newRoot;
  }
 else   if (NodeUtil.isCommutative(n.getType()) && !NodeUtil.mayHaveSideEffects(n)) {
    Node lhs=n.getFirstChild();
    while (lhs.getType() == n.getType()) {
      lhs=lhs.getFirstChild();
    }
    int precedence=NodeUtil.precedence(n.getType());
    int lhsPrecedence=NodeUtil.precedence(lhs.getType());
    int rhsPrecedence=NodeUtil.precedence(rhs.getType());
    if (rhsPrecedence == precedence && lhsPrecedence != precedence) {
      n.removeChild(rhs);
      lhs.getParent().replaceChild(lhs,rhs);
      n.addChildToBack(lhs);
      reportCodeChange();
      return n;
    }
  }
  return n;
}
Program: 27849
Project: 27849
Buggy source:
public void testRotateAssociativeOperators(){
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
}

Fixed version (ground truth):
public void testRotateAssociativeOperators(){
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27850
Project: 27850
Buggy source:
/** 
 * Runs the Compiler and calls System.exit() with the exit status of the compiler.
 */
public final void run(){
  int result=0;
  int runs=1;
  try {
    for (int i=0; i < runs && result == 0; i++) {
      result=doRun();
    }
  }
 catch (  AbstractCommandLineRunner.FlagUsageException e) {
    System.err.println(e.getMessage());
    result=-1;
  }
catch (  Throwable t) {
    t.printStackTrace();
    result=-2;
  }
  try {
    if (jsOutput instanceof Closeable) {
      ((Closeable)jsOutput).close();
    }
  }
 catch (  IOException e) {
    throw Throwables.propagate(e);
  }
  if (testMode) {
    exitCodeReceiverForTesting.apply(result);
  }
 else {
    System.exit(result);
  }
}

Fixed version (ground truth):
/** 
 * Runs the Compiler and calls System.exit() with the exit status of the compiler.
 */
public final void run(){
  int result=0;
  int runs=1;
  try {
    for (int i=0; i < runs && result == 0; i++) {
      result=doRun();
    }
  }
 catch (  AbstractCommandLineRunner.FlagUsageException e) {
    System.err.println(e.getMessage());
    result=-1;
  }
catch (  Throwable t) {
    t.printStackTrace();
    result=-2;
  }
  if (testMode) {
    exitCodeReceiverForTesting.apply(result);
  }
 else {
    System.exit(result);
  }
}
Program: 27851
Project: 27851
Buggy source:
void outputSingleBinary() throws IOException {
  Function<String,String> escaper=null;
  String marker=OUTPUT_MARKER;
  if (config.outputWrapper.contains(OUTPUT_MARKER_JS_STRING)) {
    marker=OUTPUT_MARKER_JS_STRING;
    escaper=getJavascriptEscaper();
  }
  writeOutput(jsOutput,compiler,compiler.toSource(),config.outputWrapper,marker,escaper);
}

Fixed version (ground truth):
void outputSingleBinary() throws IOException {
  Function<String,String> escaper=null;
  String marker=OUTPUT_MARKER;
  if (config.outputWrapper.contains(OUTPUT_MARKER_JS_STRING)) {
    marker=OUTPUT_MARKER_JS_STRING;
    escaper=getJavascriptEscaper();
  }
  Appendable jsOutput=createDefaultOutput();
  writeOutput(jsOutput,compiler,compiler.toSource(),config.outputWrapper,marker,escaper);
  closeAppendable(jsOutput);
}
Program: 27853
Project: 27853
Buggy source:
AbstractCommandLineRunner(PrintStream out,PrintStream err){
  this.config=new CommandLineConfig();
  this.jsOutput=Preconditions.checkNotNull(out);
  this.err=Preconditions.checkNotNull(err);
}

Fixed version (ground truth):
AbstractCommandLineRunner(PrintStream out,PrintStream err){
  this.config=new CommandLineConfig();
  this.defaultJsOutput=Preconditions.checkNotNull(out);
  this.err=Preconditions.checkNotNull(err);
}
Program: 27855
Project: 27855
Buggy source:
/** 
 * Creates a file containing the current module graph in JSON serialization.
 */
private void outputModuleGraphJson() throws IOException {
  if (config.outputModuleDependencies != null && config.outputModuleDependencies != "String_Node_Str") {
    Writer out=fileNameToOutputWriter2(config.outputModuleDependencies);
    printModuleGraphJsonTo(out);
    out.close();
  }
}

Fixed version (ground truth):
/** 
 * Creates a file containing the current module graph in JSON serialization.
 */
private void outputModuleGraphJson() throws IOException {
  if (config.outputModuleDependencies != null && config.outputModuleDependencies.length() != 0) {
    Writer out=fileNameToOutputWriter2(config.outputModuleDependencies);
    printModuleGraphJsonTo(out);
    out.close();
  }
}
Program: 27856
Project: 27856
Buggy source:
private Appendable createDefaultOutput() throws IOException {
  boolean writeOutputToFile=!config.jsOutputFile.isEmpty();
  File test=new File(config.jsOutputFile);
  if (writeOutputToFile) {
    return fileNameToLegacyOutputWriter(config.jsOutputFile);
  }
 else {
    return streamToLegacyOutputWriter(defaultJsOutput);
  }
}

Fixed version (ground truth):
private Appendable createDefaultOutput() throws IOException {
  boolean writeOutputToFile=!config.jsOutputFile.isEmpty();
  if (writeOutputToFile) {
    return fileNameToLegacyOutputWriter(config.jsOutputFile);
  }
 else {
    return streamToLegacyOutputWriter(defaultJsOutput);
  }
}
Program: 27858
Project: 27858
Buggy source:
/** 
 * Tries apply our various peephole minimizations on the passed in node.
 */
@Override @SuppressWarnings("String_Node_Str") public Node optimizeSubtree(Node node){
switch (node.getType()) {
case Token.TRUE:
case Token.FALSE:
    return reduceTrueFalse(node);
case Token.NEW:
  node=tryFoldStandardConstructors(node);
if (!node.isCall()) {
  return node;
}
case Token.CALL:
Node result=tryFoldLiteralConstructor(node);
if (result == node) {
result=tryFoldSimpleFunctionCall(node);
if (result == node) {
result=tryFoldImmediateCallToBoundFunction(node);
}
}
return result;
case Token.RETURN:
return tryReduceReturn(node);
case Token.COMMA:
return trySplitComma(node);
case Token.NAME:
return tryReplaceUndefined(node);
case Token.ARRAYLIT:
return tryMinimizeArrayLiteral(node);
default :
return node;
}
}

Fixed version (ground truth):
/** 
 * Tries apply our various peephole minimizations on the passed in node.
 */
@Override @SuppressWarnings("String_Node_Str") public Node optimizeSubtree(Node node){
switch (node.getType()) {
case Token.TRUE:
case Token.FALSE:
    return reduceTrueFalse(node);
case Token.NEW:
  node=tryFoldStandardConstructors(node);
if (!node.isCall()) {
  return node;
}
case Token.CALL:
Node result=tryFoldLiteralConstructor(node);
if (result == node) {
result=tryFoldSimpleFunctionCall(node);
if (result == node) {
result=tryFoldImmediateCallToBoundFunction(node);
}
}
return result;
case Token.RETURN:
return tryReduceReturn(node);
case Token.COMMA:
return trySplitComma(node);
case Token.NAME:
return tryReplaceUndefined(node);
case Token.ARRAYLIT:
return tryMinimizeArrayLiteral(node);
case Token.MUL:
case Token.AND:
case Token.OR:
case Token.BITOR:
case Token.BITXOR:
case Token.BITAND:
return tryRotateAssociativeOperator(node);
default :
return node;
}
}
Program: 27859
Project: 27859
Buggy source:
/** 
 * After a struct object is created, we can't add new properties to it, with one exception. We allow creation of "static" properties like Foo.prototype.bar = baz; where Foo.prototype is a struct, if the assignment happens at the top level and the constructor Foo is defined in the same file.
 */
private void checkPropCreation(NodeTraversal t,Node lvalue){
  if (lvalue.isGetProp()) {
    Node obj=lvalue.getFirstChild();
    Node prop=lvalue.getLastChild();
    JSType objType=getJSType(obj);
    String pname=prop.getString();
    if (!objType.isStruct() || objType.hasProperty(pname)) {
      return;
    }
    Scope s=t.getScope();
    if (obj.isThis() && getJSType(s.getRootNode()).isConstructor()) {
      return;
    }
    Node assgnExp=lvalue.getParent();
    Node assgnStm=assgnExp.getParent();
    if (objType instanceof ObjectType && s.isGlobal() && NodeUtil.isPrototypePropertyDeclaration(assgnStm)) {
      ObjectType instance=objType.toObjectType().getOwnerFunction().getInstanceType();
      String file=lvalue.getSourceFileName();
      Node ctor=instance.getConstructor().getSource();
      if (ctor != null && ctor.getSourceFileName().equals(file)) {
        JSType rvalueType=assgnExp.getLastChild().getJSType();
        instance.defineInferredProperty(pname,rvalueType,lvalue);
        return;
      }
    }
    report(t,prop,ILLEGAL_PROPERTY_CREATION);
  }
}

Fixed version (ground truth):
private void checkPropCreation(NodeTraversal t,Node lvalue){
  if (lvalue.isGetProp()) {
    JSType objType=getJSType(lvalue.getFirstChild());
    Node prop=lvalue.getLastChild();
    if (objType.isStruct() && !objType.hasProperty(prop.getString())) {
      report(t,prop,ILLEGAL_PROPERTY_CREATION);
    }
  }
}
Program: 27861
Project: 27861
Buggy source:
private ThrowStatement throwStatement() throws IOException {
  if (currentToken != Token.THROW)   codeBug();
  consumeToken();
  int pos=ts.tokenBeg, lineno=ts.lineno;
  if (peekTokenOrEOL() == Token.EOL) {
    reportError("String_Node_Str");
  }
  AstNode expr=expr();
  ThrowStatement pn=new ThrowStatement(pos,getNodeEnd(expr),expr);
  pn.setLineno(lineno);
  return pn;
}

Fixed version (ground truth):
private ThrowStatement throwStatement() throws IOException {
  if (currentToken != Token.THROW)   codeBug();
  consumeToken();
  int pos=ts.tokenBeg, lineno=ts.lineno;
  if (peekTokenOrEOL() == Token.EOL) {
    reportError("String_Node_Str");
  }
  AstNode expr=expr();
  ThrowStatement pn=new ThrowStatement(pos,getNodeEnd(expr) - pos,expr);
  pn.setLineno(lineno);
  return pn;
}
Program: 27864
Project: 27864
Buggy source:
/** 
 * Creates a JSType from the nodes representing a type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
public JSType createFromTypeNodes(Node n,String sourceName,StaticScope<JSType> scope){
  if (resolveMode == ResolveMode.LAZY_EXPRESSIONS) {
    boolean hasNames=hasTypeName(n);
    if (hasNames) {
      return new UnresolvedTypeExpression(this,n,sourceName);
    }
  }
  return createFromTypeNodesInternal(n,sourceName,scope);
}

Fixed version (ground truth):
/** 
 * Creates a JSType from the nodes representing a type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
public JSType createFromTypeNodes(Node n,String sourceName,StaticScope<JSType> scope){
  return createFromTypeNodesInternal(n,sourceName,scope);
}
Program: 27867
Project: 27867
Buggy source:
/** 
 * @return Whether the variable is only assigned a value once for itslifetime.
 */
boolean isAssignedOnceInLifetime(){
  Reference ref=getOneAndOnlyAssignment();
  if (ref == null) {
    return false;
  }
  for (BasicBlock block=ref.getBasicBlock(); block != null; block=block.getParent()) {
    if (block.isFunction) {
      break;
    }
 else     if (block.isLoop) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * @return Whether the variable is only assigned a value once for itslifetime.
 */
boolean isAssignedOnceInLifetime(){
  Reference ref=getOneAndOnlyAssignment();
  if (ref == null) {
    return false;
  }
  for (BasicBlock block=ref.getBasicBlock(); block != null; block=block.getParent()) {
    if (block.isFunction) {
      if (ref.getSymbol().getScope() != ref.scope) {
        return false;
      }
      break;
    }
 else     if (block.isLoop) {
      return false;
    }
  }
  return true;
}
Program: 27868
Project: 27868
Buggy source:
public void testInlineVariablesConstantsJsDocStyle(){
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInlineVariablesConstantsJsDocStyle(){
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27869
Project: 27869
Buggy source:
public void testInlineVariablesConstants(){
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInlineVariablesConstants(){
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27871
Project: 27871
Buggy source:
private void resolvedTemplateType(Map<TemplateType,JSType> map,TemplateType template,JSType resolved){
  JSType previous=map.get(template);
  if (!resolved.isUnknownType()) {
    if (previous == null) {
      map.put(template,resolved);
    }
 else {
      JSType join=previous.getLeastSupertype(resolved);
      map.put(template,join);
    }
  }
}

Fixed version (ground truth):
private static void resolvedTemplateType(Map<TemplateType,JSType> map,TemplateType template,JSType resolved){
  JSType previous=map.get(template);
  if (!resolved.isUnknownType()) {
    if (previous == null) {
      map.put(template,resolved);
    }
 else {
      JSType join=previous.getLeastSupertype(resolved);
      map.put(template,join);
    }
  }
}
Program: 27872
Project: 27872
Buggy source:
/** 
 * Suppose X is an object with inferred properties. Suppose also that X is used in a way where it would only type-check correctly if some of those properties are widened. Then we should be polite and automatically widen X's properties for him. For a concrete example, consider: param x {{prop: (number|undefined)}} function f(x) {} f({}); If we give the anonymous object an inferred property of (number|undefined), then this code will type-check appropriately.
 */
private void inferPropertyTypesToMatchConstraint(JSType type,JSType constraint){
  if (type == null || constraint == null) {
    return;
  }
  type.matchConstraint(constraint);
}

Fixed version (ground truth):
/** 
 * Suppose X is an object with inferred properties. Suppose also that X is used in a way where it would only type-check correctly if some of those properties are widened. Then we should be polite and automatically widen X's properties for him. For a concrete example, consider: param x {{prop: (number|undefined)}} function f(x) {} f({}); If we give the anonymous object an inferred property of (number|undefined), then this code will type-check appropriately.
 */
private static void inferPropertyTypesToMatchConstraint(JSType type,JSType constraint){
  if (type == null || constraint == null) {
    return;
  }
  type.matchConstraint(constraint);
}
Program: 27873
Project: 27873
Buggy source:
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  JSType type=n.getJSType();
  Preconditions.checkNotNull(type);
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    scope=traverse(name.getFirstChild(),scope);
  }
  ObjectType objectType=ObjectType.cast(type);
  if (objectType == null || n.getBooleanProp(Node.REFLECTED_OBJECT)) {
    return scope;
  }
  String qObjName=NodeUtil.getBestLValueName(NodeUtil.getBestLValue(n));
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    String memberName=NodeUtil.getObjectLitKeyName(name);
    if (memberName != null) {
      JSType rawValueType=name.getFirstChild().getJSType();
      JSType valueType=NodeUtil.getObjectLitKeyTypeFromValueType(name,rawValueType);
      if (valueType == null) {
        valueType=unknownType;
      }
      objectType.defineInferredProperty(memberName,valueType,name);
      if (qObjName != null && name.isStringKey()) {
        String qKeyName=qObjName + "String_Node_Str" + memberName;
        Var var=syntacticScope.getVar(qKeyName);
        JSType oldType=var == null ? null : var.getType();
        if (var != null && var.isTypeInferred()) {
          var.setType(oldType == null ? valueType : oldType.getLeastSupertype(oldType));
        }
        scope.inferQualifiedSlot(name,qKeyName,oldType == null ? unknownType : oldType,valueType);
      }
    }
 else {
      n.setJSType(unknownType);
    }
  }
  return scope;
}

Fixed version (ground truth):
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  JSType type=n.getJSType();
  Preconditions.checkNotNull(type);
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    scope=traverse(name.getFirstChild(),scope);
  }
  ObjectType objectType=ObjectType.cast(type);
  if (objectType == null || n.getBooleanProp(Node.REFLECTED_OBJECT) || objectType.isEnumType()) {
    return scope;
  }
  String qObjName=NodeUtil.getBestLValueName(NodeUtil.getBestLValue(n));
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    String memberName=NodeUtil.getObjectLitKeyName(name);
    if (memberName != null) {
      JSType rawValueType=name.getFirstChild().getJSType();
      JSType valueType=NodeUtil.getObjectLitKeyTypeFromValueType(name,rawValueType);
      if (valueType == null) {
        valueType=unknownType;
      }
      objectType.defineInferredProperty(memberName,valueType,name);
      if (qObjName != null && name.isStringKey()) {
        String qKeyName=qObjName + "String_Node_Str" + memberName;
        Var var=syntacticScope.getVar(qKeyName);
        JSType oldType=var == null ? null : var.getType();
        if (var != null && var.isTypeInferred()) {
          var.setType(oldType == null ? valueType : oldType.getLeastSupertype(oldType));
        }
        scope.inferQualifiedSlot(name,qKeyName,oldType == null ? unknownType : oldType,valueType);
      }
    }
 else {
      n.setJSType(unknownType);
    }
  }
  return scope;
}
Program: 27874
Project: 27874
Buggy source:
/** 
 * Add node to the list of injectables.
 * @param n node to add.
 * @param t node traversal instance.
 */
private void addNode(Node n,NodeTraversal t){
  Node target=null;
  Node fn=null;
  String name=null;
switch (n.getType()) {
case Token.ASSIGN:
    name=n.getFirstChild().getQualifiedName();
  fn=n;
while (fn.isAssign()) {
  fn=fn.getLastChild();
}
target=n.getParent();
break;
case Token.FUNCTION:
name=NodeUtil.getFunctionName(n);
fn=n;
target=n;
break;
case Token.VAR:
name=n.getFirstChild().getString();
fn=getDeclarationRValue(n);
target=n;
break;
}
if (!target.getParent().isScript() && !target.getParent().isBlock()) {
compiler.report(t.makeError(n,INJECT_IN_NON_GLOBAL_OR_BLOCK_ERROR));
return;
}
if (fn == null || !fn.isFunction()) {
compiler.report(t.makeError(n,INJECT_NON_FUNCTION_ERROR));
return;
}
Preconditions.checkNotNull(name);
injectables.add(new NodeContext(name,n,fn,target));
}

Fixed version (ground truth):
/** 
 * Add node to the list of injectables.
 * @param n node to add.
 * @param t node traversal instance.
 */
private void addNode(Node n,NodeTraversal t){
  Node target=null;
  Node fn=null;
  String name=null;
switch (n.getType()) {
case Token.ASSIGN:
    name=n.getFirstChild().getQualifiedName();
  fn=n;
while (fn.isAssign()) {
  fn=fn.getLastChild();
}
target=n.getParent();
break;
case Token.FUNCTION:
name=NodeUtil.getFunctionName(n);
fn=n;
target=n;
break;
case Token.VAR:
name=n.getFirstChild().getString();
fn=getDeclarationRValue(n);
target=n;
break;
}
if (fn == null || !fn.isFunction()) {
compiler.report(t.makeError(n,INJECT_NON_FUNCTION_ERROR));
return;
}
if (!target.getParent().isScript() && !target.getParent().isBlock()) {
compiler.report(t.makeError(n,INJECT_IN_NON_GLOBAL_OR_BLOCK_ERROR));
return;
}
Preconditions.checkNotNull(name);
injectables.add(new NodeContext(name,n,fn,target));
}
Program: 27875
Project: 27875
Buggy source:
public void testNgInjectNonFunction() throws Exception {
  test("String_Node_Str",null,AngularPass.INJECT_NON_FUNCTION_ERROR);
  test("String_Node_Str",null,AngularPass.INJECT_NON_FUNCTION_ERROR);
}

Fixed version (ground truth):
public void testNgInjectNonFunction() throws Exception {
  test("String_Node_Str" + "String_Node_Str" + "String_Node_Str",null,AngularPass.INJECT_NON_FUNCTION_ERROR);
  test("String_Node_Str",null,AngularPass.INJECT_NON_FUNCTION_ERROR);
  test("String_Node_Str",null,AngularPass.INJECT_NON_FUNCTION_ERROR);
}
Program: 27876
Project: 27876
Buggy source:
private void maybeSetBaseType(FunctionType fnType){
  if (!fnType.isInterface() && baseType != null) {
    fnType.setPrototypeBasedOn(baseType);
  }
}

Fixed version (ground truth):
private void maybeSetBaseType(FunctionType fnType){
  if (!fnType.isInterface() && baseType != null) {
    fnType.setPrototypeBasedOn(baseType);
    fnType.extendTemplateTypeMapBasedOn(baseType);
  }
}
Program: 27877
Project: 27877
Buggy source:
/** 
 * Expect that the first type is the direct superclass of the second type.
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t,Node n,ObjectType superObject,ObjectType subObject){
  FunctionType subCtor=subObject.getConstructor();
  ObjectType implicitProto=subObject.getImplicitPrototype();
  ObjectType declaredSuper=implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null && !(superObject instanceof UnknownType) && !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject,declaredSuper,report(t.makeError(n,MISSING_EXTENDS_TAG_WARNING,subObject.toString())));
    }
 else {
      mismatch(t.getSourceName(),n,"String_Node_Str",superObject,declaredSuper);
    }
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}

Fixed version (ground truth):
/** 
 * Expect that the first type is the direct superclass of the second type.
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t,Node n,ObjectType superObject,ObjectType subObject){
  FunctionType subCtor=subObject.getConstructor();
  ObjectType implicitProto=subObject.getImplicitPrototype();
  ObjectType declaredSuper=implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null && declaredSuper.isTemplatizedType()) {
    declaredSuper=declaredSuper.toMaybeTemplatizedType().getReferencedType();
  }
  if (declaredSuper != null && !(superObject instanceof UnknownType) && !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject,declaredSuper,report(t.makeError(n,MISSING_EXTENDS_TAG_WARNING,subObject.toString())));
    }
 else {
      mismatch(t.getSourceName(),n,"String_Node_Str",superObject,declaredSuper);
    }
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
Program: 27878
Project: 27878
Buggy source:
void setPrototypeBasedOn(ObjectType baseType,Node propertyNode){
  if (baseType.hasReferenceName() || isNativeObjectType() || baseType.isFunctionPrototypeType()) {
    typeOfThis.extendTemplateTypeMap(baseType.getTemplateTypeMap());
    baseType=new PrototypeObjectType(registry,getReferenceName() + "String_Node_Str",baseType);
  }
  setPrototype(baseType,propertyNode);
}

Fixed version (ground truth):
void setPrototypeBasedOn(ObjectType baseType,Node propertyNode){
  if (baseType.hasReferenceName() || isNativeObjectType() || baseType.isFunctionPrototypeType()) {
    baseType=new PrototypeObjectType(registry,getReferenceName() + "String_Node_Str",baseType);
  }
  setPrototype(baseType,propertyNode);
}
Program: 27879
Project: 27879
Buggy source:
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  JSType type=n.getJSType();
  Preconditions.checkNotNull(type);
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    scope=traverse(name.getFirstChild(),scope);
  }
  ObjectType objectType=ObjectType.cast(type);
  if (objectType == null) {
    return scope;
  }
  boolean hasLendsName=n.getJSDocInfo() != null && n.getJSDocInfo().getLendsName() != null;
  if (objectType.hasReferenceName() && !hasLendsName) {
    return scope;
  }
  String qObjName=NodeUtil.getBestLValueName(NodeUtil.getBestLValue(n));
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    String memberName=NodeUtil.getObjectLitKeyName(name);
    if (memberName != null) {
      JSType rawValueType=name.getFirstChild().getJSType();
      JSType valueType=NodeUtil.getObjectLitKeyTypeFromValueType(name,rawValueType);
      if (valueType == null) {
        valueType=unknownType;
      }
      objectType.defineInferredProperty(memberName,valueType,name);
      if (qObjName != null && name.isStringKey()) {
        String qKeyName=qObjName + "String_Node_Str" + memberName;
        Var var=syntacticScope.getVar(qKeyName);
        JSType oldType=var == null ? null : var.getType();
        if (var != null && var.isTypeInferred()) {
          var.setType(oldType == null ? valueType : oldType.getLeastSupertype(oldType));
        }
        scope.inferQualifiedSlot(name,qKeyName,oldType == null ? unknownType : oldType,valueType);
      }
    }
 else {
      n.setJSType(unknownType);
    }
  }
  return scope;
}

Fixed version (ground truth):
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  JSType type=n.getJSType();
  Preconditions.checkNotNull(type);
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    scope=traverse(name.getFirstChild(),scope);
  }
  ObjectType objectType=ObjectType.cast(type);
  if (objectType == null || n.getBooleanProp(Node.REFLECTED_OBJECT)) {
    return scope;
  }
  String qObjName=NodeUtil.getBestLValueName(NodeUtil.getBestLValue(n));
  for (Node name=n.getFirstChild(); name != null; name=name.getNext()) {
    String memberName=NodeUtil.getObjectLitKeyName(name);
    if (memberName != null) {
      JSType rawValueType=name.getFirstChild().getJSType();
      JSType valueType=NodeUtil.getObjectLitKeyTypeFromValueType(name,rawValueType);
      if (valueType == null) {
        valueType=unknownType;
      }
      objectType.defineInferredProperty(memberName,valueType,name);
      if (qObjName != null && name.isStringKey()) {
        String qKeyName=qObjName + "String_Node_Str" + memberName;
        Var var=syntacticScope.getVar(qKeyName);
        JSType oldType=var == null ? null : var.getType();
        if (var != null && var.isTypeInferred()) {
          var.setType(oldType == null ? valueType : oldType.getLeastSupertype(oldType));
        }
        scope.inferQualifiedSlot(name,qKeyName,oldType == null ? unknownType : oldType,valueType);
      }
    }
 else {
      n.setJSType(unknownType);
    }
  }
  return scope;
}
Program: 27882
Project: 27882
Buggy source:
private static final String propToString(int propType){
switch (propType) {
case VAR_ARGS_NAME:
    return "String_Node_Str";
case JSDOC_INFO_PROP:
  return "String_Node_Str";
case INCRDECR_PROP:
return "String_Node_Str";
case QUOTED_PROP:
return "String_Node_Str";
case OPT_ARG_NAME:
return "String_Node_Str";
case SYNTHETIC_BLOCK_PROP:
return "String_Node_Str";
case EMPTY_BLOCK:
return "String_Node_Str";
case ORIGINALNAME_PROP:
return "String_Node_Str";
case SIDE_EFFECT_FLAGS:
return "String_Node_Str";
case IS_CONSTANT_NAME:
return "String_Node_Str";
case IS_NAMESPACE:
return "String_Node_Str";
case IS_DISPATCHER:
return "String_Node_Str";
case DIRECTIVES:
return "String_Node_Str";
case DIRECT_EVAL:
return "String_Node_Str";
case FREE_CALL:
return "String_Node_Str";
case STATIC_SOURCE_FILE:
return "String_Node_Str";
case INPUT_ID:
return "String_Node_Str";
case LENGTH:
return "String_Node_Str";
case SLASH_V:
return "String_Node_Str";
case INFERRED_FUNCTION:
return "String_Node_Str";
case CHANGE_TIME:
return "String_Node_Str";
default :
throw new IllegalStateException("String_Node_Str" + propType);
}
}

Fixed version (ground truth):
private static final String propToString(int propType){
switch (propType) {
case VAR_ARGS_NAME:
    return "String_Node_Str";
case JSDOC_INFO_PROP:
  return "String_Node_Str";
case INCRDECR_PROP:
return "String_Node_Str";
case QUOTED_PROP:
return "String_Node_Str";
case OPT_ARG_NAME:
return "String_Node_Str";
case SYNTHETIC_BLOCK_PROP:
return "String_Node_Str";
case EMPTY_BLOCK:
return "String_Node_Str";
case ORIGINALNAME_PROP:
return "String_Node_Str";
case SIDE_EFFECT_FLAGS:
return "String_Node_Str";
case IS_CONSTANT_NAME:
return "String_Node_Str";
case IS_NAMESPACE:
return "String_Node_Str";
case IS_DISPATCHER:
return "String_Node_Str";
case DIRECTIVES:
return "String_Node_Str";
case DIRECT_EVAL:
return "String_Node_Str";
case FREE_CALL:
return "String_Node_Str";
case STATIC_SOURCE_FILE:
return "String_Node_Str";
case INPUT_ID:
return "String_Node_Str";
case LENGTH:
return "String_Node_Str";
case SLASH_V:
return "String_Node_Str";
case INFERRED_FUNCTION:
return "String_Node_Str";
case CHANGE_TIME:
return "String_Node_Str";
case REFLECTED_OBJECT:
return "String_Node_Str";
default :
throw new IllegalStateException("String_Node_Str" + propType);
}
}
Program: 27883
Project: 27883
Buggy source:
public void testPropertiesOnInterface2() throws Exception {
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  Var i=globalScope.getVar("String_Node_Str");
  assertEquals("String_Node_Str",i.getType().toString());
  assertTrue(i.getType().isInterface());
  ObjectType iPrototype=(ObjectType)((ObjectType)i.getType()).getPropertyType("String_Node_Str");
  assertEquals("String_Node_Str",iPrototype.toString());
  assertTrue(iPrototype.isFunctionPrototypeType());
  assertEquals("String_Node_Str",iPrototype.getPropertyType("String_Node_Str").toString());
  assertEquals("String_Node_Str",iPrototype.getPropertyType("String_Node_Str").toString());
  assertNull(globalScope.getVar("String_Node_Str"));
}

Fixed version (ground truth):
public void testPropertiesOnInterface2() throws Exception {
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  Var i=globalScope.getVar("String_Node_Str");
  assertEquals("String_Node_Str",i.getType().toString());
  assertTrue(i.getType().isInterface());
  ObjectType iPrototype=(ObjectType)((ObjectType)i.getType()).getPropertyType("String_Node_Str");
  assertEquals("String_Node_Str",iPrototype.toString());
  assertTrue(iPrototype.isFunctionPrototypeType());
  assertEquals("String_Node_Str",iPrototype.getPropertyType("String_Node_Str").toString());
  assertEquals("String_Node_Str",iPrototype.getPropertyType("String_Node_Str").toString());
  assertEquals(iPrototype,globalScope.getVar("String_Node_Str").getType());
}
Program: 27884
Project: 27884
Buggy source:
/** 
 * Determines whether we know enough about the given value to be able to collapse it into subsequent expressions. For example, we can collapse booleans and variable names: <code> x = 3; y = x; // y = x = 3; a = true; b = true; // b = a = true; <code> But we won't try to collapse complex expressions.
 * @param value The value node.
 * @param isLValue Whether it's on the left-hand side of an expr.
 */
private boolean isCollapsibleValue(Node value,boolean isLValue){
switch (value.getType()) {
case Token.GETPROP:
    return !isLValue || value.getFirstChild().isThis();
case Token.NAME:
  return true;
default :
return NodeUtil.isImmutableValue(value);
}
}

Fixed version (ground truth):
/** 
 * Determines whether we know enough about the given value to be able to collapse it into subsequent expressions. For example, we can collapse booleans and variable names: <code> x = 3; y = x; // y = x = 3; a = true; b = true; // b = a = true; <code> But we won't try to collapse complex expressions.
 * @param value The value node.
 * @param isLValue Whether it's on the left-hand side of an expr.
 */
private static boolean isCollapsibleValue(Node value,boolean isLValue){
switch (value.getType()) {
case Token.GETPROP:
    return !isLValue || value.getFirstChild().isThis();
case Token.NAME:
  return true;
default :
return NodeUtil.isImmutableValue(value);
}
}
Program: 27885
Project: 27885
Buggy source:
/** 
 * Checks name referenced in node to determine if it might have changed.
 * @return Whether the replacement can be made.
 */
private boolean isSafeReplacement(Node node,Node replacement){
  if (node.isName()) {
    return true;
  }
  Preconditions.checkArgument(node.isGetProp());
  Node name=node.getFirstChild();
  if (name.isName() && isNameAssignedTo(name.getString(),replacement)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks name referenced in node to determine if it might have changed.
 * @return Whether the replacement can be made.
 */
private boolean isSafeReplacement(Node node,Node replacement){
  if (node.isName()) {
    return true;
  }
  Preconditions.checkArgument(node.isGetProp());
  while (node.isGetProp()) {
    node=node.getFirstChild();
  }
  if (node.isName() && isNameAssignedTo(node.getString(),replacement)) {
    return false;
  }
  return true;
}
Program: 27888
Project: 27888
Buggy source:
@Override public boolean traverseEdge(FunctionInformation callee,Node callSite,FunctionInformation caller){
  Preconditions.checkArgument(callSite.isCall() || callSite.isNew());
  boolean changed=false;
  if (!caller.mutatesGlobalState() && callee.mutatesGlobalState()) {
    caller.setTaintsGlobalState();
    changed=true;
  }
  if (!caller.functionThrows() && callee.functionThrows()) {
    caller.setFunctionThrows();
    changed=true;
  }
  if (callee.mutatesThis()) {
    if (!callSite.isNew()) {
      Node objectNode=getCallThisObject(callSite);
      if (objectNode != null && objectNode.isName() && !isCallOrApply(callSite)) {
        if (!caller.mutatesGlobalState()) {
          caller.setTaintsGlobalState();
          changed=true;
        }
      }
 else       if (objectNode != null && objectNode.isThis()) {
        if (!caller.mutatesThis()) {
          caller.setTaintsThis();
          changed=true;
        }
      }
 else       if (objectNode != null && NodeUtil.evaluatesToLocalValue(objectNode) && !isCallOrApply(callSite)) {
      }
 else       if (!caller.mutatesGlobalState()) {
        caller.setTaintsGlobalState();
        changed=true;
      }
    }
  }
  return changed;
}

Fixed version (ground truth):
@Override public boolean traverseEdge(FunctionInformation callee,Node callSite,FunctionInformation caller){
  Preconditions.checkArgument(callSite.isCall() || callSite.isNew());
  boolean changed=false;
  if (!caller.mutatesGlobalState() && callee.mutatesGlobalState()) {
    caller.setTaintsGlobalState();
    changed=true;
  }
  if (!caller.functionThrows() && callee.functionThrows()) {
    caller.setFunctionThrows();
    changed=true;
  }
  if (callee.mutatesThis()) {
    if (!callSite.isNew()) {
      boolean isCallOrApply=isCallOrApply(callSite);
      Node objectNode=isCallOrApply ? callSite.getFirstChild().getNext() : callSite.getFirstChild().getFirstChild();
      if (objectNode != null && objectNode.isName() && !isCallOrApply) {
        if (!caller.mutatesGlobalState()) {
          caller.setTaintsGlobalState();
          changed=true;
        }
      }
 else       if (objectNode != null && objectNode.isThis()) {
        if (!caller.mutatesThis()) {
          caller.setTaintsThis();
          changed=true;
        }
      }
 else       if (objectNode != null && NodeUtil.evaluatesToLocalValue(objectNode) && !isCallOrApply) {
      }
 else       if (!caller.mutatesGlobalState()) {
        caller.setTaintsGlobalState();
        changed=true;
      }
    }
  }
  return changed;
}
Program: 27889
Project: 27889
Buggy source:
private static boolean isCallOrApply(Node callSite){
  Node callTarget=callSite.getFirstChild();
  if (NodeUtil.isGet(callTarget)) {
    String propString=callTarget.getLastChild().getString();
    if (propString.equals("String_Node_Str") || propString.equals("String_Node_Str")) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private static boolean isCallOrApply(Node callSite){
  return NodeUtil.isFunctionObjectCall(callSite) || NodeUtil.isFunctionObjectApply(callSite);
}
Program: 27890
Project: 27890
Buggy source:
public void setMutatesArguments(){
  removeFlag(Node.FLAG_ARGUMENTS_UNMODIFIED);
}

Fixed version (ground truth):
public SideEffectFlags setMutatesArguments(){
  removeFlag(Node.FLAG_ARGUMENTS_UNMODIFIED);
  return this;
}
Program: 27891
Project: 27891
Buggy source:
public void setMutatesGlobalState(){
  removeFlag(Node.FLAG_GLOBAL_STATE_UNMODIFIED);
  removeFlag(Node.FLAG_ARGUMENTS_UNMODIFIED);
  removeFlag(Node.FLAG_THIS_UNMODIFIED);
}

Fixed version (ground truth):
public SideEffectFlags setMutatesGlobalState(){
  removeFlag(Node.FLAG_GLOBAL_STATE_UNMODIFIED);
  removeFlag(Node.FLAG_ARGUMENTS_UNMODIFIED);
  removeFlag(Node.FLAG_THIS_UNMODIFIED);
  return this;
}
Program: 27892
Project: 27892
Buggy source:
/** 
 * No side-effects occur and the returned results are local. 
 */
public void clearAllFlags(){
  value=Node.NO_SIDE_EFFECTS | Node.FLAG_LOCAL_RESULTS;
}

Fixed version (ground truth):
/** 
 * No side-effects occur and the returned results are local. 
 */
public SideEffectFlags clearAllFlags(){
  value=Node.NO_SIDE_EFFECTS | Node.FLAG_LOCAL_RESULTS;
  return this;
}
Program: 27893
Project: 27893
Buggy source:
public void setThrows(){
  removeFlag(Node.FLAG_NO_THROWS);
}

Fixed version (ground truth):
public SideEffectFlags setThrows(){
  removeFlag(Node.FLAG_NO_THROWS);
  return this;
}
Program: 27894
Project: 27894
Buggy source:
public void setReturnsTainted(){
  removeFlag(Node.FLAG_LOCAL_RESULTS);
}

Fixed version (ground truth):
public SideEffectFlags setReturnsTainted(){
  removeFlag(Node.FLAG_LOCAL_RESULTS);
  return this;
}
Program: 27895
Project: 27895
Buggy source:
/** 
 * All side-effect occur and the returned results are non-local. 
 */
public void setAllFlags(){
  value=Node.SIDE_EFFECTS_ALL;
}

Fixed version (ground truth):
/** 
 * All side-effect occur and the returned results are non-local. 
 */
public SideEffectFlags setAllFlags(){
  value=Node.SIDE_EFFECTS_ALL;
  return this;
}
Program: 27896
Project: 27896
Buggy source:
public void setMutatesThis(){
  removeFlag(Node.FLAG_THIS_UNMODIFIED);
}

Fixed version (ground truth):
public SideEffectFlags setMutatesThis(){
  removeFlag(Node.FLAG_THIS_UNMODIFIED);
  return this;
}
Program: 27897
Project: 27897
Buggy source:
void addList(Node firstInList,boolean isArrayOrFunctionArgument,Context lhsContext){
  for (Node n=firstInList; n != null; n=n.getNext()) {
    boolean isFirst=n == firstInList;
    if (isFirst) {
      addExpr(n,isArrayOrFunctionArgument ? 1 : 0,lhsContext);
    }
 else {
      cc.listSeparator();
      addExpr(n,isArrayOrFunctionArgument ? 1 : 0,Context.OTHER);
    }
  }
}

Fixed version (ground truth):
void addList(Node firstInList,boolean isArrayOrFunctionArgument,Context lhsContext){
  for (Node n=firstInList; n != null; n=n.getNext()) {
    boolean isFirst=n == firstInList;
    if (isFirst) {
      addExpr(n,isArrayOrFunctionArgument ? 1 : 0,lhsContext);
    }
 else {
      cc.listSeparator();
      addExpr(n,isArrayOrFunctionArgument ? 1 : 0,getContextForNoInOperator(lhsContext));
    }
  }
}
Program: 27899
Project: 27899
Buggy source:
public void testPrintInOperatorInForLoop(){
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testPrintInOperatorInForLoop(){
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrintSame("String_Node_Str");
  assertPrintSame("String_Node_Str");
}
Program: 27900
Project: 27900
Buggy source:
AliasedTypeNode(Node typeReference,Node aliasDefinition,String aliasName){
  this.typeReference=typeReference;
  this.aliasDefinition=aliasDefinition;
  this.aliasName=aliasName;
}

Fixed version (ground truth):
AliasedTypeNode(Var aliasVar,Node aliasReference){
  super(aliasVar,aliasReference);
}
Program: 27901
Project: 27901
Buggy source:
@Override public void applyAlias(){
  String typeName=typeReference.getString();
  String aliasExpanded=Preconditions.checkNotNull(aliasDefinition.getQualifiedName());
  Preconditions.checkState(typeName.startsWith(aliasName));
  typeReference.setString(typeName.replaceFirst(aliasName,aliasExpanded));
}

Fixed version (ground truth):
@Override public void applyAlias(){
  Node aliasDefinition=aliasVar.getInitialValue();
  String aliasName=aliasVar.getName();
  String typeName=aliasReference.getString();
  String aliasExpanded=Preconditions.checkNotNull(aliasDefinition.getQualifiedName());
  Preconditions.checkState(typeName.startsWith(aliasName));
  aliasReference.setString(typeName.replaceFirst(aliasName,aliasExpanded));
}
Program: 27902
Project: 27902
Buggy source:
private void fixTypeNode(Node typeNode){
  if (typeNode.isString()) {
    String name=typeNode.getString();
    int endIndex=name.indexOf('.');
    if (endIndex == -1) {
      endIndex=name.length();
    }
    String baseName=name.substring(0,endIndex);
    Var aliasVar=aliases.get(baseName);
    if (aliasVar != null) {
      Node aliasedNode=aliasVar.getInitialValue();
      aliasUsages.add(new AliasedTypeNode(typeNode,aliasedNode,baseName));
    }
  }
  for (Node child=typeNode.getFirstChild(); child != null; child=child.getNext()) {
    fixTypeNode(child);
  }
}

Fixed version (ground truth):
private void fixTypeNode(Node typeNode){
  if (typeNode.isString()) {
    String name=typeNode.getString();
    int endIndex=name.indexOf('.');
    if (endIndex == -1) {
      endIndex=name.length();
    }
    String baseName=name.substring(0,endIndex);
    Var aliasVar=aliases.get(baseName);
    if (aliasVar != null) {
      aliasUsages.add(new AliasedTypeNode(aliasVar,typeNode));
    }
  }
  for (Node child=typeNode.getFirstChild(); child != null; child=child.getNext()) {
    fixTypeNode(child);
  }
}
Program: 27903
Project: 27903
Buggy source:
AliasedNode(Node aliasReference,Node aliasDefinition){
  this.aliasReference=aliasReference;
  this.aliasDefinition=aliasDefinition;
}

Fixed version (ground truth):
AliasedNode(Var aliasVar,Node aliasReference){
  super(aliasVar,aliasReference);
}