Community
Participate
Working Groups
The code below produces an error with the compiler in Eclipse 3.1.1 (the exact message is pasted in below): "The type Test.C<T> must implement the inherited abstract method Test.I<List<T>>.foo(List<S>)". The code compiles fine with Sun's javac version 1.5.0_04. This seems related to bugs 100869 and 105645 (but none of those involve an interface and the error message seems to be different). package gentest; import java.util.List; public class Test { public interface I<T> { public <S extends T> void foo(List<S> ls); } public abstract class A<T> implements I<T> { public <S extends T> void foo(List<S> ls) { } } public class C<T> extends A<List<T>> { } } Severity: 2 Description: Name clash: The method foo(List<S>) of type Test.A<List<T>> has the same erasure as foo(List<S>) of type Test.I<List<T>> but does not override it Resource: Test.java In Folder: gen/src/java/gentest Location: line 14 Severity: 2 Description: The type Test.C<T> must implement the inherited abstract method Test.I<List<T>>.foo(List<S>) Resource: Test.java In Folder: gen/src/java/gentest Location: line 14
Could reproduce in HEAD.
Proposed fix is to the constructor: ParameterizedMethodBinding(ParameterizedTypeBinding, MethodBinding) replace initialize variable bounds for loop with: for (int i = 0; i < length; i++) { TypeVariableBinding originalVar = originalVars[i]; TypeVariableBinding substitutedVar = substitutedVars[i]; TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVar.superclass); substitutedVar.superclass = (ReferenceBinding) (substitutedSuperclass.isArrayType() ? parameterizedDeclaringClass.environment.getType(JAVA_LANG_OBJECT) : substitutedSuperclass); substitutedVar.superInterfaces = Scope.substitute(substitution, originalVar.superInterfaces); if (substitutedVar.superclass.isInterface()) { if (substitutedVar.superInterfaces == NoSuperInterfaces) { substitutedVar.superInterfaces = new ReferenceBinding[] {substitutedVar.superclass}; } else { int size = substitutedVar.superInterfaces.length; System.arraycopy(substitutedVar.superInterfaces, 0, substitutedVar.superInterfaces = new ReferenceBinding[size + 1], 1, size); substitutedVar.superInterfaces[0] = substitutedVar.superclass; } substitutedVar.superclass = parameterizedDeclaringClass.environment.getType (JAVA_LANG_OBJECT); } if (originalVar.firstBound != null) { substitutedVar.firstBound = originalVar.firstBound == originalVar.superclass ? substitutedSuperclass // could be array type : substitutedVar.superInterfaces[0]; } }
Released similar fix. Added GenericTypeTest#test870. Fixed in 3.2 and 3.1.2 streams.
Verified for 3.2M4 in I20051212-2000
Verified for 3.1.2 in M20060109-0800.