groovy

Method dispatch with overloaded methods for Java types doesn't choose the most specific method

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.5.4
  • Fix Version/s: 1.5.5, 1.6-rc-2
  • Component/s: bytecode
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

the following test fails:


import javax.swing.*

interface ISub extends Action {}

class Super extends AbstractAction {}
class Sub extends AbstractAction implements ISub {}

static String foo(Action x) { "super" }

static String foo(ISub x) { "sub" }

def result = [new Super(), new Sub()].collect { foo(it) }

assert ["super","sub"] == result // result is ["super","super"]


The special thing here is that Action is a Java interface. If you use
a Groovy interface instead, all works fine.

Issue Links

Activity

Hide
Burt Beckwith added a comment -

I just wrote up a similar bug - http://jira.codehaus.org/browse/GROOVY-2719

Show
Burt Beckwith added a comment - I just wrote up a similar bug - http://jira.codehaus.org/browse/GROOVY-2719
Hide
blackdrag blackdrag added a comment -

different from GROOVY-2719 this bug throws a

groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method test#foo.
Cannot resolve which method to invoke for {class Sub} due to overlapping prototypes between:

{interface ISub} {interface javax.swing.Action}
Show
blackdrag blackdrag added a comment - different from GROOVY-2719 this bug throws a groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method test#foo. Cannot resolve which method to invoke for {class Sub} due to overlapping prototypes between: {interface ISub} {interface javax.swing.Action}
Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: