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/20 16:02:00 UTC

[jira] [Updated] (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 ]

Eric Milles updated GROOVY-9195:
--------------------------------
    Description: 
Follow up to GROOVY-9093 and 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.

  was:
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.


> 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
>            Priority: Major
>
> Follow up to GROOVY-9093 and 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)