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 136808 Details for
Bug 273787
[1.5][compiler] Inconsistent compiler behaviour for generics compared with Sun Java
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch and testcase
patch.txt (text/plain), 5.99 KB, created by
Kent Johnson
on 2009-05-22 10:56:23 EDT
(
hide
)
Description:
Proposed patch and testcase
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-05-22 10:56:23 EDT
Size:
5.99 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.796 >diff -u -r1.796 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 6 May 2009 21:25:43 -0000 1.796 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 May 2009 14:39:23 -0000 >@@ -49581,4 +49581,111 @@ > "----------\n" > ); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=273787 >+public void test1453() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X<T extends Comparable<?>> {\n" + >+ " public void test(T v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ " void test2(Comparable<?> v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ "X2.java", >+ "class X2<T extends Comparable<? extends T>> {\n" + >+ " public void test(T v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ " <U> void test2(Comparable<? extends U> v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ "X3.java", >+ "class X3<T extends Comparable<? super T>> {\n" + >+ " public void test(T v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ " <U> void test2(Comparable<? super U> v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ "Y.java", >+ "class Y {\n" + >+ " <U extends Number> void test(Comparable<? extends U> v) {\n" + >+ " if (v instanceof Integer) {\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X2.java (at line 3)\n" + >+ " if (v instanceof Integer) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Incompatible conditional operand types T and Integer\n" + >+ "----------\n" + >+ "2. ERROR in X2.java (at line 4)\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Cannot cast from T to Integer\n" + >+ "----------\n" + >+ "3. ERROR in X2.java (at line 8)\n" + >+ " if (v instanceof Integer) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Incompatible conditional operand types Comparable<capture#1-of ? extends U> and Integer\n" + >+ "----------\n" + >+ "4. ERROR in X2.java (at line 9)\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Cannot cast from Comparable<capture#2-of ? extends U> to Integer\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in X3.java (at line 3)\n" + >+ " if (v instanceof Integer) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Incompatible conditional operand types T and Integer\n" + >+ "----------\n" + >+ "2. ERROR in X3.java (at line 4)\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Cannot cast from T to Integer\n" + >+ "----------\n" + >+ "3. ERROR in X3.java (at line 8)\n" + >+ " if (v instanceof Integer) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Incompatible conditional operand types Comparable<capture#1-of ? super U> and Integer\n" + >+ "----------\n" + >+ "4. ERROR in X3.java (at line 9)\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Cannot cast from Comparable<capture#2-of ? super U> to Integer\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in Y.java (at line 3)\n" + >+ " if (v instanceof Integer) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Incompatible conditional operand types Comparable<capture#1-of ? extends U> and Integer\n" + >+ "----------\n" + >+ "2. ERROR in Y.java (at line 4)\n" + >+ " Object obj = Long.valueOf(((Integer) v).longValue());\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Cannot cast from Comparable<capture#2-of ? extends U> to Integer\n" + >+ "----------\n" >+ ); >+} > } >\ No newline at end of file >#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.104 >diff -u -r1.104 TypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 8 Jan 2009 20:51:04 -0000 1.104 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 22 May 2009 14:39:23 -0000 >@@ -580,7 +580,9 @@ > return !isCompatibleWith(otherType); > } > } else { >- if (!isTypeVariable() && !otherType.isTypeVariable()) { >+ if (!isTypeVariable()) { >+ // check compatibility when otherType is a type variable >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=273787 > return !isCompatibleWith(otherType); > } > } >@@ -823,7 +825,9 @@ > } > } else { > if (lowerBound2 != null) { >- if (lowerBound2.isTypeVariable() || isTypeVariable()) { >+ if (isTypeVariable()) { >+ // check compatibility when lowerBound2 is a type variable >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=273787 > return false; > } > return !lowerBound2.isCompatibleWith(this);
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 273787
:
133303
|
136700
| 136808