You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/10/15 11:57:00 UTC

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

Thodoris Sotiropoulos created GROOVY-10308:
----------------------------------------------

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


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



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