[
https://issues.apache.org/jira/browse/GROOVY-9195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-9195:
--------------------------------
Fix Version/s: 2.5.19
> 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, 2.5.19
>
> 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.20.10#820010)