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"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-beta-1
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • parser
    • 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. Groovy2849BugAST.groovy.xml
          43 kB
          Roshan Dawrani
        2. Groovy2849Bug.groovy
          0.3 kB
          Chanwit Kaewkasi
        3. Groovy2849Bug_v2.groovy
          0.8 kB
          Roshan Dawrani
        4. 2849Patch_v2.zip
          2 kB
          Roshan Dawrani

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: