You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/07/22 04:22:02 UTC

[jira] [Closed] (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:all-tabpanel ]

Paul King closed GROOVY-9136.
-----------------------------

> 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: 40m
>  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.14#76016)