nus-yam/ex-repair huggingface dataset:
Program: 11026
Project: 11026
Buggy source:
private Expression resolveQueryThisElement(String identifier){
  if (queries.size() > 0) {
    QueryContext query=queries.peek();
    if (query.isImplicit()) {
      AliasedQuerySource source=resolveAlias("String_Node_Str");
      if (source != null) {
        AliasRef aliasRef=of.createAliasRef().withName("String_Node_Str");
        if (source.getResultType() instanceof ListType) {
          aliasRef.setResultType(((ListType)source.getResultType()).getElementType());
        }
 else {
          aliasRef.setResultType(source.getResultType());
        }
        DataType resultType=resolveProperty(aliasRef.getResultType(),identifier,false);
        if (resultType != null) {
          return resolveAccessor(aliasRef,identifier);
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private Expression resolveQueryThisElement(String identifier){
  if (inQueryContext()) {
    QueryContext query=peekQueryContext();
    if (query.isImplicit()) {
      AliasedQuerySource source=resolveAlias("String_Node_Str");
      if (source != null) {
        AliasRef aliasRef=of.createAliasRef().withName("String_Node_Str");
        if (source.getResultType() instanceof ListType) {
          aliasRef.setResultType(((ListType)source.getResultType()).getElementType());
        }
 else {
          aliasRef.setResultType(source.getResultType());
        }
        DataType resultType=resolveProperty(aliasRef.getResultType(),identifier,false);
        if (resultType != null) {
          return resolveAccessor(aliasRef,identifier);
        }
      }
    }
  }
  return null;
}
Program: 11027
Project: 11027
Buggy source:
private AliasedQuerySource resolveAlias(String identifier){
  for (  QueryContext query : queries) {
    AliasedQuerySource source=query.resolveAlias(identifier);
    if (source != null) {
      return source;
    }
  }
  return null;
}

Fixed version (ground truth):
private AliasedQuerySource resolveAlias(String identifier){
  if (inQueryContext()) {
    for (int i=getScope().getQueries().size() - 1; i >= 0; i--) {
      AliasedQuerySource source=getScope().getQueries().get(i).resolveAlias(identifier);
      if (source != null) {
        return source;
      }
    }
  }
  return null;
}
Program: 11028
Project: 11028
Buggy source:
@Test public void testRecursiveFunctions() throws IOException {
  runSemanticTest("String_Node_Str",3);
}

Fixed version (ground truth):
@Test public void testRecursiveFunctions() throws IOException {
  runSemanticTest("String_Node_Str",1);
}
Program: 11029
Project: 11029
Buggy source:
@Override public Object visitConversionExpressionTerm(@NotNull cqlParser.ConversionExpressionTermContext ctx){
  TypeSpecifier targetType=parseTypeSpecifier(ctx.typeSpecifier());
  Expression operand=parseExpression(ctx.expression());
  Conversion conversion=libraryBuilder.findConversion(operand.getResultType(),targetType.getResultType(),false);
  if (conversion == null) {
    throw new IllegalArgumentException(String.format("String_Node_Str",operand.getResultType(),targetType.getResultType()));
  }
  return libraryBuilder.convertExpression(operand,conversion);
}

Fixed version (ground truth):
@Override public Object visitConversionExpressionTerm(@NotNull cqlParser.ConversionExpressionTermContext ctx){
  TypeSpecifier targetType=parseTypeSpecifier(ctx.typeSpecifier());
  Expression operand=parseExpression(ctx.expression());
  if (!DataTypes.equal(operand.getResultType(),targetType.getResultType())) {
    Conversion conversion=libraryBuilder.findConversion(operand.getResultType(),targetType.getResultType(),false);
    if (conversion == null) {
      throw new IllegalArgumentException(String.format("String_Node_Str",operand.getResultType(),targetType.getResultType()));
    }
    return libraryBuilder.convertExpression(operand,conversion);
  }
  return operand;
}
Program: 11030
Project: 11030
Buggy source:
public boolean contains(Operator operator){
  return signatures.containsKey(operator.getSignature());
}

Fixed version (ground truth):
public boolean contains(Operator operator){
  boolean result=signatures.containsKey(operator.getSignature());
  if (!result) {
    for (    SignatureNode n : signatures.values()) {
      result=n.subSignatures.contains(operator);
      if (result) {
        break;
      }
    }
  }
  return result;
}
Program: 11031
Project: 11031
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11032
Project: 11032
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11034
Project: 11034
Buggy source:
private Expression resolveFunction(String libraryName,String functionName,cqlParser.ParamListContext paramList){
  List<Expression> expressions=new ArrayList<Expression>();
  if (paramList != null && paramList.expression() != null) {
    for (    cqlParser.ExpressionContext expressionContext : paramList.expression()) {
      expressions.add((Expression)visit(expressionContext));
    }
  }
  boolean checkForward=libraryName == null || libraryName.equals("String_Node_Str") || libraryName.equals(this.libraryInfo.getLibraryName());
  Expression result=libraryBuilder.resolveFunction(libraryName,functionName,expressions,!checkForward);
  if (result == null) {
    Iterable<FunctionDefinitionInfo> functionInfos=libraryInfo.resolveFunctionReference(functionName);
    if (functionInfos != null) {
      for (      FunctionDefinitionInfo functionInfo : functionInfos) {
        internalVisitFunctionDefinition(functionInfo.getDefinition());
      }
    }
    result=libraryBuilder.resolveFunction(libraryName,functionName,expressions,true);
  }
  return result;
}

Fixed version (ground truth):
private Expression resolveFunction(String libraryName,String functionName,cqlParser.ParamListContext paramList){
  List<Expression> expressions=new ArrayList<Expression>();
  if (paramList != null && paramList.expression() != null) {
    for (    cqlParser.ExpressionContext expressionContext : paramList.expression()) {
      expressions.add((Expression)visit(expressionContext));
    }
  }
  boolean checkForward=libraryName == null || libraryName.equals("String_Node_Str") || libraryName.equals(this.libraryInfo.getLibraryName());
  Expression result=libraryBuilder.resolveFunction(libraryName,functionName,expressions,!checkForward);
  if (result == null) {
    libraryBuilder.pushExpressionDefinition(functionName);
    try {
      Iterable<FunctionDefinitionInfo> functionInfos=libraryInfo.resolveFunctionReference(functionName);
      if (functionInfos != null) {
        for (        FunctionDefinitionInfo functionInfo : functionInfos) {
          internalVisitFunctionDefinition(functionInfo.getDefinition());
        }
      }
      result=libraryBuilder.resolveFunction(libraryName,functionName,expressions,true);
    }
  finally {
      libraryBuilder.popExpressionDefinition();
    }
  }
  return result;
}
Program: 11035
Project: 11035
Buggy source:
public Object internalVisitFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx){
  FunctionDef fun=of.createFunctionDef().withAccessLevel(parseAccessModifier(ctx.accessModifier())).withName(parseString(ctx.identifier()));
  if (ctx.operandDefinition() != null) {
    for (    cqlParser.OperandDefinitionContext opdef : ctx.operandDefinition()) {
      TypeSpecifier typeSpecifier=parseTypeSpecifier(opdef.typeSpecifier());
      fun.getOperand().add((OperandDef)of.createOperandDef().withName(parseString(opdef.identifier())).withOperandTypeSpecifier(typeSpecifier).withResultType(typeSpecifier.getResultType()));
    }
  }
  if (!libraryBuilder.getTranslatedLibrary().contains(fun)) {
    libraryBuilder.beginFunctionDef(fun);
    try {
      libraryBuilder.pushExpressionContext(currentContext);
      try {
        fun.setExpression(parseExpression(ctx.functionBody()));
      }
  finally {
        libraryBuilder.popExpressionContext();
      }
    }
  finally {
      libraryBuilder.endFunctionDef();
    }
    fun.setContext(currentContext);
    fun.setResultType(fun.getExpression().getResultType());
    libraryBuilder.addExpression(fun);
  }
  return fun;
}

Fixed version (ground truth):
public Object internalVisitFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx){
  FunctionDef fun=of.createFunctionDef().withAccessLevel(parseAccessModifier(ctx.accessModifier())).withName(parseString(ctx.identifier()));
  if (ctx.operandDefinition() != null) {
    for (    cqlParser.OperandDefinitionContext opdef : ctx.operandDefinition()) {
      TypeSpecifier typeSpecifier=parseTypeSpecifier(opdef.typeSpecifier());
      fun.getOperand().add((OperandDef)of.createOperandDef().withName(parseString(opdef.identifier())).withOperandTypeSpecifier(typeSpecifier).withResultType(typeSpecifier.getResultType()));
    }
  }
  if (!libraryBuilder.getTranslatedLibrary().contains(fun)) {
    libraryBuilder.beginFunctionDef(fun);
    try {
      libraryBuilder.pushExpressionContext(currentContext);
      try {
        fun.setExpression(parseExpression(ctx.functionBody()));
      }
  finally {
        libraryBuilder.popExpressionContext();
      }
    }
  finally {
      libraryBuilder.endFunctionDef();
    }
    fun.setContext(currentContext);
    fun.setResultType(fun.getExpression().getResultType());
    if (fun.getResultType() != null) {
      libraryBuilder.addExpression(fun);
    }
  }
  return fun;
}
Program: 11036
Project: 11036
Buggy source:
public DataType ensureCompatibleTypes(DataType first,DataType second){
  if (first.equals(DataType.ANY)) {
    return second;
  }
  if (second.equals(DataType.ANY)) {
    return first;
  }
  if (first.isSuperTypeOf(second) || second.isCompatibleWith(first)) {
    return first;
  }
  if (second.isSuperTypeOf(first) || first.isCompatibleWith(second)) {
    return second;
  }
  Conversion conversion=findConversion(second,first,true);
  if (conversion != null) {
    return first;
  }
  conversion=findConversion(first,second,true);
  if (conversion != null) {
    return second;
  }
  DataTypes.verifyType(second,first);
  return first;
}

Fixed version (ground truth):
public DataType ensureCompatibleTypes(DataType first,DataType second){
  if (first == null || second == null) {
    return null;
  }
  if (first.equals(DataType.ANY)) {
    return second;
  }
  if (second.equals(DataType.ANY)) {
    return first;
  }
  if (first.isSuperTypeOf(second) || second.isCompatibleWith(first)) {
    return first;
  }
  if (second.isSuperTypeOf(first) || first.isCompatibleWith(second)) {
    return second;
  }
  Conversion conversion=findConversion(second,first,true);
  if (conversion != null) {
    return first;
  }
  conversion=findConversion(first,second,true);
  if (conversion != null) {
    return second;
  }
  DataTypes.verifyType(second,first);
  return first;
}
Program: 11037
Project: 11037
Buggy source:
public Expression ensureCompatible(Expression expression,DataType targetType){
  if (!targetType.isSuperTypeOf(expression.getResultType())) {
    return convertExpression(expression,targetType);
  }
  return expression;
}

Fixed version (ground truth):
public Expression ensureCompatible(Expression expression,DataType targetType){
  if (targetType == null) {
    return of.createNull();
  }
  if (!targetType.isSuperTypeOf(expression.getResultType())) {
    return convertExpression(expression,targetType);
  }
  return expression;
}
Program: 11038
Project: 11038
Buggy source:
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}

Fixed version (ground truth):
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null || instantiationResult.getConversionScore() < lowestConversionScore) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}
Program: 11040
Project: 11040
Buggy source:
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}

Fixed version (ground truth):
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null || instantiationResult.getConversionScore() < lowestConversionScore) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}
Program: 11041
Project: 11041
Buggy source:
public boolean contains(Operator operator){
  return signatures.containsKey(operator.getSignature());
}

Fixed version (ground truth):
public boolean contains(Operator operator){
  boolean result=signatures.containsKey(operator.getSignature());
  if (!result) {
    for (    SignatureNode n : signatures.values()) {
      result=n.subSignatures.contains(operator);
      if (result) {
        break;
      }
    }
  }
  return result;
}
Program: 11042
Project: 11042
Buggy source:
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}

Fixed version (ground truth):
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null || instantiationResult.getConversionScore() < lowestConversionScore) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}
Program: 11043
Project: 11043
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11045
Project: 11045
Buggy source:
public boolean contains(Operator operator){
  return signatures.containsKey(operator.getSignature());
}

Fixed version (ground truth):
public boolean contains(Operator operator){
  boolean result=signatures.containsKey(operator.getSignature());
  if (!result) {
    for (    SignatureNode n : signatures.values()) {
      result=n.subSignatures.contains(operator);
      if (result) {
        break;
      }
    }
  }
  return result;
}
Program: 11047
Project: 11047
Buggy source:
public boolean contains(Operator operator){
  return signatures.containsKey(operator.getSignature());
}

Fixed version (ground truth):
public boolean contains(Operator operator){
  boolean result=signatures.containsKey(operator.getSignature());
  if (!result) {
    for (    SignatureNode n : signatures.values()) {
      result=n.subSignatures.contains(operator);
      if (result) {
        break;
      }
    }
  }
  return result;
}
Program: 11048
Project: 11048
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11049
Project: 11049
Buggy source:
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}

Fixed version (ground truth):
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null || instantiationResult.getConversionScore() < lowestConversionScore) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}
Program: 11050
Project: 11050
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11051
Project: 11051
Buggy source:
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}

Fixed version (ground truth):
private Operator instantiate(Signature signature,OperatorMap operatorMap,ConversionMap conversionMap){
  List<Operator> instantiations=new ArrayList<Operator>();
  int lowestConversionScore=Integer.MAX_VALUE;
  Operator instantiation=null;
  for (  GenericOperator genericOperator : genericOperators.values()) {
    InstantiationResult instantiationResult=genericOperator.instantiate(signature,operatorMap,conversionMap);
    if (instantiationResult.getOperator() != null) {
      if (instantiationResult.getConversionScore() <= lowestConversionScore) {
        if (instantiation == null || instantiationResult.getConversionScore() < lowestConversionScore) {
          instantiation=instantiationResult.getOperator();
          lowestConversionScore=instantiationResult.getConversionScore();
        }
 else {
          throw new IllegalArgumentException(String.format("String_Node_Str",this.name,instantiation.getSignature().toString(),instantiationResult.getOperator().getSignature().toString()));
        }
      }
    }
  }
  return instantiation;
}
Program: 11053
Project: 11053
Buggy source:
private TranslatedLibrary translateLibrary(VersionedIdentifier libraryIdentifier,List<CqlTranslatorException> errors){
  InputStream librarySource=librarySourceLoader.getLibrarySource(libraryIdentifier);
  if (librarySource == null) {
    throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion());
  }
  try {
    CqlTranslator translator=CqlTranslator.fromStream(librarySource,this);
    if (errors != null) {
      errors.addAll(translator.getErrors());
    }
    TranslatedLibrary result=translator.getTranslatedLibrary();
    if (libraryIdentifier.getVersion() != null && !libraryIdentifier.getVersion().equals(result.getIdentifier().getVersion())) {
      throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion(),result.getIdentifier().getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion());
    }
    return result;
  }
 catch (  IOException e) {
    throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion(),e);
  }
}

Fixed version (ground truth):
private TranslatedLibrary translateLibrary(VersionedIdentifier libraryIdentifier,List<CqlTranslatorException> errors){
  InputStream librarySource=null;
  try {
    librarySource=librarySourceLoader.getLibrarySource(libraryIdentifier);
  }
 catch (  Exception e) {
    throw new CqlTranslatorIncludeException(e.getMessage(),libraryIdentifier.getId(),libraryIdentifier.getVersion(),e);
  }
  if (librarySource == null) {
    throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion());
  }
  try {
    CqlTranslator translator=CqlTranslator.fromStream(librarySource,this);
    if (errors != null) {
      errors.addAll(translator.getErrors());
    }
    TranslatedLibrary result=translator.getTranslatedLibrary();
    if (libraryIdentifier.getVersion() != null && !libraryIdentifier.getVersion().equals(result.getIdentifier().getVersion())) {
      throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion(),result.getIdentifier().getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion());
    }
    return result;
  }
 catch (  IOException e) {
    throw new CqlTranslatorIncludeException(String.format("String_Node_Str",libraryIdentifier.getId(),libraryIdentifier.getVersion()),libraryIdentifier.getId(),libraryIdentifier.getVersion(),e);
  }
}
Program: 11054
Project: 11054
Buggy source:
public boolean contains(Operator operator){
  return signatures.containsKey(operator.getSignature());
}

Fixed version (ground truth):
public boolean contains(Operator operator){
  boolean result=signatures.containsKey(operator.getSignature());
  if (!result) {
    for (    SignatureNode n : signatures.values()) {
      result=n.subSignatures.contains(operator);
      if (result) {
        break;
      }
    }
  }
  return result;
}
Program: 11055
Project: 11055
Buggy source:
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}

Fixed version (ground truth):
public DataType resolveTypeName(String modelName,String typeName){
  DataType result=resolveLabel(modelName,typeName);
  if (result == null) {
    if (modelName == null || modelName.equals("String_Node_Str")) {
      if (defaultModel != null) {
        DataType modelResult=defaultModel.resolveTypeName(typeName);
        if (modelResult != null) {
          return modelResult;
        }
      }
      for (      Model model : models.values()) {
        DataType modelResult=model.resolveTypeName(typeName);
        if (modelResult != null) {
          if (result != null) {
            throw new IllegalArgumentException(String.format("String_Node_Str",typeName,((NamedType)result).getName(),((NamedType)modelResult).getName()));
          }
          result=modelResult;
        }
      }
    }
 else {
      result=getModel(modelName).resolveTypeName(typeName);
    }
  }
  return result;
}
Program: 11057
Project: 11057
Buggy source:
/** 
 * Record any errors while parsing in both the list of errors but also in the library itself so they can be processed easily by a remote client
 * @param e the exception to record
 */
public void recordParsingException(CqlTranslatorException e){
  errors.add(e);
  CqlToElmError err=af.createCqlToElmError();
  err.setMessage(e.getMessage());
  err.setErrorType(ErrorType.SYNTAX);
  if (e.getLocator() != null) {
    err.setStartLine(e.getLocator().getStartLine());
    err.setEndLine(e.getLocator().getEndLine());
    err.setStartChar(e.getLocator().getStartChar());
    err.setEndChar(e.getLocator().getEndChar());
  }
  if (e.getCause() != null && e.getCause() instanceof CqlTranslatorIncludeException) {
    CqlTranslatorIncludeException incEx=(CqlTranslatorIncludeException)e.getCause();
    err.setTargetIncludeLibraryId(incEx.getLibraryId());
    err.setTargetIncludeLibraryVersionId(incEx.getVersionId());
    err.setErrorType(ErrorType.INCLUDE);
  }
  getOrInitializeLibrary().getAnnotation().add(err);
}

Fixed version (ground truth):
/** 
 * Record any errors while parsing in both the list of errors but also in the library itself so they can be processed easily by a remote client
 * @param e the exception to record
 */
public void recordParsingException(CqlTranslatorException e){
  errors.add(e);
  CqlToElmError err=af.createCqlToElmError();
  err.setMessage(e.getMessage());
  err.setErrorType(e instanceof CqlSyntaxException ? ErrorType.SYNTAX : ErrorType.SEMANTIC);
  if (e.getLocator() != null) {
    err.setStartLine(e.getLocator().getStartLine());
    err.setEndLine(e.getLocator().getEndLine());
    err.setStartChar(e.getLocator().getStartChar());
    err.setEndChar(e.getLocator().getEndChar());
  }
  if (e.getCause() != null && e.getCause() instanceof CqlTranslatorIncludeException) {
    CqlTranslatorIncludeException incEx=(CqlTranslatorIncludeException)e.getCause();
    err.setTargetIncludeLibraryId(incEx.getLibraryId());
    err.setTargetIncludeLibraryVersionId(incEx.getVersionId());
    err.setErrorType(ErrorType.INCLUDE);
  }
  getOrInitializeLibrary().getAnnotation().add(err);
}
Program: 11058
Project: 11058
Buggy source:
private ClassType resolveLabel(String modelName,String label){
  ClassType result=null;
  if (modelName == null || modelName.equals("String_Node_Str")) {
    for (    Model model : models.values()) {
      ClassType modelResult=model.resolveLabel(label);
      if (modelResult != null) {
        if (result != null) {
          throw new IllegalArgumentException(String.format("String_Node_Str",label,result.getName(),modelResult.getName()));
        }
        result=modelResult;
      }
    }
  }
 else {
    result=getModel(modelName).resolveLabel(label);
  }
  return result;
}

Fixed version (ground truth):
private ClassType resolveLabel(String modelName,String label){
  ClassType result=null;
  if (modelName == null || modelName.equals("String_Node_Str")) {
    for (    Model model : models.values()) {
      ClassType modelResult=model.resolveLabel(label);
      if (modelResult != null) {
        if (result != null) {
          throw new IllegalArgumentException(String.format("String_Node_Str",label,result.getLabel(),modelResult.getLabel()));
        }
        result=modelResult;
      }
    }
  }
 else {
    result=getModel(modelName).resolveLabel(label);
  }
  return result;
}
Program: 11059
Project: 11059
Buggy source:
private void pushExpressionDefinition(String identifier){
  if (expressionDefinitions.contains(identifier)) {
    throw new IllegalArgumentException(String.format("String_Node_Str",identifier));
  }
  expressionDefinitions.push(identifier);
}

Fixed version (ground truth):
private void pushExpressionDefinition(String identifier){
  if (expressionDefinitions.contains(identifier)) {
    throw new IllegalArgumentException(String.format("String_Node_Str",identifier));
  }
  expressionDefinitions.push(new ExpressionDefinitionContext(identifier));
}
Program: 11060
Project: 11060
Buggy source:
protected DataType resolveProperty(DataType sourceType,String identifier,boolean mustResolve){
  DataType currentType=sourceType;
  while (currentType != null) {
    if (currentType instanceof ClassType) {
      ClassType classType=(ClassType)currentType;
      for (      ClassTypeElement e : classType.getElements()) {
        if (e.getName().equals(identifier)) {
          if (e.isProhibited()) {
            throw new IllegalArgumentException(String.format("String_Node_Str",e.getName(),((ClassType)currentType).getName()));
          }
          return e.getType();
        }
      }
    }
 else     if (currentType instanceof TupleType) {
      TupleType tupleType=(TupleType)currentType;
      for (      TupleTypeElement e : tupleType.getElements()) {
        if (e.getName().equals(identifier)) {
          return e.getType();
        }
      }
    }
 else     if (currentType instanceof IntervalType) {
      IntervalType intervalType=(IntervalType)currentType;
switch (identifier) {
case "String_Node_Str":
case "String_Node_Str":
        return intervalType.getPointType();
case "String_Node_Str":
case "String_Node_Str":
      return resolveTypeName("String_Node_Str","String_Node_Str");
default :
    throw new IllegalArgumentException(String.format("String_Node_Str",identifier));
}
}
if (currentType.getBaseType() != null) {
currentType=currentType.getBaseType();
}
 else {
break;
}
}
if (mustResolve) {
throw new IllegalArgumentException(String.format("String_Node_Str",identifier,sourceType));
}
return null;
}

Fixed version (ground truth):
protected DataType resolveProperty(DataType sourceType,String identifier,boolean mustResolve){
  DataType currentType=sourceType;
  while (currentType != null) {
    if (currentType instanceof ClassType) {
      ClassType classType=(ClassType)currentType;
      for (      ClassTypeElement e : classType.getElements()) {
        if (e.getName().equals(identifier)) {
          if (e.isProhibited()) {
            throw new IllegalArgumentException(String.format("String_Node_Str",e.getName(),((ClassType)currentType).getName()));
          }
          return e.getType();
        }
      }
    }
 else     if (currentType instanceof TupleType) {
      TupleType tupleType=(TupleType)currentType;
      for (      TupleTypeElement e : tupleType.getElements()) {
        if (e.getName().equals(identifier)) {
          return e.getType();
        }
      }
    }
 else     if (currentType instanceof IntervalType) {
      IntervalType intervalType=(IntervalType)currentType;
switch (identifier) {
case "String_Node_Str":
case "String_Node_Str":
        return intervalType.getPointType();
case "String_Node_Str":
case "String_Node_Str":
      return resolveTypeName("String_Node_Str","String_Node_Str");
default :
    throw new IllegalArgumentException(String.format("String_Node_Str",identifier));
}
}
if (currentType.getBaseType() != null) {
currentType=currentType.getBaseType();
}
 else {
break;
}
}
if (mustResolve) {
throw new IllegalArgumentException(String.format("String_Node_Str",identifier,sourceType != null ? sourceType.toLabel() : null));
}
return null;
}
Program: 11061
Project: 11061
Buggy source:
@Override public Object visit(@NotNull ParseTree tree){
  if (annotate) {
    pushNarrative(tree);
  }
  Object o=null;
  try {
    try {
      o=super.visit(tree);
    }
 catch (    CqlTranslatorIncludeException e) {
      recordParsingException(new CqlTranslatorException(e.getMessage(),getTrackBack((ParserRuleContext)tree),e));
    }
catch (    CqlTranslatorException e) {
      recordParsingException(e);
    }
catch (    Exception e) {
      recordParsingException(new CqlTranslatorException(e.getMessage() == null ? "String_Node_Str" : e.getMessage(),tree instanceof ParserRuleContext ? getTrackBack((ParserRuleContext)tree) : null,e));
      o=of.createNull();
    }
  }
  finally {
    if (annotate) {
      popNarrative(tree,o);
    }
  }
  if (o instanceof Trackable && tree instanceof ParserRuleContext && !(tree instanceof cqlParser.LogicContext)) {
    this.track((Trackable)o,(ParserRuleContext)tree);
  }
  if (o instanceof Expression) {
    addExpression((Expression)o);
  }
  return o;
}

Fixed version (ground truth):
@Override public Object visit(@NotNull ParseTree tree){
  if (annotate) {
    pushNarrative(tree);
  }
  Object o=null;
  try {
    try {
      o=super.visit(tree);
    }
 catch (    CqlTranslatorIncludeException e) {
      recordParsingException(new CqlTranslatorException(e.getMessage(),getTrackBack((ParserRuleContext)tree),e));
    }
catch (    CqlTranslatorException e) {
      recordParsingException(e);
    }
catch (    Exception e) {
      CqlTranslatorException ex=new CqlSemanticException(e.getMessage() == null ? "String_Node_Str" : e.getMessage(),tree instanceof ParserRuleContext ? getTrackBack((ParserRuleContext)tree) : null,e);
      Exception rootCause=determineRootCause();
      if (rootCause == null) {
        rootCause=ex;
        recordParsingException(ex);
        setRootCause(rootCause);
      }
 else {
        if (detailedErrors) {
          recordParsingException(ex);
        }
      }
      o=of.createNull();
    }
  }
  finally {
    if (annotate) {
      popNarrative(tree,o);
    }
  }
  if (o instanceof Trackable && tree instanceof ParserRuleContext && !(tree instanceof cqlParser.LogicContext)) {
    this.track((Trackable)o,(ParserRuleContext)tree);
  }
  if (o instanceof Expression) {
    addExpression((Expression)o);
  }
  return o;
}
Program: 11062
Project: 11062
Buggy source:
@Override public void syntaxError(@NotNull Recognizer<?,?> recognizer,@Nullable Object offendingSymbol,int line,int charPositionInLine,@NotNull String msg,@Nullable RecognitionException e){
  TrackBack trackback=new TrackBack(new VersionedIdentifier().withId("String_Node_Str"),line,charPositionInLine,line,charPositionInLine);
  visitor.recordParsingException(new CqlTranslatorException(msg,trackback,e));
}

Fixed version (ground truth):
@Override public void syntaxError(@NotNull Recognizer<?,?> recognizer,@Nullable Object offendingSymbol,int line,int charPositionInLine,@NotNull String msg,@Nullable RecognitionException e){
  TrackBack trackback=new TrackBack(new VersionedIdentifier().withId("String_Node_Str"),line,charPositionInLine,line,charPositionInLine);
  if (visitor.isDetailedErrorsEnabled()) {
    visitor.recordParsingException(new CqlSyntaxException(msg,trackback,e));
  }
 else {
    if (offendingSymbol instanceof CommonToken) {
      CommonToken token=(CommonToken)offendingSymbol;
      visitor.recordParsingException(new CqlSyntaxException(String.format("String_Node_Str",token.getText()),trackback,e));
    }
 else {
      visitor.recordParsingException(new CqlSyntaxException("String_Node_Str",trackback,e));
    }
  }
}