Bug 268837

Summary: [1.6][compiler] Incorrectly report ambiguity of methods with generics
Product: [Eclipse Project] JDT Reporter: Ildar Safarov <ildar.safarov>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jarthana, joerg, srikanth_sankaran, yozh
Version: 3.5   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Archived eclipse project where bug is reproduced
none
Proposed patch and testcase none

Description Ildar Safarov CLA 2009-03-16 13:34:44 EDT
Created attachment 128957 [details]
Archived eclipse project where bug is reproduced

Build ID: M20090211-1700

Steps To Reproduce:
Define this:
===
public interface MyCollection<E> {
    <T> MyCollection<T> uncheckedCast();
}
public interface MyList<E> extends MyCollection<E> {
    <T> MyList<T> uncheckedCast();
}
public class MyCollectionImpl<E> implements MyCollection<E> {
    public <T> MyCollectionImpl<T> uncheckedCast() { return null; }
}
public class MyListImpl<E> extends MyCollectionImpl<E> implements MyList<E> {
    public <T> MyListImpl<T> uncheckedCast() { return null; }
}
public class Main {
    public static void main(String[] args) {
        MyList<Integer> ints = new MyListImpl<Integer>();
        MyList<String> strings = ints.uncheckedCast();
    }
}
===
Eclipse will report "The method uncheckedCast() is ambiguous for the type MyList<Integer> Main.java line 7". While everything is ok with javac (JDK version 1.6 update 10). Compiler compliance level is set to 1.6 in project settings.

More information:
I already reported similar bug for static methods - id was 225518 - but presented example was incorrect.
Comment 1 Stepan Koltsov CLA 2009-03-16 13:42:49 EDT
It is definitely a bug, because

===
List<String> l = Collections.emptyList();
===

is correct code.
Comment 2 Kent Johnson CLA 2009-03-18 11:19:03 EDT
*** Bug 225518 has been marked as a duplicate of this bug. ***
Comment 3 Kent Johnson CLA 2009-03-18 14:04:03 EDT
Created attachment 129261 [details]
Proposed patch and testcase
Comment 4 Kent Johnson CLA 2009-03-19 10:21:06 EDT
Fix and test released for 3.5M7
Comment 5 Jay Arthanareeswaran CLA 2009-04-28 01:25:58 EDT
Verified for 3.5M7 using build I20090426-2000
Comment 6 Kent Johnson CLA 2009-05-04 10:52:16 EDT
*** Bug 264491 has been marked as a duplicate of this bug. ***