Program: 23099
Project: 23099
Buggy source:
@SuppressWarnings("String_Node_Str") private TypeDetails evaluateFunctionType(ExecutionTypeContext context,TypeDetails focus,ExpressionNode exp) throws PathEngineException, DefinitionException {
  List<TypeDetails> paramTypes=new ArrayList<TypeDetails>();
  if (exp.getFunction() == Function.Is || exp.getFunction() == Function.As)   paramTypes.add(new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
 else   for (  ExpressionNode expr : exp.getParameters()) {
    if (exp.getFunction() == Function.Where || exp.getFunction() == Function.Select || exp.getFunction() == Function.Repeat)     paramTypes.add(executeType(changeThis(context,focus),focus,expr,true));
 else     paramTypes.add(executeType(context,focus,expr,true));
  }
switch (exp.getFunction()) {
case Empty:
    return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Not:
  return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Exists:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case SubsetOf:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,focus);
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case SupersetOf:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,focus);
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case IsDistinct:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Distinct:
return focus;
case Count:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Where:
return focus;
case Select:
return anything(focus.getCollectionStatus());
case All:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Repeat:
return anything(focus.getCollectionStatus());
case Item:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case As:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,exp.getParameters().get(0).getName());
}
case Is:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Single:
return focus.toSingleton();
case First:
{
checkOrdered(focus,"String_Node_Str");
return focus.toSingleton();
}
case Last:
{
checkOrdered(focus,"String_Node_Str");
return focus.toSingleton();
}
case Tail:
{
checkOrdered(focus,"String_Node_Str");
return focus;
}
case Skip:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Take:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Iif:
{
TypeDetails types=new TypeDetails(null);
types.update(paramTypes.get(0));
if (paramTypes.size() > 1) types.update(paramTypes.get(1));
return types;
}
case ToInteger:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ToDecimal:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ToString:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Substring:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case StartsWith:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case EndsWith:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Matches:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ReplaceMatches:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Contains:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Replace:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Length:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Children:
return childTypes(focus,"String_Node_Str");
case Descendants:
return childTypes(focus,"String_Node_Str");
case MemberOf:
{
checkContextCoded(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Trace:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Today:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Now:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Resolve:
{
checkContextReference(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Extension:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case HasValue:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case HtmlChecks:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Alias:
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return anything(CollectionStatus.SINGLETON);
case AliasAs:
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
case Custom:
{
return hostServices.checkFunction(context.appInfo,exp.getName(),paramTypes);
}
default :
break;
}
throw new Error("String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private TypeDetails evaluateFunctionType(ExecutionTypeContext context,TypeDetails focus,ExpressionNode exp) throws PathEngineException, DefinitionException {
  List<TypeDetails> paramTypes=new ArrayList<TypeDetails>();
  if (exp.getFunction() == Function.Is || exp.getFunction() == Function.As)   paramTypes.add(new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
 else   for (  ExpressionNode expr : exp.getParameters()) {
    if (exp.getFunction() == Function.Where || exp.getFunction() == Function.Select || exp.getFunction() == Function.Repeat)     paramTypes.add(executeType(changeThis(context,focus),focus,expr,true));
 else     paramTypes.add(executeType(context,focus,expr,true));
  }
switch (exp.getFunction()) {
case Empty:
    return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Not:
  return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Exists:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case SubsetOf:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,focus);
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case SupersetOf:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,focus);
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case IsDistinct:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Distinct:
return focus;
case Count:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Where:
return focus;
case Select:
return anything(focus.getCollectionStatus());
case All:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Repeat:
return anything(focus.getCollectionStatus());
case Item:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case As:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,exp.getParameters().get(0).getName());
}
case OfType:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,exp.getParameters().get(0).getName());
}
case Is:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Single:
return focus.toSingleton();
case First:
{
checkOrdered(focus,"String_Node_Str");
return focus.toSingleton();
}
case Last:
{
checkOrdered(focus,"String_Node_Str");
return focus.toSingleton();
}
case Tail:
{
checkOrdered(focus,"String_Node_Str");
return focus;
}
case Skip:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Take:
{
checkOrdered(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Iif:
{
TypeDetails types=new TypeDetails(null);
types.update(paramTypes.get(0));
if (paramTypes.size() > 1) types.update(paramTypes.get(1));
return types;
}
case ToInteger:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ToDecimal:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ToString:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Substring:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case StartsWith:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case EndsWith:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Matches:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case ReplaceMatches:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Contains:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Replace:
{
checkContextString(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"),new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Length:
{
checkContextPrimitive(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Children:
return childTypes(focus,"String_Node_Str");
case Descendants:
return childTypes(focus,"String_Node_Str");
case MemberOf:
{
checkContextCoded(focus,"String_Node_Str");
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Trace:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
}
case Today:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Now:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Resolve:
{
checkContextReference(focus,"String_Node_Str");
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case Extension:
{
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
}
case HasValue:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case HtmlChecks:
return new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str");
case Alias:
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return anything(CollectionStatus.SINGLETON);
case AliasAs:
checkParamTypes(exp.getFunction().toCode(),paramTypes,new TypeDetails(CollectionStatus.SINGLETON,"String_Node_Str"));
return focus;
case Custom:
{
return hostServices.checkFunction(context.appInfo,exp.getName(),paramTypes);
}
default :
break;
}
throw new Error("String_Node_Str");
}