### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.88.2.5 diff -u -r1.88.2.5 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 4 Nov 2008 17:04:50 -0000 1.88.2.5 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 23 Jan 2009 19:48:43 -0000 @@ -533,25 +533,22 @@ ((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; - if (inheritedTypeVariables == Binding.NO_TYPE_VARIABLES) return inheritedMethod; int inheritedLength = inheritedTypeVariables.length; + if (inheritedLength == 0) return inheritedMethod; // no substitution needed TypeVariableBinding[] typeVariables = currentMethod.typeVariables; int length = typeVariables.length; - if (length > 0 && inheritedLength != length) return inheritedMethod; // no match JLS 8.4.2 - TypeBinding[] arguments = new TypeBinding[inheritedLength]; - if (inheritedLength <= length) { - System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); - } else { - System.arraycopy(typeVariables, 0, arguments, 0, length); - for (int i = length; i < inheritedLength; i++) - arguments[i] = inheritedTypeVariables[i].upperBound(); - } - ParameterizedGenericMethodBinding substitute = - this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); + if (length == 0) + return inheritedMethod.asRawMethod(this.environment); + if (length != inheritedLength) + return inheritedMethod; // no match JLS 8.4.2 // interface I { void foo(T t); } // class X implements I { public void foo(T t) {} } // for the above case, we do not want to answer the substitute method since its not a match + TypeBinding[] arguments = new TypeBinding[length]; + System.arraycopy(typeVariables, 0, arguments, 0, length); + ParameterizedGenericMethodBinding substitute = + this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); for (int i = 0; i < inheritedLength; i++) { TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; TypeBinding argument = arguments[i]; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.153.2.5 diff -u -r1.153.2.5 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 4 Nov 2008 17:04:51 -0000 1.153.2.5 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 23 Jan 2009 19:48:44 -0000 @@ -7708,7 +7708,12 @@ "}" }, "----------\n" + - "1. WARNING in X.java (at line 10)\n" + + "1. WARNING in X.java (at line 3)\n" + + " public A foo(Number n) { return null; }\n" + + " ^\n" + + "Type safety: The return type A for foo(Number) from the type X2 needs unchecked conversion to conform to T from the type I\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + " A foo(Number n);\n" + " ^\n" + "Type safety: The return type A for foo(Number) from the type J needs unchecked conversion to conform to T from the type I\n" + @@ -7792,7 +7797,7 @@ "1. WARNING in X.java (at line 6)\n" + " A foo(Number n);\n" + " ^\n" + - "Type safety: The return type A for foo(Number) from the type J needs unchecked conversion to conform to A from the type I\n" + + "Type safety: The return type A for foo(Number) from the type J needs unchecked conversion to conform to A from the type I\n" + "----------\n" ); } @@ -7817,7 +7822,12 @@ "}" }, "----------\n" + - "1. WARNING in X.java (at line 9)\n" + + "1. WARNING in X.java (at line 3)\n" + + " public XX foo(Number n) { return null; }\n" + + " ^^\n" + + "Type safety: The return type XX for foo(Number) from the type X needs unchecked conversion to conform to T from the type I\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + " XX foo(Number n);\n" + " ^^\n" + "Type safety: The return type XX for foo(Number) from the type J needs unchecked conversion to conform to T from the type I\n" + @@ -8904,4 +8914,48 @@ "" ); } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=262208 +public void test183() { + this.runNegativeTest( + new String[] { + "X.java", + "class XX {\n" + + " > void a(S gC) {}\n" + + " > void b(T c) {}\n" + + " void c(G gC) {}\n" + + " > void d(S gC) {}\n" + + "}\n" + + "class X extends XX {\n" + + " @Override void a(G g) {}\n" + + " @Override void b(C c) {}\n" + + " @Override void c(G g) {}\n" + + " @Override > void d(S gc) {}\n" + + "}\n" + + "class C {}\n" + + "class G {}" + }, + "----------\n" + + "1. WARNING in X.java (at line 8)\n" + + " @Override void a(G g) {}\n" + + " ^\n" + + "G is a raw type. References to generic type G should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " @Override void c(G g) {}\n" + + " ^\n" + + "G is a raw type. References to generic type G should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 11)\n" + + " @Override > void d(S gc) {}\n" + + " ^^^^^^^\n" + + "Name clash: The method d(S) of type X has the same erasure as d(S) of type XX but does not override it\n" + + "----------\n" + + "4. ERROR in X.java (at line 11)\n" + + " @Override > void d(S gc) {}\n" + + " ^^^^^^^\n" + + mustOverrideMessage("d(S)", "X") + + "----------\n" + ); +} } \ No newline at end of file