Program: 185522
Project: 185522
Buggy source:
@Override public void visitClosureExpression(ClosureExpression node){
  VariableScope parent=scopes.getLast();
  VariableScope scope=new VariableScope(parent,node,false);
  scopes.add(scope);
  ClassNode[] inferredParamTypes=inferClosureParamTypes(scope,node);
  Parameter[] parameters=node.getParameters();
  final int n;
  if (parameters != null && (n=parameters.length) > 0) {
    handleParameterList(parameters);
    for (int i=0; i < n; i+=1) {
      Parameter parameter=parameters[i];
      if (inferredParamTypes[i] != VariableScope.OBJECT_CLASS_NODE && parameter.isDynamicTyped()) {
        parameter.setType(inferredParamTypes[i]);
        scope.addVariable(parameter);
      }
    }
  }
 else   if (inferredParamTypes[0] != VariableScope.OBJECT_CLASS_NODE && !scope.containsInThisScope("String_Node_Str")) {
    scope.addVariable("String_Node_Str",inferredParamTypes[0],VariableScope.OBJECT_CLASS_NODE);
  }
  if (scope.lookupNameInCurrentScope("String_Node_Str") == null) {
    inferItType(node,scope);
  }
  if (parent.getEnclosingClosure() != null) {
    ClassNode closureType=GenericsUtils.nonGeneric(VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",closureType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",closureType,VariableScope.CLOSURE_CLASS_NODE);
  }
 else {
    ClassNode ownerType=scope.getThis();
    VariableScope.VariableInfo inf=scope.lookupName("String_Node_Str");
    if (inf == null || inf.scopeNode instanceof ClosureExpression) {
      scope.addVariable("String_Node_Str",ownerType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",ownerType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.OBJECT_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.OBJECT_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLASS_ARRAY_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLASS_ARRAY_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
  }
  VariableScope.CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != null && cat.getDelegateType(node) != null) {
    ClassNode delegateType=cat.getDelegateType(node);
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
  }
 else {
    ClassNode delegateType=scope.lookupName("String_Node_Str").type;
    VariableScope.VariableInfo inf=scope.lookupName("String_Node_Str");
    if (inf == null || inf.scopeNode instanceof ClosureExpression) {
      scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
  }
  super.visitClosureExpression(node);
  handleSimpleExpression(node);
  scopes.removeLast();
}

Fixed version (ground truth):
@Override public void visitClosureExpression(ClosureExpression node){
  VariableScope parent=scopes.getLast();
  VariableScope scope=new VariableScope(parent,node,false);
  scopes.add(scope);
  ClassNode[] inferredParamTypes=inferClosureParamTypes(scope,node);
  Parameter[] parameters=node.getParameters();
  final int n;
  if (parameters != null && (n=parameters.length) > 0) {
    handleParameterList(parameters);
    for (int i=0; i < n; i+=1) {
      Parameter parameter=parameters[i];
      if (inferredParamTypes[i] != VariableScope.OBJECT_CLASS_NODE && parameter.isDynamicTyped()) {
        parameter.setType(inferredParamTypes[i]);
        scope.addVariable(parameter);
      }
    }
  }
 else   if (inferredParamTypes[0] != VariableScope.OBJECT_CLASS_NODE && !scope.containsInThisScope("String_Node_Str")) {
    scope.addVariable("String_Node_Str",inferredParamTypes[0],VariableScope.OBJECT_CLASS_NODE);
  }
  if (scope.lookupNameInCurrentScope("String_Node_Str") == null) {
    inferItType(node,scope);
  }
  if (parent.getEnclosingClosure() != null) {
    ClassNode closureType=GenericsUtils.nonGeneric(VariableScope.CLOSURE_CLASS_NODE);
    closureType.putNodeMetaData("String_Node_Str",parent.getEnclosingClosureScope());
    scope.addVariable("String_Node_Str",closureType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",closureType,VariableScope.CLOSURE_CLASS_NODE);
  }
 else {
    ClassNode ownerType=scope.getThis();
    VariableScope.VariableInfo inf=scope.lookupName("String_Node_Str");
    if (inf == null || inf.scopeNode instanceof ClosureExpression) {
      scope.addVariable("String_Node_Str",ownerType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",ownerType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.OBJECT_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.OBJECT_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLASS_ARRAY_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLASS_ARRAY_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.INTEGER_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
  }
  VariableScope.CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != null && cat.getDelegateType(node) != null) {
    ClassNode delegateType=cat.getDelegateType(node);
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
  }
 else {
    ClassNode delegateType=scope.getOwner();
    VariableScope.VariableInfo inf=scope.lookupName("String_Node_Str");
    if (inf == null || inf.scopeNode instanceof ClosureExpression) {
      scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",delegateType,VariableScope.CLOSURE_CLASS_NODE);
  }
  super.visitClosureExpression(node);
  handleSimpleExpression(node);
  scopes.removeLast();
}