### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v retrieving revision 1.62 diff -u -r1.62 AmbiguousMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 27 Feb 2009 16:58:43 -0000 1.62 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 18 Mar 2009 18:02:53 -0000 @@ -2894,30 +2894,20 @@ " ^\n" + "The return types are incompatible for the inherited methods J.a(), I.a()\n" + "----------\n" + - "4. ERROR in Y.java (at line 15)\n" + - " byte a = a();\n" + - " ^\n" + - "The method a() is ambiguous for the type Y\n" + - "----------\n" + - "5. ERROR in Y.java (at line 20)\n" + + "4. ERROR in Y.java (at line 20)\n" + " abstract class Y2 extends X implements J, I {\n" + " ^^\n" + "The return types are incompatible for the inherited methods J.c(), X.c()\n" + "----------\n" + - "6. ERROR in Y.java (at line 20)\n" + + "5. ERROR in Y.java (at line 20)\n" + " abstract class Y2 extends X implements J, I {\n" + " ^^\n" + "The return types are incompatible for the inherited methods I.b(), X.b()\n" + "----------\n" + - "7. ERROR in Y.java (at line 20)\n" + + "6. ERROR in Y.java (at line 20)\n" + " abstract class Y2 extends X implements J, I {\n" + " ^^\n" + "The return types are incompatible for the inherited methods I.a(), J.a()\n" + - "----------\n" + - "8. ERROR in Y.java (at line 22)\n" + - " byte a = a();\n" + - " ^\n" + - "The method a() is ambiguous for the type Y2\n" + "----------\n" ); } @@ -3066,4 +3056,154 @@ "----------\n" ); } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=268837 +public void test076() { + this.runNegativeTest( + new String[] { + "X.java", + "interface I {\n" + + " I a();\n" + + " I b();\n" + + " I c();\n" + + "}\n" + + "interface J extends I {\n" + + " J a();\n" + + " J b();\n" + + " J c();\n" + + "}\n" + + "class X {\n" + + " void a(J ints) {\n" + + " ints.a();\n" + + " J a = ints.a();\n" + + " J b = ints.a();\n" + // incompatible types + " J c = ints.a();\n" + // incompatible types + " J d = ints.a();\n" + + " I e = ints.a();\n" + + " I f = ints.a();\n" + // incompatible types + " I g = ints.a();\n" + // incompatible types + " I h = ints.a();\n" + + " }\n" + + " void b(J ints) {\n" + + " ints.b();\n" + // ambiguous + " J a = ints.b();\n" + // ambiguous + " J b = ints.b();\n" + // ambiguous + " J c = ints.b();\n" + // ambiguous + " J d = ints.b();\n" + // ambiguous + " I e = ints.b();\n" + // ambiguous + " I f = ints.b();\n" + // ambiguous + " I g = ints.b();\n" + // ambiguous + " I h = ints.b();\n" + // ambiguous + " }\n" + + " void c(J ints) {\n" + + " ints.c();\n" + + " J a = ints.c();\n" + + " J b = ints.c();\n" + + " J c = ints.c();\n" + + " J d = ints.c();\n" + + " I e = ints.c();\n" + + " I f = ints.c();\n" + + " I g = ints.c();\n" + + " I h = ints.c();\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 15)\n" + + " J b = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "2. ERROR in X.java (at line 16)\n" + + " J c = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "3. WARNING in X.java (at line 17)\n" + + " J d = ints.a();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 19)\n" + + " I f = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "5. ERROR in X.java (at line 20)\n" + + " I g = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "6. WARNING in X.java (at line 21)\n" + + " I h = ints.a();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "7. ERROR in X.java (at line 24)\n" + + " ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "8. ERROR in X.java (at line 25)\n" + + " J a = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "9. ERROR in X.java (at line 26)\n" + + " J b = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "10. ERROR in X.java (at line 27)\n" + + " J c = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "11. WARNING in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "12. ERROR in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "13. ERROR in X.java (at line 29)\n" + + " I e = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "14. ERROR in X.java (at line 30)\n" + + " I f = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "15. ERROR in X.java (at line 31)\n" + + " I g = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "16. WARNING in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "17. ERROR in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "18. WARNING in X.java (at line 39)\n" + + " J d = ints.c();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "19. WARNING in X.java (at line 43)\n" + + " I h = ints.c();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + ); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.350 diff -u -r1.350 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 20 Feb 2009 21:27:39 -0000 1.350 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 18 Mar 2009 18:02:55 -0000 @@ -3705,11 +3705,13 @@ if (original2 == null || !original.areParameterErasuresEqual(original2)) continue nextSpecific; // current does not override next if (original.returnType != original2.returnType) { - if (!current.returnType.isCompatibleWith(next.returnType)) + if (current instanceof ParameterizedGenericMethodBinding) { + if (original.returnType.erasure().findSuperTypeOriginatingFrom(original2.returnType.erasure()) == null) + continue nextSpecific; + } else if (!current.returnType.isCompatibleWith(next.returnType)) { continue nextSpecific; - if (original.returnType.erasure().findSuperTypeOriginatingFrom(original2.returnType.erasure()) == null) - continue nextSpecific; - // continue with original 15.12.2 + } + // continue with original 15.12.2.5 } if (shouldIntersectExceptions && original2.declaringClass.isInterface()) { if (current.thrownExceptions != next.thrownExceptions) {