Summary: | [1.5][compiler] Is this a name clash? | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Kent Johnson <kent_johnson> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | nwrk |
Version: | 3.1 | ||
Target Milestone: | 3.1 M5 | ||
Hardware: | PC | ||
OS: | All | ||
Whiteboard: |
Description
Kent Johnson
2004-12-15 16:50:46 EST
I agree with Kent in his case, but my case it most likely the following one : interface I<E extends Comparable<E>> { public >>E<< test(E element); } class A implements I<Integer> { public >>Integer<< test(Integer i) {} } class B extends A { public >>Comparable<< test(>>Comparable<< i) {} } Isn't there an obvious name clash because of the return type ? I would also that it is only generics-related, because in Java 1.4 you can't even have this : class A { public Comparable test(Comparable c); } class B { public Integer test(Integer i); } ... and only because it is a kind of generics. Actually, Kent, should it diagnose a nameclash due to conflict with bridge method from A ? Mikael - return types are not considered when looking for name clashes, since its only the parameters which decide the correct method to dispatch. Philippe - I have yet to see any case when the bridge method was used for comparison. Another case that causes a name clash with javac: class E extends F<E> { public int compareTo(Object o) { return 0; } // name clash: compareTo(java.lang.Object) in E and compareTo(U) in I<E> // have the same erasure, yet neither overrides the other } abstract class F<T extends F<T>> implements I<T>{ public final int compareTo(T o) { return 0; } } interface I<U>{ int compareTo(U o); } But since E inherits from F that provides a valid implementation of compareTo (F) and a bridge method for compareTo(Object), I don't see why E.compareTo (Object) would cause a name clash. This is a simplified case from bug 80626 Reworked our name clash detection. Added MethodVerify test034 Verified in I20050215-2300 |