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.120 diff -u -r1.120 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 12 Mar 2007 08:14:52 -0000 1.120 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 16 Mar 2007 18:13:40 -0000 @@ -7510,4 +7510,38 @@ "The method bar(String, String) of type X is not generic; it cannot be parameterized with arguments \n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174445 +public void test127() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " enum Enum1 {\n" + + " value;\n" + + " }\n" + + " enum Enum2 {\n" + + " value;\n" + + " }\n" + + " static abstract class A {\n" + + " abstract U foo();\n" + + " }\n" + + " static class B extends A> {\n" + + " @Override\n" + + " Enum foo() {\n" + + " return Enum1.value;\n" + + " } \n" + + " }\n" + + " public static void main(String[] args) {\n" + + " A> a = new B();\n" + + " Enum2 value = a.foo();\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. WARNING in X.java (at line 13)\n" + + " Enum foo() {\n" + + " ^^^^\n" + + "Type safety: The return type Enum for foo() from the type X.B needs unchecked conversion to conform to U from the type X.A\n" + + "----------\n"); +} } 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.70 diff -u -r1.70 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 12 Mar 2007 08:14:55 -0000 1.70 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 16 Mar 2007 18:13:40 -0000 @@ -134,9 +134,8 @@ if (originalInherited.returnType != currentMethod.returnType) { // if (currentMethod.returnType.needsUncheckedConversion(inheritedMethod.returnType)) { // problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type); - if (inheritedMethod.returnType.leafComponentType().isParameterizedType()) { - if (currentMethod.returnType.leafComponentType().isRawType()) - problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type); + if (inheritedMethod.returnType.leafComponentType().isParameterizedType() && currentMethod.returnType.leafComponentType().isRawType()) { + problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type); } else if (inheritedMethod.hasSubstitutedReturnType() && originalInherited.returnType.leafComponentType().isTypeVariable()) { if (((TypeVariableBinding) originalInherited.returnType.leafComponentType()).declaringElement == originalInherited) { // see 81618 - type variable from inherited method TypeBinding currentReturnType = currentMethod.returnType.leafComponentType(); @@ -527,7 +526,7 @@ int inheritedLength = inheritedTypeVariables.length; TypeVariableBinding[] typeVariables = currentMethod.typeVariables; int length = typeVariables.length; - if (length > 0 && inheritedLength != length) return inheritedMethod; + 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);