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

Inner class can't access container class inherited attributes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.x
    • 2.4.0-beta-4
    • Compiler
    • Any

    Description

      An inner class cannot directly access the inherited attributes of its container class.

      To reproduce:

      class Parent {
      String name
      }
      class External extends Parent {
      String outer
      Internal inner(String p)

      { new Internal(inner:p) }

      class Internal {
      String inner
      void boom()

      { println "Outer is " + outer + ", inner is " + inner //******** HERE'S THE PROBLEM println "But parent is " + name // Only works with External.this.name or getName() }

      }
      }

      new External(outer:"good", name:"fucked").inner("good").boom()

      Attachments

        Activity

          People

            Unassigned Unassigned
            chochos Enrique Zamudio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: