jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-449

classes cant access superclass fields

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0-JSR-4
  • Component/s: None
  • Labels:
    None
  • Environment:
    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.

Issue Links

is depended upon by

Task - A task that needs to be done. GROOVY-754 scoping

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 20/Nov/05 7:23 PM

this should be fixed by the jsr parser since it requires a "def " if you want to declare a variable in classes

Show
blackdrag blackdrag added a comment - 20/Nov/05 7:23 PM this should be fixed by the jsr parser since it requires a "def " if you want to declare a variable in classes

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    John Stump
Vote (0)
Watch (0)

Dates

  • Created:
    07/May/04 5:10 PM
    Updated:
    20/Nov/05 7:23 PM
    Resolved:
    20/Nov/05 7:23 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.