### 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.764 diff -u -r1.764 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 7 Nov 2008 16:02:34 -0000 1.764 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Nov 2008 14:51:46 -0000 @@ -47555,4 +47555,74 @@ "Bound mismatch: The generic method bar() of type X is not applicable for the arguments (). The inferred type Comparable> is not a valid substitute for the bounded parameter >\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=240807 +public void test1405() throws Exception { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X {\n" + + " X(List rawList, List unboundList) {\n" + + " Throwable t0 = (Throwable) Collections.emptyList();\n" + + " Throwable t1 = (Throwable) rawList;\n" + + " Throwable t2 = (Throwable) unboundList;\n" + + " Map m0 = (Map) Collections.emptyList();\n" + + " Map m1 = (Map) rawList;\n" + + " Map m2 = (Map) unboundList;\n" + + " Zork z;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " X(List rawList, List unboundList) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " Throwable t0 = (Throwable) Collections.emptyList();\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from List to Throwable\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " Throwable t2 = (Throwable) unboundList;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from List to Throwable\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " Map m0 = (Map) Collections.emptyList();\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " Map m0 = (Map) Collections.emptyList();\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "6. WARNING in X.java (at line 8)\n" + + " Map m1 = (Map) rawList;\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " Map m1 = (Map) rawList;\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " Map m2 = (Map) unboundList;\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "9. WARNING in X.java (at line 9)\n" + + " Map m2 = (Map) unboundList;\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "10. ERROR in X.java (at line 10)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n"); +} } \ No newline at end of file #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java,v retrieving revision 1.122 diff -u -r1.122 CastExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 4 Jul 2008 10:09:24 -0000 1.122 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 10 Nov 2008 14:51:47 -0000 @@ -386,6 +386,12 @@ case Binding.TYPE_PARAMETER : this.bits |= ASTNode.UnsafeCast; return true; + case Binding.TYPE : + if (isNarrowing && match == null && expressionType.isParameterizedType()) { + this.bits |= ASTNode.UnsafeCast; + return true; + } + break; } if (!isNarrowing && match == this.resolvedType.leafComponentType()) { // do not tag as unnecessary when recursing through upper bounds tagAsUnnecessaryCast(scope, castType);