Program: 185530
Project: 185530
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);
  }
  CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != 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 thisType=scope.getThis();
    if (scope.lookupName("String_Node_Str") == null) {
      scope.addVariable("String_Node_Str",thisType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",thisType,VariableScope.CLOSURE_CLASS_NODE);
  }
  if (parent.getEnclosingClosure() != null) {
    scope.addVariable("String_Node_Str",VariableScope.CLOSURE_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLOSURE_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
  }
 else {
    ClassNode thisType=scope.getThis();
    if (scope.lookupName("String_Node_Str") == null) {
      scope.addVariable("String_Node_Str",thisType,VariableScope.CLOSURE_CLASS_NODE);
    }
    scope.addVariable("String_Node_Str",thisType,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);
  }
  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);
  }
  VariableScope.CallAndType cat=scope.getEnclosingMethodCallExpression();
  if (cat != 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.getThis();
    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);
  }
  if (parent.getEnclosingClosure() != null) {
    scope.addVariable("String_Node_Str",VariableScope.CLOSURE_CLASS_NODE,VariableScope.CLOSURE_CLASS_NODE);
    scope.addVariable("String_Node_Str",VariableScope.CLOSURE_CLASS_NODE,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);
  }
  super.visitClosureExpression(node);
  handleSimpleExpression(node);
  scopes.removeLast();
}