Program: 185528
Project: 185528
Buggy source:
/** 
 * Determines if the parameter type can be implicitly determined.  We look for DGM method calls that take closures and see what kind of type they expect.
 * @return array of {@link ClassNode}s specifying the inferred types of the closure's parameters
 */
private static ClassNode[] inferClosureParamTypes(VariableScope scope,ClosureExpression closure){
  int paramCount=closure.getParameters() == null ? 0 : closure.getParameters().length;
  if (paramCount == 0) {
    paramCount+=1;
  }
  ClassNode[] inferredTypes=new ClassNode[paramCount];
  CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != null) {
    ClassNode delegateType=cat.declaringType;
    String methodName=cat.call.getMethodAsString();
    ClassNode inferredParamType;
    if (dgmClosureDelegateMethods.contains(methodName)) {
      inferredParamType=VariableScope.extractElementType(delegateType);
    }
 else {
      inferredParamType=dgmClosureFixedTypeMethods.get(methodName);
    }
    if (inferredParamType != null) {
      Arrays.fill(inferredTypes,inferredParamType);
      if (methodName.equals("String_Node_Str") && inferredTypes.length > 1) {
        inferredTypes[inferredTypes.length - 1]=VariableScope.INTEGER_CLASS_NODE;
      }
      if (delegateType.getName().equals(VariableScope.MAP_CLASS_NODE.getName())) {
        if ((dgmClosureMaybeMap.contains(methodName) && paramCount == 2) || (methodName.equals("String_Node_Str") && paramCount == 3)) {
          GenericsType[] typeParams=inferredParamType.getGenericsTypes();
          if (typeParams != null && typeParams.length == 2) {
            inferredTypes[0]=typeParams[0].getType();
            inferredTypes[1]=typeParams[1].getType();
          }
        }
      }
      return inferredTypes;
    }
  }
  Arrays.fill(inferredTypes,VariableScope.OBJECT_CLASS_NODE);
  return inferredTypes;
}

Fixed version (ground truth):
/** 
 * Determines if the parameter type can be implicitly determined.  We look for DGM method calls that take closures and see what kind of type they expect.
 * @return array of {@link ClassNode}s specifying the inferred types of the closure's parameters
 */
private static ClassNode[] inferClosureParamTypes(VariableScope scope,ClosureExpression closure){
  int paramCount=closure.getParameters() == null ? 0 : closure.getParameters().length;
  if (paramCount == 0) {
    paramCount+=1;
  }
  ClassNode[] inferredTypes=new ClassNode[paramCount];
  VariableScope.CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != null) {
    ClassNode delegateType=cat.declaringType;
    String methodName=cat.call.getMethodAsString();
    ClassNode inferredParamType;
    if (dgmClosureDelegateMethods.contains(methodName)) {
      inferredParamType=VariableScope.extractElementType(delegateType);
    }
 else {
      inferredParamType=dgmClosureFixedTypeMethods.get(methodName);
    }
    if (inferredParamType != null) {
      Arrays.fill(inferredTypes,inferredParamType);
      if (methodName.equals("String_Node_Str") && inferredTypes.length > 1) {
        inferredTypes[inferredTypes.length - 1]=VariableScope.INTEGER_CLASS_NODE;
      }
      if (delegateType.getName().equals(VariableScope.MAP_CLASS_NODE.getName())) {
        if ((dgmClosureMaybeMap.contains(methodName) && paramCount == 2) || (methodName.equals("String_Node_Str") && paramCount == 3)) {
          GenericsType[] typeParams=inferredParamType.getGenericsTypes();
          if (typeParams != null && typeParams.length == 2) {
            inferredTypes[0]=typeParams[0].getType();
            inferredTypes[1]=typeParams[1].getType();
          }
        }
      }
      return inferredTypes;
    }
  }
  Arrays.fill(inferredTypes,VariableScope.OBJECT_CLASS_NODE);
  return inferredTypes;
}