| Summary: | [1.5][compiler] false ambiguous generics method error report | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Kenneth Xu <kennethxu> |
| Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
| Status: | CLOSED WORKSFORME | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | kennethxu |
| Version: | 3.1.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
The method add(E o) method in the IMother interface is most likely the trigger of the bug. Althought it is not necessary to declare again, a lot of times it was done for the purpose of generating javadoc. For example, java.util.Set redeclares the add method of java.util.Collection. A more real world example is listed below:
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
public class EclipseAmbiguousBug2 {
interface Addable<E> {
boolean add(E e);
}
interface XCollection<E> extends Collection<E>, Addable<E> {}
interface XSet<E> extends XCollection<E>, Set<E> {}
static class TestXSet<E> extends AbstractSet<E> implements XSet<E> {
public boolean add(E e) {return false;}
public Iterator<E> iterator() {return null;}
public int size() {return 0;}
}
public static void main(String[] args) {
XSet xs = new TestXSet();
xs.add(""); // correctly generated warning
XSet<String> xs2 = new TestXSet<String>();
xs2.add(""); // false ambiguous error message
}
}
Kenneth, both cases are fixed in 3.2 Kent, thanks for your response. I downloaded 3.2RC7 and yes it works fine. verified works in 3.2RC7, closing the bug. |
Eclipse generates false ambiguous method error for code below bug javac doesn't public class EclipseAmbiguousBug { interface IWorker<E> { void add(E e); } interface IPerson<E> { void add(E e); } interface IFather<E> extends IWorker<E>, IPerson<E>{ } interface IMother<E> extends IPerson<E> { void add(E e); } interface IChild<E> extends IFather<E>, IMother<E> { } static class Child<E> implements IChild<E> { public void add(E e) {} } public static void main(String[] args) { IChild c = new Child(); c.add(""); // correct warning IChild<String> cg = new Child<String>(); cg.add(""); // false ambiguous error } }