Issue Details (XML | Word | Printable)

Key: GROOVY-2698
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Jochen Theodorou
Reporter: Dierk Koenig
Votes: 0
Watchers: 1
Operations

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

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

Created: 19/Mar/08 12:28 PM   Updated: 09/Apr/08 08:36 PM   Resolved: 09/Apr/08 08:36 PM
Component/s: bytecode
Affects Version/s: 1.5.4
Fix Version/s: 1.5.5, 1.6-rc-2

Time Tracking:
Not Specified

Issue Links:
Related
 

Testcase included: yes


 Description  « Hide

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.



Burt Beckwith added a comment - 01/Apr/08 08:29 AM

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


Jochen Theodorou added a comment - 01/Apr/08 08:42 AM

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}

Jochen Theodorou added a comment - 09/Apr/08 08:36 PM

fixed