Program: 75492
Project: 75492
Buggy source:
/** 
 * Set the type of the given node to be the return type of the function determined for the given node.
 * @param node The specified node.
 * @exception IllegalActionException If an inference error occurs.
 */
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException {
  int argCount=node.jjtGetNumChildren() - 1;
  Type[] childTypes=new Type[argCount];
  for (int i=0; i < argCount; i++) {
    childTypes[i]=_inferChild(node,i + 1);
    if (childTypes[i] == null) {
      throw new RuntimeException("String_Node_Str" + node + "String_Node_Str");
    }
  }
  Type baseType=_inferChild(node,0);
  if (baseType instanceof FunctionType) {
    _setType(node,((FunctionType)baseType).getReturnType());
    return;
  }
 else   if (argCount == 1) {
    if (baseType instanceof ArrayType) {
      _setType(node,((ArrayType)baseType).getElementType());
      return;
    }
 else {
      _assert(true,node,"String_Node_Str" + "String_Node_Str" + node.getFunctionName() + "String_Node_Str");
    }
  }
 else   if (argCount == 2) {
    if (baseType instanceof UnsizedMatrixType) {
      _setType(node,((UnsizedMatrixType)baseType).getElementType());
      return;
    }
 else {
      _assert(true,node,"String_Node_Str" + "String_Node_Str" + node.getFunctionName() + "String_Node_Str");
    }
  }
  String functionName=node.getFunctionName();
  if (functionName == null) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + node.getFunctionName());
  }
  if (functionName.compareTo("String_Node_Str") == 0 && argCount == 2) {
    ASTPtRootNode castTypeNode=((ASTPtRootNode)node.jjtGetChild(0 + 1));
    ParseTreeEvaluator parseTreeEvaluator=new ParseTreeEvaluator();
    try {
      ptolemy.data.Token t=parseTreeEvaluator.evaluateParseTree(castTypeNode,_scope);
      _setType(node,t.getType());
    }
 catch (    IllegalActionException ex) {
      _setType(node,childTypes[0]);
    }
    return;
  }
  if (functionName.compareTo("String_Node_Str") == 0) {
    _setType(node,BaseType.GENERAL);
    return;
  }
  if (functionName.compareTo("String_Node_Str") == 0) {
    _setType(node,BaseType.GENERAL);
    return;
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(functionName,childTypes,CachedMethod.FUNCTION);
  if (cachedMethod.isValid()) {
    Type type=cachedMethod.getReturnType();
    _setType(node,type);
  }
 else {
    StringBuffer buffer=new StringBuffer();
    for (int i=0; i < childTypes.length; i++) {
      if (i == 0) {
        buffer.append(childTypes[i].toString());
      }
 else {
        buffer.append("String_Node_Str" + childTypes[i].toString());
      }
    }
    throw new IllegalActionException("String_Node_Str" + node.getFunctionName() + "String_Node_Str"+ buffer+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Set the type of the given node to be the return type of the function determined for the given node.
 * @param node The specified node.
 * @exception IllegalActionException If an inference error occurs.
 */
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException {
  int argCount=node.jjtGetNumChildren() - 1;
  String functionName=node.getFunctionName();
  Type[] childTypes=new Type[argCount];
  for (int i=0; i < argCount; i++) {
    childTypes[i]=_inferChild(node,i + 1);
    if (childTypes[i] == null) {
      throw new RuntimeException("String_Node_Str" + node + "String_Node_Str");
    }
  }
  Type baseType=null;
  if (_scope != null && functionName != null) {
    baseType=_scope.getType(functionName);
  }
  if (baseType != null || functionName == null) {
    baseType=_inferChild(node,0);
    if (baseType instanceof FunctionType) {
      _setType(node,((FunctionType)baseType).getReturnType());
      return;
    }
 else     if (argCount == 1) {
      if (baseType instanceof ArrayType) {
        _setType(node,((ArrayType)baseType).getElementType());
        return;
      }
 else {
        _assert(true,node,"String_Node_Str" + "String_Node_Str" + node.getFunctionName() + "String_Node_Str");
      }
    }
 else     if (argCount == 2) {
      if (baseType instanceof UnsizedMatrixType) {
        _setType(node,((UnsizedMatrixType)baseType).getElementType());
        return;
      }
 else {
        _assert(true,node,"String_Node_Str" + "String_Node_Str" + node.getFunctionName() + "String_Node_Str");
      }
    }
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + functionName);
  }
  if (functionName.compareTo("String_Node_Str") == 0 && argCount == 2) {
    ASTPtRootNode castTypeNode=((ASTPtRootNode)node.jjtGetChild(0 + 1));
    ParseTreeEvaluator parseTreeEvaluator=new ParseTreeEvaluator();
    try {
      ptolemy.data.Token t=parseTreeEvaluator.evaluateParseTree(castTypeNode,_scope);
      _setType(node,t.getType());
    }
 catch (    IllegalActionException ex) {
      _setType(node,childTypes[0]);
    }
    return;
  }
  if (functionName.compareTo("String_Node_Str") == 0) {
    _setType(node,BaseType.GENERAL);
    return;
  }
  if (functionName.compareTo("String_Node_Str") == 0) {
    _setType(node,BaseType.GENERAL);
    return;
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(functionName,childTypes,CachedMethod.FUNCTION);
  if (cachedMethod.isValid()) {
    Type type=cachedMethod.getReturnType();
    _setType(node,type);
  }
 else {
    StringBuffer buffer=new StringBuffer();
    for (int i=0; i < childTypes.length; i++) {
      if (i == 0) {
        buffer.append(childTypes[i].toString());
      }
 else {
        buffer.append("String_Node_Str" + childTypes[i].toString());
      }
    }
    throw new IllegalActionException("String_Node_Str" + node.getFunctionName() + "String_Node_Str"+ buffer+ "String_Node_Str");
  }
}