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
    • 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

      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development