Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2425

Cannot resolve which method to invoke with extended interfaces

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5
    • 1.5.2, 1.6-rc-2
    • None
    • None
    • Windows XP, Java 1.5

    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

      Attachments

        1. src.zip
          1 kB
          Dave Dunkin

        Activity

          People

            blackdrag Jochen Theodorou
            ddunkin Dave Dunkin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: