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 181354 Details for
Bug 282152
[1.5][compiler] Generics code rejected by Eclipse but accepted by javac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revised patch
patch.txt (text/plain), 7.17 KB, created by
Srikanth Sankaran
on 2010-10-21 00:41:31 EDT
(
hide
)
Description:
Revised patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-10-21 00:41:31 EDT
Size:
7.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java,v >retrieving revision 1.74 >diff -u -r1.74 TypeVariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 14 May 2009 14:50:31 -0000 1.74 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 21 Oct 2010 04:39:54 -0000 >@@ -114,6 +114,9 @@ > break; > > case Wildcard.SUPER : >+ // if the wildcard is lower-bounded by a type variable that has no relevant upper bound there's nothing to check here (bug 282152): >+ if (wildcard.bound.isTypeVariable() && ((TypeVariableBinding)wildcard.bound).superclass.id == TypeIds.T_JavaLangObject) >+ break; > return boundCheck(substitution, wildcard.bound); > > case Wildcard.UNBOUND : >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericsRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 6 Sep 2010 03:26:04 -0000 1.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 21 Oct 2010 04:39:57 -0000 >@@ -379,4 +379,138 @@ > "Incompatible operand types Class<X> and Class<I>\n" + > "----------\n"); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 >+public void test282152() { >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public interface Test<T extends Number> {\n" + >+ " public <U> void test(Test<? super U> t, U value);\n" + >+ " public void setValue(T v);" + >+ "}", >+ "Impl.java", >+ "public class Impl<T extends Number> implements Test<T>{\n" + >+ " T val;" + >+ " public <U> void test(Test<? super U> t, U value) {\n" + >+ " t.setValue(value);\n" + >+ " }\n" + >+ " public void setValue(T v) {\n" + >+ " this.val = v;\n" + >+ " }\n" + >+ "}", >+ "Client.java", >+ "public class Client {\n" + >+ " void test() {\n" + >+ " Impl<Integer> t1 = new Impl<Integer>();\n" + >+ " Double n = Double.valueOf(3.14);\n" + >+ " t1.test(new Impl<Number>(), n);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ ""); // no specific success output string >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 >+// violating lower bound >+public void test282152b() { >+ this.runNegativeTest( >+ new String[] { >+ "Test.java", >+ "public interface Test<T extends Number> {\n" + >+ " public <U> void test(Test<? super U> t, U value);\n" + >+ " public void setValue(T v);" + >+ "}", >+ "Impl.java", >+ "public class Impl<T extends Number> implements Test<T>{\n" + >+ " T val;" + >+ " public <U> void test(Test<? super U> t, U value) {\n" + >+ " t.setValue(value);\n" + >+ " }\n" + >+ " public void setValue(T v) {\n" + >+ " this.val = v;\n" + >+ " }\n" + >+ "}", >+ "Client.java", >+ "public class Client {\n" + >+ " void test() {\n" + >+ " Impl<Integer> t1 = new Impl<Integer>();\n" + >+ " Number n = Double.valueOf(3.14);\n" + >+ " t1.test(new Impl<Double>(), n);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in Client.java (at line 5)\n" + >+ " t1.test(new Impl<Double>(), n);\n" + >+ " ^^^^\n" + >+ "The method test(Test<? super U>, U) in the type Impl<Integer> is not applicable for the arguments (Impl<Double>, Number)\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 >+// contradictory bounds >+public void test282152c() { >+ this.runNegativeTest( >+ new String[] { >+ "Test.java", >+ "public interface Test<T extends Number> {\n" + >+ " public <U extends Exception> void test(Test<? super U> t, U value);\n" + >+ " public void setValue(T v);" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in Test.java (at line 2)\n" + >+ " public <U extends Exception> void test(Test<? super U> t, U value);\n" + >+ " ^^^^^^^^^\n" + >+ "Bound mismatch: The type ? super U is not a valid substitute for the bounded parameter <T extends Number> of the type Test<T>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 >+// compatible constraints >+public void test282152d() { >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public interface Test<T extends Number> {\n" + >+ " public <U extends Integer> void test(Test<? super U> t, U value);\n" + >+ " public void setValue(T v);" + >+ "}", >+ "Impl.java", >+ "public class Impl<T extends Number> implements Test<T>{\n" + >+ " T val;" + >+ " public <U extends Integer> void test(Test<? super U> t, U value) {\n" + >+ " t.setValue(value);\n" + >+ " }\n" + >+ " public void setValue(T v) {\n" + >+ " this.val = v;\n" + >+ " }\n" + >+ "}", >+ "Client.java", >+ "public class Client {\n" + >+ " void test() {\n" + >+ " Impl<Integer> t1 = new Impl<Integer>();\n" + >+ " Integer i = Integer.valueOf(3);\n" + >+ " t1.test(new Impl<Integer>(), i);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ ""); // no specific success output string >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 >+// direct use of type variable does not involve capture, thus no merging of constraints happens >+public void test282152e() { >+ this.runNegativeTest( >+ new String[] { >+ "Test.java", >+ "public interface Test<T extends Number> {\n" + >+ " public <U> void test(Test<U> t, U value);\n" + >+ " public void setValue(T v);" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in Test.java (at line 2)\n" + >+ " public <U> void test(Test<U> t, U value);\n" + >+ " ^\n" + >+ "Bound mismatch: The type U is not a valid substitute for the bounded parameter <T extends Number> of the type Test<T>\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 282152
:
172848
|
181354
|
181619