Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3010 fix private field visibility
  3. GROOVY-3008

Superclass can access field declared in subclass

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.6
    • 2.3.11
    • class generator
    • None
    • Windows XP

    Description

      Why does something like that work?

      class Base {
        String test() {
           return subClassField   // subClassField is unknown in class Base!!
        }
      }
      
      class Sub extends Base {
        
        private subClassField = "foo"
        
        static main(args) {
           println new Sub().test() // -> "foo"
        }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            torsten.feig@sarros.com Torsten Feig
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: