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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: