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

Scope of method call changed from non-static to static 2.4->2.5

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.12
    • 4.0.0-alpha-1, 3.0.5, 2.5.13
    • None
    • None

    Description

       

      class Foo { 
         static storageProvider 
         def getStorageProvider(Boolean a) { 
            return storageProvider
         }
         def getStorageProvider() { 
           if(!storageProvider) {
             getStorageProvider(true) // <-- Attempts to call statically in 2.5 
           } 
          return storageProvider
         } 
      } 
      new Foo().getStorageProvider()
      
      

      In groovy 2.5+ it seems it gets confused if you have a static variable in a class, say static storageProvider, and a non-static method def getStorageProvider(Boolean x) it tries to call the getStorageProvider(true) statically, which does not exist.

       

      In the groovyConsole you can see the change happen between conversion and semantic analysis - it changes from non-static to static.

       

      Unsure this is intended or not. I couldn't find mention of it in any changes. It would be nice to document/know why the change happened between 2.4/2.5.

       

      Attachments

        Activity

          People

            emilles Eric Milles
            erichelgeson Eric Helgeson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h