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 125658 Details for
Bug 264843
[1.5][compiler] Eclipse compiler fails to reject invalid code with primitives autoboxed to generics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and testcase
patch.txt (text/plain), 4.58 KB, created by
Kent Johnson
on 2009-02-13 11:41:18 EST
(
hide
)
Description:
Proposed patch and testcase
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-02-13 11:41:18 EST
Size:
4.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java,v >retrieving revision 1.64 >diff -u -r1.64 ReturnStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java 14 Oct 2008 16:04:56 -0000 1.64 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java 13 Feb 2009 16:40:22 -0000 >@@ -245,6 +245,7 @@ > || (expressionType.isBaseType() // narrowing then boxing ? > && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5 // autoboxing > && !methodType.isBaseType() >+ && !methodType.isTypeVariable() > && this.expression.isConstantValueOfTypeAssignableToType(expressionType, scope.environment().computeBoxingType(methodType)))) { > this.expression.computeConversion(scope, methodType, expressionType); > if (this.expression instanceof CastExpression >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java,v >retrieving revision 1.120 >diff -u -r1.120 AutoBoxingTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java 2 Dec 2008 10:03:08 -0000 1.120 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java 13 Feb 2009 16:40:25 -0000 >@@ -5043,4 +5043,63 @@ > "The expression of type Integer is unboxed into int\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=264843 >+public void test168() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " <T extends Integer> T a() { return 35; }\n" + >+ " <T extends Integer> T[] b() { return new int[]{35}; }\n" + >+ " <T extends Integer> T c() { return new Integer(35); }\n" + >+ " <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " <T extends Integer> T a() { return 35; }\n" + >+ " ^^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + >+ " <T extends Integer> T a() { return 35; }\n" + >+ " ^^\n" + >+ "Type mismatch: cannot convert from int to T\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 3)\n" + >+ " <T extends Integer> T[] b() { return new int[]{35}; }\n" + >+ " ^^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 3)\n" + >+ " <T extends Integer> T[] b() { return new int[]{35}; }\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from int[] to T[]\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 4)\n" + >+ " <T extends Integer> T c() { return new Integer(35); }\n" + >+ " ^^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 4)\n" + >+ " <T extends Integer> T c() { return new Integer(35); }\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from Integer to T\n" + >+ "----------\n" + >+ "7. WARNING in X.java (at line 5)\n" + >+ " <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + >+ " ^^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n" + >+ "8. ERROR in X.java (at line 5)\n" + >+ " <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from Integer[] to T[]\n" + >+ "----------\n" + >+ "9. WARNING in X.java (at line 5)\n" + >+ " <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + >+ " ^^\n" + >+ "The expression of type int is boxed into Integer\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 264843
: 125658 |
125920
|
125935