Leonard Brünings created GROOVY-10590:
-----------------------------------------

             Summary: Static methods of interfaces are not resolved anymore in 
4.x
                 Key: GROOVY-10590
                 URL: https://issues.apache.org/jira/browse/GROOVY-10590
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.1
            Reporter: Leonard Brünings


{code:java|title=SomeInterface.java}
public interface SomeInterface {
    static String getSomeVersion() {
        return "1.0";
    }
}
{code}

{code:groovy|title=Reproducer.groovy}
import spock.lang.Specification

class Reproducer extends Specification implements SomeInterface{
    def "someLibraryMethod returns true"() {
        expect:
        someVersion == "1.0"
    }
}
{code}

Succeeds in 3.x but fails in 4.x

{noformat}
Condition failed with Exception:

someVersion == "1.0"
|
groovy.lang.MissingPropertyException: No such property: someVersion for class: 
reproducer.Reproducer
        at reproducer.Reproducer.someLibraryMethod returns 
true(Reproducer.groovy:11)
{noformat}

Method variation fails as well
{code:groovy}
class Reproducer extends Specification implements SomeInterface {
    def "someLibraryMethod returns true"() {
        expect:
        getSomeVersion() == "1.0"
    }
}
{code}
Even the qualified property version fails
{code:groovy}
class Reproducer extends Specification implements SomeInterface {
    def "someLibraryMethod returns true"() {
        expect:
        SomeInterface.someVersion == "1.0"
    }
}
{code}

Only the qualified method version works.
{code:groovy}
class Reproducer extends Specification implements SomeInterface {
    def "someLibraryMethod returns true"() {
        expect:
        SomeInterface.getSomeVersion() == "1.0"
    }
}
{code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to