Bug 268837 - [1.6][compiler] Incorrectly report ambiguity of methods with generics
Summary: [1.6][compiler] Incorrectly report ambiguity of methods with generics
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 225518 264491 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-16 13:34 EDT by Ildar Safarov CLA
Modified: 2009-05-04 10:52 EDT (History)
4 users (show)

See Also:


Attachments
Archived eclipse project where bug is reproduced (2.39 KB, application/octet-stream)
2009-03-16 13:34 EDT, Ildar Safarov CLA
no flags Details
Proposed patch and testcase (8.83 KB, patch)
2009-03-18 14:04 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***