nus-yam/ex-repair huggingface dataset:
Program: 27543
Project: 27543
Buggy source:
boolean unifyWithSubtype(NominalType other,List<String> typeParameters,Multimap<String,JSType> typeMultimap){
  other=other.findMatchingAncestorWith(this);
  if (other == null) {
    return false;
  }
  if (!isGeneric()) {
    return true;
  }
  Preconditions.checkState(!typeMap.isEmpty());
  if (other.typeMap.isEmpty()) {
    return true;
  }
  boolean hasUnified=true;
  for (  String typeParam : this.rawType.typeParameters) {
    JSType fromOtherMap=other.typeMap.get(typeParam);
    Preconditions.checkNotNull(fromOtherMap,"String_Node_Str",typeParam,other.typeMap);
    hasUnified=hasUnified && this.typeMap.get(typeParam).unifyWithSubtype(fromOtherMap,typeParameters,typeMultimap);
  }
  return hasUnified && isInvariantWith(typeMultimap,other);
}

Fixed version (ground truth):
boolean unifyWithSubtype(NominalType other,List<String> typeParameters,Multimap<String,JSType> typeMultimap){
  other=other.findMatchingAncestorWith(this);
  if (other == null) {
    return false;
  }
  if (!isGeneric()) {
    return true;
  }
  Preconditions.checkState(!typeMap.isEmpty());
  if (other.typeMap.isEmpty()) {
    return true;
  }
  boolean hasUnified=true;
  for (  String typeParam : this.rawType.typeParameters) {
    JSType fromOtherMap=other.typeMap.get(typeParam);
    Preconditions.checkNotNull(fromOtherMap,"String_Node_Str",typeParam,other.typeMap);
    hasUnified=hasUnified && this.typeMap.get(typeParam).unifyWithSubtype(fromOtherMap,typeParameters,typeMultimap);
  }
  return hasUnified && (allowCovariantGenerics(this) || isInvariantWith(typeMultimap,other));
}
Program: 27545
Project: 27545
Buggy source:
public void testGenericsVariance(){
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
}

Fixed version (ground truth):
public void testGenericsVariance(){
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck(Joiner.on('\n').join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),NewTypeInference.MISTYPED_ASSIGN_RHS);
}
Program: 27547
Project: 27547
Buggy source:
public DeclaredFunctionType toDeclaredFunctionType(){
  if (isQmarkFunction()) {
    return FunctionTypeBuilder.qmarkFunctionBuilder().buildDeclaration();
  }
  Preconditions.checkState(!isLoose());
  if (isGeneric()) {
    return null;
  }
  if (nominalType != null) {
    return null;
  }
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  for (  JSType type : requiredFormals) {
    builder.addReqFormal(type);
  }
  for (  JSType type : optionalFormals) {
    builder.addOptFormal(type);
  }
  builder.addRestFormals(restFormals);
  builder.addRetType(returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  return builder.buildDeclaration();
}

Fixed version (ground truth):
public DeclaredFunctionType toDeclaredFunctionType(){
  if (isQmarkFunction()) {
    return FunctionTypeBuilder.qmarkFunctionBuilder().buildDeclaration();
  }
  Preconditions.checkState(!isLoose(),"String_Node_Str",this);
  if (isGeneric()) {
    return null;
  }
  if (nominalType != null) {
    return null;
  }
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  for (  JSType type : requiredFormals) {
    builder.addReqFormal(type);
  }
  for (  JSType type : optionalFormals) {
    builder.addOptFormal(type);
  }
  builder.addRestFormals(restFormals);
  builder.addRetType(returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  return builder.buildDeclaration();
}
Program: 27549
Project: 27549
Buggy source:
FunctionType specialize(FunctionType other){
  if (other == null || other.isQmarkFunction() || !this.isLoose() && other.isLoose()) {
    return this;
  }
  FunctionType result=FunctionType.meet(this,other);
  if (this.isLoose() && !result.isLoose()) {
    result=result.withLoose();
  }
  return result;
}

Fixed version (ground truth):
FunctionType specialize(FunctionType other){
  if (other == null || other.isQmarkFunction() || !this.isLoose() && other.isLoose()) {
    return this;
  }
  FunctionType result=meet(this,other);
  if (this.isLoose() && !result.isLoose()) {
    result=result.withLoose();
  }
  return result;
}
Program: 27553
Project: 27553
Buggy source:
PropertyDef(Node defSite,DeclaredFunctionType methodType,Scope methodScope){
  Preconditions.checkArgument(defSite.isGetProp() || NodeUtil.isObjectLitKey(defSite));
  this.defSite=defSite;
  this.methodType=methodType;
  this.methodScope=methodScope;
}

Fixed version (ground truth):
PropertyDef(Node defSite,DeclaredFunctionType methodType,Scope methodScope){
  Preconditions.checkNotNull(defSite);
  Preconditions.checkArgument(defSite.isGetProp() || NodeUtil.isObjectLitKey(defSite));
  this.defSite=defSite;
  this.methodType=methodType;
  this.methodScope=methodScope;
}
Program: 27555
Project: 27555
Buggy source:
public DeclaredFunctionType withTypeInfoFromSuper(DeclaredFunctionType superType){
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  int i=0;
  for (  JSType formal : requiredFormals) {
    builder.addReqFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  for (  JSType formal : optionalFormals) {
    builder.addOptFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  if (restFormals != null) {
    builder.addRestFormals(restFormals);
  }
 else   if (superType.hasRestFormals()) {
    builder.addRestFormals(superType.restFormals);
  }
  builder.addRetType(returnType != null ? returnType : superType.returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  if (!typeParameters.isEmpty()) {
    builder.addTypeParameters(typeParameters);
  }
 else   if (!superType.typeParameters.isEmpty()) {
    builder.addTypeParameters(superType.typeParameters);
  }
  return builder.buildDeclaration();
}

Fixed version (ground truth):
public DeclaredFunctionType withTypeInfoFromSuper(DeclaredFunctionType superType,boolean getsTypeInfoFromParentMethod){
  if (getsTypeInfoFromParentMethod) {
    return new DeclaredFunctionType(superType.requiredFormals,superType.optionalFormals,superType.restFormals,superType.returnType,superType.nominalType,this.receiverType,superType.typeParameters);
  }
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  int i=0;
  for (  JSType formal : requiredFormals) {
    builder.addReqFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  for (  JSType formal : optionalFormals) {
    builder.addOptFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  if (restFormals != null) {
    builder.addRestFormals(restFormals);
  }
 else   if (superType.hasRestFormals()) {
    builder.addRestFormals(superType.restFormals);
  }
  builder.addRetType(returnType != null ? returnType : superType.returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  if (!typeParameters.isEmpty()) {
    builder.addTypeParameters(typeParameters);
  }
 else   if (!superType.typeParameters.isEmpty()) {
    builder.addTypeParameters(superType.typeParameters);
  }
  return builder.buildDeclaration();
}
Program: 27556
Project: 27556
Buggy source:
public void testOverride(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",TypeCheck.UNKNOWN_OVERRIDE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",TypeCheck.UNKNOWN_OVERRIDE);
}

Fixed version (ground truth):
public void testOverride(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_OPERAND_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",TypeCheck.UNKNOWN_OVERRIDE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",TypeCheck.UNKNOWN_OVERRIDE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
}
Program: 27558
Project: 27558
Buggy source:
public DeclaredFunctionType withTypeInfoFromSuper(DeclaredFunctionType superType){
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  int i=0;
  for (  JSType formal : requiredFormals) {
    builder.addReqFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  for (  JSType formal : optionalFormals) {
    builder.addOptFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  if (restFormals != null) {
    builder.addRestFormals(restFormals);
  }
 else   if (superType.hasRestFormals()) {
    builder.addRestFormals(superType.restFormals);
  }
  builder.addRetType(returnType != null ? returnType : superType.returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  builder.addTypeParameters(typeParameters);
  return builder.buildDeclaration();
}

Fixed version (ground truth):
public DeclaredFunctionType withTypeInfoFromSuper(DeclaredFunctionType superType){
  FunctionTypeBuilder builder=new FunctionTypeBuilder();
  int i=0;
  for (  JSType formal : requiredFormals) {
    builder.addReqFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  for (  JSType formal : optionalFormals) {
    builder.addOptFormal(formal != null ? formal : superType.getFormalType(i));
    i++;
  }
  if (restFormals != null) {
    builder.addRestFormals(restFormals);
  }
 else   if (superType.hasRestFormals()) {
    builder.addRestFormals(superType.restFormals);
  }
  builder.addRetType(returnType != null ? returnType : superType.returnType);
  builder.addNominalType(nominalType);
  builder.addReceiverType(receiverType);
  if (!typeParameters.isEmpty()) {
    builder.addTypeParameters(typeParameters);
  }
 else   if (!superType.typeParameters.isEmpty()) {
    builder.addTypeParameters(superType.typeParameters);
  }
  return builder.buildDeclaration();
}
Program: 27561
Project: 27561
Buggy source:
static ObjectType join(ObjectType obj1,ObjectType obj2){
  Preconditions.checkState(areRelatedClasses(obj1.nominalType,obj2.nominalType));
  if (obj1.equals(obj2)) {
    return obj1;
  }
  boolean isLoose=obj1.isLoose || obj2.isLoose;
  FunctionType fn=FunctionType.join(obj1.fn,obj2.fn);
  PersistentMap<String,Property> props;
  if (isLoose) {
    fn=fn == null ? null : fn.withLoose();
    props=joinPropsLoosely(obj1.props,obj2.props);
  }
 else {
    props=joinProps(obj1.props,obj2.props);
  }
  NominalType nominal=NominalType.pickSuperclass(obj1.nominalType,obj2.nominalType);
  if (nominal == null || !nominal.isFunction()) {
    fn=null;
  }
  return ObjectType.makeObjectType(nominal,props,fn,isLoose,ObjectKind.join(obj1.objectKind,obj2.objectKind));
}

Fixed version (ground truth):
static ObjectType join(ObjectType obj1,ObjectType obj2){
  NominalType nom1=obj1.nominalType;
  NominalType nom2=obj2.nominalType;
  Preconditions.checkState(areRelatedClasses(nom1,nom2));
  if (obj1.equals(obj2)) {
    return obj1;
  }
  boolean isLoose=obj1.isLoose || obj2.isLoose;
  FunctionType fn=FunctionType.join(obj1.fn,obj2.fn);
  PersistentMap<String,Property> props;
  if (isLoose) {
    fn=fn == null ? null : fn.withLoose();
    props=joinPropsLoosely(obj1.props,obj2.props);
  }
 else {
    props=joinProps(obj1.props,obj2.props,nom1,nom2);
  }
  NominalType nominal=NominalType.pickSuperclass(nom1,nom2);
  if (nominal == null || !nominal.isFunction()) {
    fn=null;
  }
  return ObjectType.makeObjectType(nominal,props,fn,isLoose,ObjectKind.join(obj1.objectKind,obj2.objectKind));
}
Program: 27562
Project: 27562
Buggy source:
private static PersistentMap<String,Property> joinProps(Map<String,Property> props1,Map<String,Property> props2){
  PersistentMap<String,Property> newProps=PersistentMap.create();
  for (  Map.Entry<String,Property> propsEntry : props1.entrySet()) {
    String pname=propsEntry.getKey();
    if (!props2.containsKey(pname)) {
      newProps=newProps.with(pname,propsEntry.getValue().withOptional());
    }
  }
  for (  Map.Entry<String,Property> propsEntry : props2.entrySet()) {
    String pname=propsEntry.getKey();
    Property prop2=propsEntry.getValue();
    if (props1.containsKey(pname)) {
      newProps=newProps.with(pname,Property.join(props1.get(pname),prop2));
    }
 else {
      newProps=newProps.with(pname,prop2.withOptional());
    }
  }
  return newProps;
}

Fixed version (ground truth):
private static PersistentMap<String,Property> joinProps(Map<String,Property> props1,Map<String,Property> props2,NominalType nom1,NominalType nom2){
  PersistentMap<String,Property> newProps=PersistentMap.create();
  for (  String pname : Sets.union(props1.keySet(),props2.keySet())) {
    Property prop1=getProp(props1,nom1,pname);
    Property prop2=getProp(props2,nom2,pname);
    Property newProp=null;
    if (prop1 == null) {
      newProp=prop2.withOptional();
    }
 else     if (prop2 == null) {
      newProp=prop1.withOptional();
    }
 else {
      newProp=Property.join(prop1,prop2);
    }
    newProps=newProps.with(pname,newProp);
  }
  return newProps;
}
Program: 27563
Project: 27563
Buggy source:
static ImmutableSet<ObjectType> joinSets(ImmutableSet<ObjectType> objs1,ImmutableSet<ObjectType> objs2){
  if (objs1.isEmpty()) {
    return objs2;
  }
 else   if (objs2.isEmpty()) {
    return objs1;
  }
  ObjectType[] objs1Arr=objs1.toArray(new ObjectType[0]);
  ObjectType[] keptFrom1=objs1Arr.clone();
  ImmutableSet.Builder<ObjectType> newObjs=ImmutableSet.builder();
  for (  ObjectType obj2 : objs2) {
    boolean addedObj2=false;
    for (int i=0; i < objs1Arr.length; i++) {
      ObjectType obj1=objs1Arr[i];
      NominalType nominalType1=obj1.nominalType;
      NominalType nominalType2=obj2.nominalType;
      if (areRelatedClasses(nominalType1,nominalType2)) {
        if (nominalType2 == null && nominalType1 != null && !obj1.isSubtypeOf(obj2) || nominalType1 == null && nominalType2 != null && !obj2.isSubtypeOf(obj1)) {
          break;
        }
        keptFrom1[i]=null;
        newObjs.add(join(obj1,obj2));
        addedObj2=true;
        break;
      }
    }
    if (!addedObj2) {
      newObjs.add(obj2);
    }
  }
  for (  ObjectType o : keptFrom1) {
    if (o != null) {
      newObjs.add(o);
    }
  }
  return newObjs.build();
}

Fixed version (ground truth):
static ImmutableSet<ObjectType> joinSets(ImmutableSet<ObjectType> objs1,ImmutableSet<ObjectType> objs2){
  if (objs1.isEmpty()) {
    return objs2;
  }
 else   if (objs2.isEmpty()) {
    return objs1;
  }
  ObjectType[] objs1Arr=objs1.toArray(new ObjectType[0]);
  ObjectType[] keptFrom1=objs1Arr.clone();
  ImmutableSet.Builder<ObjectType> newObjs=ImmutableSet.builder();
  for (  ObjectType obj2 : objs2) {
    boolean addedObj2=false;
    for (int i=0; i < objs1Arr.length; i++) {
      ObjectType obj1=objs1Arr[i];
      NominalType nominalType1=obj1.nominalType;
      NominalType nominalType2=obj2.nominalType;
      if (areRelatedClasses(nominalType1,nominalType2)) {
        if (nominalType2 == null && nominalType1 != null && !obj1.isSubtypeOf(obj2) || nominalType1 == null && nominalType2 != null && !obj2.isSubtypeOf(obj1)) {
          break;
        }
        keptFrom1[i]=null;
        addedObj2=true;
        newObjs.add(join(obj1,obj2));
        break;
      }
    }
    if (!addedObj2) {
      newObjs.add(obj2);
    }
  }
  for (  ObjectType o : keptFrom1) {
    if (o != null) {
      newObjs.add(o);
    }
  }
  return newObjs.build();
}
Program: 27564
Project: 27564
Buggy source:
Property withOptional(){
  return new Property(defSite,inferredType,declaredType,Attribute.OPTIONAL);
}

Fixed version (ground truth):
Property withOptional(){
  return isOptional() ? this : new Property(defSite,inferredType,declaredType,Attribute.OPTIONAL);
}
Program: 27565
Project: 27565
Buggy source:
Property withRequired(){
  return new Property(defSite,inferredType,declaredType,Attribute.REQUIRED);
}

Fixed version (ground truth):
Property withRequired(){
  return isRequired() ? this : new Property(defSite,inferredType,declaredType,Attribute.REQUIRED);
}
Program: 27566
Project: 27566
Buggy source:
private StringBuilder appendGenericSuffixTo(StringBuilder builder,Map<String,JSType> typeMap){
  Preconditions.checkState(typeMap.isEmpty() || typeMap.keySet().containsAll(typeParameters));
  if (typeParameters.isEmpty()) {
    return builder;
  }
  boolean firstIteration=true;
  builder.append("String_Node_Str");
  for (  String typeParam : typeParameters) {
    if (!firstIteration) {
      builder.append(',');
    }
    JSType concrete=typeMap.get(typeParam);
    if (concrete != null) {
      concrete.appendTo(builder);
    }
 else {
      builder.append(typeParam);
    }
  }
  builder.append('>');
  return builder;
}

Fixed version (ground truth):
private StringBuilder appendGenericSuffixTo(StringBuilder builder,Map<String,JSType> typeMap){
  Preconditions.checkState(typeMap.isEmpty() || typeMap.keySet().containsAll(typeParameters));
  if (typeParameters.isEmpty()) {
    return builder;
  }
  boolean firstIteration=true;
  builder.append("String_Node_Str");
  for (  String typeParam : typeParameters) {
    if (firstIteration) {
      firstIteration=false;
    }
 else {
      builder.append(',');
    }
    JSType concrete=typeMap.get(typeParam);
    if (concrete != null) {
      concrete.appendTo(builder);
    }
 else {
      builder.append(typeParam);
    }
  }
  builder.append('>');
  return builder;
}
Program: 27567
Project: 27567
Buggy source:
boolean unifyWithSubtype(NominalType other,List<String> typeParameters,Multimap<String,JSType> typeMultimap){
  if (this.rawType != other.rawType) {
    return false;
  }
  if (this.rawType.typeParameters.isEmpty()) {
    return true;
  }
  Preconditions.checkState(!typeMap.isEmpty());
  if (other.typeMap.isEmpty()) {
    return true;
  }
  boolean hasUnified=true;
  for (  String typeParam : rawType.typeParameters) {
    hasUnified=hasUnified && typeMap.get(typeParam).unifyWithSubtype(other.typeMap.get(typeParam),typeParameters,typeMultimap);
  }
  return hasUnified;
}

Fixed version (ground truth):
boolean unifyWithSubtype(NominalType other,List<String> typeParameters,Multimap<String,JSType> typeMultimap){
  if (this.rawType != other.rawType) {
    return false;
  }
  if (!isGeneric()) {
    return true;
  }
  Preconditions.checkState(!typeMap.isEmpty());
  if (other.typeMap.isEmpty()) {
    return true;
  }
  boolean hasUnified=true;
  for (  String typeParam : rawType.typeParameters) {
    hasUnified=hasUnified && typeMap.get(typeParam).unifyWithSubtype(other.typeMap.get(typeParam),typeParameters,typeMultimap);
  }
  return hasUnified && isInvariantWith(typeMultimap,other);
}
Program: 27568
Project: 27568
Buggy source:
public void testUnifyWithGenericUnion(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
}

Fixed version (ground truth):
public void testUnifyWithGenericUnion(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",NewTypeInference.FAILED_TO_UNIFY);
}
Program: 27569
Project: 27569
Buggy source:
private void visitCallNode(Node call,Node parent){
  String required=codingConvention.extractClassNameIfRequire(call,parent);
  if (required != null) {
    requires.put(required,call);
  }
  for (Node qNameNode=call.getFirstChild(); qNameNode != null; qNameNode=qNameNode.getFirstChild()) {
    weakUsages.put(qNameNode.getQualifiedName(),qNameNode);
  }
}

Fixed version (ground truth):
private void visitCallNode(Node call,Node parent){
  String required=codingConvention.extractClassNameIfRequire(call,parent);
  if (required != null) {
    requires.put(required,call);
  }
}
Program: 27572
Project: 27572
Buggy source:
public void testWarning(){
  testSame("String_Node_Str",EXTRA_REQUIRE_WARNING);
}

Fixed version (ground truth):
public void testWarning(){
  testError("String_Node_Str",EXTRA_REQUIRE_WARNING);
  testError("String_Node_Str",EXTRA_REQUIRE_WARNING);
}
Program: 27573
Project: 27573
Buggy source:
public void testNoWarning(){
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
}

Fixed version (ground truth):
public void testNoWarning(){
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  testSame("String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27574
Project: 27574
Buggy source:
@Override protected CompilerOptions getOptions(CompilerOptions options){
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE,CheckLevel.WARNING);
  return super.getOptions(options);
}

Fixed version (ground truth):
@Override protected CompilerOptions getOptions(CompilerOptions options){
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE,CheckLevel.ERROR);
  return super.getOptions(options);
}
Program: 27575
Project: 27575
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  TypeDeclarationNode type=n.getDeclaredTypeExpression();
  if (type == null) {
    return;
  }
  JSDocInfo info=n.getJSDocInfo();
  Preconditions.checkState(info == null || info.getType() == null,"String_Node_Str");
  JSDocInfoBuilder builder=JSDocInfoBuilder.maybeCopyFrom(info);
  Node typeRoot=convertWithLocation(type);
  JSTypeExpression typeExpression=new JSTypeExpression(typeRoot,n.getSourceFileName());
  if (n.isFunction()) {
    builder.recordReturnType(typeExpression);
  }
 else {
    builder.recordType(typeExpression);
    builder.recordInlineType();
  }
  info=builder.build(n);
  n.setJSDocInfo(info);
  n.setDeclaredTypeExpression(null);
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  TypeDeclarationNode type=n.getDeclaredTypeExpression();
  if (type == null) {
    return;
  }
  JSDocInfo info=n.getJSDocInfo();
  Preconditions.checkState(info == null || info.getType() == null,"String_Node_Str");
  JSDocInfoBuilder builder=JSDocInfoBuilder.maybeCopyFrom(info);
  Node typeRoot=convertWithLocation(type);
  JSTypeExpression typeExpression=new JSTypeExpression(typeRoot,n.getSourceFileName());
  if (n.isFunction()) {
    builder.recordReturnType(typeExpression);
  }
 else   if (n.getType() == Token.MEMBER_VARIABLE_DEF) {
    builder.recordType(typeExpression);
  }
 else {
    builder.recordType(typeExpression);
    builder.recordInlineType();
  }
  info=builder.build(n);
  n.setJSDocInfo(info);
  n.setDeclaredTypeExpression(null);
}
Program: 27576
Project: 27576
Buggy source:
private boolean mayAddPropToType(Node getProp,RawNominalType rawType){
  if (!rawType.isStruct()) {
    return true;
  }
  Node parent=getProp.getParent();
  return parent.isAssign() && getProp == parent.getFirstChild() && currentScope.isConstructor();
}

Fixed version (ground truth):
private boolean mayAddPropToType(Node getProp,RawNominalType rawType){
  if (!rawType.isStruct()) {
    return true;
  }
  Node parent=getProp.getParent();
  return (parent.isAssign() && getProp == parent.getFirstChild() || parent.isExprResult()) && currentScope.isConstructor();
}
Program: 27577
Project: 27577
Buggy source:
public void testBasicTypeCheck_error() throws Exception {
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}

Fixed version (ground truth):
public void testBasicTypeCheck_error(){
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}
Program: 27578
Project: 27578
Buggy source:
public void testFunctionParameter_error() throws Exception {
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}

Fixed version (ground truth):
public void testFunctionParameter_error(){
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}
Program: 27579
Project: 27579
Buggy source:
public void testFunctionParameter() throws Exception {
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testFunctionParameter(){
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}
Program: 27580
Project: 27580
Buggy source:
public void testClassMemberVariable() throws Exception {
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str","String_Node_Str");
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}

Fixed version (ground truth):
public void testClassMemberVariable(){
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str","String_Node_Str");
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}
Program: 27581
Project: 27581
Buggy source:
public void testFunctionType_error() throws Exception {
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}

Fixed version (ground truth):
public void testFunctionType_error(){
  test(createCompilerOptions(),"String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}
Program: 27582
Project: 27582
Buggy source:
public void testFunctionType_correct() throws Exception {
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testFunctionType_correct(){
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}
Program: 27583
Project: 27583
Buggy source:
public void testBasicTypeCheck() throws Exception {
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testBasicTypeCheck(){
  test(createCompilerOptions(),"String_Node_Str","String_Node_Str");
}
Program: 27584
Project: 27584
Buggy source:
public void testClassMemberVariable_static() throws Exception {
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str","String_Node_Str");
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}

Fixed version (ground truth):
public void testClassMemberVariable_static(){
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str" + "String_Node_Str","String_Node_Str");
  test(createCompilerOptions(),"String_Node_Str" + "String_Node_Str",TypeValidator.TYPE_MISMATCH_WARNING);
}
Program: 27586
Project: 27586
Buggy source:
protected final void addES6TranspilationPasses(){
  passes.add(makePassFactory("String_Node_Str",new Es6RenameVariablesInParamLists(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6SplitVariableDeclarations(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ConvertSuper(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ToEs3Converter(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6RewriteLetConst(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6RewriteGenerators(compiler)));
  passes.add(makePassFactory("String_Node_Str",new InjectEs6RuntimeLibrary(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ToEs3ClassSideInheritance(compiler)));
}

Fixed version (ground truth):
protected final void addES6TranspilationPasses(){
  passes.add(makePassFactory("String_Node_Str",new Es6RenameVariablesInParamLists(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6SplitVariableDeclarations(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ConvertSuper(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6TypedToEs6Converter(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ToEs3Converter(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6RewriteLetConst(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6RewriteGenerators(compiler)));
  passes.add(makePassFactory("String_Node_Str",new InjectEs6RuntimeLibrary(compiler)));
  passes.add(makePassFactory("String_Node_Str",new Es6ToEs3ClassSideInheritance(compiler)));
}
Program: 27588
Project: 27588
Buggy source:
public void testExportDefault(){
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
public void testExportDefault(){
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  test("String_Node_Str",Joiner.on('\n').join(FILEOVERVIEW,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
}
Program: 27589
Project: 27589
Buggy source:
private EnvTypePair analyzeLogicalOpFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  int exprKind=expr.getType();
  Node lhs=expr.getFirstChild();
  Node rhs=expr.getLastChild();
  if ((specializedType.isTruthy() && exprKind == Token.AND) || (specializedType.isFalsy() && exprKind == Token.OR)) {
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType);
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,JSType.UNKNOWN,specializedType);
    return rhsPair;
  }
 else   if ((specializedType.isFalsy() && exprKind == Token.AND) || (specializedType.isTruthy() && exprKind == Token.OR)) {
    EnvTypePair shortCircuitPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType);
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType.negate());
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,JSType.UNKNOWN,specializedType);
    return EnvTypePair.join(rhsPair,shortCircuitPair);
  }
 else {
    JSType stopAfterLhsType=exprKind == Token.AND ? JSType.FALSY : JSType.TRUTHY;
    EnvTypePair shortCircuitPair=analyzeExprFwd(lhs,inEnv,requiredType,stopAfterLhsType);
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,stopAfterLhsType.negate());
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,requiredType,specializedType);
    return EnvTypePair.join(rhsPair,shortCircuitPair);
  }
}

Fixed version (ground truth):
private EnvTypePair analyzeLogicalOpFwd(Node expr,TypeEnv inEnv,JSType requiredType,JSType specializedType){
  int exprKind=expr.getType();
  Node lhs=expr.getFirstChild();
  Node rhs=expr.getLastChild();
  if ((specializedType.isTruthy() && exprKind == Token.AND) || (specializedType.isFalsy() && exprKind == Token.OR)) {
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType);
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,JSType.UNKNOWN,specializedType);
    return rhsPair;
  }
 else   if ((specializedType.isFalsy() && exprKind == Token.AND) || (specializedType.isTruthy() && exprKind == Token.OR)) {
    EnvTypePair shortCircuitPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType);
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,specializedType.negate());
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,JSType.UNKNOWN,specializedType);
    return EnvTypePair.join(rhsPair,shortCircuitPair);
  }
 else {
    JSType stopAfterLhsType=exprKind == Token.AND ? JSType.FALSY : JSType.TRUTHY;
    EnvTypePair shortCircuitPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,stopAfterLhsType);
    EnvTypePair lhsPair=analyzeExprFwd(lhs,inEnv,JSType.UNKNOWN,stopAfterLhsType.negate());
    EnvTypePair rhsPair=analyzeExprFwd(rhs,lhsPair.env,requiredType,specializedType);
    return EnvTypePair.join(rhsPair,shortCircuitPair);
  }
}
Program: 27590
Project: 27590
Buggy source:
public void testAndOr(){
  typeCheck("String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
}

Fixed version (ground truth):
public void testAndOr(){
  typeCheck("String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}
Program: 27591
Project: 27591
Buggy source:
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis,JSType other){
  if (isUnknown() || other.isUnknown() || other.isTop()) {
    return true;
  }
  if (!EnumType.areSubtypes(this,other)) {
    return false;
  }
  int mask=getMask() & ~ENUM_MASK;
  if ((mask | other.getMask()) != other.getMask()) {
    return false;
  }
  if (!Objects.equals(getTypeVar(),other.getTypeVar())) {
    return false;
  }
  if (getObjs() == null) {
    return true;
  }
  return ObjectType.isUnionSubtype(keepLoosenessOfThis,getObjs(),other.getObjs());
}

Fixed version (ground truth):
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis,JSType other){
  if (isUnknown() || other.isUnknown() || other.isTop()) {
    return true;
  }
  if (!EnumType.areSubtypes(this,other)) {
    return false;
  }
  int mask=getMask() & ~ENUM_MASK;
  if ((mask | other.getMask()) != other.getMask()) {
    return false;
  }
  if (getTypeVar() != null && !getTypeVar().equals(other.getTypeVar())) {
    return false;
  }
  if (getObjs() == null) {
    return true;
  }
  return ObjectType.isUnionSubtype(keepLoosenessOfThis,getObjs(),other.getObjs());
}
Program: 27592
Project: 27592
Buggy source:
/** 
 * Removes a cast from the given node.
 */
public Builder removeCast(Node n,AbstractCompiler compiler){
  Preconditions.checkArgument(n.isCast());
  JSDocInfo jsDoc=n.getJSDocInfo();
  Node child=n.getFirstChild();
  replacements.put(n.getSourceFileName(),new CodeReplacement(jsDoc.getOriginalCommentPosition(),n.getSourceOffset() + n.getLength() - jsDoc.getOriginalCommentPosition(),generateCode(compiler,child)));
  return this;
}

Fixed version (ground truth):
/** 
 * Removes a cast from the given node.
 */
public Builder removeCast(Node n,AbstractCompiler compiler){
  Preconditions.checkArgument(n.isCast());
  JSDocInfo jsDoc=n.getJSDocInfo();
  replacements.put(n.getSourceFileName(),new CodeReplacement(jsDoc.getOriginalCommentPosition(),n.getSourceOffset() - jsDoc.getOriginalCommentPosition() + 1,"String_Node_Str"));
  replacements.put(n.getSourceFileName(),new CodeReplacement(n.getSourceOffset() + n.getLength() - 1,1,"String_Node_Str"));
  return this;
}
Program: 27593
Project: 27593
Buggy source:
@Test public void testRemoveCast(){
  String before="String_Node_Str";
  String after="String_Node_Str";
  Compiler compiler=getCompiler(before + after);
  JSError[] errors=compiler.getErrors();
  assertEquals(Arrays.toString(errors),1,errors.length);
  SuggestedFix fix=ErrorToFixMapper.getFixForJsError(errors[0],compiler);
  CodeReplacement replacement=new CodeReplacement(before.length(),after.length() - 1,"String_Node_Str");
  assertReplacement(fix,replacement);
}

Fixed version (ground truth):
@Test public void testRemoveCast(){
  String code="String_Node_Str";
  String expectedCode="String_Node_Str";
  Compiler compiler=getCompiler(code);
  JSError[] errors=compiler.getErrors();
  assertEquals(Arrays.toString(errors),1,errors.length);
  SuggestedFix fix=ErrorToFixMapper.getFixForJsError(errors[0],compiler);
  assertChanges(fix,"String_Node_Str",code,expectedCode);
}
Program: 27594
Project: 27594
Buggy source:
@Test public void testRemoveCast(){
  String input="String_Node_Str";
  Compiler compiler=getCompiler(input);
  Node root=compileToScriptRoot(compiler);
  Node castNode=root.getFirstChild().getFirstChild().getFirstChild();
  assertTrue(castNode.isCast());
  SuggestedFix fix=new SuggestedFix.Builder().removeCast(castNode,compiler).build();
  CodeReplacement replacement=new CodeReplacement("String_Node_Str".length(),"String_Node_Str".length(),"String_Node_Str");
  assertReplacement(fix,replacement);
}

Fixed version (ground truth):
@Test public void testRemoveCast(){
  String input="String_Node_Str";
  String expectedCode="String_Node_Str";
  Compiler compiler=getCompiler(input);
  Node root=compileToScriptRoot(compiler);
  Node castNode=root.getFirstChild().getFirstChild().getFirstChild();
  assertTrue(castNode.isCast());
  SuggestedFix fix=new SuggestedFix.Builder().removeCast(castNode,compiler).build();
  assertChanges(fix,"String_Node_Str",input,expectedCode);
}
Program: 27595
Project: 27595
Buggy source:
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if (c == '"' && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}

Fixed version (ground truth):
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if ((c == '"' || c == '\'') && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}
Program: 27597
Project: 27597
Buggy source:
@Override void appendOp(String op,boolean binOp){
  if (binOp) {
    if (getLastChar() != ' ' && op.charAt(0) != ',') {
      append("String_Node_Str");
    }
    append(op);
    append("String_Node_Str");
  }
 else {
    append(op);
  }
}

Fixed version (ground truth):
@Override void appendOp(String op,boolean binOp){
  if (getLastChar() != ' ' && binOp && op.charAt(0) != ',') {
    append("String_Node_Str");
  }
  append(op);
  if (binOp) {
    append("String_Node_Str");
  }
}
Program: 27598
Project: 27598
Buggy source:
public void testStrict(){
  String result=parsePrint("String_Node_Str",false,false,0,false,true);
  assertEquals("String_Node_Str",result);
}

Fixed version (ground truth):
public void testStrict(){
  String result=new CodePrinter.Builder(parse("String_Node_Str",true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(0);
    }
  }
)).setOutputTypes(false).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(true).build();
  assertEquals("String_Node_Str",result);
}
Program: 27599
Project: 27599
Buggy source:
String parsePrint(String js,boolean prettyprint,boolean lineBreak,int lineThreshold,boolean outputTypes,boolean tagAsStrict){
  return new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(prettyprint,lineThreshold,lineBreak)).setOutputTypes(outputTypes).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(tagAsStrict).build();
}

Fixed version (ground truth):
String parsePrint(String js,CompilerOptions options){
  return new CodePrinter.Builder(parse(js)).setCompilerOptions(options).build();
}
Program: 27600
Project: 27600
Buggy source:
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,10));
}

Fixed version (ground truth):
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(10);
    }
  }
)));
}
Program: 27601
Project: 27601
Buggy source:
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,false,false,false,30));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,false,false,true,30));
}

Fixed version (ground truth):
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(false);
    }
  }
)));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(true);
    }
  }
)));
}
Program: 27602
Project: 27602
Buggy source:
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27603
Project: 27603
Buggy source:
CompilerOptions newCompilerOptions(boolean prettyprint,int lineThreshold,boolean lineBreak){
  CompilerOptions options=newCompilerOptions(prettyprint,lineThreshold);
  options.setLineBreak(lineBreak);
  return options;
}

Fixed version (ground truth):
CompilerOptions newCompilerOptions(CompilerOptionBuilder builder){
  CompilerOptions options=new CompilerOptions();
  options.setTrustedStrings(trustedStrings);
  options.preserveTypeAnnotations=preserveTypeAnnotations;
  options.setLanguageOut(languageMode);
  builder.setOptions(options);
  return options;
}
Program: 27605
Project: 27605
Buggy source:
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27606
Project: 27606
Buggy source:
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD,true));
}

Fixed version (ground truth):
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)).setOutputTypes(true).setTypeRegistry(lastCompiler.getTypeRegistry()).build());
}