### Eclipse Workspace Patch 1.0 #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.654 diff -u -r1.654 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Oct 2007 11:51:45 -0000 1.654 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Oct 2007 14:08:12 -0000 @@ -39832,4 +39832,56 @@ "Cannot cast from X to X\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=120088 +public void test1194() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " X t = new X();\n" + + " if (t.getClass() == Object.class)\n" + + " System.out.println(\"OK\");\n" + + " }\n" + + "}\n", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " if (t.getClass() == Object.class)\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Incompatible operand types Class and Class\n" + + "----------\n"); +} +public void testONLY_1195() { + this.runConformTest( + new String[] { + "java/lang/Class.java", + "package java.lang;\n" + + "public class Class {\n" + + " Class getSuperclass() { return null; }\n" + + " void foo() {\n" + + " boolean foo = getSuperclass() == Enum.class;\n" + + " }\n" + + "}\n", // ================= + }, + ""); +} +public void testONLY_1196() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " Class getSuperclass() { return null; }\n" + + " void foo() {\n" + + " boolean foo = getSuperclass() == Enum.class;\n" + + " }\n" + + "}\n" + + "class Y {\n" + + " void bar() {\n" + + " boolean bar = this.getClass().getSuperclass() == Enum.class;\n" + + " } \n" + + "}\n", // ================= + }, + ""); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v retrieving revision 1.90 diff -u -r1.90 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 10 Oct 2007 11:51:48 -0000 1.90 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 10 Oct 2007 14:08:13 -0000 @@ -628,11 +628,15 @@ final TypeVariableBinding variable = (TypeVariableBinding) this; if (variable.isCapture()) { CaptureBinding capture = (CaptureBinding) variable; - lowerBound1 = capture.lowerBound; - if (lowerBound1 == null) { - if (capture.firstBound == null) + switch (capture.wildcard.boundKind) { + case Wildcard.EXTENDS: + upperBound1 = capture.wildcard.bound; + break; + case Wildcard.SUPER: + lowerBound1 = capture.wildcard.bound; + break; + case Wildcard.UNBOUND: return false; - upperBound1 = capture.firstBound; } break; } @@ -679,11 +683,15 @@ TypeVariableBinding otherVariable = (TypeVariableBinding) otherArgument; if (otherVariable.isCapture()) { CaptureBinding otherCapture = (CaptureBinding) otherVariable; - lowerBound2 = otherCapture.lowerBound; - if (lowerBound2 == null) { - if (otherCapture.firstBound == null) + switch (otherCapture.wildcard.boundKind) { + case Wildcard.EXTENDS: + upperBound2 = otherCapture.wildcard.bound; + break; + case Wildcard.SUPER: + lowerBound2 = otherCapture.wildcard.bound; + break; + case Wildcard.UNBOUND: return false; - upperBound2 = otherCapture.firstBound; } break; } @@ -712,8 +720,14 @@ return false; // Object could always be a candidate } else if (upperBound2 != null) { + if (lowerBound1.isTypeVariable() || upperBound2.isTypeVariable()) { + return false; + } return !lowerBound1.isCompatibleWith(upperBound2); } else { + if (lowerBound1.isTypeVariable() || otherArgument.isTypeVariable()) { + return false; + } return !lowerBound1.isCompatibleWith(otherArgument); } } else if (upperBound1 != null) { @@ -727,6 +741,9 @@ } } else { if (lowerBound2 != null) { + if (lowerBound2.isTypeVariable() || this.isTypeVariable()) { + return false; + } return !lowerBound2.isCompatibleWith(this); } else if (upperBound2 != null) { return this.isProvableDistinctSubType(upperBound2);