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

Reference outer class property via inner class

    XMLWordPrintableJSON

Details

    Description

      @CompileStatic
      class Outer {
        def foo = 1
        Inner createInner() { new Inner() }
        class Inner {}
      }
      
      @CompileStatic  // works without @CompileStatic
      class Main {
        static void main(String[] args) {
          def i = new Outer().createInner()
          println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner
        }
      }
      

      I think should work in both static and dynamic contexts or fail in both.
      Please close this issue if this is by design.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              daniilo Daniil Ovchinnikov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: