You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2019/05/23 18:35:00 UTC
[jira] [Commented] (GROOVY-9136) Compile error when accessing a
public field inside a closure
[ https://issues.apache.org/jira/browse/GROOVY-9136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16846946#comment-16846946 ]
Eric Milles commented on GROOVY-9136:
-------------------------------------
Line and column can be set by adding "receiver.setSourcePosition(expr);" to {{VariableExpressionTransformer.tryTransformDelegateToProperty}}
> 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
> Priority: Major
>
> 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)