Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 117437 Details for
Bug 240807
[1.5][compiler] Missing unchecked cast warning on interface cast
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
240807.txt (text/plain), 4.80 KB, created by
Philipe Mulet
on 2008-11-10 09:52:10 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-11-10 09:52:10 EST
Size:
4.80 KB
patch
obsolete
>### 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<A> is not applicable for the arguments (). The inferred type Comparable<Comparable<B>> is not a valid substitute for the bounded parameter <B extends Comparable<B>>\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<E> 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<Object> 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<capture#1-of ?> 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<K,V> 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<K,V> 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<K,V> 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<K,V> 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<K,V> 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<K,V> 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);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 240807
: 117437