Bug 186382 - [1.5][compiler] Ambiguous method call error reported on a demonstrably unambiguous call
Summary: [1.5][compiler] Ambiguous method call error reported on a demonstrably unambi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-10 11:11 EDT by Christian Damus CLA
Modified: 2007-05-24 04:54 EDT (History)
4 users (show)

See Also:
philippe_mulet: review+


Attachments
Small test project (2.67 KB, application/octet-stream)
2007-05-10 11:14 EDT, Christian Damus CLA
no flags Details
Proposed patch (5.41 KB, patch)
2007-05-14 15:35 EDT, Kent Johnson CLA
no flags Details | Diff
Example project (2 java files, .project, .classpath) (8.13 KB, application/x-zip-compressed)
2007-05-22 07:25 EDT, TobyS CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Damus CLA 2007-05-10 11:11:46 EDT
Reproduced with Eclipse SDK 3.3 M6 build.

JDT compiler is producing an ambiguous method call error in code with Java 5.0 generic methods that the Sun javac compiler compiles without incident.

Rather than attempt to describe the test case, I will attach a tiny project that demonstrates the problem.
Comment 1 Christian Damus CLA 2007-05-10 11:14:09 EDT
Created attachment 66696 [details]
Small test project

Attached a small test project demonstrating the problem.  The PartTimeEmpoyee class's implementation of the respond(...) method shows an ambiguous method call error on the call to super, which has the identical signature.  The superclass's (Employee) own delegation to its superclass's implementation (Person) does not report this error.
Comment 2 Kent Johnson CLA 2007-05-14 15:35:25 EDT
Philippe - please review the patch.

This code comes from the verifier when it validates a substite.
Comment 3 Kent Johnson CLA 2007-05-14 15:35:53 EDT
Created attachment 67125 [details]
Proposed patch
Comment 4 Philipe Mulet CLA 2007-05-15 04:42:31 EDT
Patch is good providing changing the signature of
TypeVariableBinding#isInterchangeableWith(...)

to take a Substitution as 2nd argument (instead of ParameterizedGenericMethodBinding).
Comment 5 Kent Johnson CLA 2007-05-15 10:37:58 EDT
Updated signature of TypeVariableBinding#isInterchangeableWith(...)

Released into HEAD for 3.3RC1
Comment 6 Eric Jodet CLA 2007-05-16 06:14:25 EDT
Verified for 3.3 RC1 using build I20070516-0010
Comment 7 TobyS CLA 2007-05-22 07:25:06 EDT
Created attachment 68100 [details]
Example project (2 java files, .project, .classpath)
Comment 8 TobyS CLA 2007-05-22 07:30:04 EDT
I'm still seeing this bug, or something very similar to it. The uploaded zip file contains example code to demonstrate it. The code compiles under Sun's javac (Java 1.5.0_10) but not in Eclipse 3.3RC1, build I20070517-1700

MyList extends ArrayList and declares a method "void add(Comparable o)". TestClass then calls add(o) on an instance of MyList and eclipse complains that the method add(Comparable) is ambiguous for the type MyList.

Comment 9 Kent Johnson CLA 2007-05-23 15:33:08 EDT
Toby - your case is not related to this one.

I've entered bug 188741 for your case.
Comment 10 TobyS CLA 2007-05-24 04:54:37 EDT
Thanks for the quick fix under 188741, and apologies that it wasn't related - I'm always wary of creating duplicates, perhaps too much so!