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

Inner class of inner class cannot reference outer class members

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.2
    • 2.3.4
    • groovy-runtime
    • None

    Description

      class A {
        def x = 1
        def b = new B()
        class B {
          def y = 2
          def c = new C()
          def f () {
            println y
            println x
          }
          class C {
            def z = 3
            def f() {
              println z
              println y
              println x
            }
          }
        }
      }
      
      def a = new A()
      a.b.f()
      a.b.c.f()
      

      produces the output:

      2
      1
      3
      2
      Exception thrown
      May 3, 2013 6:49:34 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize
      WARNING: Sanitizing stacktrace:
      groovy.lang.MissingFieldException: No such field: x for class: A$B

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            rattigan Richard Rattigan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: