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 191198 Details for
Bug 338011
COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS wrongly suppresses constructor parameter type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch under consideration
patch.txt (text/plain), 15.09 KB, created by
Srikanth Sankaran
on 2011-03-15 05:13:37 EDT
(
hide
)
Description:
Patch under consideration
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-03-15 05:13:37 EDT
Size:
15.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.187 >diff -u -r1.187 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 21 Jan 2011 07:16:33 -0000 1.187 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 15 Mar 2011 09:13:10 -0000 >@@ -1395,7 +1395,7 @@ > method.tagBits |= TagBits.HasParameterAnnotations; > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 >- boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; >+ boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && !method.isConstructor() && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; > TypeBinding parameterType; > if (deferRawTypeCheck) { > arg.type.bits |= ASTNode.IgnoreRawTypeCheck; >#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.8 >diff -u -r1.8 GenericsRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 15 Mar 2011 05:44:19 -0000 1.8 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 15 Mar 2011 09:13:23 -0000 >@@ -1460,4 +1460,284 @@ > compilerOptions15, > null); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 >+public void test337962() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.List;\n" + >+ "import java.util.ArrayList;\n" + >+ "class Super {\n" + >+ " protected List fList;\n" + >+ "}\n" + >+ "public class X extends Super {\n" + >+ " protected List fSubList; // raw type warning (good)\n" + >+ " {\n" + >+ " fSubList = new ArrayList();\n " + >+ " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ " void foo(String s) {\n" + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ " X(String s) {\n" + >+ " fSubList = new ArrayList();\n " + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " protected List fList;\n" + >+ " ^^^^\n" + >+ "List is a raw type. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " protected List fSubList; // raw type warning (good)\n" + >+ " ^^^^\n" + >+ "List is a raw type. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " fSubList = new ArrayList();\n" + >+ " ^^^^^^^^^\n" + >+ "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 10)\n" + >+ " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 11)\n" + >+ " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 12)\n" + >+ " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "7. WARNING in X.java (at line 15)\n" + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "8. WARNING in X.java (at line 16)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "9. WARNING in X.java (at line 17)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "10. WARNING in X.java (at line 20)\n" + >+ " fSubList = new ArrayList();\n" + >+ " ^^^^^^^^^\n" + >+ "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + >+ "----------\n" + >+ "11. WARNING in X.java (at line 21)\n" + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "12. WARNING in X.java (at line 22)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "13. WARNING in X.java (at line 23)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions15, >+ null); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 >+public void test337962b() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.List;\n" + >+ "import java.util.ArrayList;\n" + >+ "class Super {\n" + >+ " protected List fList;\n" + >+ "}\n" + >+ "public class X extends Super {\n" + >+ " protected List fSubList; // raw type warning (good)\n" + >+ " {\n" + >+ " fSubList = new ArrayList();\n " + >+ " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ " void foo(String s) {\n" + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ " X(String s) {\n" + >+ " fSubList = new ArrayList();\n " + >+ " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " protected List fList;\n" + >+ " ^^^^\n" + >+ "List is a raw type. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " protected List fSubList; // raw type warning (good)\n" + >+ " ^^^^\n" + >+ "List is a raw type. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " fSubList = new ArrayList();\n" + >+ " ^^^^^^^^^\n" + >+ "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 12)\n" + >+ " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 17)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 20)\n" + >+ " fSubList = new ArrayList();\n" + >+ " ^^^^^^^^^\n" + >+ "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + >+ "----------\n" + >+ "7. WARNING in X.java (at line 23)\n" + >+ " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions15, >+ null); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 >+public void test338011() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ "public class X extends A {\n" + >+ " public X(Map m) { // should warn about raw type m\n" + >+ " super(m);\n" + >+ " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + >+ " }\n" + >+ " public X(Map<String, Integer> m, boolean b) {\n" + >+ " super(m); // shows that parametrizing the parameter type is no problem \n" + >+ " new A(m);\n" + >+ " m.put(\"one\", 1);\n" + >+ " }\n" + >+ "}\n" + >+ "class A {\n" + >+ " public A (Map m) {\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public X(Map m) { // should warn about raw type m\n" + >+ " ^^^\n" + >+ "Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 14)\n" + >+ " public A (Map m) {\n" + >+ " ^^^\n" + >+ "Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions15, >+ null); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 >+public void test338011b() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ "public class X extends A {\n" + >+ " public X(Map m) { // should warn about raw type m\n" + >+ " super(m);\n" + >+ " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + >+ " }\n" + >+ " public X(Map<String, Integer> m, boolean b) {\n" + >+ " super(m); // shows that parametrizing the parameter type is no problem \n" + >+ " new A(m);\n" + >+ " m.put(\"one\", 1);\n" + >+ " }\n" + >+ "}\n" + >+ "class A {\n" + >+ " public A (Map m) {\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public X(Map m) { // should warn about raw type m\n" + >+ " ^^^\n" + >+ "Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 14)\n" + >+ " public A (Map m) {\n" + >+ " ^^^\n" + >+ "Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions15, >+ null); >+} > } >\ 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 338011
: 191198