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

A property name in a nested closure interferes with a class property when refering with "this.prop"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6-beta-1
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: parser
    • Labels:
      None

      Description

      I guess this may be a parser bug (I'm not sure).

      This class is working fine:

      private class TestClosure {
      def test = 1
      def c1 = {
      def test = 2
      def c2 =

      { println this.test this.test+=10 println this.test }

      c2()
      }
      }

      new TestClosure().c1()

      But when we change:

      def c2 =

      { println this.test this.test+=10 println this.test test = 3 }

      then thing is screwed up.
      'this.test' is resolved to be 'test' of the c1 closure, which is not correct.

        Attachments

        1. 2849Patch_v2.zip
          2 kB
          Roshan Dawrani
        2. Groovy2849Bug_v2.groovy
          0.8 kB
          Roshan Dawrani
        3. Groovy2849Bug.groovy
          0.3 kB
          Chanwit Kaewkasi
        4. Groovy2849BugAST.groovy.xml
          43 kB
          Roshan Dawrani

          Issue Links

            Activity

              People

              • Assignee:
                roshandawrani Roshan Dawrani
                Reporter:
                chanwit Chanwit Kaewkasi
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: