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

classes cant access superclass fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-JSR-4
    • None
    • None
    • Mac OS X 10.3.3, java 1.4.2

    Description

      I posted this on the mailing lists, but got no reply, so I will create a bug report:

      I am having problems with a child class accessing a super
      class's fields. Here is the simplest code that demonstrate this
      problem:

      A.groovy:

      class A {
      public aa

      A()

      { aa = "this is not set!" }

      doit()

      { println aa }

      }

      B.groovy:

      class B extends A {
      B()

      { //super() /* doesn't matter if this is here or not */ aa = "now B has set it!" doit() }

      static void main(args)

      { bb = new B() }

      }

      Now when I run:

      $ groovy B.groovy

      I get:

      this is not set.

      So it seems that B set his own copy of aa instead of the super
      class's aa. If I changed the line:

      aa = "now B has set it!"

      to:

      this.aa = "now B has set it!"

      it works.

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              johnstump John Stump
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: