### Eclipse Workspace Patch 1.0 #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.107 diff -u -r1.107 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 2 Dec 2009 18:35:40 -0000 1.107 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 17 Feb 2010 12:46:54 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -612,7 +612,7 @@ ReferenceBinding otherEnclosing = otherParamType.enclosingType(); if (otherEnclosing == null) return true; if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { - if (enclosing != otherEnclosing) return true; + if (enclosing.isProvablyDistinct(otherEnclosing)) return true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302919 } else { if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) return true; } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java,v retrieving revision 1.50 diff -u -r1.50 CastTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java 25 Sep 2009 16:58:36 -0000 1.50 +++ src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java 17 Feb 2010 12:47:03 -0000 @@ -1782,6 +1782,93 @@ "----------\n" ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=302919 +public void test048() { + CompilerOptions options = new CompilerOptions(getCompilerOptions()); + if (options.sourceLevel < ClassFileConstants.JDK1_5) return; + this.runNegativeTest( + new String[] { + "A.java", + "public class A extends D {\n" + + " public class A1 extends D1 {\n" + + " }\n" + + " void m1(A tree) {\n" + + " A.A1 v = ((A.A1) tree.root);\n" + + " }\n" + + " Zork z;\n" + + "}\n" + + "class D {\n" + + " protected D1 root;\n" + + " protected class D1 {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in A.java (at line 7)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=302919 +public void test049() { + CompilerOptions options = new CompilerOptions(getCompilerOptions()); + if (options.sourceLevel < ClassFileConstants.JDK1_5) return; + this.runNegativeTest( + new String[] { + "A.java", + "public class A {\n" + + " void foo(Other2.Member2 om2) {\n" + + " Other.Member m = (Other.Member) om2;\n" + + " m = om2;\n" + + " }\n" + + "}\n" + + "class Other {\n" + + " class Member {}\n" + + "}\n" + + "class Other2 extends Other {\n" + + " class Member2 extends Other.Member {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in A.java (at line 3)\n" + + " Other.Member m = (Other.Member) om2;\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Unnecessary cast from Other2.Member2 to Other.Member\n" + + "----------\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=302919 +public void test050() { + CompilerOptions options = new CompilerOptions(getCompilerOptions()); + if (options.sourceLevel < ClassFileConstants.JDK1_5) return; + this.runNegativeTest( + new String[] { + "A.java", + "public class A extends D {\n" + + " public class A1 extends D.D1 {\n" + + " }\n" + + " void m1(A tree) {\n" + + " A.A1 v = ((A.A1) tree.root);\n" + + " }\n" + + " Zork z;\n" + + "}\n" + + "class D {\n" + + " protected D1 root;\n" + + " protected class D1 {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in A.java (at line 7)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + ); +} public static Class testClass() { return CastTest.class; } 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.811 diff -u -r1.811 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 25 Nov 2009 04:56:21 -0000 1.811 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 17 Feb 2010 12:47:56 -0000 @@ -45577,11 +45577,11 @@ " }\n" + "}\n", // ================= }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " Other.Member m = (Other.Member) om2;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot cast from Other2.Member2 to Other.Member\n" + + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " Other.Member m = (Other.Member) om2;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Other2.Member2 to Other.Member\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=233800 - variation @@ -45602,11 +45602,11 @@ " }\n" + "}\n", // ================= }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " Other.Member m = (Other.Member) om2;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot cast from Other2.Member2 to Other.Member\n" + + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " Other.Member m = (Other.Member) om2;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Other2.Member2 to Other.Member\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=234619