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

Access to private fields of superclass from a block fails in subclass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.x
    • 5.0.0-alpha-1
    • Compiler
    • None

    Description

      Test code:

      class Foo {
        private static final String wth='wth'
        def foo() {
          1.times {
            println wth
          }
        }
      }
      class Bar extends Foo { }
      new Bar().foo() 
      

      Causes “groovy.lang.MissingPropertyException: No such property: wth for class: Bar”. Seems to affect all 4* versions (myself I've tested just a couple of them), did work in 3 and I am told it again works in 5.

      There's an easy work-around, an explicit qualifier, in this case "println Foo.wth", fixes the problem.

      Attachments

        Activity

          People

            emilles Eric Milles
            oc OC
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: