[ https://issues.apache.org/jira/browse/GROOVY-9136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-9136. ------------------------------- Resolution: Fixed Assignee: Paul King Fix Version/s: 3.0.0-beta-2 2.5.8 > Compile error when accessing a public field inside a closure > ------------------------------------------------------------ > > Key: GROOVY-9136 > URL: https://issues.apache.org/jira/browse/GROOVY-9136 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.5.7 > Reporter: John Bellassai > Assignee: Paul King > Priority: Major > Fix For: 2.5.8, 3.0.0-beta-2 > > Time Spent: 10m > Remaining Estimate: 0h > > The following code works fine in 2.5.6 but breaks in 2.5.7: > {code:java} > import groovy.transform.CompileStatic > @CompileStatic > class Class1 { > public String prop1 > } > @CompileStatic > class Class2 { > String doThing(Class1 c1) { > return 'something'.with { > println c1.prop1 > return it > } > } > } > new Class2().doThing(new Class1(prop1: 'value1')) > {code} > The error is > {noformat} > Access to Class1#c1 is forbidden at line: -1, column: -1 > {noformat} > Note that if you remove the `public` modifier from `Class1.prop1` the code is > fine. Likewise, if you take `@CompileStatic` off of `Class2`, everything > works fine. -- This message was sent by Atlassian JIRA (v7.6.3#76005)