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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • 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()
              }
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              roshandawrani Roshan Dawrani
              hans_d Hans Dockter
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: