groovy
  1. groovy
  2. GROOVY-2621

Local variable shadows method in closure call, even if method is called with this keyword.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      testSimilarNamesForMethodAndLocalWithLocalAsMethodArgument fails.

      class DelegationTest extends GroovyTestCase {
          void testSimilarNamesForMethodAndLocalWithLocalAsMethodArgument() {
              new Executer().failingExecute()
          }
          void testSimilarNamesForMethodAndLocalWithNoArgMethod() {
              new Executer().workingExecute()
          }
      }
      
      class Executer {
          void convention(String arg) {
               println 'called'
          }
      
          void convention() {
               println 'called'
          }
      
          void failingExecute() {
              def convention= 'value'
              10.times {
                  this.convention(convention)
              }
          }
          void workingExecute() {
              def convention= 'value'
              10.times {
                  this.convention()
              }
          }
      }
      

        Issue Links

          Activity

          Hide
          Roshan Dawrani added a comment -

          This bug is internally related to same implementation issue in ACG as identified in GROOVY-3156. Even this is case of a method call expression explicitly qualified by "this" being made inside a closure when compileStack contains a variable of the same name as the method.

          The patches supplied with GROOVY-3156 fix this issue as well on versions 1.5.8, 1.6-RC-1, 1.7-beta-1. I have test verified.

          rgds,
          Roshan

          Show
          Roshan Dawrani added a comment - This bug is internally related to same implementation issue in ACG as identified in GROOVY-3156 . Even this is case of a method call expression explicitly qualified by "this" being made inside a closure when compileStack contains a variable of the same name as the method. The patches supplied with GROOVY-3156 fix this issue as well on versions 1.5.8, 1.6-RC-1, 1.7-beta-1. I have test verified. rgds, Roshan
          Hide
          Roshan Dawrani added a comment -

          Internally, GROOVY-3156 and GROOVY-2621 are found to be related to the exact same implementation issue and same (GROOVY-3156) patch solves both these issues.

          Show
          Roshan Dawrani added a comment - Internally, GROOVY-3156 and GROOVY-2621 are found to be related to the exact same implementation issue and same ( GROOVY-3156 ) patch solves both these issues.
          Hide
          Roshan Dawrani added a comment -

          Fixed by the GROOVY-3156 patch as it was related to the exactly same issue.

          Show
          Roshan Dawrani added a comment - Fixed by the GROOVY-3156 patch as it was related to the exactly same issue.

            People

            • Assignee:
              Roshan Dawrani
              Reporter:
              Hans Dockter
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: