### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v retrieving revision 1.81 diff -u -r1.81 BatchASTCreationTests.java --- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 27 Jun 2008 16:02:37 -0000 1.81 +++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 7 Jan 2009 16:10:50 -0000 @@ -1404,11 +1404,41 @@ "class W extends Z {\n" + "}", }, - "Lp1/X;.foo;>(Lp1/Z;)V%<>" + "Lp1/X;.foo;>(Lp1/Z;)V%;>;>" ); } /* + * Ensures that a raw method binding can be created using its key in batch creation. + * (regression test for bug 87749 different IMethodBindings of generic method have equal getKey()) + */ + public void test063a() throws CoreException { + assertRequestedBindingFound( + new String[] { + "/P/p1/X.java", + "package p1;\n" + + "public class X> {\n" + + " public void foo(Z z) {\n" + + " }\n" + + " /**\n" + + " * @see #foo(Z)\n" + + " */\n" + + " static void bar(X x) {\n" + + " /*start*/x.foo(new W())/*end*/;\n" + + " }\n" + + "}\n" + + "class Y {\n" + + "}\n" + + "class Z {\n" + + "}\n" + + "class W extends Z {\n" + + "}", + }, + "Lp1/X<>;.foo(Lp1/Z;)V" + ); + } + + /* * Ensures that a parameterized type binding with a capture binding in its arguments can be created using its key in batch creation. * (regression test for bug 94092 ASTParser#createASTs(..) restores wrong bindings from capture keys) */ #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java,v retrieving revision 1.40 diff -u -r1.40 JavadocTest_1_5.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java 27 Jun 2008 16:04:44 -0000 1.40 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java 7 Jan 2009 16:10:59 -0000 @@ -1883,7 +1883,7 @@ } ); } - public void testBug95521b() { + public void testONLY_Bug95521b() { runConformTest( new String[] { "test/X.java", Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.780 diff -u -r1.780 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 15 Dec 2008 11:11:54 -0000 1.780 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 7 Jan 2009 16:10:59 -0000 @@ -13989,21 +13989,21 @@ " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + - "----------\n" + - "2. WARNING in X.java (at line 16)\n" + - " return m_manager.getById(getClass(), new Integer(1));\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation getById(Class, Integer) of the generic method getById(Class, Integer) of type Test.Manager\n" + - "----------\n" + - "3. WARNING in X.java (at line 16)\n" + - " return m_manager.getById(getClass(), new Integer(1));\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type capture#1-of ? extends Test needs unchecked conversion to conform to ITest\n" + + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. WARNING in X.java (at line 16)\n" + + " return m_manager.getById(getClass(), new Integer(1));\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation getById(Class, Integer) of the generic method getById(Class, Integer) of type Test.Manager\n" + + "----------\n" + + "3. WARNING in X.java (at line 16)\n" + + " return m_manager.getById(getClass(), new Integer(1));\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type ITest needs unchecked conversion to conform to ITest\n" + "----------\n"); } @@ -15121,21 +15121,26 @@ " }\n" + "}\n" }, - "----------\n" + - "1. WARNING in X.java (at line 8)\n" + - " take(new A());\n" + - " ^^^^^^^\n" + - "Type safety: The expression of type Super.A needs unchecked conversion to conform to Super.A\n" + - "----------\n" + - "2. WARNING in X.java (at line 8)\n" + - " take(new A());\n" + - " ^\n" + - "Super.A is a raw type. References to generic type Super.A should be parameterized\n" + - "----------\n" + - "3. ERROR in X.java (at line 14)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 8)\n" + + " take(new A());\n" + + " ^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation take(Super.A) of the generic method take(Super.A) of type Super\n" + + "----------\n" + + "2. WARNING in X.java (at line 8)\n" + + " take(new A());\n" + + " ^^^^^^^\n" + + "Type safety: The expression of type Super.A needs unchecked conversion to conform to Super.A\n" + + "----------\n" + + "3. WARNING in X.java (at line 8)\n" + + " take(new A());\n" + + " ^\n" + + "Super.A is a raw type. References to generic type Super.A should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 14)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } @@ -15734,81 +15739,81 @@ " Zork z;\n" + "}\n" }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " public void test(List list,final Comparator comparator, X x) {\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 6)\n" + - " public void test(List list,final Comparator comparator, X x) {\n" + - " ^^^^^^^^^^\n" + - "Comparator is a raw type. References to generic type Comparator should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 6)\n" + - " public void test(List list,final Comparator comparator, X x) {\n" + - " ^\n" + - "X is a raw type. References to generic type X should be parameterized\n" + - "----------\n" + - "4. WARNING in X.java (at line 7)\n" + - " foo(list, comparator);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation foo(List, Comparator) of the generic method foo(List, Comparator) of type X\n" + - "----------\n" + - "5. WARNING in X.java (at line 7)\n" + - " foo(list, comparator);\n" + - " ^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "6. WARNING in X.java (at line 7)\n" + - " foo(list, comparator);\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + - "----------\n" + - "7. WARNING in X.java (at line 8)\n" + - " bar(list, comparator);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, Comparator) of the generic method bar(List, Comparator) of type X\n" + - "----------\n" + - "8. WARNING in X.java (at line 8)\n" + - " bar(list, comparator);\n" + - " ^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "9. WARNING in X.java (at line 8)\n" + - " bar(list, comparator);\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + - "----------\n" + - "10. WARNING in X.java (at line 10)\n" + - " x.foo(list, comparator);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: The method foo(List, Comparator) belongs to the raw type X. References to generic type X should be parameterized\n" + - "----------\n" + - "11. WARNING in X.java (at line 11)\n" + - " x.bar(list, comparator);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^\n" + - "The static method bar(List, Comparator) from the type X should be accessed in a static way\n" + - "----------\n" + - "12. WARNING in X.java (at line 11)\n" + - " x.bar(list, comparator);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, Comparator) of the generic method bar(List, Comparator) of type X\n" + - "----------\n" + - "13. WARNING in X.java (at line 11)\n" + - " x.bar(list, comparator);\n" + - " ^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "14. WARNING in X.java (at line 11)\n" + - " x.bar(list, comparator);\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + - "----------\n" + - "15. ERROR in X.java (at line 18)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " public void test(List list,final Comparator comparator, X x) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " public void test(List list,final Comparator comparator, X x) {\n" + + " ^^^^^^^^^^\n" + + "Comparator is a raw type. References to generic type Comparator should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " public void test(List list,final Comparator comparator, X x) {\n" + + " ^\n" + + "X is a raw type. References to generic type X should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " foo(list, comparator);\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation foo(List, Comparator) of the generic method foo(List, Comparator) of type X\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " foo(list, comparator);\n" + + " ^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "6. WARNING in X.java (at line 7)\n" + + " foo(list, comparator);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " bar(list, comparator);\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, Comparator) of the generic method bar(List, Comparator) of type X\n" + + "----------\n" + + "8. WARNING in X.java (at line 8)\n" + + " bar(list, comparator);\n" + + " ^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "9. WARNING in X.java (at line 8)\n" + + " bar(list, comparator);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + + "----------\n" + + "10. WARNING in X.java (at line 10)\n" + + " x.foo(list, comparator);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method foo(List, Comparator) belongs to the raw type X. References to generic type X should be parameterized\n" + + "----------\n" + + "11. WARNING in X.java (at line 11)\n" + + " x.bar(list, comparator);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The static method bar(List, Comparator) from the type X should be accessed in a static way\n" + + "----------\n" + + "12. WARNING in X.java (at line 11)\n" + + " x.bar(list, comparator);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, Comparator) of the generic method bar(List, Comparator) of type X\n" + + "----------\n" + + "13. WARNING in X.java (at line 11)\n" + + " x.bar(list, comparator);\n" + + " ^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "14. WARNING in X.java (at line 11)\n" + + " x.bar(list, comparator);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator\n" + + "----------\n" + + "15. ERROR in X.java (at line 18)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } // array bound for wildcard @@ -16653,36 +16658,36 @@ " }\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 9)\n" + - " Class c = Foo.class;\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^^^^\n" + - "Enum is a raw type. References to generic type Enum should be parameterized\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^^^^\n" + - "Bound mismatch: The type Enum is not a valid substitute for the bounded parameter > of the type EnumSet\n" + - "----------\n" + - "4. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + - "----------\n" + - "5. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type EnumSet needs unchecked conversion to conform to EnumSet\n" + - "----------\n" + - "6. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^\n" + - "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Class c = Foo.class;\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^^^^\n" + + "Enum is a raw type. References to generic type Enum should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^^^^\n" + + "Bound mismatch: The type Enum is not a valid substitute for the bounded parameter > of the type EnumSet\n" + + "----------\n" + + "4. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + + "----------\n" + + "5. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type EnumSet needs unchecked conversion to conform to EnumSet\n" + + "----------\n" + + "6. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=86838 - variation @@ -16729,7 +16734,7 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=86838 - variation public void test0536() { - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "import java.util.EnumSet;\n" + @@ -16741,11 +16746,37 @@ "public class X {\n" + " public static void main(String[] args) {\n" + " Class c = Foo.class;\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + + " EnumSet eSet = (EnumSet) EnumSet.allOf(c);\n" + " }\n" + + " Zork z;\n" + "}\n", }, - "" + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Class c = Foo.class;\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = (EnumSet) EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unnecessary cast from EnumSet to EnumSet\n" + + "----------\n" + + "3. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = (EnumSet) EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + + "----------\n" + + "4. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = (EnumSet) EnumSet.allOf(c);\n" + + " ^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class>>\n" + + "----------\n" + + "5. ERROR in X.java (at line 12)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=86838 - variation @@ -16767,26 +16798,26 @@ " Zork z;\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 9)\n" + - " Class c = Foo.class;\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + - "----------\n" + - "3. WARNING in X.java (at line 10)\n" + - " EnumSet eSet = EnumSet.allOf(c);\n" + - " ^\n" + - "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + - "----------\n" + - "4. ERROR in X.java (at line 12)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Class c = Foo.class;\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + + "----------\n" + + "3. WARNING in X.java (at line 10)\n" + + " EnumSet eSet = EnumSet.allOf(c);\n" + + " ^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class>>\n" + + "----------\n" + + "4. ERROR in X.java (at line 12)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=86838 - variation @@ -16807,31 +16838,31 @@ " }\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 9)\n" + - " Class c = Foo.class;\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + - "2. ERROR in X.java (at line 10)\n" + - " EnumSet> eSet = EnumSet.allOf(c);\n" + - " ^^^^\n" + - "Bound mismatch: The type Enum is not a valid substitute for the bounded parameter > of the type EnumSet\n" + - "----------\n" + - "3. WARNING in X.java (at line 10)\n" + - " EnumSet> eSet = EnumSet.allOf(c);\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + - "----------\n" + - "4. WARNING in X.java (at line 10)\n" + - " EnumSet> eSet = EnumSet.allOf(c);\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type EnumSet needs unchecked conversion to conform to EnumSet>\n" + - "----------\n" + - "5. WARNING in X.java (at line 10)\n" + - " EnumSet> eSet = EnumSet.allOf(c);\n" + - " ^\n" + - "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Class c = Foo.class;\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 10)\n" + + " EnumSet> eSet = EnumSet.allOf(c);\n" + + " ^^^^\n" + + "Bound mismatch: The type Enum is not a valid substitute for the bounded parameter > of the type EnumSet\n" + + "----------\n" + + "3. WARNING in X.java (at line 10)\n" + + " EnumSet> eSet = EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type EnumSet\n" + + "----------\n" + + "4. WARNING in X.java (at line 10)\n" + + " EnumSet> eSet = EnumSet.allOf(c);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type EnumSet needs unchecked conversion to conform to EnumSet>\n" + + "----------\n" + + "5. WARNING in X.java (at line 10)\n" + + " EnumSet> eSet = EnumSet.allOf(c);\n" + + " ^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class>\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=86838 - variation @@ -18874,21 +18905,21 @@ " Zork z;\n" + "}\n", }, - "----------\n" + - "1. WARNING in Ball.java (at line 2)\n" + - " class Ball implements Comparable {\n" + - " ^^^^^^^^^^\n" + - "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + - "----------\n" + - "2. WARNING in Ball.java (at line 10)\n" + - " Collections.sort(foo);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation sort(List) of the generic method sort(List) of type Collections\n" + - "----------\n" + - "3. ERROR in Ball.java (at line 12)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in Ball.java (at line 2)\n" + + " class Ball implements Comparable {\n" + + " ^^^^^^^^^^\n" + + "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + + "----------\n" + + "2. WARNING in Ball.java (at line 10)\n" + + " Collections.sort(foo);\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation sort(LinkedList) of the generic method sort(List) of type Collections\n" + + "----------\n" + + "3. ERROR in Ball.java (at line 12)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=81831 @@ -22751,36 +22782,36 @@ " Zork z;\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 13)\n" + - " public class ActionImpl extends Action implements Comparable {\n" + - " ^^^^^^^^^^\n" + - "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 14)\n" + - " public int compareTo(ActionImpl o) {\n" + - " ^^^^^^^^^^\n" + - "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 20)\n" + - " Set set = new TreeSet();\n" + - " ^^^^^^^^^^\n" + - "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + - "----------\n" + - "4. WARNING in X.java (at line 20)\n" + - " Set set = new TreeSet();\n" + - " ^^^^^^^^^^\n" + - "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + - "----------\n" + - "5. WARNING in X.java (at line 21)\n" + - " Collections.max(set);\n" + - " ^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation max(Collection) of the generic method max(Collection) of type Collections\n" + - "----------\n" + - "6. ERROR in X.java (at line 23)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 13)\n" + + " public class ActionImpl extends Action implements Comparable {\n" + + " ^^^^^^^^^^\n" + + "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 14)\n" + + " public int compareTo(ActionImpl o) {\n" + + " ^^^^^^^^^^\n" + + "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 20)\n" + + " Set set = new TreeSet();\n" + + " ^^^^^^^^^^\n" + + "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 20)\n" + + " Set set = new TreeSet();\n" + + " ^^^^^^^^^^\n" + + "X.ActionImpl is a raw type. References to generic type X.ActionImpl should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 21)\n" + + " Collections.max(set);\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation max(Set) of the generic method max(Collection) of type Collections\n" + + "----------\n" + + "6. ERROR in X.java (at line 23)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=98364 @@ -27607,36 +27638,36 @@ "\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 20)\n" + - " List o = Foo.foo1();\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "2. ERROR in X.java (at line 20)\n" + - " List o = Foo.foo1();\n" + - " ^^^^\n" + - "The method foo1() in the type Foo is not applicable for the arguments ()\n" + - "----------\n" + - "3. ERROR in X.java (at line 21)\n" + - " Foo.bar1(o);\n" + - " ^^^^\n" + - "The method bar1(List>) in the type Foo is not applicable for the arguments (List)\n" + - "----------\n" + - "4. WARNING in X.java (at line 24)\n" + - " List o = Foo.foo2();\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "5. WARNING in X.java (at line 25)\n" + - " Foo.bar2(o);\n" + - " ^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar2(List) of the generic method bar2(List) of type Foo\n" + - "----------\n" + - "6. WARNING in X.java (at line 25)\n" + - " Foo.bar2(o);\n" + - " ^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "1. WARNING in X.java (at line 20)\n" + + " List o = Foo.foo1();\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 20)\n" + + " List o = Foo.foo1();\n" + + " ^^^^\n" + + "The method foo1() in the type Foo is not applicable for the arguments ()\n" + + "----------\n" + + "3. ERROR in X.java (at line 21)\n" + + " Foo.bar1(o);\n" + + " ^^^^\n" + + "The method bar1(List>) in the type Foo is not applicable for the arguments (List)\n" + + "----------\n" + + "4. WARNING in X.java (at line 24)\n" + + " List o = Foo.foo2();\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 25)\n" + + " Foo.bar2(o);\n" + + " ^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar2(List) of the generic method bar2(List) of type Foo\n" + + "----------\n" + + "6. WARNING in X.java (at line 25)\n" + + " Foo.bar2(o);\n" + + " ^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=114365 @@ -28272,21 +28303,21 @@ " }\n" + "}\n" , }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " String s = getClass();\n" + - " ^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Class to String\n" + - "----------\n" + - "2. ERROR in X.java (at line 8)\n" + - " return (String) getDefault(getClass());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot cast from capture#2-of ? extends X to String\n" + - "----------\n" + - "3. WARNING in X.java (at line 8)\n" + - " return (String) getDefault(getClass());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation getDefault(Class) of the generic method getDefault(Class) of type X\n" + + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " String s = getClass();\n" + + " ^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Class to String\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " return (String) getDefault(getClass());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Cannot cast from X to String\n" + + "----------\n" + + "3. WARNING in X.java (at line 8)\n" + + " return (String) getDefault(getClass());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation getDefault(Class) of the generic method getDefault(Class) of type X\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=125445 @@ -30043,31 +30074,31 @@ " }\n" + "}\n", }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " Class enumType = null;\n" + - " ^^^^\n" + - "Enum is a raw type. References to generic type Enum should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 7)\n" + - " final Collection test = allOf(enumType);\n" + - " ^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " final Collection test = allOf(enumType);\n" + - " ^^^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Collection to Collection\n" + - "----------\n" + - "4. WARNING in X.java (at line 9)\n" + - " Collection colType = null;\n" + - " ^^^^\n" + - "Enum is a raw type. References to generic type Enum should be parameterized\n" + - "----------\n" + - "5. ERROR in X.java (at line 10)\n" + - " final Collection test2 = colType;\n" + - " ^^^^^^^\n" + - "Type mismatch: cannot convert from Collection to Collection\n" + + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " Class enumType = null;\n" + + " ^^^^\n" + + "Enum is a raw type. References to generic type Enum should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 7)\n" + + " final Collection test = allOf(enumType);\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation allOf(Class) of the generic method allOf(Class) of type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " final Collection test = allOf(enumType);\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Collection needs unchecked conversion to conform to Collection\n" + + "----------\n" + + "4. WARNING in X.java (at line 9)\n" + + " Collection colType = null;\n" + + " ^^^^\n" + + "Enum is a raw type. References to generic type Enum should be parameterized\n" + + "----------\n" + + "5. ERROR in X.java (at line 10)\n" + + " final Collection test2 = colType;\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from Collection to Collection\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=119238 @@ -31106,21 +31137,26 @@ " Zork z;\n" + "}\n" }, - "----------\n" + - "1. WARNING in X.java (at line 7)\n" + - " X x = newInstance();\n" + - " ^\n" + - "X is a raw type. References to generic type X should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 8)\n" + - " return new X[] { x };\n" + - " ^^^^^^^^^^^^^\n" + - "Type safety: The expression of type X[] needs unchecked conversion to conform to X[]\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 7)\n" + + " X x = newInstance();\n" + + " ^\n" + + "X is a raw type. References to generic type X should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " X x = newInstance();\n" + + " ^^^^^^^^^^^\n" + + "Bound mismatch: The generic method newInstance() of type X is not applicable for the arguments (). The inferred type Comparable> is not a valid substitute for the bounded parameter >\n" + + "----------\n" + + "3. WARNING in X.java (at line 8)\n" + + " return new X[] { x };\n" + + " ^^^^^^^^^^^^^\n" + + "Type safety: The expression of type X[] needs unchecked conversion to conform to X[]\n" + + "----------\n" + + "4. ERROR in X.java (at line 10)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=118273 - variation @@ -31163,7 +31199,7 @@ "5. WARNING in X.java (at line 7)\n" + " Comparable c = newInstance2(x);\n" + " ^\n" + - "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + + "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + "----------\n" + "6. ERROR in X.java (at line 9)\n" + " Zork z;\n" + @@ -32482,26 +32518,31 @@ " }\n" + "}", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 9)\n" + - " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation chain(Iterator...) of the generic method chain(Iterator...) of type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 9)\n" + - " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator\n" + - "----------\n" + - "3. ERROR in X.java (at line 14)\n" + - " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + - " ^^^^^\n" + - "The method chain(Iterator...) in the type X is not applicable for the arguments (Iterator, Iterator)\n" + - "----------\n" + - "4. WARNING in X.java (at line 18)\n" + - " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety : A generic array of Iterator is created for a varargs parameter\n" + + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation chain(Iterator[]) of the generic method chain(Iterator...) of type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Iterator[] needs unchecked conversion to conform to Iterator[]\n" + + "----------\n" + + "4. ERROR in X.java (at line 14)\n" + + " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + + " ^^^^^\n" + + "The method chain(Iterator...) in the type X is not applicable for the arguments (Iterator, Iterator)\n" + + "----------\n" + + "5. WARNING in X.java (at line 18)\n" + + " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety : A generic array of Iterator is created for a varargs parameter\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=144879 @@ -32530,36 +32571,41 @@ " }\n" + "}", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 9)\n" + - " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation chain(Iterator...) of the generic method chain(Iterator...) of type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 9)\n" + - " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator\n" + - "----------\n" + - "3. WARNING in X.java (at line 14)\n" + - " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety : A generic array of Iterator> is created for a varargs parameter\n" + - "----------\n" + - "4. ERROR in X.java (at line 14)\n" + - " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Iterator> to Iterator\n" + - "----------\n" + - "5. WARNING in X.java (at line 18)\n" + - " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety : A generic array of Iterator is created for a varargs parameter\n" + - "----------\n" + - "6. ERROR in X.java (at line 18)\n" + - " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Iterator to Iterator\n" + + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation chain(Iterator[]) of the generic method chain(Iterator...) of type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " Iterator it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Iterator[] needs unchecked conversion to conform to Iterator[]\n" + + "----------\n" + + "4. WARNING in X.java (at line 14)\n" + + " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety : A generic array of Iterator> is created for a varargs parameter\n" + + "----------\n" + + "5. ERROR in X.java (at line 14)\n" + + " Iterator it2 = X.chain(l1.iterator(), l2.iterator());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Iterator> to Iterator\n" + + "----------\n" + + "6. WARNING in X.java (at line 18)\n" + + " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety : A generic array of Iterator is created for a varargs parameter\n" + + "----------\n" + + "7. ERROR in X.java (at line 18)\n" + + " Iterator it2 = X.chain(l1.iterator(), l1.iterator());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Iterator to Iterator\n" + "----------\n"); } public void test1001() { @@ -32770,7 +32816,7 @@ " X x = bar(l, c);\n" + " }\n" + " T bar(L l, C c) { \n" + - " return null;\n" + + " return zork;\n" + " } \n" + "}\n" + "class C {}\n" + @@ -32778,26 +32824,31 @@ "\n" + "\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 2)\r\n" + - " void foo(L l, C c) {\r\n" + - " ^\n" + - "L is a raw type. References to generic type L should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\r\n" + - " X x = bar(l, c);\r\n" + - " ^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(L, C) of the generic method bar(L, C) of type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 3)\r\n" + - " X x = bar(l, c);\r\n" + - " ^^^^^^^^^\n" + - "Type mismatch: cannot convert from Object to X\n" + - "----------\n" + - "4. WARNING in X.java (at line 3)\r\n" + - " X x = bar(l, c);\r\n" + - " ^\n" + - "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo(L l, C c) {\n" + + " ^\n" + + "L is a raw type. References to generic type L should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " X x = bar(l, c);\n" + + " ^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(L, C) of the generic method bar(L, C) of type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " X x = bar(l, c);\n" + + " ^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to X\n" + + "----------\n" + + "4. WARNING in X.java (at line 3)\n" + + " X x = bar(l, c);\n" + + " ^\n" + + "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " return zork;\n" + + " ^^^^\n" + + "zork cannot be resolved\n" + "----------\n", JavacTestOptions.EclipseJustification.EclipseBug148061); } @@ -32873,31 +32924,36 @@ " void bar3(Map map, U s, Map map2) {}\n" + "}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " void foo(HashMap map, String s, Map map2) {\n" + - " ^^^^^^^\n" + - "HashMap is a raw type. References to generic type HashMap should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 4)\n" + - " bar(map, s, map2); //1\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(Map, Object, Map) of the generic method bar(Map, U, Map) of type X\n" + - "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " bar(map, s, map2); //1\n" + - " ^^^\n" + - "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + - "----------\n" + - "4. WARNING in X.java (at line 6)\n" + - " bar2(map, s, map2); //3\n" + - " ^^^\n" + - "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + - "----------\n" + - "5. WARNING in X.java (at line 7)\n" + - " bar3(map, s, map2); //4\n" + - " ^^^\n" + - "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " void foo(HashMap map, String s, Map map2) {\n" + + " ^^^^^^^\n" + + "HashMap is a raw type. References to generic type HashMap should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " bar(map, s, map2); //1\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(HashMap, String, Map) of the generic method bar(Map, U, Map) of type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " bar(map, s, map2); //1\n" + + " ^^^\n" + + "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " bar2(map, s, map2); //3\n" + + " ^^^\n" + + "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " bar3(map, s, map2); //4\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar3(HashMap, String, Map) of the generic method bar3(Map, U, Map) of type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 7)\n" + + " bar3(map, s, map2); //4\n" + + " ^^^\n" + + "Type safety: The expression of type HashMap needs unchecked conversion to conform to Map\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=148061 - variation @@ -32918,63 +32974,68 @@ " return null;\n" + " }\n" + " C bar3(L l, C c) {\n" + - " return null;\n" + + " return zork;\n" + " }\n" + "}\n" + "\n" + "class C {}\n" + "class L {}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 2)\r\n" + - " void foo(L l, C c) {\r\n" + - " ^\n" + - "L is a raw type. References to generic type L should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\r\n" + - " X x = bar1(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar1(L, C) of the generic method bar1(L, C) of type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 3)\r\n" + - " X x = bar1(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Object to X\n" + - "----------\n" + - "4. WARNING in X.java (at line 3)\r\n" + - " X x = bar1(l, c);\r\n" + - " ^\n" + - "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + - "----------\n" + - "5. WARNING in X.java (at line 4)\r\n" + - " L lx = bar2(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar2(L, C) of the generic method bar2(L, C) of type X\n" + - "----------\n" + - "6. WARNING in X.java (at line 4)\r\n" + - " L lx = bar2(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + - "----------\n" + - "7. WARNING in X.java (at line 4)\r\n" + - " L lx = bar2(l, c);\r\n" + - " ^\n" + - "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + - "----------\n" + - "8. WARNING in X.java (at line 5)\r\n" + - " C cx = bar3(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar3(L, C) of the generic method bar3(L, C) of type X\n" + - "----------\n" + - "9. WARNING in X.java (at line 5)\r\n" + - " C cx = bar3(l, c);\r\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type C needs unchecked conversion to conform to C\n" + - "----------\n" + - "10. WARNING in X.java (at line 5)\r\n" + - " C cx = bar3(l, c);\r\n" + - " ^\n" + - "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo(L l, C c) {\n" + + " ^\n" + + "L is a raw type. References to generic type L should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " X x = bar1(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar1(L, C) of the generic method bar1(L, C) of type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " X x = bar1(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to X\n" + + "----------\n" + + "4. WARNING in X.java (at line 3)\n" + + " X x = bar1(l, c);\n" + + " ^\n" + + "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "5. WARNING in X.java (at line 4)\n" + + " L lx = bar2(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar2(L, C) of the generic method bar2(L, C) of type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 4)\n" + + " L lx = bar2(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "7. WARNING in X.java (at line 4)\n" + + " L lx = bar2(l, c);\n" + + " ^\n" + + "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "8. WARNING in X.java (at line 5)\n" + + " C cx = bar3(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar3(L, C) of the generic method bar3(L, C) of type X\n" + + "----------\n" + + "9. WARNING in X.java (at line 5)\n" + + " C cx = bar3(l, c);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type C needs unchecked conversion to conform to C\n" + + "----------\n" + + "10. WARNING in X.java (at line 5)\n" + + " C cx = bar3(l, c);\n" + + " ^\n" + + "Type safety: The expression of type L needs unchecked conversion to conform to L\n" + + "----------\n" + + "11. ERROR in X.java (at line 14)\n" + + " return zork;\n" + + " ^^^^\n" + + "zork cannot be resolved\n" + "----------\n", JavacTestOptions.EclipseJustification.EclipseBug148061); } @@ -33010,41 +33071,41 @@ " }\n" + "}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 14)\r\n" + - " void foo(List l1, List l2) {\r\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 15)\r\n" + - " X x = bar1(l1, l2);\r\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar1(List, List) of the generic method bar1(List, List) of type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 15)\r\n" + - " X x = bar1(l1, l2);\r\n" + - " ^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Object to X\n" + - "----------\n" + - "4. WARNING in X.java (at line 15)\r\n" + - " X x = bar1(l1, l2);\r\n" + - " ^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "5. WARNING in X.java (at line 17)\r\n" + - " List lx = bar2(l1, l2);\r\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar2(List, List) of the generic method bar2(List, List) of type X\n" + - "----------\n" + - "6. WARNING in X.java (at line 17)\r\n" + - " List lx = bar2(l1, l2);\r\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "7. WARNING in X.java (at line 17)\r\n" + - " List lx = bar2(l1, l2);\r\n" + - " ^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "1. WARNING in X.java (at line 14)\n" + + " void foo(List l1, List l2) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 15)\n" + + " X x = bar1(l1, l2);\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar1(List, List) of the generic method bar1(List, List) of type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 15)\n" + + " X x = bar1(l1, l2);\n" + + " ^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to X\n" + + "----------\n" + + "4. WARNING in X.java (at line 15)\n" + + " X x = bar1(l1, l2);\n" + + " ^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "5. WARNING in X.java (at line 17)\n" + + " List lx = bar2(l1, l2);\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar2(List, List) of the generic method bar2(List, List) of type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 17)\n" + + " List lx = bar2(l1, l2);\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "7. WARNING in X.java (at line 17)\n" + + " List lx = bar2(l1, l2);\n" + + " ^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + "----------\n", JavacTestOptions.EclipseJustification.EclipseBug148061); } @@ -33063,41 +33124,41 @@ " Map bar(List lu, List lv) { return null; }\n" + "}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 4)\n" + - " void foo1(List l, List ls) {\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 5)\n" + - " Set> mss1 = bar(l, ls).entrySet();\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + - "----------\n" + - "3. WARNING in X.java (at line 5)\n" + - " Set> mss1 = bar(l, ls).entrySet();\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type Set needs unchecked conversion to conform to Set>\n" + - "----------\n" + - "4. WARNING in X.java (at line 5)\n" + - " Set> mss1 = bar(l, ls).entrySet();\n" + - " ^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "5. WARNING in X.java (at line 6)\n" + - " String s = bar(l, ls).entrySet();\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + - "----------\n" + - "6. ERROR in X.java (at line 6)\n" + - " String s = bar(l, ls).entrySet();\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Set to String\n" + - "----------\n" + - "7. WARNING in X.java (at line 6)\n" + - " String s = bar(l, ls).entrySet();\n" + - " ^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " void foo1(List l, List ls) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " Set> mss1 = bar(l, ls).entrySet();\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 5)\n" + + " Set> mss1 = bar(l, ls).entrySet();\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Set needs unchecked conversion to conform to Set>\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " Set> mss1 = bar(l, ls).entrySet();\n" + + " ^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "5. WARNING in X.java (at line 6)\n" + + " String s = bar(l, ls).entrySet();\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 6)\n" + + " String s = bar(l, ls).entrySet();\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Set to String\n" + + "----------\n" + + "7. WARNING in X.java (at line 6)\n" + + " String s = bar(l, ls).entrySet();\n" + + " ^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=148061 - variation @@ -33114,41 +33175,41 @@ " List bar(List lu, List lv) { return null; }\n" + "}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " void foo1(List l, List ls) {\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 4)\n" + - " List ls1 = bar(l, ls);\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + - "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " List ls1 = bar(l, ls);\n" + - " ^^^^^^^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "4. WARNING in X.java (at line 4)\n" + - " List ls1 = bar(l, ls);\n" + - " ^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "5. WARNING in X.java (at line 5)\n" + - " String s = bar(l, ls);\n" + - " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + - "----------\n" + - "6. ERROR in X.java (at line 5)\n" + - " String s = bar(l, ls);\n" + - " ^^^^^^^^^^\n" + - "Type mismatch: cannot convert from List to String\n" + - "----------\n" + - "7. WARNING in X.java (at line 5)\n" + - " String s = bar(l, ls);\n" + - " ^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " void foo1(List l, List ls) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " List ls1 = bar(l, ls);\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " List ls1 = bar(l, ls);\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "4. WARNING in X.java (at line 4)\n" + + " List ls1 = bar(l, ls);\n" + + " ^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "5. WARNING in X.java (at line 5)\n" + + " String s = bar(l, ls);\n" + + " ^^^^^^^^^^\n" + + "Type safety: Unchecked invocation bar(List, List) of the generic method bar(List, List) of type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 5)\n" + + " String s = bar(l, ls);\n" + + " ^^^^^^^^^^\n" + + "Type mismatch: cannot convert from List to String\n" + + "----------\n" + + "7. WARNING in X.java (at line 5)\n" + + " String s = bar(l, ls);\n" + + " ^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=148061 - variation @@ -33926,16 +33987,21 @@ "}", // ================= }, - "----------\n" + - "1. WARNING in ComparableComparator.java (at line 14)\n" + - " static Comparator baz() {\n" + - " ^^^^^^\n" + - "The type parameter M should not be bounded by the final type String. Final types cannot be further extended\n" + - "----------\n" + - "2. ERROR in ComparableComparator.java (at line 27)\n" + - " static Object BAR2 = ComparableComparator.bar();//1a\n" + - " ^^^\n" + - "Bound mismatch: The generic method bar() of type ComparableComparator is not applicable for the arguments (). The inferred type Comparable> is not a valid substitute for the bounded parameter >\n" + + "----------\n" + + "1. WARNING in ComparableComparator.java (at line 14)\n" + + " static Comparator baz() {\n" + + " ^^^^^^\n" + + "The type parameter M should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in ComparableComparator.java (at line 25)\n" + + " static Comparator BAR = ComparableComparator.bar();//0\n" + + " ^^^\n" + + "Bound mismatch: The generic method bar() of type ComparableComparator is not applicable for the arguments (). The inferred type Comparable> is not a valid substitute for the bounded parameter >\n" + + "----------\n" + + "3. ERROR in ComparableComparator.java (at line 27)\n" + + " static Object BAR2 = ComparableComparator.bar();//1a\n" + + " ^^^\n" + + "Bound mismatch: The generic method bar() of type ComparableComparator is not applicable for the arguments (). The inferred type Comparable> is not a valid substitute for the bounded parameter >\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=158548 @@ -44592,7 +44658,7 @@ "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 -public void _test1322() { +public void test1322() { this.runNegativeTest( new String[] { "X.java", // ================= @@ -44620,35 +44686,35 @@ "class Bob2 extends Bob {}\n" + "class Thingy {}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation doStuff(Class, Thingy) of the generic method doStuff(Class, Thingy) of type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + - "----------\n" + - "3. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^\n" + - "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + - "----------\n" + - "4. ERROR in X.java (at line 15)\n" + - " x.doStuff(Jim.class, new Thingy());\n" + - " ^^^^^^^\n" + - "Bound mismatch: The generic method doStuff(Class, Thingy) of type X is not applicable for the arguments (Class, Thingy). The inferred type Jim is not a valid substitute for the bounded parameter \n" + - "----------\n" + - "5. WARNING in X.java (at line 15)\n" + - " x.doStuff(Jim.class, new Thingy());\n" + - " ^^^^^^\n" + - "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation doStuff(Class, Thingy) of the generic method doStuff(Class, Thingy) of type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^\n" + + "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 15)\n" + + " x.doStuff(Jim.class, new Thingy());\n" + + " ^^^^^^^\n" + + "Bound mismatch: The generic method doStuff(Class, Thingy) of type X is not applicable for the arguments (Class, Thingy). The inferred type Jim is not a valid substitute for the bounded parameter \n" + + "----------\n" + + "5. WARNING in X.java (at line 15)\n" + + " x.doStuff(Jim.class, new Thingy());\n" + + " ^^^^^^\n" + + "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 - variation -public void _test1323() { +public void test1323() { this.runNegativeTest( new String[] { "X.java", // ================= @@ -44665,40 +44731,40 @@ "class Bob2 extends Bob {}\n" + "class Thingy {}\n", // ================= }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " x.doStuff2(Jim.class, new Thingy());\n" + - " ^^^^^^^^\n" + - "Bound mismatch: The generic method doStuff2(Class, Thingy) of type X is not applicable for the arguments (Class, Thingy). The inferred type Jim is not a valid substitute for the bounded parameter \n" + - "----------\n" + - "2. WARNING in X.java (at line 4)\n" + - " x.doStuff2(Jim.class, new Thingy());\n" + - " ^^^^^^\n" + - "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 5)\n" + - " String s = x.doStuff2(Bob2.class, new Thingy());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation doStuff2(Class, Thingy) of the generic method doStuff2(Class, Thingy) of type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " String s = x.doStuff2(Bob2.class, new Thingy());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Bob2 to String\n" + - "----------\n" + - "5. WARNING in X.java (at line 5)\n" + - " String s = x.doStuff2(Bob2.class, new Thingy());\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + - "----------\n" + - "6. WARNING in X.java (at line 5)\n" + - " String s = x.doStuff2(Bob2.class, new Thingy());\n" + - " ^^^^^^\n" + - "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " x.doStuff2(Jim.class, new Thingy());\n" + + " ^^^^^^^^\n" + + "Bound mismatch: The generic method doStuff2(Class, Thingy) of type X is not applicable for the arguments (Class, Thingy). The inferred type Jim is not a valid substitute for the bounded parameter \n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " x.doStuff2(Jim.class, new Thingy());\n" + + " ^^^^^^\n" + + "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 5)\n" + + " String s = x.doStuff2(Bob2.class, new Thingy());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation doStuff2(Class, Thingy) of the generic method doStuff2(Class, Thingy) of type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " String s = x.doStuff2(Bob2.class, new Thingy());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Bob to String\n" + + "----------\n" + + "5. WARNING in X.java (at line 5)\n" + + " String s = x.doStuff2(Bob2.class, new Thingy());\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + + "----------\n" + + "6. WARNING in X.java (at line 5)\n" + + " String s = x.doStuff2(Bob2.class, new Thingy());\n" + + " ^^^^^^\n" + + "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 - variation -public void _test1324() { +public void test1324() { this.runNegativeTest( new String[] { "X.java", // ================= @@ -44717,26 +44783,26 @@ "class Bob {}\n" + "class Thingy {}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation doStuff(Class, Thingy) of the generic method doStuff(Class, Thingy) of type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^^^^^^^\n" + - "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + - "----------\n" + - "3. WARNING in X.java (at line 6)\n" + - " x.doStuff(Bob.class, new Thingy());\n" + - " ^^^^^^\n" + - "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + - "----------\n" + - "4. ERROR in X.java (at line 8)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation doStuff(Class, Thingy) of the generic method doStuff(Class, Thingy) of type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The expression of type Thingy needs unchecked conversion to conform to Thingy\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " x.doStuff(Bob.class, new Thingy());\n" + + " ^^^^^^\n" + + "Thingy is a raw type. References to generic type Thingy should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 - variation @@ -44753,30 +44819,30 @@ " }\n" + "}\n", // ================= }, - "----------\n" + - "1. WARNING in X.java (at line 5)\n" + - " void bar(X x) {\n" + - " ^\n" + - "X is a raw type. References to generic type X should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 6)\n" + - " X xs2 = foo(x);\n" + - " ^^^^^^\n" + - "Type safety: Unchecked invocation foo(X) of the generic method foo(X) of type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 6)\n" + - " X xs2 = foo(x);\n" + - " ^^^^^^\n" + - "Type mismatch: cannot convert from Object to X\n" + - "----------\n" + - "4. WARNING in X.java (at line 6)\n" + - " X xs2 = foo(x);\n" + - " ^\n" + - "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " void bar(X x) {\n" + + " ^\n" + + "X is a raw type. References to generic type X should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " X xs2 = foo(x);\n" + + " ^^^^^^\n" + + "Type safety: Unchecked invocation foo(X) of the generic method foo(X) of type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " X xs2 = foo(x);\n" + + " ^^^^^^\n" + + "Type mismatch: cannot convert from Object to X\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " X xs2 = foo(x);\n" + + " ^\n" + + "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 - variation -public void _test1326() { +public void test1326() { this.runNegativeTest( new String[] { "X.java", // ================= @@ -44830,7 +44896,7 @@ "2. WARNING in X.java (at line 9)\n" + " X xs2 = foo(x, xs).identity();\n" + " ^^^^^^^^^^\n" + - "Type safety: Unchecked invocation foo(X, X) of the generic method foo(X, X) of type X\n" + + "Type safety: Unchecked invocation foo(X, X) of the generic method foo(X, X) of type X\n" + "----------\n" + "3. WARNING in X.java (at line 9)\n" + " X xs2 = foo(x, xs).identity();\n" + @@ -44840,7 +44906,7 @@ "4. WARNING in X.java (at line 9)\n" + " X xs2 = foo(x, xs).identity();\n" + " ^\n" + - "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + + "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=231094 - variation @@ -45617,31 +45683,41 @@ "class Y {}\n" + "class Z { Zork z; }\n", // ================= }, - "----------\n" + - "1. WARNING in Scratch.java (at line 2)\n" + - " private Y rawObject = new Y();\n" + - " ^\n" + - "Y is a raw type. References to generic type Y should be parameterized\n" + - "----------\n" + - "2. WARNING in Scratch.java (at line 2)\n" + - " private Y rawObject = new Y();\n" + - " ^\n" + - "Y is a raw type. References to generic type Y should be parameterized\n" + - "----------\n" + - "3. WARNING in Scratch.java (at line 4)\n" + - " method(new X>(), rawObject); // compile error in javac, unchecked conversion in Eclipse\n" + - " ^^^^^^^^^\n" + - "Type safety: The expression of type Y needs unchecked conversion to conform to Y\n" + - "----------\n" + - "4. WARNING in Scratch.java (at line 5)\n" + - " this.>method(new X>(), rawObject); // unchecked warning in both\n" + - " ^^^^^^^^^\n" + - "Type safety: The expression of type Y needs unchecked conversion to conform to Y\n" + - "----------\n" + - "5. ERROR in Scratch.java (at line 11)\n" + - " class Z { Zork z; }\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in Scratch.java (at line 2)\n" + + " private Y rawObject = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "2. WARNING in Scratch.java (at line 2)\n" + + " private Y rawObject = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "3. WARNING in Scratch.java (at line 4)\n" + + " method(new X>(), rawObject); // compile error in javac, unchecked conversion in Eclipse\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation method(X>, Y) of the generic method method(X, T) of type Scratch\n" + + "----------\n" + + "4. WARNING in Scratch.java (at line 4)\n" + + " method(new X>(), rawObject); // compile error in javac, unchecked conversion in Eclipse\n" + + " ^^^^^^^^^\n" + + "Type safety: The expression of type Y needs unchecked conversion to conform to Y\n" + + "----------\n" + + "5. WARNING in Scratch.java (at line 5)\n" + + " this.>method(new X>(), rawObject); // unchecked warning in both\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation method(X>, Y) of the generic method method(X, T) of type Scratch\n" + + "----------\n" + + "6. WARNING in Scratch.java (at line 5)\n" + + " this.>method(new X>(), rawObject); // unchecked warning in both\n" + + " ^^^^^^^^^\n" + + "Type safety: The expression of type Y needs unchecked conversion to conform to Y\n" + + "----------\n" + + "7. ERROR in Scratch.java (at line 11)\n" + + " class Z { Zork z; }\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=238484 @@ -47636,7 +47712,7 @@ "----------\n"); } public void test1406() { - this.runConformTest( + this.runNegativeTest( new String[] { "GenericTest.java", //----------------------------------------------------------------------- "import java.util.*;\n" + @@ -47651,7 +47727,32 @@ " }\n" + "}\n",//----------------------------------------------------------------------- }, - ""); + "----------\n" + + "1. WARNING in GenericTest.java (at line 5)\n" + + " Set testList = GenericTest.method1(new Class[] { ArrayList.class });\n" + + " ^^^\n" + + "Set is a raw type. References to generic type Set should be parameterized\n" + + "----------\n" + + "2. WARNING in GenericTest.java (at line 5)\n" + + " Set testList = GenericTest.method1(new Class[] { ArrayList.class });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation method1(Class[]) of the generic method method1(Class[]) of type GenericTest\n" + + "----------\n" + + "3. ERROR in GenericTest.java (at line 5)\n" + + " Set testList = GenericTest.method1(new Class[] { ArrayList.class });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to Set\n" + + "----------\n" + + "4. WARNING in GenericTest.java (at line 5)\n" + + " Set testList = GenericTest.method1(new Class[] { ArrayList.class });\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Class[] needs unchecked conversion to conform to Class[]\n" + + "----------\n" + + "5. WARNING in GenericTest.java (at line 8)\n" + + " public static I method1(Class[] params) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n"); } public void test1407() { this.runNegativeTest( @@ -47659,41 +47760,29 @@ "Foo.java", //----------------------------------------------------------------------- "public class Foo {\n" + " public static I m1(Class c) { return null; }\n" + - " public static I m2(Class c) { return null; } \n" + " void bar() {\n" + - " Foo l1 = m1((Class)Foo.class); //ok - unchecked conversion from Class to Class - I inferred to be Foo\n" + - " Foo l2 = m2((Class)Foo.class); //unchecked call, erased return type and error because Object != Foo \n" + + " Foo l1 = m1((Class)Foo.class);\n" + " }\n" + "}\n",//----------------------------------------------------------------------- }, "----------\n" + - "1. WARNING in Foo.java (at line 5)\n" + - " Foo l1 = m1((Class)Foo.class); //ok - unchecked conversion from Class to Class - I inferred to be Foo\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + - "----------\n" + - "2. WARNING in Foo.java (at line 5)\n" + - " Foo l1 = m1((Class)Foo.class); //ok - unchecked conversion from Class to Class - I inferred to be Foo\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + - "3. WARNING in Foo.java (at line 6)\n" + - " Foo l2 = m2((Class)Foo.class); //unchecked call, erased return type and error because Object != Foo \n" + + "1. WARNING in Foo.java (at line 4)\n" + + " Foo l1 = m1((Class)Foo.class);\n" + " ^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation m2(Class) of the generic method m2(Class) of type Foo\n" + + "Type safety: Unchecked invocation m1(Class) of the generic method m1(Class) of type Foo\n" + "----------\n" + - "4. ERROR in Foo.java (at line 6)\n" + - " Foo l2 = m2((Class)Foo.class); //unchecked call, erased return type and error because Object != Foo \n" + + "2. ERROR in Foo.java (at line 4)\n" + + " Foo l1 = m1((Class)Foo.class);\n" + " ^^^^^^^^^^^^^^^^^^^^\n" + "Type mismatch: cannot convert from Object to Foo\n" + "----------\n" + - "5. WARNING in Foo.java (at line 6)\n" + - " Foo l2 = m2((Class)Foo.class); //unchecked call, erased return type and error because Object != Foo \n" + + "3. WARNING in Foo.java (at line 4)\n" + + " Foo l1 = m1((Class)Foo.class);\n" + " ^^^^^^^^^^^^^^^^\n" + - "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + "----------\n" + - "6. WARNING in Foo.java (at line 6)\n" + - " Foo l2 = m2((Class)Foo.class); //unchecked call, erased return type and error because Object != Foo \n" + + "4. WARNING in Foo.java (at line 4)\n" + + " Foo l1 = m1((Class)Foo.class);\n" + " ^^^^^\n" + "Class is a raw type. References to generic type Class should be parameterized\n" + "----------\n"); @@ -48344,12 +48433,50 @@ }, ""); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 public void test1429() { this.runNegativeTest( new String[] { "X.java", //----------------------------------------------------------------------- "class Foo {}\n" + "public class X {\n" + + " public void test() {\n" + + " Integer i = m(new Foo>(), new Foo());\n" + + " }\n" + + " public T m(Foo x, T t) {\n" + + " return t;\n" + + " }\n" + + "}\n",//----------------------------------------------------------------------- + }, + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " Integer i = m(new Foo>(), new Foo());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation m(Foo>, Foo) of the generic method m(Foo, T) of type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Integer i = m(new Foo>(), new Foo());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to Integer\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " Integer i = m(new Foo>(), new Foo());\n" + + " ^^^^^^^^^\n" + + "Type safety: The expression of type Foo needs unchecked conversion to conform to Foo\n" + + "----------\n" + + "4. WARNING in X.java (at line 4)\n" + + " Integer i = m(new Foo>(), new Foo());\n" + + " ^^^\n" + + "Foo is a raw type. References to generic type Foo should be parameterized\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation +public void test1430() { + this.runNegativeTest( + new String[] { + "X.java", //----------------------------------------------------------------------- + "class Foo {}\n" + + "public class X {\n" + " public void test() {\n" + " m(new Foo>(), new Foo());\n" + " }\n" + @@ -48359,44 +48486,149 @@ "----------\n" + "1. WARNING in X.java (at line 4)\n" + " m(new Foo>(), new Foo());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation m(Foo>, Foo) of the generic method m(Foo, T) of type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " m(new Foo>(), new Foo());\n" + " ^^^^^^^^^\n" + "Type safety: The expression of type Foo needs unchecked conversion to conform to Foo\n" + "----------\n" + - "2. WARNING in X.java (at line 4)\n" + + "3. WARNING in X.java (at line 4)\n" + " m(new Foo>(), new Foo());\n" + " ^^^\n" + "Foo is a raw type. References to generic type Foo should be parameterized\n" + "----------\n"); } -public void test1430() { +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation +public void test1431() { this.runNegativeTest( new String[] { "X.java", //----------------------------------------------------------------------- - "class Foo {}\n" + + "class Foo {\n" + + " T bar(Foo ft, T t) {\n" + + " return t;\n" + + " }\n" + + "}\n" + "public class X {\n" + " public void test() {\n" + - " Integer i = m(new Foo>(), new Foo());\n" + - " }\n" + - " public T m(Foo x, T t) {\n" + - " return t;\n" + + " Foo> ffi = new Foo>();\n" + + " Integer j = ffi.bar(ffi, new Foo());\n" + " }\n" + "}\n",//----------------------------------------------------------------------- }, "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " Integer i = m(new Foo>(), new Foo());\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "1. ERROR in X.java (at line 9)\n" + + " Integer j = ffi.bar(ffi, new Foo());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + "Type mismatch: cannot convert from Foo to Integer\n" + "----------\n" + - "2. WARNING in X.java (at line 4)\n" + - " Integer i = m(new Foo>(), new Foo());\n" + - " ^^^^^^^^^\n" + + "2. WARNING in X.java (at line 9)\n" + + " Integer j = ffi.bar(ffi, new Foo());\n" + + " ^^^^^^^^^\n" + "Type safety: The expression of type Foo needs unchecked conversion to conform to Foo\n" + "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " Integer i = m(new Foo>(), new Foo());\n" + - " ^^^\n" + + "3. WARNING in X.java (at line 9)\n" + + " Integer j = ffi.bar(ffi, new Foo());\n" + + " ^^^\n" + "Foo is a raw type. References to generic type Foo should be parameterized\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation +public void test1432() { + this.runNegativeTest( + new String[] { + "X.java", //----------------------------------------------------------------------- + "import java.util.*;\n" + + "public class X {\n" + + " Zork z;\n" + + " void foo(X xu) {}\n" + + " void bar(X x) {\n" + + " foo(x);\n" + + " }\n" + + "}\n",//----------------------------------------------------------------------- + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " void bar(X x) {\n" + + " ^\n" + + "X is a raw type. References to generic type X should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " foo(x);\n" + + " ^^^^^^\n" + + "Type safety: Unchecked invocation foo(X) of the generic method foo(X) of type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " foo(x);\n" + + " ^\n" + + "Type safety: The expression of type X needs unchecked conversion to conform to X\n" + + "----------\n"); +} +public void test1433() { + this.runNegativeTest( + new String[] { + "Foo.java", //----------------------------------------------------------------------- + "public class Foo {\n" + + " public static I m2(Class c) { return null; } \n" + + " void bar() {\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " }\n" + + "}\n",//----------------------------------------------------------------------- + }, + "----------\n" + + "1. WARNING in Foo.java (at line 4)\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation m2(Class) of the generic method m2(Class) of type Foo\n" + + "----------\n" + + "2. ERROR in Foo.java (at line 4)\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to Foo\n" + + "----------\n" + + "3. WARNING in Foo.java (at line 4)\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "----------\n" + + "4. WARNING in Foo.java (at line 4)\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Unnecessary cast from Class to Class\n" + + "----------\n" + + "5. WARNING in Foo.java (at line 4)\n" + + " Foo l2 = m2((Class)Foo.class);\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n"); +} +public void test1434() { + this.runNegativeTest( + new String[] { + "X.java", //----------------------------------------------------------------------- + "public class X {\n" + + " > T min(T x, T y) { return x; }\n" + + " \n" + + " void foo(Foo f, Bar b) {\n" + + " min(f, f);\n" + + " min(b, b);\n" + + " }\n" + + "}\n" + + "abstract class Foo implements Comparable {\n" + + "}\n" + + "abstract class Bar extends Foo {}\n",//----------------------------------------------------------------------- + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " min(b, b);\n" + + " ^^^\n" + + "Bound mismatch: The generic method min(T, T) of type X is not applicable for the arguments (Bar, Bar). The inferred type Bar is not a valid substitute for the bounded parameter >\n" + + "----------\n"); +} } \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.172 diff -u -r1.172 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 21 Nov 2008 20:03:13 -0000 1.172 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 7 Jan 2009 16:11:01 -0000 @@ -2981,22 +2981,27 @@ " public static void foo(List... e) {}\n" + "}\n" }, - "----------\n" + - "1. WARNING in p\\X.java (at line 6)\n" + - " public X() { foo(data.l); }\n" + - " ^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation foo(List...) of the generic method foo(List...) of type Z\n" + - "----------\n" + - "2. WARNING in p\\X.java (at line 6)\n" + - " public X() { foo(data.l); }\n" + - " ^^^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "----------\n" + - "1. WARNING in p\\Y.java (at line 4)\n" + - " List l = null;\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "1. WARNING in p\\X.java (at line 6)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^^^^^^\n" + + "Type safety : A generic array of List is created for a varargs parameter\n" + + "----------\n" + + "2. WARNING in p\\X.java (at line 6)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation foo(List) of the generic method foo(List...) of type Z\n" + + "----------\n" + + "3. WARNING in p\\X.java (at line 6)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "----------\n" + + "1. WARNING in p\\Y.java (at line 4)\n" + + " List l = null;\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + "----------\n" // unchecked conversion warnings ); @@ -3021,22 +3026,27 @@ " public static void foo(List... e) {}\n" + "}\n" }, - "----------\n" + - "1. WARNING in p\\X.java (at line 5)\n" + - " public X() { foo(data.l); }\n" + - " ^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation foo(List...) of the generic method foo(List...) of type Y\n" + - "----------\n" + - "2. WARNING in p\\X.java (at line 5)\n" + - " public X() { foo(data.l); }\n" + - " ^^^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "----------\n" + - "1. WARNING in p\\Y.java (at line 4)\n" + - " List l = null;\n" + - " ^^^^\n" + - "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "1. WARNING in p\\X.java (at line 5)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^^^^^^\n" + + "Type safety : A generic array of List is created for a varargs parameter\n" + + "----------\n" + + "2. WARNING in p\\X.java (at line 5)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation foo(List) of the generic method foo(List...) of type Y\n" + + "----------\n" + + "3. WARNING in p\\X.java (at line 5)\n" + + " public X() { foo(data.l); }\n" + + " ^^^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "----------\n" + + "1. WARNING in p\\Y.java (at line 4)\n" + + " List l = null;\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + "----------\n" // unchecked conversion warnings ); #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java,v retrieving revision 1.20 diff -u -r1.20 NameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java 25 Sep 2008 23:10:29 -0000 1.20 +++ compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java 7 Jan 2009 16:11:07 -0000 @@ -26,39 +26,47 @@ //will be a TypeReference (static message sends.....) and there is //no changeClass in java. public NameReference() { - super(); this.bits |= Binding.TYPE | Binding.VARIABLE; // restrictiveFlag - } + public FieldBinding fieldBinding() { //this method should be sent ONLY after a check against isFieldReference() //check its use doing senders......... - return (FieldBinding) this.binding ; } + public boolean isSuperAccess() { return false; } + public boolean isTypeAccess() { // null is acceptable when we are resolving the first part of a reference return this.binding == null || this.binding instanceof ReferenceBinding; } + public boolean isTypeReference() { return this.binding instanceof ReferenceBinding; } + public void setActualReceiverType(ReferenceBinding receiverType) { if (receiverType == null) return; // error scenario only this.actualReceiverType = receiverType; } + public void setDepth(int depth) { this.bits &= ~DepthMASK; // flush previous depth if any if (depth > 0) { this.bits |= (depth & 0xFF) << DepthSHIFT; // encoded on 8 bits } } + public void setFieldIndex(int index){ // ignored } +public void setUnchecked(boolean isUnchecked) { + // ignored +} + public abstract String unboundReferenceErrorName(); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java,v retrieving revision 1.63 diff -u -r1.63 Javadoc.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java 24 Nov 2008 08:22:40 -0000 1.63 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java 7 Jan 2009 16:11:07 -0000 @@ -266,15 +266,11 @@ // if binding is valid then look if we have a reference to an overriden method/constructor if (messageSend.binding != null && messageSend.binding.isValidBinding() && messageSend.actualReceiverType instanceof ReferenceBinding) { ReferenceBinding methodReceiverType = (ReferenceBinding) messageSend.actualReceiverType; - if ((methodReceiverType.isSuperclassOf(methDecl.binding.declaringClass) || (methodReceiverType.isInterface() && methDecl.binding.declaringClass.implementsInterface(methodReceiverType, true))) && - CharOperation.equals(messageSend.selector, methDecl.selector) && - (methDecl.binding.returnType.isCompatibleWith(messageSend.binding.returnType))) { - if (messageSend.arguments == null && methDecl.arguments == null) { + TypeBinding superType = methDecl.binding.declaringClass.findSuperTypeOriginatingFrom(methodReceiverType); + if (superType != null && superType.original() != methDecl.binding.declaringClass && CharOperation.equals(messageSend.selector, methDecl.selector)) { + if (methScope.environment().methodVerifier().doesMethodOverride(methDecl.binding, messageSend.binding.original())) { superRef = true; } - else if (messageSend.arguments != null && methDecl.arguments != null) { - superRef = methDecl.binding.areParameterErasuresEqual(messageSend.binding); - } } } } @@ -282,14 +278,16 @@ JavadocAllocationExpression allocationExpr = (JavadocAllocationExpression) this.seeReferences[i]; // if binding is valid then look if we have a reference to an overriden method/constructor if (allocationExpr.binding != null && allocationExpr.binding.isValidBinding()) { - if (methDecl.binding.declaringClass.isCompatibleWith(allocationExpr.resolvedType)) { + ReferenceBinding allocType = (ReferenceBinding) allocationExpr.resolvedType.original(); + TypeBinding superType = methDecl.binding.declaringClass.findSuperTypeOriginatingFrom(allocType); + if (superType != null && superType.original() != methDecl.binding.declaringClass) { if (allocationExpr.arguments == null && methDecl.arguments == null) { superRef = true; } else if (allocationExpr.arguments != null && methDecl.arguments != null && allocationExpr.arguments.length == methDecl.arguments.length) { superRef = methDecl.binding.areParametersCompatibleWith(allocationExpr.binding.parameters); } - } + } } } } Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.96 diff -u -r1.96 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 30 Sep 2008 15:31:26 -0000 1.96 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 7 Jan 2009 16:11:06 -0000 @@ -39,7 +39,7 @@ public final static int Bit14 = 0x2000; // strictly assigned (reference lhs) | discard enclosing instance (explicit constr call) | hasBeenGenerated (type decl) public final static int Bit15 = 0x4000; // is unnecessary cast (expression) | is varargs (type ref) | isSubRoutineEscaping (try statement) | superAccess (javadoc allocation expression/javadoc message send/javadoc return statement) public final static int Bit16 = 0x8000; // in javadoc comment (name ref, type ref, msg) - public final static int Bit17 = 0x10000; // compound assigned (reference lhs) + public final static int Bit17 = 0x10000; // compound assigned (reference lhs) | unchecked (msg, alloc, explicit constr call) public final static int Bit18 = 0x20000; // non null (expression) | onDemand (import reference) public final static int Bit19 = 0x40000; // didResolve (parameterized qualified type ref/parameterized single type ref) | empty (javadoc return statement) | needReceiverGenericCast (msg/fieldref) public final static int Bit20 = 0x80000; @@ -159,6 +159,9 @@ // for explicit constructor call public static final int DiscardEnclosingInstance = Bit14; // used for codegen + // for all method/constructor invocations (msg, alloc, expl. constr call) + public static final int Unchecked = Bit17; + // for empty statement public static final int IsUsefulEmptyStatement = Bit1; @@ -241,14 +244,14 @@ return INVOCATION_ARGUMENT_WILDCARD; } } - TypeBinding checkedParameterType = originalParameterType == null ? parameterType : originalParameterType; + TypeBinding checkedParameterType = parameterType; // originalParameterType == null ? parameterType : originalParameterType; if (argumentType != checkedParameterType && argumentType.needsUncheckedConversion(checkedParameterType)) { scope.problemReporter().unsafeTypeConversion(argument, argumentType, checkedParameterType); return INVOCATION_ARGUMENT_UNCHECKED; } return INVOCATION_ARGUMENT_OK; } - public static void checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite) { + public static void checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite, boolean uncheckedBoundCheck) { TypeBinding[] params = method.parameters; int paramLength = params.length; boolean isRawMemberInvocation = !method.isStatic() @@ -260,7 +263,7 @@ if (!isRawMemberInvocation) { if (method instanceof ParameterizedGenericMethodBinding) { ParameterizedGenericMethodBinding paramMethod = (ParameterizedGenericMethodBinding) method; - if (paramMethod.isUnchecked || (paramMethod.isRaw && method.hasSubstitutedParameters())) { + if (paramMethod.isRaw && method.hasSubstitutedParameters()) { rawOriginalGenericMethod = method.original(); } } @@ -296,9 +299,8 @@ for (int i = lastIndex; i < argLength; i++) { invocationStatus |= checkInvocationArgument(scope, arguments[i], parameterType, argumentTypes[i], originalRawParam); } - } - - if (paramLength == argumentTypes.length) { // 70056 + } + if (paramLength == argLength) { // 70056 int varargsIndex = paramLength - 1; ArrayBinding varargsType = (ArrayBinding) params[varargsIndex]; TypeBinding lastArgType = argumentTypes[varargsIndex]; @@ -335,8 +337,13 @@ scope.problemReporter().wildcardInvocation((ASTNode)invocationSite, receiverType, method, argumentTypes); } else if (!method.isStatic() && !receiverType.isUnboundWildcard() && method.declaringClass.isRawType() && method.hasSubstitutedParameters()) { scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method); - } else if (rawOriginalGenericMethod != null) { - scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method); + } else if (rawOriginalGenericMethod != null + || uncheckedBoundCheck + || ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 + && method instanceof ParameterizedGenericMethodBinding + /*&& method.returnType != scope.environment().convertToRawType(method.returnType.erasure(), true)*/)) { + invocationSite.setUnchecked(true); + scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method, argumentTypes); } } public ASTNode concreteStatement() { Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.91 diff -u -r1.91 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 17 Sep 2008 11:11:09 -0000 1.91 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 7 Jan 2009 16:11:07 -0000 @@ -369,7 +369,7 @@ if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); } - checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); } @@ -446,7 +446,7 @@ this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); } if (this.arguments != null) { - checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); } if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments); Index: compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java,v retrieving revision 1.33 diff -u -r1.33 AbstractVariableDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java 27 Jun 2008 16:03:55 -0000 1.33 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java 7 Jan 2009 16:11:06 -0000 @@ -128,4 +128,9 @@ public void setFieldIndex(int depth) { // do nothing by default } + + public void setUnchecked(boolean isUnchecked) { + // ignored + } + } Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v retrieving revision 1.76 diff -u -r1.76 AllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 17 Sep 2008 11:11:09 -0000 1.76 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 7 Jan 2009 16:11:06 -0000 @@ -353,7 +353,7 @@ } if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); - checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); } @@ -372,6 +372,15 @@ // ignored } +public void setUnchecked(boolean isUnchecked) { + if (isUnchecked) { + this.bits |= ASTNode.Unchecked; + } else { + this.bits &= ~ASTNode.Unchecked; + } + +} + public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { if (this.typeArguments != null) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v retrieving revision 1.67 diff -u -r1.67 ExplicitConstructorCall.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 17 Sep 2008 11:11:09 -0000 1.67 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 7 Jan 2009 16:11:06 -0000 @@ -397,7 +397,7 @@ if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) { scope.problemReporter().deprecatedMethod(this.binding, this); } - checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); if (this.binding.isPrivate() || receiverType.isLocalType()) { this.binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } @@ -430,6 +430,15 @@ // ignore for here } + public void setUnchecked(boolean isUnchecked) { + if (isUnchecked) { + this.bits |= ASTNode.Unchecked; + } else { + this.bits &= ~ASTNode.Unchecked; + } + + } + public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { if (this.qualification != null) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v retrieving revision 1.124 diff -u -r1.124 FieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 1 Oct 2008 22:27:55 -0000 1.124 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 7 Jan 2009 16:11:07 -0000 @@ -609,6 +609,10 @@ // ignored } +public void setUnchecked(boolean isUnchecked) { + // ignored +} + public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { this.receiver.traverse(visitor, scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java,v retrieving revision 1.63 diff -u -r1.63 Argument.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 27 Jun 2008 16:03:55 -0000 1.63 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 7 Jan 2009 16:11:06 -0000 @@ -93,7 +93,6 @@ } public TypeBinding resolveForCatch(BlockScope scope) { - // resolution on an argument of a catch clause // provide the scope with a side effect : insertion of a LOCAL // that represents the argument. The type must be from JavaThrowable Index: compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java,v retrieving revision 1.124 diff -u -r1.124 CastExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 2 Dec 2008 10:02:46 -0000 1.124 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 7 Jan 2009 16:11:06 -0000 @@ -256,6 +256,7 @@ public void setActualReceiverType(ReferenceBinding actualReceiverType) { /* ignore */} public void setDepth(int depth) { /* ignore */} public void setFieldIndex(int depth){ /* ignore */} + public void setUnchecked(boolean isUnchecked) {/* ignore */} public int sourceStart() { return 0; } public int sourceEnd() { return 0; } }; @@ -287,7 +288,8 @@ } } for (int i = 0; i < argumentLength; i++) { - if (originalArgumentTypes[i] != alternateArgumentTypes[i]) { + if (originalArgumentTypes[i] != alternateArgumentTypes[i] + /*&& !originalArgumentTypes[i].needsUncheckedConversion(alternateArgumentTypes[i])*/) { scope.problemReporter().unnecessaryCast((CastExpression)arguments[i]); } } Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.138 diff -u -r1.138 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 17 Dec 2008 17:37:42 -0000 1.138 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 7 Jan 2009 16:11:07 -0000 @@ -396,8 +396,7 @@ scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, argumentTypes); return null; } - this.binding = - this.receiver.isImplicitThis() + this.binding = this.receiver.isImplicitThis() ? scope.getImplicitMethod(this.selector, argumentTypes, this) : scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this); if (!this.binding.isValidBinding()) { @@ -468,7 +467,7 @@ scope.problemReporter().indirectAccessToStaticMethod(this, this.binding); } } - checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); //-------message send that are known to fail at compile time----------- if (this.binding.isAbstract()) { @@ -484,8 +483,18 @@ if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) { this.resolvedType = this.actualReceiverType; } else { - TypeBinding returnType = this.binding.returnType; - if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd); + TypeBinding returnType; + if ((this.bits & ASTNode.Unchecked) != 0) { + returnType = this.binding.original().returnType; + if (returnType != null) { + returnType = scope.environment().convertToRawType(returnType.erasure(), true); + } + } else { + returnType = this.binding.returnType; + if (returnType != null) { + returnType = returnType.capture(scope, this.sourceEnd); + } + } this.resolvedType = returnType; } if (this.receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) { @@ -529,6 +538,14 @@ // ignore for here } +public void setUnchecked(boolean isUnchecked) { + if (isUnchecked) { + this.bits |= ASTNode.Unchecked; + } else { + this.bits &= ~ASTNode.Unchecked; + } +} + public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { this.receiver.traverse(visitor, blockScope); Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v retrieving revision 1.111 diff -u -r1.111 ParameterizedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 6 Oct 2008 13:23:51 -0000 1.111 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 7 Jan 2009 16:11:10 -0000 @@ -151,7 +151,13 @@ * A >> F corresponds to: F.collectSubstitutes(..., A, ..., CONSTRAINT_SUPER (2)) */ public void collectSubstitutes(Scope scope, TypeBinding actualType, InferenceContext inferenceContext, int constraint) { - if ((this.tagBits & TagBits.HasTypeVariable) == 0) return; + if ((this.tagBits & TagBits.HasTypeVariable) == 0) { + TypeBinding actualEquivalent = actualType.findSuperTypeOriginatingFrom(this.type); + if (actualEquivalent != null && actualEquivalent.isRawType()) { + inferenceContext.isUnchecked = true; + } + return; + } if (actualType == TypeBinding.NULL) return; if (!(actualType instanceof ReferenceBinding)) return; @@ -186,7 +192,7 @@ formalArguments = ((ParameterizedTypeBinding)formalEquivalent).arguments; break; case Binding.RAW_TYPE : - if (!inferenceContext.checkRawSubstitution()) { + if (inferenceContext.depth > 0) { inferenceContext.status = InferenceContext.FAILED; // marker for impossible inference } return; @@ -202,8 +208,10 @@ actualArguments = ((ParameterizedTypeBinding)actualEquivalent).arguments; break; case Binding.RAW_TYPE : - if (!inferenceContext.checkRawSubstitution()) { + if (inferenceContext.depth > 0) { inferenceContext.status = InferenceContext.FAILED; // marker for impossible inference + } else { + inferenceContext.isUnchecked = true; } return; default : Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java,v retrieving revision 1.27 diff -u -r1.27 ParameterizedMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 27 Jun 2008 16:04:02 -0000 1.27 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 7 Jan 2009 16:11:09 -0000 @@ -26,7 +26,6 @@ * Create method of parameterized type, substituting original parameters/exception/return type with type arguments. */ public ParameterizedMethodBinding(final ParameterizedTypeBinding parameterizedDeclaringClass, MethodBinding originalMethod) { - super( originalMethod.modifiers, originalMethod.selector, @@ -49,7 +48,7 @@ final TypeVariableBinding[] substitutedVariables = new TypeVariableBinding[length]; for (int i = 0; i < length; i++) { // copy original type variable to relocate TypeVariableBinding originalVariable = originalVariables[i]; - substitutedVariables[i] = new TypeVariableBinding(originalVariable.sourceName, this, originalVariable.rank); + substitutedVariables[i] = new TypeVariableBinding(originalVariable.sourceName, this, originalVariable.rank, parameterizedDeclaringClass.environment); } this.typeVariables = substitutedVariables; @@ -136,7 +135,6 @@ * This is a CODE ASSIST method ONLY. */ public ParameterizedMethodBinding(final ReferenceBinding declaringClass, MethodBinding originalMethod, char[][] alternateParamaterNames, final LookupEnvironment environment) { - super( originalMethod.modifiers, originalMethod.selector, @@ -162,7 +160,8 @@ originalVariable.sourceName : alternateParamaterNames[i], this, - originalVariable.rank); + originalVariable.rank, + environment); } this.typeVariables = substitutedVariables; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java,v retrieving revision 1.13 diff -u -r1.13 InvocationSite.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java 27 Jun 2008 16:04:02 -0000 1.13 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java 7 Jan 2009 16:11:08 -0000 @@ -15,14 +15,19 @@ TypeBinding[] genericTypeArguments(); boolean isSuperAccess(); boolean isTypeAccess(); - void setDepth(int depth); - void setFieldIndex(int depth); - // in case the receiver type does not match the actual receiver type // e.g. pkg.Type.C (receiver type of C is type of source context, // but actual receiver type is pkg.Type) // e.g2. in presence of implicit access to enclosing type void setActualReceiverType(ReferenceBinding receiverType); - int sourceStart(); + void setDepth(int depth); + void setFieldIndex(int depth); + /** + * Positioned when a method/constructor invocation is detected having required unchecked conversion + * for becoming applicable. + * @param isUnchecked + */ + void setUnchecked(boolean isUnchecked); int sourceEnd(); + int sourceStart(); } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java,v retrieving revision 1.65 diff -u -r1.65 ParameterizedGenericMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 27 Jun 2008 16:04:02 -0000 1.65 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 7 Jan 2009 16:11:09 -0000 @@ -27,17 +27,15 @@ public boolean wasInferred; // only set to true for instances resulting from method invocation inferrence public boolean isRaw; // set to true for method behaving as raw for substitution purpose private MethodBinding tiebreakMethod; - public boolean isUnchecked; // transient flag set during inference (warning: bindings are shared, so flag cannot be trusted beyond) /** * Perform inference of generic method type parameters and/or expected type */ public static MethodBinding computeCompatibleMethod(MethodBinding originalMethod, TypeBinding[] arguments, Scope scope, InvocationSite invocationSite) { - ParameterizedGenericMethodBinding methodSubstitute; TypeVariableBinding[] typeVariables = originalMethod.typeVariables; TypeBinding[] substitutes = invocationSite.genericTypeArguments(); - + TypeBinding[] uncheckedArguments = null; computeSubstitutes: { if (substitutes != null) { // explicit type arguments got supplied @@ -48,19 +46,21 @@ methodSubstitute = scope.environment().createParameterizedGenericMethod(originalMethod, substitutes); break computeSubstitutes; } - // perform type argument inference (15.12.2.7) - // initializes the map of substitutes (var --> type[][]{ equal, extends, super} TypeBinding[] parameters = originalMethod.parameters; InferenceContext inferenceContext = new InferenceContext(originalMethod); methodSubstitute = inferFromArgumentTypes(scope, originalMethod, arguments, parameters, inferenceContext); if (methodSubstitute == null) return null; + // substitutes may hold null to denote unresolved vars, but null arguments got replaced with respective original variable in param method - // 15.12.2.8 - inferring unresolved type arguments if (inferenceContext.hasUnresolvedTypeArgument()) { + if (inferenceContext.isUnchecked) { // only remember unchecked status post 15.12.2.7 + int length = inferenceContext.substitutes.length; + System.arraycopy(inferenceContext.substitutes, 0, uncheckedArguments = new TypeBinding[length], 0, length); + } if (methodSubstitute.returnType != TypeBinding.VOID) { TypeBinding expectedType = null; // if message invocation has expected type @@ -83,10 +83,11 @@ } // bounds check - if (!methodSubstitute.isRaw) { + if (true || false) { for (int i = 0, length = typeVariables.length; i < length; i++) { TypeVariableBinding typeVariable = typeVariables[i]; TypeBinding substitute = methodSubstitute.typeArguments[i]; + if (uncheckedArguments != null && uncheckedArguments[i] == null) continue; // only bound check if inferred through 15.12.2.6 switch (typeVariable.boundCheck(methodSubstitute, substitute)) { case TypeConstants.MISMATCH : // incompatible due to bound check @@ -98,11 +99,12 @@ return new ProblemMethodBinding(methodSubstitute, originalMethod.selector, augmentedArguments, ProblemReasons.ParameterBoundMismatch); case TypeConstants.UNCHECKED : // tolerate unchecked bounds - methodSubstitute.isUnchecked = true; + invocationSite.setUnchecked(true); break; } } } + // check presence of unchecked argument conversion a posteriori (15.12.2.6) return methodSubstitute; } @@ -110,7 +112,6 @@ * Collect argument type mapping, handling varargs */ private static ParameterizedGenericMethodBinding inferFromArgumentTypes(Scope scope, MethodBinding originalMethod, TypeBinding[] arguments, TypeBinding[] parameters, InferenceContext inferenceContext) { - if (originalMethod.isVarargs()) { int paramLength = parameters.length; int minArgLength = paramLength - 1; @@ -152,10 +153,6 @@ if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution } } - if (inferenceContext.status == InferenceContext.RAW_SUBSTITUTION) { - // raw generic method inferred - return scope.environment().createParameterizedGenericMethod(originalMethod, (RawTypeBinding)null); - } TypeVariableBinding[] originalVariables = originalMethod.typeVariables; if (!resolveSubstituteConstraints(scope, originalVariables , inferenceContext, false/*ignore Ti<:Uk*/)) return null; // impossible substitution @@ -261,7 +258,6 @@ * Only invoked for non-static generic methods of raw type */ public ParameterizedGenericMethodBinding(MethodBinding originalMethod, RawTypeBinding rawType, LookupEnvironment environment) { - TypeVariableBinding[] originalVariables = originalMethod.typeVariables; int length = originalVariables.length; TypeBinding[] rawArguments = new TypeBinding[length]; @@ -296,7 +292,6 @@ * Create method of parameterized type, substituting original parameters with type arguments. */ public ParameterizedGenericMethodBinding(MethodBinding originalMethod, TypeBinding[] typeArguments, LookupEnvironment environment) { - this.environment = environment; this.modifiers = originalMethod.modifiers; this.selector = originalMethod.selector; @@ -307,10 +302,10 @@ this.tagBits = originalMethod.tagBits; this.originalMethod = originalMethod; this.parameters = Scope.substitute(this, originalMethod.parameters); - this.thrownExceptions = Scope.substitute(this, originalMethod.thrownExceptions); // error case where exception type variable would have been substituted by a non-reference type (207573) - if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS; this.returnType = Scope.substitute(this, originalMethod.returnType); + this.thrownExceptions = Scope.substitute(this, originalMethod.thrownExceptions); + if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS; checkMissingType: { if ((this.tagBits & TagBits.HasMissingType) != 0) break checkMissingType; @@ -389,67 +384,56 @@ private ParameterizedGenericMethodBinding inferFromExpectedType(Scope scope, InferenceContext inferenceContext) { TypeVariableBinding[] originalVariables = this.originalMethod.typeVariables; // immediate parent (could be a parameterized method) int varLength = originalVariables.length; - - computeSubstitutes: { - // infer from expected return type - if (inferenceContext.expectedType != null) { - this.returnType.collectSubstitutes(scope, inferenceContext.expectedType, inferenceContext, TypeConstants.CONSTRAINT_SUPER); - if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution - } - // infer from bounds of type parameters - for (int i = 0; i < varLength; i++) { - TypeVariableBinding originalVariable = originalVariables[i]; - TypeBinding argument = this.typeArguments[i]; - boolean argAlreadyInferred = argument != originalVariable; - if (originalVariable.firstBound == originalVariable.superclass) { - TypeBinding substitutedBound = Scope.substitute(this, originalVariable.superclass); - argument.collectSubstitutes(scope, substitutedBound, inferenceContext, TypeConstants.CONSTRAINT_SUPER); + // infer from expected return type + if (inferenceContext.expectedType != null) { + this.returnType.collectSubstitutes(scope, inferenceContext.expectedType, inferenceContext, TypeConstants.CONSTRAINT_SUPER); + if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution + } + // infer from bounds of type parameters + for (int i = 0; i < varLength; i++) { + TypeVariableBinding originalVariable = originalVariables[i]; + TypeBinding argument = this.typeArguments[i]; + boolean argAlreadyInferred = argument != originalVariable; + if (originalVariable.firstBound == originalVariable.superclass) { + TypeBinding substitutedBound = Scope.substitute(this, originalVariable.superclass); + argument.collectSubstitutes(scope, substitutedBound, inferenceContext, TypeConstants.CONSTRAINT_SUPER); + if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution + // JLS 15.12.2.8 claims reverse inference shouldn't occur, however it improves inference + // e.g. given: > S test1(S param) + // invocation: test1(new Vector()) will infer: S=Vector and with code below: E=String + if (argAlreadyInferred) { + substitutedBound.collectSubstitutes(scope, argument, inferenceContext, TypeConstants.CONSTRAINT_EXTENDS); if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution - // JLS 15.12.2.8 claims reverse inference shouldn't occur, however it improves inference - // e.g. given: > S test1(S param) - // invocation: test1(new Vector()) will infer: S=Vector and with code below: E=String - if (argAlreadyInferred) { - substitutedBound.collectSubstitutes(scope, argument, inferenceContext, TypeConstants.CONSTRAINT_EXTENDS); - if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution - } } - for (int j = 0, max = originalVariable.superInterfaces.length; j < max; j++) { - TypeBinding substitutedBound = Scope.substitute(this, originalVariable.superInterfaces[j]); - argument.collectSubstitutes(scope, substitutedBound, inferenceContext, TypeConstants.CONSTRAINT_SUPER); + } + for (int j = 0, max = originalVariable.superInterfaces.length; j < max; j++) { + TypeBinding substitutedBound = Scope.substitute(this, originalVariable.superInterfaces[j]); + argument.collectSubstitutes(scope, substitutedBound, inferenceContext, TypeConstants.CONSTRAINT_SUPER); + if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution + // JLS 15.12.2.8 claims reverse inference shouldn't occur, however it improves inference + if (argAlreadyInferred) { + substitutedBound.collectSubstitutes(scope, argument, inferenceContext, TypeConstants.CONSTRAINT_EXTENDS); if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution - // JLS 15.12.2.8 claims reverse inference shouldn't occur, however it improves inference - if (argAlreadyInferred) { - substitutedBound.collectSubstitutes(scope, argument, inferenceContext, TypeConstants.CONSTRAINT_EXTENDS); - if (inferenceContext.status == InferenceContext.FAILED) return null; // impossible substitution - } } } - if (inferenceContext.status == InferenceContext.RAW_SUBSTITUTION) { - // raw generic method inferred - this.isRaw = true; - this.isUnchecked = false; - for (int i = 0; i < varLength; i++) { - this.typeArguments[i] = originalVariables[i].upperBound(); - } - break computeSubstitutes; - } - if (!resolveSubstituteConstraints(scope, originalVariables, inferenceContext, true/*consider Ti<:Uk*/)) - return null; // incompatible - // this.typeArguments = substitutes; - no op since side effects got performed during #resolveSubstituteConstraints - for (int i = 0; i < varLength; i++) { - TypeBinding substitute = inferenceContext.substitutes[i]; - if (substitute != null) { - this.typeArguments[i] = inferenceContext.substitutes[i]; - } else { - // remaining unresolved variable are considered to be Object (or their bound actually) - this.typeArguments[i] = originalVariables[i].upperBound(); - } - } } + if (!resolveSubstituteConstraints(scope, originalVariables, inferenceContext, true/*consider Ti<:Uk*/)) + return null; // incompatible + // this.typeArguments = substitutes; - no op since side effects got performed during #resolveSubstituteConstraints + for (int i = 0; i < varLength; i++) { + TypeBinding substitute = inferenceContext.substitutes[i]; + if (substitute != null) { + this.typeArguments[i] = inferenceContext.substitutes[i]; + } else { + // remaining unresolved variable are considered to be Object (or their bound actually) + this.typeArguments[i] = originalVariables[i].upperBound(); + } + } // may still need an extra substitution at the end (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121369) // to properly substitute a remaining unresolved variable which also appear in a formal bound - this.typeArguments = Scope.substitute(this, this.typeArguments); - // adjust method types to reflect latest inference + this.typeArguments = Scope.substitute(this, this.typeArguments); + + // adjust method types to reflect latest inference TypeBinding oldReturnType = this.returnType; this.returnType = Scope.substitute(this, this.returnType); this.inferredReturnType = inferenceContext.hasExplicitExpectedType && this.returnType != oldReturnType; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java,v retrieving revision 1.24 diff -u -r1.24 CaptureBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java 27 Jun 2008 16:04:02 -0000 1.24 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java 7 Jan 2009 16:11:08 -0000 @@ -25,7 +25,7 @@ public int position; public CaptureBinding(WildcardBinding wildcard, ReferenceBinding sourceType, int position, int captureID) { - super(TypeConstants.WILDCARD_CAPTURE_NAME_PREFIX, null, 0); + super(TypeConstants.WILDCARD_CAPTURE_NAME_PREFIX, null, 0, wildcard.environment); this.wildcard = wildcard; this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat capture as public this.fPackage = wildcard.fPackage; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v retrieving revision 1.114 diff -u -r1.114 BinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 27 Jun 2008 16:04:02 -0000 1.114 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 7 Jan 2009 16:11:08 -0000 @@ -114,7 +114,7 @@ break; case Binding.TYPE_PARAMETER : - ((TypeVariableBinding) type).resolve(environment); + ((TypeVariableBinding) type).resolve(); break; case Binding.GENERIC_TYPE : @@ -606,7 +606,7 @@ pendingVariable = false; int colon = CharOperation.indexOf(':', typeSignature, i); char[] variableName = CharOperation.subarray(typeSignature, i, colon); - variables.add(new TypeVariableBinding(variableName, this, rank++)); + variables.add(new TypeVariableBinding(variableName, this, rank++, this.environment)); } } } @@ -807,7 +807,7 @@ // NOTE: member types of binary types are resolved when needed public TypeVariableBinding getTypeVariable(char[] variableName) { TypeVariableBinding variable = super.getTypeVariable(variableName); - variable.resolve(this.environment); + variable.resolve(); return variable; } private void initializeTypeVariable(TypeVariableBinding variable, TypeVariableBinding[] existingVariables, SignatureWrapper wrapper, char[][][] missingTypeNames) { @@ -934,7 +934,7 @@ } } for (int i = method.typeVariables.length; --i >= 0;) { - method.typeVariables[i].resolve(this.environment); + method.typeVariables[i].resolve(); } method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; return method; @@ -983,7 +983,7 @@ return this.typeVariables; for (int i = this.typeVariables.length; --i >= 0;) - this.typeVariables[i].resolve(this.environment); + this.typeVariables[i].resolve(); this.tagBits &= ~TagBits.HasUnresolvedTypeVariables; return this.typeVariables; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.346 diff -u -r1.346 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 5 Dec 2008 12:41:29 -0000 1.346 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 7 Jan 2009 16:11:11 -0000 @@ -45,6 +45,11 @@ public int kind; public Scope parent; + protected Scope(int kind, Scope parent) { + this.kind = kind; + this.parent = parent; + } + /* Answer an int describing the relationship between the given types. * * NOT_RELATED @@ -59,7 +64,131 @@ return Scope.NOT_RELATED; } - public static TypeBinding getBaseType(char[] name) { + /** + * Returns a type where either all variables or specific ones got discarded. + * e.g. List (discarding ) will return: List> + */ + public static TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { + if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { + switch (originalType.kind()) { + case Binding.ARRAY_TYPE : + ArrayBinding originalArrayType = (ArrayBinding) originalType; + TypeBinding originalLeafComponentType = originalArrayType.leafComponentType; + TypeBinding substitute = convertEliminatingTypeVariables(originalLeafComponentType, genericType, rank, eliminatedVariables); // substitute could itself be array type + if (substitute != originalLeafComponentType) { + return originalArrayType.environment.createArrayType(substitute.leafComponentType(), substitute.dimensions() + originalArrayType.dimensions()); + } + break; + case Binding.PARAMETERIZED_TYPE : + ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) originalType; + ReferenceBinding originalEnclosing = paramType.enclosingType(); + ReferenceBinding substitutedEnclosing = originalEnclosing; + if (originalEnclosing != null) { + substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); + } + TypeBinding[] originalArguments = paramType.arguments; + TypeBinding[] substitutedArguments = originalArguments; + for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { + TypeBinding originalArgument = originalArguments[i]; + TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, paramType.genericType(), i, eliminatedVariables); + if (substitutedArgument != originalArgument) { + if (substitutedArguments == originalArguments) { + System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); + } + substitutedArguments[i] = substitutedArgument; + } else if (substitutedArguments != originalArguments) { + substitutedArguments[i] = originalArgument; + } + } + if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { + return paramType.environment.createParameterizedType(paramType.genericType(), substitutedArguments, substitutedEnclosing); + } + break; + case Binding.TYPE_PARAMETER : + if (genericType == null) { + break; + } + TypeVariableBinding originalVariable = (TypeVariableBinding) originalType; + if (eliminatedVariables != null && eliminatedVariables.contains(originalType)) { + return originalVariable.environment.createWildcard(genericType, rank, null, null, Wildcard.UNBOUND); + } + TypeBinding originalUpperBound = originalVariable.upperBound(); + if (eliminatedVariables == null) { + eliminatedVariables = new HashSet(2); + } + eliminatedVariables.add(originalVariable); + TypeBinding substitutedUpperBound = convertEliminatingTypeVariables(originalUpperBound, genericType, rank, eliminatedVariables); + eliminatedVariables.remove(originalVariable); + return originalVariable.environment.createWildcard(genericType, rank, substitutedUpperBound, null, Wildcard.EXTENDS); + case Binding.RAW_TYPE : + break; + case Binding.GENERIC_TYPE : + ReferenceBinding currentType = (ReferenceBinding) originalType; + originalEnclosing = currentType.enclosingType(); + substitutedEnclosing = originalEnclosing; + if (originalEnclosing != null) { + substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); + } + originalArguments = currentType.typeVariables(); + substitutedArguments = originalArguments; + for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { + TypeBinding originalArgument = originalArguments[i]; + TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, currentType, i, eliminatedVariables); + if (substitutedArgument != originalArgument) { + if (substitutedArguments == originalArguments) { + System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); + } + substitutedArguments[i] = substitutedArgument; + } else if (substitutedArguments != originalArguments) { + substitutedArguments[i] = originalArgument; + } + } + if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { + return ((TypeVariableBinding)originalArguments[0]).environment.createParameterizedType(genericType, substitutedArguments, substitutedEnclosing); + } + break; + case Binding.WILDCARD_TYPE : + WildcardBinding wildcard = (WildcardBinding) originalType; + TypeBinding originalBound = wildcard.bound; + TypeBinding substitutedBound = originalBound; + if (originalBound != null) { + substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); + if (substitutedBound != originalBound) { + return wildcard.environment.createWildcard(wildcard.genericType, wildcard.rank, substitutedBound, null, wildcard.boundKind); + } + } + break; + case Binding.INTERSECTION_TYPE : + WildcardBinding intersection = (WildcardBinding) originalType; + originalBound = intersection.bound; + substitutedBound = originalBound; + if (originalBound != null) { + substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); + } + TypeBinding[] originalOtherBounds = intersection.otherBounds; + TypeBinding[] substitutedOtherBounds = originalOtherBounds; + for (int i = 0, length = originalOtherBounds == null ? 0 : originalOtherBounds.length; i < length; i++) { + TypeBinding originalOtherBound = originalOtherBounds[i]; + TypeBinding substitutedOtherBound = convertEliminatingTypeVariables(originalOtherBound, genericType, rank, eliminatedVariables); + if (substitutedOtherBound != originalOtherBound) { + if (substitutedOtherBounds == originalOtherBounds) { + System.arraycopy(originalOtherBounds, 0, substitutedOtherBounds = new TypeBinding[length], 0, i); + } + substitutedOtherBounds[i] = substitutedOtherBound; + } else if (substitutedOtherBounds != originalOtherBounds) { + substitutedOtherBounds[i] = originalOtherBound; + } + } + if (substitutedBound != originalBound || substitutedOtherBounds != originalOtherBounds) { + return intersection.environment.createWildcard(intersection.genericType, intersection.rank, substitutedBound, substitutedOtherBounds, intersection.boundKind); + } + break; + } + } + return originalType; + } + + public static TypeBinding getBaseType(char[] name) { // list should be optimized (with most often used first) int length = name.length; if (length > 2 && length < 8) { @@ -121,7 +250,7 @@ return null; } - // 5.1.10 + // 5.1.10 public static ReferenceBinding[] greaterLowerBound(ReferenceBinding[] types) { if (types == null) return null; int length = types.length; @@ -335,11 +464,6 @@ return substitutedTypes; } - protected Scope(int kind, Scope parent) { - this.kind = kind; - this.parent = parent; - } - /* * Boxing primitive */ @@ -587,7 +711,7 @@ int count = 0; for (int i = 0; i < length; i++) { TypeParameter typeParameter = typeParameters[i]; - TypeVariableBinding parameterBinding = new TypeVariableBinding(typeParameter.name, declaringElement, i); + TypeVariableBinding parameterBinding = new TypeVariableBinding(typeParameter.name, declaringElement, i, environment()); parameterBinding.fPackage = unitPackage; typeParameter.binding = parameterBinding; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.100 diff -u -r1.100 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 3 Oct 2008 18:10:36 -0000 1.100 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 7 Jan 2009 16:11:08 -0000 @@ -11,9 +11,7 @@ package org.eclipse.jdt.internal.compiler.lookup; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ClassFilePool; @@ -386,123 +384,6 @@ return packageBinding; } -public TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { - if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { - switch (originalType.kind()) { - case Binding.ARRAY_TYPE : - ArrayBinding originalArrayType = (ArrayBinding) originalType; - TypeBinding originalLeafComponentType = originalArrayType.leafComponentType; - TypeBinding substitute = convertEliminatingTypeVariables(originalLeafComponentType, genericType, rank, eliminatedVariables); // substitute could itself be array type - if (substitute != originalLeafComponentType) { - return createArrayType(substitute.leafComponentType(), substitute.dimensions() + originalArrayType.dimensions()); - } - break; - case Binding.PARAMETERIZED_TYPE : - ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) originalType; - ReferenceBinding originalEnclosing = paramType.enclosingType(); - ReferenceBinding substitutedEnclosing = originalEnclosing; - if (originalEnclosing != null) { - substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); - } - TypeBinding[] originalArguments = paramType.arguments; - TypeBinding[] substitutedArguments = originalArguments; - for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { - TypeBinding originalArgument = originalArguments[i]; - TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, paramType.genericType(), i, eliminatedVariables); - if (substitutedArgument != originalArgument) { - if (substitutedArguments == originalArguments) { - System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); - } - substitutedArguments[i] = substitutedArgument; - } else if (substitutedArguments != originalArguments) { - substitutedArguments[i] = originalArgument; - } - } - if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { - return createParameterizedType(paramType.genericType(), substitutedArguments, substitutedEnclosing); - } - break; - case Binding.TYPE_PARAMETER : - if (eliminatedVariables != null && eliminatedVariables.contains(originalType)) { - return createWildcard(genericType, rank, null, null, Wildcard.UNBOUND); - } - TypeVariableBinding variable = (TypeVariableBinding) originalType; - TypeBinding originalUpperBound = variable.upperBound(); - if (eliminatedVariables == null) { - eliminatedVariables = new HashSet(2); - } - eliminatedVariables.add(variable); - TypeBinding substitutedUpperBound = convertEliminatingTypeVariables(originalUpperBound, genericType, rank, eliminatedVariables); - eliminatedVariables.remove(variable); - return createWildcard(genericType, rank, substitutedUpperBound, null, Wildcard.EXTENDS); - case Binding.RAW_TYPE : - break; - case Binding.GENERIC_TYPE : - ReferenceBinding currentType = (ReferenceBinding) originalType; - originalEnclosing = currentType.enclosingType(); - substitutedEnclosing = originalEnclosing; - if (originalEnclosing != null) { - substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); - } - originalArguments = currentType.typeVariables(); - substitutedArguments = originalArguments; - for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { - TypeBinding originalArgument = originalArguments[i]; - TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, currentType, i, eliminatedVariables); - if (substitutedArgument != originalArgument) { - if (substitutedArguments == originalArguments) { - System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); - } - substitutedArguments[i] = substitutedArgument; - } else if (substitutedArguments != originalArguments) { - substitutedArguments[i] = originalArgument; - } - } - if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { - return createParameterizedType(genericType, substitutedArguments, substitutedEnclosing); - } - break; - case Binding.WILDCARD_TYPE : - WildcardBinding wildcard = (WildcardBinding) originalType; - TypeBinding originalBound = wildcard.bound; - TypeBinding substitutedBound = originalBound; - if (originalBound != null) { - substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); - if (substitutedBound != originalBound) { - return createWildcard(wildcard.genericType, wildcard.rank, substitutedBound, null, wildcard.boundKind); - } - } - break; - case Binding.INTERSECTION_TYPE : - WildcardBinding intersection = (WildcardBinding) originalType; - originalBound = intersection.bound; - substitutedBound = originalBound; - if (originalBound != null) { - substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); - } - TypeBinding[] originalOtherBounds = intersection.otherBounds; - TypeBinding[] substitutedOtherBounds = originalOtherBounds; - for (int i = 0, length = originalOtherBounds == null ? 0 : originalOtherBounds.length; i < length; i++) { - TypeBinding originalOtherBound = originalOtherBounds[i]; - TypeBinding substitutedOtherBound = convertEliminatingTypeVariables(originalOtherBound, genericType, rank, eliminatedVariables); - if (substitutedOtherBound != originalOtherBound) { - if (substitutedOtherBounds == originalOtherBounds) { - System.arraycopy(originalOtherBounds, 0, substitutedOtherBounds = new TypeBinding[length], 0, i); - } - substitutedOtherBounds[i] = substitutedOtherBound; - } else if (substitutedOtherBounds != originalOtherBounds) { - substitutedOtherBounds[i] = originalOtherBound; - } - } - if (substitutedBound != originalBound || substitutedOtherBounds != originalOtherBounds) { - return createWildcard(intersection.genericType, intersection.rank, substitutedBound, substitutedOtherBounds, intersection.boundKind); - } - break; - } - } - return originalType; -} - /** * Convert a given source type into a parameterized form if generic. * generic X --> param X @@ -598,6 +479,27 @@ return type; } +/** + * Convert an array of types in raw forms. + * Only allocate an array if anything is different. + */ +public ReferenceBinding[] convertToRawTypes(ReferenceBinding[] originalTypes, boolean forceErasure, boolean forceRawEnclosingType) { + if (originalTypes == null) return null; + ReferenceBinding[] convertedTypes = originalTypes; + for (int i = 0, length = originalTypes.length; i < length; i++) { + ReferenceBinding originalType = originalTypes[i]; + ReferenceBinding convertedType = (ReferenceBinding) convertToRawType(forceErasure ? originalType.erasure() : originalType, forceRawEnclosingType); + if (convertedType != originalType) { + if (convertedTypes == originalTypes) { + System.arraycopy(originalTypes, 0, convertedTypes = new ReferenceBinding[length], 0, i); + } + convertedTypes[i] = convertedType; + } else if (convertedTypes != originalTypes) { + convertedTypes[i] = originalType; + } + } + return convertedTypes; +} // variation for unresolved types in binaries (consider generic type as raw) public TypeBinding convertUnresolvedBinaryToRawType(TypeBinding type) { 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.69 diff -u -r1.69 TypeVariableBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 26 Sep 2008 16:32:56 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 7 Jan 2009 16:11:11 -0000 @@ -32,22 +32,24 @@ public ReferenceBinding superclass; public ReferenceBinding[] superInterfaces; public char[] genericTypeSignature; - - public TypeVariableBinding(char[] sourceName, Binding declaringElement, int rank) { + LookupEnvironment environment; + + public TypeVariableBinding(char[] sourceName, Binding declaringElement, int rank, LookupEnvironment environment) { this.sourceName = sourceName; this.declaringElement = declaringElement; this.rank = rank; this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat type var as public this.tagBits |= TagBits.HasTypeVariable; + this.environment = environment; } /** * Returns true if the argument type satisfies all bounds of the type parameter */ public int boundCheck(Substitution substitution, TypeBinding argumentType) { - - if (argumentType == TypeBinding.NULL || argumentType == this) + if (argumentType == TypeBinding.NULL || argumentType == this) { return TypeConstants.OK; + } boolean hasSubstitution = substitution != null; if (!(argumentType instanceof ReferenceBinding || argumentType.isArrayType())) return TypeConstants.MISMATCH; @@ -63,27 +65,27 @@ TypeBinding wildcardBound = wildcard.bound; if (wildcardBound == this) return TypeConstants.OK; - ReferenceBinding superclassBound = hasSubstitution ? (ReferenceBinding)Scope.substitute(substitution, this.superclass) : this.superclass; boolean isArrayBound = wildcardBound.isArrayType(); if (!wildcardBound.isInterface()) { - if (superclassBound.id != TypeIds.T_JavaLangObject) { + TypeBinding substitutedSuperType = hasSubstitution ? Scope.substitute(substitution, this.superclass) : this.superclass; + if (substitutedSuperType.id != TypeIds.T_JavaLangObject) { if (isArrayBound) { - if (!wildcardBound.isCompatibleWith(superclassBound)) + if (!wildcardBound.isCompatibleWith(substitutedSuperType)) return TypeConstants.MISMATCH; } else { - TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(superclassBound); + TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(substitutedSuperType); if (match != null) { - if (superclassBound.isProvablyDistinct(match)) { + if (substitutedSuperType.isProvablyDistinct(match)) { return TypeConstants.MISMATCH; } } else { - match = superclassBound.findSuperTypeOriginatingFrom(wildcardBound); + match = substitutedSuperType.findSuperTypeOriginatingFrom(wildcardBound); if (match != null) { if (match.isProvablyDistinct(wildcardBound)) { return TypeConstants.MISMATCH; } } else { - if (!wildcardBound.isTypeVariable() && !superclassBound.isTypeVariable()) { + if (!wildcardBound.isTypeVariable() && !substitutedSuperType.isTypeVariable()) { return TypeConstants.MISMATCH; } } @@ -91,18 +93,16 @@ } } } - ReferenceBinding[] superInterfaceBounds = hasSubstitution ? Scope.substitute(substitution, this.superInterfaces) : this.superInterfaces; - int length = superInterfaceBounds.length; boolean mustImplement = isArrayBound || ((ReferenceBinding)wildcardBound).isFinal(); - for (int i = 0; i < length; i++) { - TypeBinding superInterfaceBound = superInterfaceBounds[i]; + for (int i = 0, length = this.superInterfaces.length; i < length; i++) { + TypeBinding substitutedSuperType = hasSubstitution ? Scope.substitute(substitution, this.superInterfaces[i]) : this.superInterfaces[i]; if (isArrayBound) { - if (!wildcardBound.isCompatibleWith(superInterfaceBound)) + if (!wildcardBound.isCompatibleWith(substitutedSuperType)) return TypeConstants.MISMATCH; } else { - TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(superInterfaceBound); + TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(substitutedSuperType); if (match != null) { - if (superInterfaceBound.isProvablyDistinct(match)) { + if (substitutedSuperType.isProvablyDistinct(match)) { return TypeConstants.MISMATCH; } } else if (mustImplement) { @@ -380,19 +380,19 @@ public char[] readableName() { return this.sourceName; } - ReferenceBinding resolve(LookupEnvironment environment) { + ReferenceBinding resolve() { if ((this.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0) return this; TypeBinding oldSuperclass = this.superclass, oldFirstInterface = null; if (this.superclass != null) - this.superclass = (ReferenceBinding) BinaryTypeBinding.resolveType(this.superclass, environment, true /* raw conversion */); + this.superclass = (ReferenceBinding) BinaryTypeBinding.resolveType(this.superclass, this.environment, true /* raw conversion */); ReferenceBinding[] interfaces = this.superInterfaces; int length; if ((length = interfaces.length) != 0) { oldFirstInterface = interfaces[0]; for (int i = length; --i >= 0;) { - interfaces[i] = (ReferenceBinding) BinaryTypeBinding.resolveType(interfaces[i], environment, true /* raw conversion */); + interfaces[i] = (ReferenceBinding) BinaryTypeBinding.resolveType(interfaces[i], this.environment, true /* raw conversion */); } } // refresh the firstBound in case it changed Index: compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext.java,v retrieving revision 1.5 diff -u -r1.5 InferenceContext.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext.java 27 Jun 2008 16:04:02 -0000 1.5 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext.java 7 Jan 2009 16:11:08 -0000 @@ -21,9 +21,9 @@ int status; TypeBinding expectedType; boolean hasExplicitExpectedType; // indicates whether the expectedType (if set) was explicit in code, or set by default + public boolean isUnchecked; TypeBinding[] substitutes; final static int FAILED = 1; - final static int RAW_SUBSTITUTION = 2; public InferenceContext(MethodBinding genericMethod) { this.genericMethod = genericMethod; @@ -33,16 +33,6 @@ this.substitutes = new TypeBinding[varLength]; } -public boolean checkRawSubstitution() { - // only at first level, during inference from arguments - if (this.depth > 0) return false; -// if (this.argumentIndex < 0 || this.depth != 0) { -// return false; -// } - this.status = RAW_SUBSTITUTION; - return true; -} - public TypeBinding[] getSubstitutes(TypeVariableBinding typeVariable, int constraint) { return this.collectedSubstitutes[typeVariable.rank][constraint]; } @@ -99,9 +89,6 @@ case FAILED : buffer.append("failed]");//$NON-NLS-1$ break; - case RAW_SUBSTITUTION : - buffer.append("raw-subst]");//$NON-NLS-1$ - break; } if (this.expectedType == null) { buffer.append(" [expectedType=null]"); //$NON-NLS-1$ Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java,v retrieving revision 1.45 diff -u -r1.45 LocalVariableBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 7 Jul 2008 17:08:07 -0000 1.45 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 7 Jan 2009 16:11:08 -0000 @@ -53,7 +53,6 @@ * Answer the receiver's binding type from Binding.BindingID. */ public final int kind() { - return LOCAL; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v retrieving revision 1.103 diff -u -r1.103 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 6 Oct 2008 13:23:51 -0000 1.103 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 7 Jan 2009 16:11:11 -0000 @@ -724,7 +724,7 @@ } if (variable.firstBound == null) // unbound variable return false; - TypeBinding eliminatedType = (paramType.environment.convertEliminatingTypeVariables(variable, paramType.genericType(), rank, null)); + TypeBinding eliminatedType = Scope.convertEliminatingTypeVariables(variable, paramType.genericType(), rank, null); switch (eliminatedType.kind()) { case Binding.WILDCARD_TYPE : case Binding.INTERSECTION_TYPE : @@ -779,7 +779,7 @@ } if (otherVariable.firstBound == null) // unbound variable return false; - TypeBinding otherEliminatedType = (paramType.environment.convertEliminatingTypeVariables(otherVariable, paramType.genericType(), rank, null)); + TypeBinding otherEliminatedType = Scope.convertEliminatingTypeVariables(otherVariable, paramType.genericType(), rank, null); switch (otherEliminatedType.kind()) { case Binding.WILDCARD_TYPE : case Binding.INTERSECTION_TYPE : Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java,v retrieving revision 1.34 diff -u -r1.34 CodeSnippetReturnStatement.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 17 Sep 2008 09:08:40 -0000 1.34 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 7 Jan 2009 16:11:14 -0000 @@ -142,4 +142,7 @@ // ignored } +public void setUnchecked(boolean isUnchecked) { + // ignored +} } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java,v retrieving revision 1.20 diff -u -r1.20 CodeSnippetSuperReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java 27 Jun 2008 16:04:06 -0000 1.20 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java 7 Jan 2009 16:11:14 -0000 @@ -55,5 +55,9 @@ // ignored } +public void setUnchecked(boolean isUnchecked) { + // ignored +} + } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v retrieving revision 1.60 diff -u -r1.60 CodeSnippetMessageSend.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 30 Sep 2008 15:31:26 -0000 1.60 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 7 Jan 2009 16:11:13 -0000 @@ -11,6 +11,7 @@ package org.eclipse.jdt.internal.eval; import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.CastExpression; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.MessageSend; @@ -311,7 +312,7 @@ } } } - checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); //-------message send that are known to fail at compile time----------- if (this.binding.isAbstract()) { @@ -331,7 +332,13 @@ this.resolvedType = this.actualReceiverType; } else { TypeBinding returnType = this.binding.returnType; - if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd); + + if (returnType != null) { + if ((this.bits & ASTNode.Unchecked) != 0) { + returnType = scope.environment().convertToRawType(returnType.erasure(), true); + } + returnType = returnType.capture(scope, this.sourceEnd); + } this.resolvedType = returnType; } return this.resolvedType; Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java,v retrieving revision 1.35 diff -u -r1.35 CodeSnippetThisReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java 25 Sep 2008 23:10:29 -0000 1.35 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java 7 Jan 2009 16:11:14 -0000 @@ -41,6 +41,7 @@ this.evaluationContext = evaluationContext; this.isImplicit = isImplicit; } + public boolean checkAccess(MethodScope methodScope) { // this/super cannot be used in constructor call if (this.evaluationContext.isConstructorCall) { @@ -55,6 +56,7 @@ } return true; } + public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; if (valueRequired) { @@ -63,18 +65,22 @@ } codeStream.recordPositionsFrom(pc, this.sourceStart); } + /** * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments() */ public TypeBinding[] genericTypeArguments() { return null; } + public boolean isSuperAccess(){ return false; } + public boolean isTypeAccess(){ return false; } + public StringBuffer printExpression(int indent, StringBuffer output){ char[] declaringType = this.evaluationContext.declaringTypeName; @@ -85,8 +91,8 @@ output.append(declaringType); return output.append(")this"); //$NON-NLS-1$ } + public TypeBinding resolveType(BlockScope scope) { - // implicit this this.constant = Constant.NotAConstant; TypeBinding snippetType = null; @@ -105,13 +111,20 @@ } return this.resolvedType = this.delegateThis.type; } + public void setActualReceiverType(ReferenceBinding receiverType) { // ignored } + public void setDepth(int depth){ // ignored } + public void setFieldIndex(int index){ // ignored } + + public void setUnchecked(boolean isUnchecked) { + // ignored + } } Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.386 diff -u -r1.386 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 10 Dec 2008 19:39:17 -0000 1.386 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jan 2009 16:11:13 -0000 @@ -21,15 +21,97 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.compiler.InvalidInputException; -import org.eclipse.jdt.internal.compiler.*; -import org.eclipse.jdt.internal.compiler.ast.*; +import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; +import org.eclipse.jdt.internal.compiler.IProblemFactory; +import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; +import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; +import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.Argument; +import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression; +import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference; +import org.eclipse.jdt.internal.compiler.ast.ArrayReference; +import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference; +import org.eclipse.jdt.internal.compiler.ast.Assignment; +import org.eclipse.jdt.internal.compiler.ast.BinaryExpression; +import org.eclipse.jdt.internal.compiler.ast.Block; +import org.eclipse.jdt.internal.compiler.ast.BranchStatement; +import org.eclipse.jdt.internal.compiler.ast.CaseStatement; +import org.eclipse.jdt.internal.compiler.ast.CastExpression; +import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; +import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression; +import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; +import org.eclipse.jdt.internal.compiler.ast.EqualExpression; +import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall; +import org.eclipse.jdt.internal.compiler.ast.Expression; +import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; +import org.eclipse.jdt.internal.compiler.ast.FieldReference; +import org.eclipse.jdt.internal.compiler.ast.ImportReference; +import org.eclipse.jdt.internal.compiler.ast.Initializer; +import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression; +import org.eclipse.jdt.internal.compiler.ast.IntLiteral; +import org.eclipse.jdt.internal.compiler.ast.LabeledStatement; +import org.eclipse.jdt.internal.compiler.ast.Literal; +import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; +import org.eclipse.jdt.internal.compiler.ast.LongLiteral; +import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; +import org.eclipse.jdt.internal.compiler.ast.MessageSend; +import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.NameReference; +import org.eclipse.jdt.internal.compiler.ast.NumberLiteral; +import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; +import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; +import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression; +import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; +import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; +import org.eclipse.jdt.internal.compiler.ast.Reference; +import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; +import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; +import org.eclipse.jdt.internal.compiler.ast.Statement; +import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; +import org.eclipse.jdt.internal.compiler.ast.ThisReference; +import org.eclipse.jdt.internal.compiler.ast.TryStatement; +import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.eclipse.jdt.internal.compiler.ast.TypeParameter; +import org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.eclipse.jdt.internal.compiler.ast.UnaryExpression; +import org.eclipse.jdt.internal.compiler.ast.Wildcard; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.AccessRestriction; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; -import org.eclipse.jdt.internal.compiler.lookup.*; -import org.eclipse.jdt.internal.compiler.parser.*; +import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; +import org.eclipse.jdt.internal.compiler.lookup.Binding; +import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; +import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; +import org.eclipse.jdt.internal.compiler.lookup.InvocationSite; +import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; +import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; +import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; +import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; +import org.eclipse.jdt.internal.compiler.lookup.Scope; +import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding; +import org.eclipse.jdt.internal.compiler.lookup.TagBits; +import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; +import org.eclipse.jdt.internal.compiler.lookup.TypeIds; +import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; +import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; +import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants; +import org.eclipse.jdt.internal.compiler.parser.Parser; +import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner; +import org.eclipse.jdt.internal.compiler.parser.Scanner; +import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; +import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; import org.eclipse.jdt.internal.compiler.util.Messages; public class ProblemReporter extends ProblemHandler { @@ -6828,7 +6910,7 @@ nodeSourceStart(field,location), nodeSourceEnd(field, location)); } -public void unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod) { +public void unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes) { boolean isConstructor = rawMethod.isConstructor(); int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawGenericConstructorInvocation : IProblem.UnsafeRawGenericMethodInvocation); if (severity == ProblemSeverities.Ignore) return; @@ -6839,13 +6921,13 @@ new String(rawMethod.declaringClass.sourceName()), typesAsString(rawMethod.original().isVarargs(), rawMethod.original().parameters, false), new String(rawMethod.declaringClass.readableName()), - typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false), + typesAsString(rawMethod.original().isVarargs(), argumentTypes, false), }, new String[] { new String(rawMethod.declaringClass.sourceName()), typesAsString(rawMethod.original().isVarargs(), rawMethod.original().parameters, true), new String(rawMethod.declaringClass.shortReadableName()), - typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true), + typesAsString(false, argumentTypes, true), }, severity, location.sourceStart, @@ -6857,13 +6939,13 @@ new String(rawMethod.selector), typesAsString(rawMethod.original().isVarargs(), rawMethod.original().parameters, false), new String(rawMethod.declaringClass.readableName()), - typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false), + typesAsString(false, argumentTypes, false), }, new String[] { new String(rawMethod.selector), typesAsString(rawMethod.original().isVarargs(), rawMethod.original().parameters, true), new String(rawMethod.declaringClass.shortReadableName()), - typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true), + typesAsString(false, argumentTypes, true), }, severity, location.sourceStart, Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.382 diff -u -r1.382 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 5 Dec 2008 15:55:50 -0000 1.382 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 7 Jan 2009 16:11:06 -0000 @@ -452,6 +452,7 @@ public void setActualReceiverType(ReferenceBinding receiverType) {/* empty */} public void setDepth(int depth){/* empty */} public void setFieldIndex(int depth){/* empty */} + public void setUnchecked(boolean isUnchecked) {/* empty */} public int sourceEnd() { return 0; } public int sourceStart() { return 0; } };