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

When using @CompileStatic you cannot access class properties in some circumstances

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • None
    • None

    Description

      Following code:

      @groovy.transform.CompileStatic
      abstract class Test {
          def foo() {
              def bar = createBar()
          
              
              for(f in bar.foo) {
                println f
              }
          }
          
          Bar createBar() { new Bar() }
      }
      class Bar {
          List<String> foo = []
      }
      

      Produces

      Access to Bar#foo is forbidden at line: 7, column: 18
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: