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 2021/10/23 16:23:00 UTC

[jira] [Updated] (GROOVY-10308) STC incorrectly reports "access to Object#field" is forbidden

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

Eric Milles updated GROOVY-10308:
---------------------------------
    Description: 
I have the following program:
{code:groovy}
class A<T> {
  T p
}
@groovy.transform.CompileStatic
void test() {
  Closure<A<String>> x = {  -> new A<String>() }
  def y = x()
  def z = y.p
}
test()
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 9: Access to java.lang.Object#f is forbidden @ line 9, column 13.
       def z = x.f
               ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master

  was:
I have the following program
{code:java}
class A<T> {
  T f
}

class Test {
  public void test() {
    Closure<A<String>> y = {  -> new A<String>() }
    def x = y()
    def z = x.f
    x = null
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 9: Access to java.lang.Object#f is forbidden @ line 9, column 13.
       def z = x.f
               ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master


> STC incorrectly reports "access to Object#field" is forbidden
> -------------------------------------------------------------
>
>                 Key: GROOVY-10308
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10308
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Priority: Major
>
> I have the following program:
> {code:groovy}
> class A<T> {
>   T p
> }
> @groovy.transform.CompileStatic
> void test() {
>   Closure<A<String>> x = {  -> new A<String>() }
>   def y = x()
>   def z = y.p
> }
> test()
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 9: Access to java.lang.Object#f is forbidden @ line 9, column 13.
>        def z = x.f
>                ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Tested against master



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