History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2425
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Dave Dunkin
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Cannot resolve which method to invoke with extended interfaces

Created: 20/Dec/07 02:26 PM   Updated: 17/Jan/08 03:19 PM
Component/s: None
Affects Version/s: 1.5
Fix Version/s: 1.6, 1.5.2

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive src.zip (1 kb)

Environment: Windows XP, Java 1.5

Testcase included: yes


 Description  « Hide
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 {class C} 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



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou - 17/Jan/08 03:19 PM
fixed