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 87506 Details for
Bug 215843
[1.5][compiler] Compiler error with generic covariant
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
215843.txt (text/plain), 5.79 KB, created by
Philipe Mulet
on 2008-01-22 06:45:26 EST
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-01-22 06:45:26 EST
Size:
5.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.321 >diff -u -r1.321 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 7 Jan 2008 14:16:19 -0000 1.321 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 22 Jan 2008 11:44:51 -0000 >@@ -2596,14 +2596,19 @@ > TypeBinding oneParam = oneParams[i]; > TypeBinding twoParam = twoParams[i]; > if (oneParam == twoParam) { >- if (oneParam.leafComponentType().isRawType()) { >- // A#RAW is not more specific than a rawified A<T> >- if (oneParam == one.original().parameters[i] && oneParam != two.original().parameters[i]) >+ if (twoParam.leafComponentType().isRawType()) { >+ // must detect & reject this case >+ // when Y<U> extends X<U> >+ // void foo(Y y) {} >+ // <T extends X<Object>> void foo(T t) {} >+ // foo(T) will show up as foo(Y#RAW) and not foo(X#RAW) >+ // Y#RAW is not more specific than a rawified X<T> >+ if (oneParam == one.original().parameters[i] >+ && twoParam.leafComponentType().erasure() != two.original().parameters[i].leafComponentType().erasure()) { > return false; >+ } > } >- continue; >- } >- if (oneParam.isCompatibleWith(twoParam)) { >+ } else if (oneParam.isCompatibleWith(twoParam)) { > if (oneParam.leafComponentType().isRawType()) { > // A#RAW is not more specific than a rawified A<T> > if (oneParam.needsUncheckedConversion(two.declaringClass.isRawType() ? twoParam : two.original().parameters[i])) >#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.680 >diff -u -r1.680 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 17 Jan 2008 13:00:31 -0000 1.680 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 Jan 2008 11:45:01 -0000 >@@ -41119,4 +41119,111 @@ > false, > null); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 >+public void test1232() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void testCovariant(SubInterface sub1, SubInterface sub2) {\n" + >+ " SubInterface sub3 = sub1.and(sub2);\n" + >+ " }\n" + >+ " public interface SuperInterface<E> {\n" + >+ " public Number getNumber();\n" + >+ " public SuperInterface<E> and(SuperInterface<E> a);\n" + >+ " }\n" + >+ " public interface SubInterface extends SuperInterface {\n" + >+ " public Integer getNumber();\n" + >+ " public SubInterface and(SuperInterface s);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ ""); >+ >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation >+public void test1233() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void testCovariant(SubInterface<String> sub1, SubInterface<String> sub2) {\n" + >+ " SubInterface<String> sub3 = sub1.and(sub2);\n" + >+ " }\n" + >+ " public interface SuperInterface<E> {\n" + >+ " public Number getNumber();\n" + >+ " public SuperInterface<E> and(SuperInterface<E> a);\n" + >+ " }\n" + >+ " public interface SubInterface<F> extends SuperInterface<F> {\n" + >+ " public Integer getNumber();\n" + >+ " public SubInterface<F> and(SuperInterface<F> s);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation >+public void test1234() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X { \n" + >+ " void a3(G x) {} \n" + >+ " <T extends F<X>> void a3(T x) {}\n" + >+ "\n" + >+ " public static void ambiguousCases() { \n" + >+ " H<X> hx = null;\n" + >+ " H hraw = null;\n" + >+ " new X().a3(hx);\n" + >+ " new X().a3(hraw);\n" + >+ " } \n" + >+ "}\n" + >+ "class F<T1> {} \n" + >+ "class G<T2> extends F<T2> {}\n" + >+ "class H<T3> extends G<T3> {}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " void a3(G x) {} \n" + >+ " ^\n" + >+ "G is a raw type. References to generic type G<T2> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " H hraw = null;\n" + >+ " ^\n" + >+ "H is a raw type. References to generic type H<T3> should be parameterized\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " new X().a3(hx);\n" + >+ " ^^\n" + >+ "The method a3(G) is ambiguous for the type X\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 9)\n" + >+ " new X().a3(hraw);\n" + >+ " ^^\n" + >+ "The method a3(G) is ambiguous for the type X\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=215843 - variation >+public void test1235() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X { \n" + >+ " <T extends G<X>> void a3(T x) {}\n" + >+ " <T extends F<X>> void a3(T x) {}\n" + >+ "\n" + >+ " public static void ambiguousCases() { \n" + >+ " H<X> hx = null;\n" + >+ " H hraw = null;\n" + >+ " new X().a3(hx);\n" + >+ " new X().a3(hraw);\n" + >+ " } \n" + >+ "}\n" + >+ "class F<T1> {} \n" + >+ "class G<T2> extends F<T2> {}\n" + >+ "class H<T3> extends G<T3> {}\n", >+ }, >+ ""); >+} > }
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 215843
:
87394
| 87506