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 Bug
    • Status: Closed
    • Priority: Major 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.

      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

          Chanwit Kaewkasi created issue -
          Chanwit Kaewkasi made changes -
          Field Original Value New Value
          Attachment Groovy2849Bug.groovy [ 34667 ]
          Jochen Theodorou made changes -
          Fix Version/s 1.6-beta-2 [ 14261 ]
          Fix Version/s 1.5.7 [ 14242 ]
          Guillaume Delcroix made changes -
          Fix Version/s 1.6-beta-2 [ 14261 ]
          Fix Version/s 1.5.7 [ 14242 ]
          Fix Version/s 1.5.8 [ 14630 ]
          Roshan Dawrani made changes -
          Attachment 2849Patch.zip [ 38123 ]
          Roshan Dawrani made changes -
          Attachment Groovy2849Bug_v2.groovy [ 38126 ]
          Roshan Dawrani made changes -
          Attachment Groovy2849BugAST.groovy.xml [ 38142 ]
          Roshan Dawrani made changes -
          Attachment 2849Patch.zip [ 38123 ]
          Roshan Dawrani made changes -
          Attachment Groovy2849Bug_v2.groovy [ 38126 ]
          Roshan Dawrani made changes -
          Attachment 2849Patch_v2.zip [ 38159 ]
          Roshan Dawrani made changes -
          Attachment Groovy2849Bug_v2.groovy [ 38160 ]
          Jochen Theodorou made changes -
          Link This issue is depended upon by GROOVY-3156 [ GROOVY-3156 ]
          Jochen Theodorou made changes -
          Assignee Jochen Theodorou [ blackdrag ] Roshan Dawrani [ roshandawrani ]
          Jochen Theodorou made changes -
          Fix Version/s 1.6-rc-1 [ 14009 ]
          Fix Version/s 1.7-beta-1 [ 14014 ]
          Roshan Dawrani made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12731869 ] Default workflow, editable Closed status [ 12743767 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12969872 ] Default workflow, editable Closed status [ 12977586 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development