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

Scoping: precedence rules for getters / property access / field access

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0-JSR-4
    • 1.0
    • class generator
    • None

    Description

      > With the latest build I found the behaviour
      > below but I'm not sure that this is the expected
      > behaviour.
      > Seems like either the getter override for properties
      > has trouble or the name resolution in testZero().
      > ----
      > class ExplicitThisTest extends GroovyTestCase {
      > @Property zero = 0
      >
      > def getZero()

      { return 1 }

      >
      > void testZero()

      { > assert 0 == zero // ? > assert 0 == this.zero // 1 ? > assert 0 == this.@zero > }


      > }

      I would not say it is a new scoping bug, it is a old one with new face.
      This one is on my todo list. But first we should maybe make clear what
      this should mean. I would say:

      assert 1==zero
      assert 1==this.zero
      assert 0==this.@zero

      bye blackdrag


      agreed by mittie, tug, MrG

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              codevise Dierk König
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: