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/07/16 16:03:00 UTC

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

Eric Milles created GROOVY-9195:
-----------------------------------

             Summary: 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


Follow up to GROOVY-9136.  Consider the following:
{code:groovy}
class Foo {
  private String field = 'value'
}
class Bar {
  void test(Foo foo) {
    foo.with {
      field // Access to Foo#field is forbidden
    }
  }
}
{code}

{code:groovy}
class Foo {
  private String field = 'value'
}
class Bar {
  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
(v7.6.14#76016)