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 23598 Details for
Bug 98538
[1.5][compiler] Inference broken for subtypes of subtypes of F-bounded types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for GenericTypeTest
98538-tests-compiler.txt (text/plain), 9.18 KB, created by
Philipe Mulet
on 2005-06-21 04:53:06 EDT
(
hide
)
Description:
Patch for GenericTypeTest
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2005-06-21 04:53:06 EDT
Size:
9.18 KB
patch
obsolete
>Index: GenericTypeTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.319 >diff -u -r1.319 GenericTypeTest.java >--- GenericTypeTest.java 17 Jun 2005 09:26:42 -0000 1.319 >+++ GenericTypeTest.java 21 Jun 2005 08:32:48 -0000 >@@ -21388,7 +21388,7 @@ > "----------\n"); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=98538 >-public void _test742() { >+public void test742() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -21396,79 +21396,53 @@ > "\n" + > " public class X {\n" + > " \n" + >- " /**Subclasses are parameterized by their own type*/\n" + >- " private static abstract class SelfType<T extends SelfType<T>>{\n" + >- " public abstract T getThis();\n" + >+ " static abstract class SelfType<T extends SelfType<T>>{\n" + > " }\n" + > " \n" + >- " /**Supertype inherits directly from the parameterized SelfType*/\n" + >- " private static class SuperType extends SelfType<SuperType>{\n" + >- " @Override\n" + >- " public SuperType getThis(){\n" + >- " return this;\n" + >- " }\n" + >+ " static class SuperType extends SelfType<SuperType>{\n" + > " }\n" + > " \n" + >- " /**Subtype inherits indirectly from the parameterized SelfType*/\n" + >- " private static class SubType extends SuperType{}\n" + >+ " static class SubType extends SuperType{}\n" + > " \n" + >- " /**Creates a list containing a single SelfType*/\n" + >- " public static <T extends SelfType<T>> List<T> makeSingletonList(T t){\n" + >+ " static <T extends SelfType<T>> List<T> makeSingletonList(T t){\n" + > " return Collections.singletonList(t);\n" + > " }\n" + > " \n" + >- " /**\n" + >- " * Creates a list containing a single SelfType, allowing the list\'s\n" + >- " * element-type to be a supertype of the type of its single element\n" + >- " */\n" + >- " public static <T extends SelfType<T>,S extends T> List<T> makeSingletonList2(S s){\n" + >- " return Collections.singletonList((T)s);\n" + >+ " static <T extends SelfType<T>,S extends T> List<T> makeSingletonList2(S s){\n" + >+ " return Collections.singletonList((T)s); // #0\n" + > " }\n" + > " \n" + > " public static void main(String[] args){\n" + >- " /*making lists of super types works fine ...*/\n" + >- " makeSingletonList(new SuperType());\n" + >- " List<SuperType> lsup = makeSingletonList(new SuperType());\n" + >- " \n" + >- " /*but we can\'t make a list of sub types; seems weird ...*/\n" + >- " List<SubType> lsub = makeSingletonList(new SubType()); //ERROR\n" + >- " \n" + >- " /*can\'t even call it w/o assigning the return value:*/\n" + >- " makeSingletonList(new SubType()); //ERROR\n" + >- " \n" + >- " \n" + >- " /*so instead, we should be able to make lists of super type containing sub type elements*/\n" + >- " makeSingletonList2(new SubType()); //ERROR\n" + >- " /*even if we assign the return value:*/\n" + >- " lsup = makeSingletonList2(new SubType()); // ERROR (eclipse is okay with this though)\n" + >- " /*this still doesn\'t work either:*/\n" + >- " lsub = makeSingletonList2(new SubType()); // ERROR\n" + >- " \n" + >- " /*we can make lists of super type this way though*/\n" + >- " makeSingletonList2(new SuperType()); // (eclipse doesn\'t like this though)\n" + >- " /*also ok if we assign the return value*/\n" + >- " lsup = makeSingletonList2(new SuperType());\n" + >+ " makeSingletonList(new SuperType()); // #1 - OK\n" + >+ " List<SuperType> lsup = makeSingletonList(new SuperType()); // #2 - OK\n" + >+ " List<SubType> lsub = makeSingletonList(new SubType()); // #3 - ERROR\n" + >+ " makeSingletonList(new SubType()); // #4 - ERROR\n" + >+ " makeSingletonList2(new SubType()); // #5 - ERROR\n" + >+ " lsup = makeSingletonList2(new SubType()); // #6 - OK\n" + >+ " lsub = makeSingletonList2(new SubType()); // #7 - ERROR\n" + >+ " makeSingletonList2(new SuperType()); // #8 - OK\n" + >+ " lsup = makeSingletonList2(new SuperType()); // #9 - OK\n" + > " }\n" + > "}\n" > }, > "----------\n" + >- "1. ERROR in X.java (at line 40)\n" + >- " List<SubType> lsub = makeSingletonList(new SubType()); //ERROR\n" + >+ "1. ERROR in X.java (at line 24)\n" + >+ " List<SubType> lsub = makeSingletonList(new SubType()); // #3 - ERROR\n" + > " ^^^^^^^^^^^^^^^^^\n" + > "Bound mismatch: The generic method makeSingletonList(T) of type X is not applicable for the arguments (X.SubType) since the type X.SubType is not a valid substitute for the bounded parameter <T extends X.SelfType<T>>\n" + > "----------\n" + >- "2. ERROR in X.java (at line 43)\n" + >- " makeSingletonList(new SubType()); //ERROR\n" + >+ "2. ERROR in X.java (at line 25)\n" + >+ " makeSingletonList(new SubType()); // #4 - ERROR\n" + > " ^^^^^^^^^^^^^^^^^\n" + > "Bound mismatch: The generic method makeSingletonList(T) of type X is not applicable for the arguments (X.SubType) since the type X.SubType is not a valid substitute for the bounded parameter <T extends X.SelfType<T>>\n" + > "----------\n" + >- "3. ERROR in X.java (at line 47)\n" + >- " makeSingletonList2(new SubType()); //ERROR\n" + >+ "3. ERROR in X.java (at line 26)\n" + >+ " makeSingletonList2(new SubType()); // #5 - ERROR\n" + > " ^^^^^^^^^^^^^^^^^^\n" + > "Bound mismatch: The generic method makeSingletonList2(S) of type X is not applicable for the arguments (X.SubType) since the type X.SubType is not a valid substitute for the bounded parameter <T extends X.SelfType<T>>\n" + > "----------\n" + >- "4. ERROR in X.java (at line 51)\n" + >- " lsub = makeSingletonList2(new SubType()); // ERROR\n" + >+ "4. ERROR in X.java (at line 28)\n" + >+ " lsub = makeSingletonList2(new SubType()); // #7 - ERROR\n" + > " ^^^^^^^^^^^^^^^^^^\n" + > "Bound mismatch: The generic method makeSingletonList2(S) of type X is not applicable for the arguments (X.SubType) since the type X.SubType is not a valid substitute for the bounded parameter <T extends X.SelfType<T>>\n" + > "----------\n"); >@@ -22010,5 +21984,99 @@ > }, > ""); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100527 >+public void test764() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ " \n" + >+ "interface IIfClosure {}\n" + >+ " \n" + >+ "public class X {\n" + >+ " public X(String label, HashMap<String,Object> bindings) {\n" + >+ " this(label, bindings, (List<IIfClosure>)Collections.emptyList());\n" + >+ " }\n" + >+ " \n" + >+ " public X(String label, HashMap<String,Object> bindings, Collection<IIfClosure> coll) {\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\r\n" + >+ " this(label, bindings, (List<IIfClosure>)Collections.emptyList());\r\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from List<Object> to List<IIfClosure>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=98379 >+public void test765() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " static <T extends X> T f1() throws Exception{\n" + >+ " return null;\n" + >+ " }\n" + >+ " static <U extends X> U f2() throws Exception {\n" + >+ " return f1();\n" + >+ " }\n" + >+ "}\n", >+ }, >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99453 >+public void test766() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ "\n" + >+ "interface Cloneable<T extends Cloneable<T>> {\n" + >+ " public T clone();\n" + >+ "}\n" + >+ "\n" + >+ "interface CloneableMap<K, V extends Cloneable<V>> extends Map<K, V>, Cloneable<CloneableMap<K, V>> {\n" + >+ "}\n" + >+ "\n" + >+ "interface C<T extends C<T>> extends Cloneable<T> {\n" + >+ "}\n" + >+ "public class X {\n" + >+ " void foo() {\n" + >+ " CloneableMap<String, C<?>> map = null;\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 14)\n" + >+ " CloneableMap<String, C<?>> map = null;\n" + >+ " ^\n" + >+ "Bound mismatch: The type C<?> is not a valid substitute for the bounded parameter <V extends Cloneable<V>> of the type CloneableMap<K,V>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99453 - variation >+public void test767() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ "\n" + >+ "interface Cloneable<T extends Cloneable<T>> {\n" + >+ " public T clone();\n" + >+ "}\n" + >+ "\n" + >+ "interface CloneableMap<K, V extends Cloneable<V>> extends Map<K, V>, Cloneable<CloneableMap<K, V>> {\n" + >+ "}\n" + >+ "\n" + >+ "interface C extends Cloneable<C> {\n" + >+ "}\n" + >+ "public class X {\n" + >+ " void foo() {\n" + >+ " CloneableMap<String, C> map = null;\n" + >+ " }\n" + >+ "}\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 98538
:
22429
|
23536
| 23598