nus-yam/ex-repair huggingface dataset:
Program: 18792
Project: 18792
Buggy source:
/** 
 * Adds global variable "stubs" for any properties of a global name that are only set in a local scope or read but never set.
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we areadding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be addedas children
 * @param addAfter The child of after which newvariables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(Name n,String alias,Node parent,Node addAfter){
  Preconditions.checkState(n.canCollapseUnannotatedChildNames());
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs=0;
  if (n.props != null) {
    for (    Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias=appendPropForAlias(alias,p.getName());
        Node nameNode=Node.newString(Token.NAME,propAlias);
        Node newVar=new Node(Token.VAR,nameNode).copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar,addAfter);
        addAfter=newVar;
        numStubs++;
        compiler.reportCodeChange();
        if (p.getRefs().get(0).node.getLastChild().getBooleanProp(Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME,true);
        }
      }
    }
  }
  return numStubs;
}

Fixed version (ground truth):
/** 
 * Adds global variable "stubs" for any properties of a global name that are only set in a local scope or read but never set.
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we areadding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be addedas children
 * @param addAfter The child of after which newvariables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(Name n,String alias,Node parent,Node addAfter){
  Preconditions.checkState(n.canCollapseUnannotatedChildNames());
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs=0;
  if (n.props != null) {
    for (    Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias=appendPropForAlias(alias,p.getBaseName());
        Node nameNode=Node.newString(Token.NAME,propAlias);
        Node newVar=new Node(Token.VAR,nameNode).copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar,addAfter);
        addAfter=newVar;
        numStubs++;
        compiler.reportCodeChange();
        if (p.getRefs().get(0).node.getLastChild().getBooleanProp(Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME,true);
        }
      }
    }
  }
  return numStubs;
}
Program: 18793
Project: 18793
Buggy source:
/** 
 * Flattens all references to a collapsible property of a global name except its initial definition.
 * @param n A global property name (e.g. "a.b" or "a.b.c.d")
 * @param alias The flattened name (e.g. "a$b" or "a$b$c$d")
 */
private void flattenReferencesTo(Name n,String alias){
  String originalName=n.fullName();
  for (  Ref r : n.getRefs()) {
    if (r == n.getDeclaration()) {
      continue;
    }
    Node rParent=r.node.getParent();
    if (!NodeUtil.isObjectLitKey(r.node,rParent) && (r.getTwin() == null || r.isSet())) {
      flattenNameRef(alias,r.node,rParent,originalName);
    }
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      flattenPrefixes(alias,p,1);
    }
  }
}

Fixed version (ground truth):
/** 
 * Flattens all references to a collapsible property of a global name except its initial definition.
 * @param n A global property name (e.g. "a.b" or "a.b.c.d")
 * @param alias The flattened name (e.g. "a$b" or "a$b$c$d")
 */
private void flattenReferencesTo(Name n,String alias){
  String originalName=n.getFullName();
  for (  Ref r : n.getRefs()) {
    if (r == n.getDeclaration()) {
      continue;
    }
    Node rParent=r.node.getParent();
    if (!NodeUtil.isObjectLitKey(r.node,rParent) && (r.getTwin() == null || r.isSet())) {
      flattenNameRef(alias,r.node,rParent,originalName);
    }
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      flattenPrefixes(alias,p,1);
    }
  }
}
Program: 18794
Project: 18794
Buggy source:
/** 
 * Flattens all occurrences of a name as a prefix of subnames beginning with a particular subname.
 * @param n A global property name (e.g. "a.b.c.d")
 * @param alias A flattened prefix name (e.g. "a$b")
 * @param depth The difference in depth between the property name andthe prefix name (e.g. 2)
 */
private void flattenPrefixes(String alias,Name n,int depth){
  String originalName=n.fullName();
  Ref decl=n.getDeclaration();
  if (decl != null && decl.node != null && decl.node.getType() == Token.GETPROP) {
    flattenNameRefAtDepth(alias,decl.node,depth,originalName);
  }
  for (  Ref r : n.getRefs()) {
    if (r == decl) {
      continue;
    }
    if (r.getTwin() == null || r.isSet()) {
      flattenNameRefAtDepth(alias,r.node,depth,originalName);
    }
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      flattenPrefixes(alias,p,depth + 1);
    }
  }
}

Fixed version (ground truth):
/** 
 * Flattens all occurrences of a name as a prefix of subnames beginning with a particular subname.
 * @param n A global property name (e.g. "a.b.c.d")
 * @param alias A flattened prefix name (e.g. "a$b")
 * @param depth The difference in depth between the property name andthe prefix name (e.g. 2)
 */
private void flattenPrefixes(String alias,Name n,int depth){
  String originalName=n.getFullName();
  Ref decl=n.getDeclaration();
  if (decl != null && decl.node != null && decl.node.getType() == Token.GETPROP) {
    flattenNameRefAtDepth(alias,decl.node,depth,originalName);
  }
  for (  Ref r : n.getRefs()) {
    if (r == decl) {
      continue;
    }
    if (r.getTwin() == null || r.isSet()) {
      flattenNameRefAtDepth(alias,r.node,depth,originalName);
    }
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      flattenPrefixes(alias,p,depth + 1);
    }
  }
}
Program: 18796
Project: 18796
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.getType() == Token.THIS) {
    compiler.report(JSError.make(name.getDeclaration().getSourceName(),n,UNSAFE_THIS,name.fullName()));
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.getType() == Token.THIS) {
    compiler.report(JSError.make(name.getDeclaration().getSourceName(),n,UNSAFE_THIS,name.getFullName()));
  }
}
Program: 18797
Project: 18797
Buggy source:
/** 
 * Reports a warning because a namespace was aliased.
 * @param nameObj A namespace that is being aliased
 * @param ref The reference that forced the alias
 */
private void warnAboutNamespaceAliasing(Name nameObj,Ref ref){
  compiler.report(JSError.make(ref.getSourceName(),ref.node,UNSAFE_NAMESPACE_WARNING,nameObj.fullName()));
}

Fixed version (ground truth):
/** 
 * Reports a warning because a namespace was aliased.
 * @param nameObj A namespace that is being aliased
 * @param ref The reference that forced the alias
 */
private void warnAboutNamespaceAliasing(Name nameObj,Ref ref){
  compiler.report(JSError.make(ref.getSourceName(),ref.node,UNSAFE_NAMESPACE_WARNING,nameObj.getFullName()));
}
Program: 18798
Project: 18798
Buggy source:
/** 
 * Flattens a stub declaration. This is mostly a hack to support legacy users.
 */
private void flattenSimpleStubDeclaration(Name name,String alias){
  Ref ref=Iterables.getOnlyElement(name.getRefs());
  Node nameNode=NodeUtil.newName(compiler.getCodingConvention(),alias,ref.node,name.fullName());
  Node varNode=new Node(Token.VAR,nameNode).copyInformationFrom(nameNode);
  Preconditions.checkState(ref.node.getParent().getType() == Token.EXPR_RESULT);
  Node parent=ref.node.getParent();
  Node gramps=parent.getParent();
  gramps.replaceChild(parent,varNode);
  compiler.reportCodeChange();
}

Fixed version (ground truth):
/** 
 * Flattens a stub declaration. This is mostly a hack to support legacy users.
 */
private void flattenSimpleStubDeclaration(Name name,String alias){
  Ref ref=Iterables.getOnlyElement(name.getRefs());
  Node nameNode=NodeUtil.newName(compiler.getCodingConvention(),alias,ref.node,name.getFullName());
  Node varNode=new Node(Token.VAR,nameNode).copyInformationFrom(nameNode);
  Preconditions.checkState(ref.node.getParent().getType() == Token.EXPR_RESULT);
  Node parent=ref.node.getParent();
  Node gramps=parent.getParent();
  gramps.replaceChild(parent,varNode);
  compiler.reportCodeChange();
}
Program: 18799
Project: 18799
Buggy source:
/** 
 * Collapses definitions of the collapsible properties of a global name. Recurses on subnames that also represent JavaScript objects with collapsible properties.
 * @param n A node representing a global name
 * @param alias The flattened name for {@code n}
 */
private void collapseDeclarationOfNameAndDescendants(Name n,String alias){
  boolean canCollapseChildNames=n.canCollapseUnannotatedChildNames();
  if (n.canCollapse()) {
    updateObjLitOrFunctionDeclaration(n,alias,canCollapseChildNames);
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      collapseDeclarationOfNameAndDescendants(p,appendPropForAlias(alias,p.getName()));
      if (!p.inExterns && canCollapseChildNames && p.getDeclaration() != null && p.canCollapse() && p.getDeclaration().node != null && p.getDeclaration().node.getParent() != null && p.getDeclaration().node.getParent().getType() == Token.ASSIGN) {
        updateSimpleDeclaration(appendPropForAlias(alias,p.getName()),p,p.getDeclaration());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Collapses definitions of the collapsible properties of a global name. Recurses on subnames that also represent JavaScript objects with collapsible properties.
 * @param n A node representing a global name
 * @param alias The flattened name for {@code n}
 */
private void collapseDeclarationOfNameAndDescendants(Name n,String alias){
  boolean canCollapseChildNames=n.canCollapseUnannotatedChildNames();
  if (n.canCollapse()) {
    updateObjLitOrFunctionDeclaration(n,alias,canCollapseChildNames);
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      collapseDeclarationOfNameAndDescendants(p,appendPropForAlias(alias,p.getBaseName()));
      if (!p.inExterns && canCollapseChildNames && p.getDeclaration() != null && p.canCollapse() && p.getDeclaration().node != null && p.getDeclaration().node.getParent() != null && p.getDeclaration().node.getParent().getType() == Token.ASSIGN) {
        updateSimpleDeclaration(appendPropForAlias(alias,p.getBaseName()),p,p.getDeclaration());
      }
    }
  }
}
Program: 18800
Project: 18800
Buggy source:
@Override public String getName(){
  return name;
}

Fixed version (ground truth):
@Override public String getName(){
  return getFullName();
}
Program: 18801
Project: 18801
Buggy source:
Name(String name,Name parent,boolean inExterns){
  this.name=name;
  this.parent=parent;
  this.type=Type.OTHER;
  this.inExterns=inExterns;
}

Fixed version (ground truth):
Name(String name,Name parent,boolean inExterns){
  this.baseName=name;
  this.parent=parent;
  this.type=Type.OTHER;
  this.inExterns=inExterns;
}
Program: 18802
Project: 18802
Buggy source:
@Override public String toString(){
  return fullName() + "String_Node_Str" + type+ "String_Node_Str"+ globalSets+ "String_Node_Str"+ localSets+ "String_Node_Str"+ totalGets+ "String_Node_Str"+ aliasingGets+ "String_Node_Str"+ callGets;
}

Fixed version (ground truth):
@Override public String toString(){
  return getFullName() + "String_Node_Str" + type+ "String_Node_Str"+ globalSets+ "String_Node_Str"+ localSets+ "String_Node_Str"+ totalGets+ "String_Node_Str"+ aliasingGets+ "String_Node_Str"+ callGets;
}
Program: 18804
Project: 18804
Buggy source:
/** 
 * A   {@link UnionType} contains a given type (alternate) iff the membervector contains it.
 * @param alternate The alternate which might be in this union.
 * @return {@code true} if the alternate is in the union
 */
public boolean contains(JSType type){
  for (  JSType alt : alternates) {
    if (alt.isEquivalentTo(type)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * A   {@link UnionType} contains a given type (alternate) iff the membervector contains it.
 * @param type The alternate which might be in this union.
 * @return {@code true} if the alternate is in the union
 */
public boolean contains(JSType type){
  for (  JSType alt : alternates) {
    if (alt.isEquivalentTo(type)) {
      return true;
    }
  }
  return false;
}
Program: 18805
Project: 18805
Buggy source:
/** 
 * @param item The item to inspect
 * @param propType The property to look for
 * @return The replacement list if the property was removed, or'item' otherwise.
 */
private PropListItem removeProp(PropListItem item,int propType){
  if (item == null) {
    return null;
  }
 else   if (item.getType() == propType) {
    return item.getNext();
  }
 else {
    PropListItem result=removeProp(item.getNext(),propType);
    if (result != item.getNext()) {
      item.setNext(result);
      return item;
    }
 else {
      return item;
    }
  }
}

Fixed version (ground truth):
/** 
 * @param item The item to inspect
 * @param propType The property to look for
 * @return The replacement list if the property was removed, or'item' otherwise.
 */
private PropListItem removeProp(PropListItem item,int propType){
  if (item == null) {
    return null;
  }
 else   if (item.getType() == propType) {
    return item.getNext();
  }
 else {
    PropListItem result=removeProp(item.getNext(),propType);
    if (result != item.getNext()) {
      return item.chain(result);
    }
 else {
      return item;
    }
  }
}
Program: 18808
Project: 18808
Buggy source:
/** 
 * BasicTypeExpression := '*' | 'null' | 'undefined' | TypeName | FunctionType | UnionType | RecordType | ArrayType
 */
private Node parseBasicTypeExpression(JsDocToken token){
  if (token == JsDocToken.STAR) {
    return newNode(Token.STAR);
  }
 else   if (token == JsDocToken.LB) {
    skipEOLs();
    return parseArrayType(next());
  }
 else   if (token == JsDocToken.LC) {
    skipEOLs();
    return parseRecordType(next());
  }
 else   if (token == JsDocToken.LP) {
    skipEOLs();
    return parseUnionType(next());
  }
 else   if (token == JsDocToken.STRING) {
    String string=stream.getString();
    if ("String_Node_Str".equals(string)) {
      skipEOLs();
      return parseFunctionType(next());
    }
 else     if ("String_Node_Str".equals(string) || "String_Node_Str".equals(string)) {
      return newStringNode(string);
    }
 else {
      return parseTypeName(token);
    }
  }
  return reportGenericTypeSyntaxWarning();
}

Fixed version (ground truth):
/** 
 * BasicTypeExpression := '*' | 'null' | 'undefined' | TypeName | FunctionType | UnionType | RecordType | ArrayType
 */
private Node parseBasicTypeExpression(JsDocToken token){
  if (token == JsDocToken.STAR) {
    return newNode(Token.STAR);
  }
 else   if (token == JsDocToken.LB) {
    skipEOLs();
    return parseArrayType(next());
  }
 else   if (token == JsDocToken.LC) {
    skipEOLs();
    return parseRecordType(next());
  }
 else   if (token == JsDocToken.LP) {
    skipEOLs();
    return parseUnionType(next());
  }
 else   if (token == JsDocToken.STRING) {
    String string=stream.getString();
    if ("String_Node_Str".equals(string)) {
      skipEOLs();
      return parseFunctionType(next());
    }
 else     if ("String_Node_Str".equals(string) || "String_Node_Str".equals(string)) {
      return newStringNode(string);
    }
 else {
      return parseTypeName(token);
    }
  }
  restoreLookAhead(token);
  return reportGenericTypeSyntaxWarning();
}
Program: 18811
Project: 18811
Buggy source:
@Override public void hotSwapScript(Node scriptRoot,Scope globalScope){
  NodeTraversal.traverse(compiler,scriptRoot,this);
}

Fixed version (ground truth):
@Override public void hotSwapScript(Node scriptRoot){
  NodeTraversal.traverse(compiler,scriptRoot,this);
}
Program: 18812
Project: 18812
Buggy source:
/** 
 * Returns the root node of the AST, which includes both externs and source.
 */
public Node getRoot(){
  return externAndJsRoot;
}

Fixed version (ground truth):
@Override public Node getRoot(){
  return externAndJsRoot;
}
Program: 18813
Project: 18813
Buggy source:
@Override public void hotSwapScript(Node scriptRoot,Scope globalScope){
  makeTypeCheck(compiler).check(scriptRoot,false);
}

Fixed version (ground truth):
@Override public void hotSwapScript(Node scriptRoot){
  regenerateGlobalTypedScope(compiler,compiler.getRoot());
}
Program: 18814
Project: 18814
Buggy source:
/** 
 * Process the JS with root node root. This is supposed to be significantly faster compared to corresponding full-compiler passes.
 * @param scriptRoot Root node corresponding to the file that is modified,should be of type  {@code Token.SCRIPT}.
 * @param globalScope The global scope which is not necessarily types.
 */
void hotSwapScript(Node scriptRoot,Scope globalScope);

Fixed version (ground truth):
/** 
 * Process the JS with root node root. This is supposed to be significantly faster compared to corresponding full-compiler passes.
 * @param scriptRoot Root node corresponding to the file that is modified,should be of type  {@code Token.SCRIPT}.
 */
void hotSwapScript(Node scriptRoot);
Program: 18815
Project: 18815
Buggy source:
@Override public void hotSwapScript(Node scriptRoot,Scope globalScope){
  this.compiler.process(this);
}

Fixed version (ground truth):
@Override public void hotSwapScript(Node scriptRoot){
  this.compiler.process(this);
}
Program: 18816
Project: 18816
Buggy source:
@Override public void hotSwapScript(Node scriptRoot,Scope globalScope){
  Preconditions.checkState(scriptRoot.getType() == Token.SCRIPT);
  NodeTraversal t=new NodeTraversal(compiler,this);
  t.traverseWithScope(scriptRoot,globalScope);
}

Fixed version (ground truth):
@Override public void hotSwapScript(Node scriptRoot){
  Preconditions.checkState(scriptRoot.getType() == Token.SCRIPT);
  NodeTraversal t=new NodeTraversal(compiler,this);
  Scope scope=new SyntacticScopeCreator(compiler).createScope(compiler.getRoot(),null);
  t.traverseWithScope(scriptRoot,scope);
}
Program: 18817
Project: 18817
Buggy source:
@Override public boolean acceptEcmaScript5(){
  return options.getLanguageIn() == LanguageMode.ECMASCRIPT5;
}

Fixed version (ground truth):
@Override public boolean acceptEcmaScript5(){
switch (options.getLanguageIn()) {
case ECMASCRIPT5:
case ECMASCRIPT5_STRICT:
    return true;
}
return false;
}
Program: 18818
Project: 18818
Buggy source:
/** 
 * Creates a RecordType from the nodes representing said record type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
private JSType createRecordTypeFromNodes(Node n,String sourceName,StaticScope<JSType> scope){
  RecordTypeBuilder builder=new RecordTypeBuilder(this);
  for (Node fieldTypeNode=n.getFirstChild(); fieldTypeNode != null; fieldTypeNode=fieldTypeNode.getNext()) {
    Node fieldNameNode=fieldTypeNode;
    boolean hasType=false;
    if (fieldTypeNode.getType() == Token.COLON) {
      fieldNameNode=fieldTypeNode.getFirstChild();
      hasType=true;
    }
    String fieldName=fieldNameNode.getString();
    if (fieldName.startsWith("String_Node_Str") || fieldName.startsWith("String_Node_Str")) {
      fieldName=fieldName.substring(1,fieldName.length() - 1);
    }
    JSType fieldType=null;
    if (hasType) {
      fieldType=createFromTypeNodesInternal(fieldTypeNode.getLastChild(),sourceName,scope);
    }
 else {
      fieldType=getNativeType(JSTypeNative.UNKNOWN_TYPE);
    }
    builder.addProperty(fieldName,fieldType,fieldNameNode);
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Creates a RecordType from the nodes representing said record type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
private JSType createRecordTypeFromNodes(Node n,String sourceName,StaticScope<JSType> scope){
  RecordTypeBuilder builder=new RecordTypeBuilder(this);
  for (Node fieldTypeNode=n.getFirstChild(); fieldTypeNode != null; fieldTypeNode=fieldTypeNode.getNext()) {
    Node fieldNameNode=fieldTypeNode;
    boolean hasType=false;
    if (fieldTypeNode.getType() == Token.COLON) {
      fieldNameNode=fieldTypeNode.getFirstChild();
      hasType=true;
    }
    String fieldName=fieldNameNode.getString();
    if (fieldName.startsWith("String_Node_Str") || fieldName.startsWith("String_Node_Str")) {
      fieldName=fieldName.substring(1,fieldName.length() - 1);
    }
    JSType fieldType=null;
    if (hasType) {
      fieldType=createFromTypeNodesInternal(fieldTypeNode.getLastChild(),sourceName,scope);
    }
 else {
      fieldType=getNativeType(JSTypeNative.UNKNOWN_TYPE);
    }
    if (builder.addProperty(fieldName,fieldType,fieldNameNode) == null) {
      reporter.warning("String_Node_Str" + fieldName,sourceName,n.getLineno(),"String_Node_Str",n.getCharno());
    }
  }
  return builder.build();
}
Program: 18819
Project: 18819
Buggy source:
/** 
 * Creates a record.
 * @return The record type.
 */
public JSType build(){
  if (isEmpty) {
    return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE);
  }
  return registry.createRecordType(properties.build());
}

Fixed version (ground truth):
/** 
 * Creates a record.
 * @return The record type.
 */
public JSType build(){
  if (isEmpty) {
    return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE);
  }
  return registry.createRecordType(Collections.unmodifiableMap(properties));
}
Program: 18820
Project: 18820
Buggy source:
/** 
 * Adds a property with the given name and type to the record type.
 * @param name the name of the new property
 * @param type the JSType of the new property
 * @param propertyNode the node that holds this property definition
 * @return The builder itself for chaining purposes.
 */
public RecordTypeBuilder addProperty(String name,JSType type,Node propertyNode){
  isEmpty=false;
  properties.put(name,new RecordProperty(type,propertyNode));
  return this;
}

Fixed version (ground truth):
/** 
 * Adds a property with the given name and type to the record type.
 * @param name the name of the new property
 * @param type the JSType of the new property
 * @param propertyNode the node that holds this property definition
 * @return The builder itself for chaining purposes, or null if there'sa duplicate.
 */
public RecordTypeBuilder addProperty(String name,JSType type,Node propertyNode){
  isEmpty=false;
  if (properties.containsKey(name)) {
    return null;
  }
  properties.put(name,new RecordProperty(type,propertyNode));
  return this;
}
Program: 18821
Project: 18821
Buggy source:
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name. This involves flattening the global name (if it's not just a global variable name already), collapsing object literal keys into global variables, declaring stub global variables for properties added later in a local scope, and eliminating the global name entirely (if possible).
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name for {@code n} (e.g. "a", "a$b$c")
 */
private void updateObjLitOrFunctionDeclaration(Name n,String alias){
switch (n.declaration.node.getParent().getType()) {
case Token.ASSIGN:
    updateObjLitOrFunctionDeclarationAtAssignNode(n,alias);
  break;
case Token.VAR:
updateObjLitOrFunctionDeclarationAtVarNode(n);
break;
case Token.FUNCTION:
updateFunctionDeclarationAtFunctionNode(n);
break;
}
}

Fixed version (ground truth):
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name. This involves flattening the global name (if it's not just a global variable name already), collapsing object literal keys into global variables, declaring stub global variables for properties added later in a local scope. It may seem odd that this function also takes care of declaring stubs for direct children. The ultimate goal of this function is to eliminate the global name entirely (when possible), so that "middlemen" namespaces disappear, and to do that we need to make sure that all the direct children will be collapsed as well.
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name for {@code n} (e.g. "a", "a$b$c")
 * @param canCollapseChildNames Whether it's possible to collapse children ofthis name. (This is mostly passed for convenience; it's equivalent to n.canCollapseChildNames()).
 */
private void updateObjLitOrFunctionDeclaration(Name n,String alias,boolean canCollapseChildNames){
  if (n.declaration == null) {
    return;
  }
  if (n.declaration.getTwin() != null) {
    return;
  }
switch (n.declaration.node.getParent().getType()) {
case Token.ASSIGN:
    updateObjLitOrFunctionDeclarationAtAssignNode(n,alias,canCollapseChildNames);
  break;
case Token.VAR:
updateObjLitOrFunctionDeclarationAtVarNode(n,canCollapseChildNames);
break;
case Token.FUNCTION:
updateFunctionDeclarationAtFunctionNode(n,canCollapseChildNames);
break;
}
}
Program: 18822
Project: 18822
Buggy source:
/** 
 * Adds global variable "stubs" for any properties of a global name that are only set in a local scope or read but never set.
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we areadding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be addedas children
 * @param addAfter The child of after which newvariables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(Name n,String alias,Node parent,Node addAfter){
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs=0;
  if (n.props != null) {
    for (    Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias=appendPropForAlias(alias,p.name);
        Node nameNode=Node.newString(Token.NAME,propAlias);
        Node newVar=new Node(Token.VAR,nameNode).copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar,addAfter);
        addAfter=newVar;
        numStubs++;
        compiler.reportCodeChange();
        if (p.refs.get(0).node.getLastChild().getBooleanProp(Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME,true);
        }
      }
    }
  }
  return numStubs;
}

Fixed version (ground truth):
/** 
 * Adds global variable "stubs" for any properties of a global name that are only set in a local scope or read but never set.
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we areadding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be addedas children
 * @param addAfter The child of after which newvariables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(Name n,String alias,Node parent,Node addAfter){
  Preconditions.checkState(n.canCollapseUnannotatedChildNames());
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs=0;
  if (n.props != null) {
    for (    Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias=appendPropForAlias(alias,p.name);
        Node nameNode=Node.newString(Token.NAME,propAlias);
        Node newVar=new Node(Token.VAR,nameNode).copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar,addAfter);
        addAfter=newVar;
        numStubs++;
        compiler.reportCodeChange();
        if (p.refs.get(0).node.getLastChild().getBooleanProp(Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME,true);
        }
      }
    }
  }
  return numStubs;
}
Program: 18823
Project: 18823
Buggy source:
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name that occurs at a VAR node. See comment for  {@link #updateObjLitOrFunctionDeclaration}.
 * @param n An object representing a global name (e.g. "a")
 */
private void updateObjLitOrFunctionDeclarationAtVarNode(Name n){
  Ref ref=n.declaration;
  String name=ref.node.getString();
  Node rvalue=ref.node.getFirstChild();
  Node varNode=ref.node.getParent();
  Node gramps=varNode.getParent();
  boolean isObjLit=rvalue.getType() == Token.OBJECTLIT;
  int numChanges=0;
  if (isObjLit) {
    numChanges+=declareVarsForObjLitValues(n,name,rvalue,varNode,gramps.getChildBefore(varNode),gramps);
  }
  numChanges+=addStubsForUndeclaredProperties(n,name,gramps,varNode);
  if (isObjLit && n.canEliminate()) {
    varNode.removeChild(ref.node);
    if (!varNode.hasChildren()) {
      gramps.removeChild(varNode);
    }
    numChanges++;
    ref.node=null;
  }
  if (numChanges > 0) {
    compiler.reportCodeChange();
  }
}

Fixed version (ground truth):
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name that occurs at a VAR node. See comment for  {@link #updateObjLitOrFunctionDeclaration}.
 * @param n An object representing a global name (e.g. "a")
 */
private void updateObjLitOrFunctionDeclarationAtVarNode(Name n,boolean canCollapseChildNames){
  if (!canCollapseChildNames) {
    return;
  }
  Ref ref=n.declaration;
  String name=ref.node.getString();
  Node rvalue=ref.node.getFirstChild();
  Node varNode=ref.node.getParent();
  Node gramps=varNode.getParent();
  boolean isObjLit=rvalue.getType() == Token.OBJECTLIT;
  int numChanges=0;
  if (isObjLit) {
    numChanges+=declareVarsForObjLitValues(n,name,rvalue,varNode,gramps.getChildBefore(varNode),gramps);
  }
  numChanges+=addStubsForUndeclaredProperties(n,name,gramps,varNode);
  if (isObjLit && n.canEliminate()) {
    varNode.removeChild(ref.node);
    if (!varNode.hasChildren()) {
      gramps.removeChild(varNode);
    }
    numChanges++;
    ref.node=null;
  }
  if (numChanges > 0) {
    compiler.reportCodeChange();
  }
}
Program: 18824
Project: 18824
Buggy source:
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name that occurs at a FUNCTION node. See comment for  {@link #updateObjLitOrFunctionDeclaration}.
 * @param n An object representing a global name (e.g. "a")
 */
private void updateFunctionDeclarationAtFunctionNode(Name n){
  Ref ref=n.declaration;
  String fnName=ref.node.getString();
  addStubsForUndeclaredProperties(n,fnName,ref.node.getAncestor(2),ref.node.getParent());
}

Fixed version (ground truth):
/** 
 * Updates the first initialization (a.k.a "declaration") of a global name that occurs at a FUNCTION node. See comment for  {@link #updateObjLitOrFunctionDeclaration}.
 * @param n An object representing a global name (e.g. "a")
 */
private void updateFunctionDeclarationAtFunctionNode(Name n,boolean canCollapseChildNames){
  if (!canCollapseChildNames) {
    return;
  }
  Ref ref=n.declaration;
  String fnName=ref.node.getString();
  addStubsForUndeclaredProperties(n,fnName,ref.node.getAncestor(2),ref.node.getParent());
}
Program: 18826
Project: 18826
Buggy source:
/** 
 * Collapses definitions of the collapsible properties of a global name. Recurses on subnames that also represent JavaScript objects with collapsible properties.
 * @param n A node representing a global name
 * @param alias The flattened name for {@code n}
 */
private void collapseDeclarationOfNameAndDescendants(Name n,String alias){
  boolean canCollapseChildNames=n.canCollapseUnannotatedChildNames();
  if (n.canCollapse() && canCollapseChildNames) {
    updateObjLitOrFunctionDeclaration(n,alias);
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      collapseDeclarationOfNameAndDescendants(p,appendPropForAlias(alias,p.name));
      if (!p.inExterns && canCollapseChildNames && p.declaration != null && p.declaration.node != null && p.declaration.node.getParent() != null && p.declaration.node.getParent().getType() == Token.ASSIGN) {
        updateSimpleDeclaration(appendPropForAlias(alias,p.name),p,p.declaration);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Collapses definitions of the collapsible properties of a global name. Recurses on subnames that also represent JavaScript objects with collapsible properties.
 * @param n A node representing a global name
 * @param alias The flattened name for {@code n}
 */
private void collapseDeclarationOfNameAndDescendants(Name n,String alias){
  boolean canCollapseChildNames=n.canCollapseUnannotatedChildNames();
  if (n.canCollapse()) {
    updateObjLitOrFunctionDeclaration(n,alias,canCollapseChildNames);
  }
  if (n.props != null) {
    for (    Name p : n.props) {
      collapseDeclarationOfNameAndDescendants(p,appendPropForAlias(alias,p.name));
      if (!p.inExterns && canCollapseChildNames && p.declaration != null && p.declaration.node != null && p.declaration.node.getParent() != null && p.declaration.node.getParent().getType() == Token.ASSIGN) {
        updateSimpleDeclaration(appendPropForAlias(alias,p.name),p,p.declaration);
      }
    }
  }
}
Program: 18827
Project: 18827
Buggy source:
/** 
 * Creates a RecordType from the nodes representing said record type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
private JSType createRecordTypeFromNodes(Node n,String sourceName,StaticScope<JSType> scope){
  RecordTypeBuilder builder=new RecordTypeBuilder(this);
  for (Node fieldTypeNode=n.getFirstChild(); fieldTypeNode != null; fieldTypeNode=fieldTypeNode.getNext()) {
    Node fieldNameNode=fieldTypeNode;
    boolean hasType=false;
    if (fieldTypeNode.getType() == Token.COLON) {
      fieldNameNode=fieldTypeNode.getFirstChild();
      hasType=true;
    }
    String fieldName=fieldNameNode.getString();
    if (fieldName.startsWith("String_Node_Str") || fieldName.startsWith("String_Node_Str")) {
      fieldName=fieldName.substring(1,fieldName.length() - 1);
    }
    JSType fieldType=null;
    if (hasType) {
      fieldType=createFromTypeNodesInternal(fieldTypeNode.getLastChild(),sourceName,scope);
    }
 else {
      fieldType=getNativeType(JSTypeNative.UNKNOWN_TYPE);
    }
    if (builder.addProperty(fieldName,fieldType,fieldNameNode) == null) {
      reporter.warning("String_Node_Str" + fieldName,sourceName,n.getLineno(),"String_Node_Str",n.getCharno());
    }
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Creates a RecordType from the nodes representing said record type.
 * @param n The node with type info.
 * @param sourceName The source file name.
 * @param scope A scope for doing type name lookups.
 */
private JSType createRecordTypeFromNodes(Node n,String sourceName,StaticScope<JSType> scope){
  RecordTypeBuilder builder=new RecordTypeBuilder(this);
  for (Node fieldTypeNode=n.getFirstChild(); fieldTypeNode != null; fieldTypeNode=fieldTypeNode.getNext()) {
    Node fieldNameNode=fieldTypeNode;
    boolean hasType=false;
    if (fieldTypeNode.getType() == Token.COLON) {
      fieldNameNode=fieldTypeNode.getFirstChild();
      hasType=true;
    }
    String fieldName=fieldNameNode.getString();
    if (fieldName.startsWith("String_Node_Str") || fieldName.startsWith("String_Node_Str")) {
      fieldName=fieldName.substring(1,fieldName.length() - 1);
    }
    JSType fieldType=null;
    if (hasType) {
      fieldType=createFromTypeNodesInternal(fieldTypeNode.getLastChild(),sourceName,scope);
    }
 else {
      fieldType=getNativeType(JSTypeNative.UNKNOWN_TYPE);
    }
    if (builder.addProperty(fieldName,fieldType,fieldNameNode) == null) {
      reporter.warning("String_Node_Str" + fieldName,sourceName,n.getLineno(),"String_Node_Str",fieldNameNode.getCharno());
    }
  }
  return builder.build();
}
Program: 18828
Project: 18828
Buggy source:
void addGuard(WarningsGuard guard){
  if (guard instanceof ComposeWarningsGuard) {
    addGuards(Lists.reverse(((ComposeWarningsGuard)guard).guards));
  }
 else {
    int index=Collections.binarySearch(this.guards,guard,guardComparator);
    if (index < 0) {
      index=-index - 1;
    }
    this.guards.add(index,guard);
  }
}

Fixed version (ground truth):
void addGuard(WarningsGuard guard){
  if (guard instanceof ComposeWarningsGuard) {
    addGuards(((ComposeWarningsGuard)guard).guards.descendingSet());
  }
 else {
    numberOfAdds++;
    orderOfAddition.put(guard,numberOfAdds);
    guards.remove(guard);
    guards.add(guard);
  }
}
Program: 18829
Project: 18829
Buggy source:
@Override public int compare(WarningsGuard a,WarningsGuard b){
  return a.getPriority() - b.getPriority();
}

Fixed version (ground truth):
@Override public int compare(WarningsGuard a,WarningsGuard b){
  int priorityDiff=a.getPriority() - b.getPriority();
  if (priorityDiff != 0) {
    return priorityDiff;
  }
  return orderOfAddition.get(b).intValue() - orderOfAddition.get(a).intValue();
}
Program: 18830
Project: 18830
Buggy source:
List<WarningsGuard> getGuards(){
  return Collections.unmodifiableList(guards);
}

Fixed version (ground truth):
List<WarningsGuard> getGuards(){
  return Collections.unmodifiableList(Lists.newArrayList(guards));
}
Program: 18831
Project: 18831
Buggy source:
private CompilerOptions createCompilerOptions(){
  CompilerOptions options=new CompilerOptions();
  this.compilationLevel.setOptionsForCompilationLevel(options);
  if (this.debugOptions) {
    this.compilationLevel.setDebugOptionsForCompilationLevel(options);
  }
  options.prettyPrint=this.prettyPrint;
  options.printInputDelimiter=this.printInputDelimiter;
  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);
  return options;
}

Fixed version (ground truth):
private CompilerOptions createCompilerOptions(){
  CompilerOptions options=new CompilerOptions();
  this.compilationLevel.setOptionsForCompilationLevel(options);
  if (this.debugOptions) {
    this.compilationLevel.setDebugOptionsForCompilationLevel(options);
  }
  options.prettyPrint=this.prettyPrint;
  options.printInputDelimiter=this.printInputDelimiter;
  options.generateExports=this.generateExports;
  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);
  return options;
}
Program: 18832
Project: 18832
Buggy source:
public CompileTask(){
  this.warningLevel=WarningLevel.DEFAULT;
  this.debugOptions=false;
  this.compilationLevel=CompilationLevel.SIMPLE_OPTIMIZATIONS;
  this.customExternsOnly=false;
  this.manageDependencies=false;
  this.prettyPrint=false;
  this.printInputDelimiter=false;
  this.externFileLists=Lists.newLinkedList();
  this.sourceFileLists=Lists.newLinkedList();
}

Fixed version (ground truth):
public CompileTask(){
  this.warningLevel=WarningLevel.DEFAULT;
  this.debugOptions=false;
  this.compilationLevel=CompilationLevel.SIMPLE_OPTIMIZATIONS;
  this.customExternsOnly=false;
  this.manageDependencies=false;
  this.prettyPrint=false;
  this.printInputDelimiter=false;
  this.generateExports=false;
  this.externFileLists=Lists.newLinkedList();
  this.sourceFileLists=Lists.newLinkedList();
}
Program: 18835
Project: 18835
Buggy source:
CheckAccessControls(AbstractCompiler compiler){
  this.compiler=compiler;
  this.validator=compiler.getTypeValidator();
}

Fixed version (ground truth):
CheckAccessControls(AbstractCompiler compiler){
  this.compiler=compiler;
  this.validator=compiler.getTypeValidator();
  this.initializedConstantProperties=HashMultimap.create();
}
Program: 18836
Project: 18836
Buggy source:
public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case Token.NAME:
    checkNameDeprecation(t,n,parent);
  checkNameVisibility(t,n,parent);
break;
case Token.GETPROP:
checkPropertyDeprecation(t,n,parent);
checkPropertyVisibility(t,n,parent);
break;
case Token.NEW:
checkConstructorDeprecation(t,n,parent);
break;
}
}

Fixed version (ground truth):
public void visit(NodeTraversal t,Node n,Node parent){
switch (n.getType()) {
case Token.NAME:
    checkNameDeprecation(t,n,parent);
  checkNameVisibility(t,n,parent);
break;
case Token.GETPROP:
checkPropertyDeprecation(t,n,parent);
checkPropertyVisibility(t,n,parent);
checkConstantProperty(t,n);
break;
case Token.NEW:
checkConstructorDeprecation(t,n,parent);
break;
}
}
Program: 18837
Project: 18837
Buggy source:
@Override protected CompilerOptions getOptions(){
  CompilerOptions options=super.getOptions();
  options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS,CheckLevel.ERROR);
  return options;
}

Fixed version (ground truth):
@Override protected CompilerOptions getOptions(){
  CompilerOptions options=super.getOptions();
  options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS,CheckLevel.ERROR);
  options.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY,CheckLevel.ERROR);
  return options;
}
Program: 18838
Project: 18838
Buggy source:
public void testWarningForSuperClassWithDeprecatedSubclassMethod(){
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
public void testWarningForSuperClassWithDeprecatedSubclassMethod(){
  testSame("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 18840
Project: 18840
Buggy source:
public void testMinimizeWhileCondition(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testMinimizeWhileCondition(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
}
Program: 18841
Project: 18841
Buggy source:
private void maybeCollectMember(NodeTraversal t,Node member,Node nodeWithJsDocInfo,@Nullable Node value){
  JSDocInfo info=nodeWithJsDocInfo.getJSDocInfo();
  if (info == null || member.getType() != Token.GETPROP || member.getFirstChild().getType() != Token.THIS) {
    return;
  }
  member.getFirstChild().setJSType(thisType);
  JSType jsType=getDeclaredPropType(t,info,member,value);
  Node name=member.getLastChild();
  if (jsType != null && (name.getType() == Token.NAME || name.getType() == Token.STRING)) {
    thisType.defineDeclaredProperty(name.getString(),jsType,false,member);
  }
}

Fixed version (ground truth):
private void maybeCollectMember(NodeTraversal t,Node member,Node nodeWithJsDocInfo,@Nullable Node value){
  JSDocInfo info=nodeWithJsDocInfo.getJSDocInfo();
  if (info == null || member.getType() != Token.GETPROP || member.getFirstChild().getType() != Token.THIS) {
    return;
  }
  member.getFirstChild().setJSType(thisType);
  JSType jsType=getDeclaredType(t.getSourceName(),info,member,value);
  Node name=member.getLastChild();
  if (jsType != null && (name.getType() == Token.NAME || name.getType() == Token.STRING)) {
    thisType.defineDeclaredProperty(name.getString(),jsType,false,member);
  }
}
Program: 18842
Project: 18842
Buggy source:
private JSType getDeclaredTypeInAnnotation(String sourceName,Node node,JSDocInfo info){
  JSType jsType=null;
  Node objNode=node.getType() == Token.GETPROP ? node.getFirstChild() : NodeUtil.isObjectLitKey(node,node.getParent()) ? node.getParent() : null;
  if (info != null) {
    if (info.hasType()) {
      jsType=info.getType().evaluate(scope,typeRegistry);
    }
 else     if (FunctionTypeBuilder.isFunctionTypeDeclaration(info)) {
      String fnName=node.getQualifiedName();
      jsType=createFunctionTypeFromNodes(null,fnName,info,node);
    }
  }
  return jsType;
}

Fixed version (ground truth):
/** 
 * Returns the type specified in a JSDoc annotation near a GETPROP or NAME. Extracts type information from either the   {@code @type} tag or fromthe  {@code @return} and {@code @param} tags.
 */
private JSType getDeclaredTypeInAnnotation(String sourceName,Node node,JSDocInfo info){
  JSType jsType=null;
  Node objNode=node.getType() == Token.GETPROP ? node.getFirstChild() : NodeUtil.isObjectLitKey(node,node.getParent()) ? node.getParent() : null;
  if (info != null) {
    if (info.hasType()) {
      jsType=info.getType().evaluate(scope,typeRegistry);
    }
 else     if (FunctionTypeBuilder.isFunctionTypeDeclaration(info)) {
      String fnName=node.getQualifiedName();
      jsType=createFunctionTypeFromNodes(null,fnName,info,node);
    }
  }
  return jsType;
}
Program: 18843
Project: 18843
Buggy source:
/** 
 * Defines a variable based on the   {@link Token#NAME} node passed.
 * @param name The {@link Token#NAME} node.
 * @param var The parent of the {@code name} node, which must be a{@link Token#VAR} node.
 * @param parent {@code var}'s parent.
 * @param info the {@link JSDocInfo} information relating to this{@code name} node.
 */
private void defineName(Node name,Node var,Node parent,JSDocInfo info){
  Node value=name.getFirstChild();
  JSType type=null;
  if (value != null && value.getType() == Token.FUNCTION && shouldUseFunctionLiteralType((FunctionType)value.getJSType(),info,name)) {
    type=value.getJSType();
  }
  if (type == null) {
    if (info == null) {
      CompilerInput input=compiler.getInput(sourceName);
      Preconditions.checkNotNull(input,sourceName);
      type=input.isExtern() ? getNativeType(UNKNOWN_TYPE) : null;
    }
 else     if (info.hasEnumParameterType()) {
      if (value != null && value.getType() == Token.OBJECTLIT) {
        type=value.getJSType();
      }
 else {
        type=createEnumTypeFromNodes(value,name.getString(),info,name);
      }
    }
 else     if (info.isConstructor()) {
      type=createFunctionTypeFromNodes(value,name.getString(),info,name);
    }
 else {
      type=getDeclaredTypeInAnnotation(sourceName,name,info);
    }
  }
  defineSlot(name,var,type);
}

Fixed version (ground truth):
/** 
 * Defines a variable based on the   {@link Token#NAME} node passed.
 * @param name The {@link Token#NAME} node.
 * @param var The parent of the {@code name} node, which must be a{@link Token#VAR} node.
 * @param parent {@code var}'s parent.
 * @param info the {@link JSDocInfo} information relating to this{@code name} node.
 */
private void defineName(Node name,Node var,Node parent,JSDocInfo info){
  Node value=name.getFirstChild();
  JSType type=getDeclaredType(sourceName,info,name,value);
  if (type == null) {
    CompilerInput input=compiler.getInput(sourceName);
    Preconditions.checkNotNull(input,sourceName);
    type=input.isExtern() ? getNativeType(UNKNOWN_TYPE) : null;
  }
  defineSlot(name,var,type);
}