Buggy code:
public class ClosureWriter { private int closureCount = 1 ; public ClassNode createClosureClass ( ClassNode classNode , MethodNode methodNode , ClosureExpression expression , boolean addOldVariable , boolean addResultVariable , int mods ) { ClassNode outerClass = getOutermostClass ( classNode ) ; String name = ( ( outerClass . getName ( ) ) + "$" ) + ( getClosureInnerName ( outerClass , classNode ) ) ; ArrayList < Parameter > parametersTemp = new ArrayList < Parameter > ( Arrays . asList ( expression . getParameters ( ) ) ) ; removeParameter ( "old" , parametersTemp ) ; removeParameter ( "result" , parametersTemp ) ; if ( ( ( methodNode != null ) && addResultVariable ) && ( ( methodNode . getReturnType ( ) ) != ( ClassHelper . VOID_TYPE ) ) ) { parametersTemp . add ( new Parameter ( ClassHelper . DYNAMIC_TYPE , "result" ) ) ; } if ( addOldVariable ) { parametersTemp . add ( new Parameter ( ClassHelper . DYNAMIC_TYPE , "old" ) ) ; } Parameter [ ] parameters = parametersTemp . toArray ( new Parameter [ parametersTemp . size ( ) ] ) ; if ( parameters == null ) { parameters = Parameter . EMPTY_ARRAY ; } else if ( ( parameters . length ) == 0 ) { Parameter it = new Parameter ( ClassHelper . OBJECT_TYPE , "it" , ConstantExpression . NULL ) ; parameters = new Parameter [ ] { it } ; Variable ref = expression . getVariableScope ( ) . getDeclaredVariable ( "it" ) ; if ( ref != null ) it . setClosureSharedVariable ( ref . isClosureSharedVariable ( ) ) ; } Parameter [ ] localVariableParams = getClosureSharedVariables ( expression ) ; removeInitialValues ( localVariableParams ) ; <START_BUG> InnerClassNode answer = new InnerClassNode ( outerClass , name , mods , ClassHelper . CLOSURE_TYPE ) ; <END_BUG> answer . setEnclosingMethod ( null ) ; answer . setSynthetic ( true ) ; answer . setUsingGenerics ( outerClass . isUsingGenerics ( ) ) ; MethodNode method = answer . addMethod ( "doCall" , ACC_PUBLIC , OBJECT_TYPE , parameters , EMPTY_ARRAY , expression . getCode ( ) ) ; method . setSourcePosition ( expression ) ; VariableScope varScope = expression . getVariableScope ( ) ; if ( varScope == null ) { throw new RuntimeException ( ( ( ( "Must<seq2seq4repair_space>have<seq2seq4repair_space>a<seq2seq4repair_space>VariableScope<seq2seq4repair_space>by<seq2seq4repair_space>now!<seq2seq4repair_space>for<seq2seq4repair_space>expression:<seq2seq4repair_space>" + expression ) + "<seq2seq4repair_space>class:<seq2seq4repair_space>" ) + name ) ) ; } else { method . setVariableScope ( varScope . copy ( ) ) ; } if ( ( ( parameters . length ) > 1 ) || ( ( ( ( parameters . length ) == 1 ) && ( ( parameters [ 0 ] . getType ( ) ) != null ) ) && ( ( parameters [ 0 ] . getType ( ) ) != ( ClassHelper . OBJECT_TYPE ) ) ) ) { MethodNode call = answer . addMethod ( "call" , ACC_PUBLIC , OBJECT_TYPE , parameters , EMPTY_ARRAY , new ReturnStatement ( new MethodCallExpression ( VariableExpression . THIS_EXPRESSION , "doCall" , new ArgumentListExpression ( parameters ) ) ) ) ; call . setSourcePosition ( expression ) ; } BlockStatement block = new BlockStatement ( ) ; VariableExpression outer = new VariableExpression ( "_outerInstance" ) ; outer . setSourcePosition ( expression ) ; block . getVariableScope ( ) . putReferencedLocalVariable ( outer ) ; VariableExpression thisObject = new VariableExpression ( "_thisObject" ) ; thisObject . setSourcePosition ( expression ) ; block . getVariableScope ( ) . putReferencedLocalVariable ( thisObject ) ; TupleExpression conArgs = new TupleExpression ( outer , thisObject ) ; block . addStatement ( new ExpressionStatement ( new ConstructorCallExpression ( ClassNode . SUPER , conArgs ) ) ) ; for ( Parameter param : localVariableParams ) { String paramName = param . getName ( ) ; ClassNode type = param . getType ( ) ; if ( true ) { VariableExpression initialValue = new VariableExpression ( paramName ) ; initialValue . setAccessedVariable ( param ) ; initialValue . setUseReferenceDirectly ( true ) ; ClassNode realType = type ; type = ClassHelper . makeReference ( ) ; param . setType ( ClassHelper . makeReference ( ) ) ; FieldNode paramField = answer . addField ( paramName , ( ( ACC_PRIVATE ) | ( ACC_SYNTHETIC ) ) , type , initialValue ) ; paramField . setDeclaringClass ( ClassHelper . getWrapper ( param . getOriginType ( ) ) ) ; paramField . setHolder ( true ) ; String methodName = Verifier . capitalize ( paramName ) ; Expression fieldExp = new FieldExpression ( paramField ) ; answer . addMethod ( ( "get" + methodName ) , ACC_PUBLIC , realType , Parameter . EMPTY_ARRAY , EMPTY_ARRAY , new ReturnStatement ( fieldExp ) ) ; } } Parameter [ ] params = new Parameter [ 2 ] ; params [ 0 ] = new Parameter ( ClassHelper . OBJECT_TYPE , "_outerInstance" ) ; params [ 1 ] = new Parameter ( ClassHelper . OBJECT_TYPE , "_thisObject" ) ; ASTNode sn = answer . addConstructor ( ACC_PUBLIC , params , EMPTY_ARRAY , block ) ; sn . setSourcePosition ( expression ) ; correctAccessedVariable ( answer , expression ) ; return answer ; } private void removeParameter ( String name , List < Parameter > parameters ) { } private ClassNode getOutermostClass ( ClassNode outermostClass ) { } private Parameter [ ] getClosureSharedVariables ( ClosureExpression ce ) { } private void removeInitialValues ( Parameter [ ] params ) { } private void correctAccessedVariable ( final InnerClassNode closureClass , ClosureExpression ce ) { } private String getClosureInnerName ( ClassNode owner , ClassNode enclosingClass ) { } }

Fix:
InnerClassNode answer = new InnerClassNode ( outerClass , name , mods , CLOSURE_TYPE . getPlainNodeReference ( ) ) ;