Index: src/main/org/codehaus/groovy/transform/FieldASTTransformation.java =================================================================== --- src/main/org/codehaus/groovy/transform/FieldASTTransformation.java (revision 933bd4b8f5454c64444c4a7993f2965d8866a1a1) +++ src/main/org/codehaus/groovy/transform/FieldASTTransformation.java (revision ) @@ -26,6 +26,7 @@ import org.codehaus.groovy.ast.expr.Expression; import org.codehaus.groovy.ast.expr.VariableExpression; import org.codehaus.groovy.ast.stmt.ExpressionStatement; +import org.codehaus.groovy.classgen.VariableScopeVisitor; import org.codehaus.groovy.control.CompilePhase; import org.codehaus.groovy.control.SourceUnit; import org.objectweb.asm.Opcodes; @@ -85,7 +86,7 @@ fieldNode.setSourcePosition(de); cNode.addField(fieldNode); - // GROOVY-4833 : annotations that are not Groovy transforms should be transfered to the generated field + // GROOVY-4833 : annotations that are not Groovy transforms should be transferred to the generated field final List annotations = de.getAnnotations(); for (AnnotationNode annotation : annotations) { final ClassNode annotationClassNode = annotation.getClassNode(); @@ -95,6 +96,9 @@ } super.visitClass(cNode); + // GROOVY-5207 So that Closures can see newly added fields + VariableScopeVisitor scopeVisitor = new VariableScopeVisitor(source); + scopeVisitor.visitClass(cNode); } }