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 40256 Details for
Bug 139931
[1.5][compiler] Unnecessary cast warning and varargs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Regression test
patch_139931_tests.txt (text/plain), 5.67 KB, created by
Olivier Thomann
on 2006-05-03 12:37:05 EDT
(
hide
)
Description:
Regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-05-03 12:37:05 EDT
Size:
5.67 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java,v >retrieving revision 1.42 >diff -u -r1.42 VarargsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java 31 Mar 2006 22:14:20 -0000 1.42 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java 3 May 2006 16:35:44 -0000 >@@ -10,6 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >+import java.util.Map; >+ >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+ > import junit.framework.Test; > > public class VarargsTest extends AbstractComparableTest { >@@ -22,7 +26,7 @@ > // All specified tests which does not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test000" }; >-// TESTS_NUMBERS = new int[] { 30 }; >+// TESTS_NUMBERS = new int[] { 47 }; > // TESTS_RANGE = new int[] { 11, -1 }; > } > public static Test suite() { >@@ -1042,8 +1046,8 @@ > "}\n", > }, > "----------\n" + >- "1. ERROR in X.java (at line 2)\r\n" + >- " transient private X() {}\r\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " transient private X() {}\n" + > " ^^^\n" + > "Illegal modifier for the method X.X()\n" + > "----------\n" >@@ -1249,23 +1253,23 @@ > "}\n", > }, > "----------\n" + >- "1. ERROR in X.java (at line 8)\r\n" + >- " x.b(true);\r\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " x.b(true);\n" + > " ^\n" + > "The method b(boolean, Object[]) is ambiguous for the type X\n" + > "----------\n" + >- "2. ERROR in X.java (at line 9)\r\n" + >- " x.b(true, false);\r\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " x.b(true, false);\n" + > " ^\n" + > "The method b(boolean, Object[]) is ambiguous for the type X\n" + > "----------\n" + >- "3. ERROR in X.java (at line 10)\r\n" + >- " x.c(true, true, true);\r\n" + >+ "3. ERROR in X.java (at line 10)\n" + >+ " x.c(true, true, true);\n" + > " ^\n" + > "The method c(boolean, boolean, Object[]) is ambiguous for the type X\n" + > "----------\n" + >- "4. ERROR in X.java (at line 11)\r\n" + >- " x.c(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);\r\n" + >+ "4. ERROR in X.java (at line 11)\n" + >+ " x.c(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);\n" + > " ^\n" + > "The method c(boolean, boolean, Object[]) is ambiguous for the type X\n" + > "----------\n" >@@ -1362,18 +1366,18 @@ > "}\n", > }, > "----------\n" + >- "1. ERROR in V.java (at line 4)\r\n" + >- " v.foo2(null, \"\");\r\n" + >+ "1. ERROR in V.java (at line 4)\n" + >+ " v.foo2(null, \"\");\n" + > " ^^^^\n" + > "The method foo2(String, Object[]) is ambiguous for the type V\n" + > "----------\n" + >- "2. ERROR in V.java (at line 5)\r\n" + >- " v.foo2(null, \"\", \"\");\r\n" + >+ "2. ERROR in V.java (at line 5)\n" + >+ " v.foo2(null, \"\", \"\");\n" + > " ^^^^\n" + > "The method foo2(String, Object[]) is ambiguous for the type V\n" + > "----------\n" + >- "3. ERROR in V.java (at line 6)\r\n" + >- " v.foo3(\"\", v, null, \"\");\r\n" + >+ "3. ERROR in V.java (at line 6)\n" + >+ " v.foo3(\"\", v, null, \"\");\n" + > " ^^^^\n" + > "The method foo3(String, V, String[]) is ambiguous for the type V\n" + > "----------\n"); >@@ -1603,13 +1607,13 @@ > "}\n", > }, > "----------\n" + >- "1. WARNING in X.java (at line 10)\r\n" + >- " array((Serializable[]) new Serializable[] {3, 4}); //warns about unnecessary cast\r\n" + >+ "1. WARNING in X.java (at line 10)\n" + >+ " array((Serializable[]) new Serializable[] {3, 4}); //warns about unnecessary cast\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + > "Unnecessary cast from Serializable[] to Serializable[]\n" + > "----------\n" + >- "2. ERROR in X.java (at line 14)\r\n" + >- " Zork z;\r\n" + >+ "2. ERROR in X.java (at line 14)\n" + >+ " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + > "----------\n"); >@@ -1639,5 +1643,37 @@ > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + > "----------\n"); >- } >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=139931 >+ public void test047() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportVarargsArgumentNeedCast, CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " Y<?> [] foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " void bar(Y... y) {\n" + >+ " }\n" + >+ " void fred() {\n" + >+ " bar(foo());\n" + >+ " bar((Y[])foo());\n" + >+ " }\n" + >+ "}\n" + >+ "class Y<E> {\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " bar(foo());\n" + >+ " ^^^^^^^^^^\n" + >+ "The argument of type Y<?>[] should explicitly be cast to Y[] for the invocation of the varargs method bar(Y...) from type X. It could alternatively be cast to Y for a varargs invocation\n" + >+ "----------\n", >+ null, >+ true, >+ customOptions); >+ } > }
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 139931
:
40256
|
40311
|
40688