Summary: | [1.5][compiler] Incompatible return type on static method | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Eric Bodden <eric> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | RESOLVED DUPLICATE | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | mlists |
Version: | 3.1 | ||
Target Milestone: | 3.2 M6 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Eric Bodden
2005-08-12 13:58:24 EDT
javac returns only a warning: X.java:8: warning: create() in X overrides <W,X,Y>create() in DoubleHash; return type requires unchecked conversion found : X required: DoubleHash<W,X,Y> public static X create() { ^ 1 warning Fix will not be ready for 3.1.1, removing target milestone "3.1.1" This is the same problem as bug 125956. Static methods can 'override' inherited static methods, see the example below. The problem is with the inherited method defining its own type variables but the subclass' method remaining as is. For backwards compatibility, the compiler should issue a conversion check warning instead of an error, until the subclass' method adds the necessary type variables. The error/warnings are the same even when the methods are not static. class Z<T> extends ZZ<T> { static @Override A<?> foo() {return null;} // unchecked converion warning static @Override A<String> bar() {return null;}// unchecked converion warning static <S> A<String> baz() { return null; } // actual return type error } class ZZ<TT> { static <T> A<T> foo() { return null; } static <V> A<V> bar() { return null; } static <U> A<U> baz() { return null; } } class A<T> {} *** This bug has been marked as a duplicate of 125956 *** Added MethodVerify test80 |