You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Helgeson (Jira)" <ji...@apache.org> on 2020/06/12 15:27:00 UTC

[jira] [Created] (GROOVY-9587) Scope of method call changed from non-static to static 2.4->2.5

Eric Helgeson created GROOVY-9587:
-------------------------------------

             Summary: Scope of method call changed from non-static to static 2.4->2.5
                 Key: GROOVY-9587
                 URL: https://issues.apache.org/jira/browse/GROOVY-9587
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.5.12
            Reporter: Eric Helgeson


 
{code:java}
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()

{code}
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.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)