### Eclipse Workspace Patch 1.0 #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.321 diff -u -r1.321 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 7 Jan 2008 14:16:19 -0000 1.321 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 22 Jan 2008 11:44:51 -0000 @@ -2596,14 +2596,19 @@ TypeBinding oneParam = oneParams[i]; TypeBinding twoParam = twoParams[i]; if (oneParam == twoParam) { - if (oneParam.leafComponentType().isRawType()) { - // A#RAW is not more specific than a rawified A - if (oneParam == one.original().parameters[i] && oneParam != two.original().parameters[i]) + if (twoParam.leafComponentType().isRawType()) { + // must detect & reject this case + // when Y extends X + // void foo(Y y) {} + // > void foo(T t) {} + // foo(T) will show up as foo(Y#RAW) and not foo(X#RAW) + // Y#RAW is not more specific than a rawified X + if (oneParam == one.original().parameters[i] + && twoParam.leafComponentType().erasure() != two.original().parameters[i].leafComponentType().erasure()) { return false; + } } - continue; - } - if (oneParam.isCompatibleWith(twoParam)) { + } else if (oneParam.isCompatibleWith(twoParam)) { if (oneParam.leafComponentType().isRawType()) { // A#RAW is not more specific than a rawified A if (oneParam.needsUncheckedConversion(two.declaringClass.isRawType() ? twoParam : two.original().parameters[i])) #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.680 diff -u -r1.680 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 17 Jan 2008 13:00:31 -0000 1.680 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 Jan 2008 11:45:01 -0000 @@ -41119,4 +41119,111 @@ false, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 +public void test1232() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void testCovariant(SubInterface sub1, SubInterface sub2) {\n" + + " SubInterface sub3 = sub1.and(sub2);\n" + + " }\n" + + " public interface SuperInterface {\n" + + " public Number getNumber();\n" + + " public SuperInterface and(SuperInterface a);\n" + + " }\n" + + " public interface SubInterface extends SuperInterface {\n" + + " public Integer getNumber();\n" + + " public SubInterface and(SuperInterface s);\n" + + " }\n" + + "}\n", + }, + ""); + +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation +public void test1233() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void testCovariant(SubInterface sub1, SubInterface sub2) {\n" + + " SubInterface sub3 = sub1.and(sub2);\n" + + " }\n" + + " public interface SuperInterface {\n" + + " public Number getNumber();\n" + + " public SuperInterface and(SuperInterface a);\n" + + " }\n" + + " public interface SubInterface extends SuperInterface {\n" + + " public Integer getNumber();\n" + + " public SubInterface and(SuperInterface s);\n" + + " }\n" + + "}\n", + }, + ""); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation +public void test1234() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n" + + " void a3(G x) {} \n" + + " > void a3(T x) {}\n" + + "\n" + + " public static void ambiguousCases() { \n" + + " H hx = null;\n" + + " H hraw = null;\n" + + " new X().a3(hx);\n" + + " new X().a3(hraw);\n" + + " } \n" + + "}\n" + + "class F {} \n" + + "class G extends F {}\n" + + "class H extends G {}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void a3(G x) {} \n" + + " ^\n" + + "G is a raw type. References to generic type G should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 7)\n" + + " H hraw = null;\n" + + " ^\n" + + "H is a raw type. References to generic type H should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " new X().a3(hx);\n" + + " ^^\n" + + "The method a3(G) is ambiguous for the type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " new X().a3(hraw);\n" + + " ^^\n" + + "The method a3(G) is ambiguous for the type X\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation +public void test1235() { + this.runConformTest( + new String[] { + "X.java", + "public class X { \n" + + " > void a3(T x) {}\n" + + " > void a3(T x) {}\n" + + "\n" + + " public static void ambiguousCases() { \n" + + " H hx = null;\n" + + " H hraw = null;\n" + + " new X().a3(hx);\n" + + " new X().a3(hraw);\n" + + " } \n" + + "}\n" + + "class F {} \n" + + "class G extends F {}\n" + + "class H extends G {}\n", + }, + ""); +} }