Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10308

SC incorrectly reports "access to Object#field" is forbidden

    XMLWordPrintableJSON

Details

    Description

      I have the following program:

      class A<T> {
        T p
      }
      @groovy.transform.CompileStatic
      void test() {
        def x = { -> new A<String>() }
        def y = x()
        def z = y.p
        y = null // changes inferred type
      }
      test()
      

      Actual behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 9: Access to java.lang.Object#f is forbidden @ line 8, column 13.
             def z = y.p
                     ^
      
      1 error
      

      Expected behaviour

      Compile successfully

      Tested against master

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: