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 164036 Details for
Bug 307885
Error message for instanceof <parameterized type> wrong arguments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_307885.txt (text/plain), 3.33 KB, created by
Olivier Thomann
on 2010-04-07 08:44:46 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2010-04-07 08:44:46 EDT
Size:
3.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.408 >diff -u -r1.408 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 Mar 2010 16:22:38 -0000 1.408 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 6 Apr 2010 19:11:05 -0000 >@@ -2141,7 +2141,12 @@ > public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) { > TypeBinding erasedType = checkedType.leafComponentType().erasure(); > StringBuffer recommendedFormBuffer = new StringBuffer(10); >- recommendedFormBuffer.append(erasedType.sourceName()); >+ if (erasedType instanceof ReferenceBinding) { >+ ReferenceBinding referenceBinding = (ReferenceBinding) erasedType; >+ recommendedFormBuffer.append(referenceBinding.qualifiedSourceName()); >+ } else { >+ recommendedFormBuffer.append(erasedType.sourceName()); >+ } > int count = erasedType.typeVariables().length; > if (count > 0) { > recommendedFormBuffer.append('<'); >#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.817 >diff -u -r1.817 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 18 Mar 2010 16:22:35 -0000 1.817 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 6 Apr 2010 19:11:13 -0000 >@@ -31,7 +31,7 @@ > // All specified tests which does not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test1245" }; >-// TESTS_NUMBERS = new int[] { 1455 }; >+// TESTS_NUMBERS = new int[] { 1460 }; > // TESTS_RANGE = new int[] { 1097, -1 }; > } > public static Test suite() { >@@ -50153,4 +50153,31 @@ > "Type safety: Unchecked invocation someMethod() of the generic method someMethod() of type Bug268798\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=307885 >+public void test1460() { >+ this.runNegativeTest( >+ new String[] { >+ "Test.java", >+ "class Test<A> {\n" + >+ " interface MyInt<K> {\n" + >+ " K getKey();\n" + >+ " }\n" + >+ " class MyEntry implements MyInt<A> {\n" + >+ " public A getKey() { return null; }\n" + >+ " @Override\n" + >+ " public boolean equals(Object o) {\n" + >+ " if(!(o instanceof MyEntry))\n" + >+ " return false;\n" + >+ " return true;\n" + >+ " }\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in Test.java (at line 9)\n" + >+ " if(!(o instanceof MyEntry))\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot perform instanceof check against parameterized type Test<A>.MyEntry. Use the form Test.MyEntry instead since further generic type information will be erased at runtime\n" + >+ "----------\n"); >+} > } >\ No newline at end of file
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 307885
: 164036