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/12/09 21:36:01 UTC

[jira] [Closed] (GROOVY-9195) STC: mixed checking for access to non-public fields

     [ https://issues.apache.org/jira/browse/GROOVY-9195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-9195.
-----------------------------

> STC: mixed checking for access to non-public fields
> ---------------------------------------------------
>
>                 Key: GROOVY-9195
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9195
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.0-rc-2
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-8999, GROOVY-9093 and GROOVY-9136.  Consider the following:
> {code:groovy}
> class Foo {
>   private String field = 'value'
> }
> class Bar {
>   @groovy.transform.CompileStatic
>   void test(Foo foo) {
>     foo.with {
>       field // Access to Foo#field is forbidden
>     }
>   }
> }
> {code}
> {code:groovy}
> class Foo {
>   private String field = 'value'
> }
> class Bar {
>   @groovy.transform.CompileStatic
>   void test(Foo foo) {
>     println foo.field
>   }
> }
> new Bar().test(new Foo()) // prints "value"
> {code}
> Since STC produces an error for access to Foo.field as variable expression, I would expect the same error for access to the field through property expression.  Same goes for protected and package-private with the appropriate package separation of Foo and Bar.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)