Details
Description
Given I3 < I2 < I1
and C < B < A
The groovy runtime does not correctly pick the most specialized method when the argument type is an interface that extends two other interfaces and the parameter type is a class that implements the same structure. It's much easier to explain it in code, so I've attached a test case.
MainGroovy produces:
I1
I2
Exception in thread "main" groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method Foo#foo.
Cannot resolve which method to invoke for
due to overlapping prototypes between:
{interface I2} {interface I3} at groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:2383)
at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2336)
at groovy.lang.MetaClassImpl.getMethodWithoutCaching(MetaClassImpl.java:1002)
at groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:949)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:762)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:742)
at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:87)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:75)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:66)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:165)
at MainGroovy.main(MainGroovy.groovy:9)
Expected:
I1
I2
I3