groovy

Cannot resolve which method to invoke with extended interfaces

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5
  • Fix Version/s: 1.5.2, 1.6-rc-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows XP, Java 1.5
  • Testcase included:
    yes
  • Number of attachments :
    1

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 {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

Activity

Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: