diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java index 6eb1299..0deb894 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java @@ -11239,24 +11239,7 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088 public void test200() { Map options = getCompilerOptions(); - String compliance = (String) options.get(JavaCore.COMPILER_COMPLIANCE); - String errorMessage = compliance == JavaCore.VERSION_1_6 ? - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " int foo(Collection bar) { return 0; }\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + - " int foo(Collection bar) { return 0; }\n" + - " ^^^^^^^^^^\n" + - "Collection is a raw type. References to generic type Collection should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " double foo(Collection bar) {return 0; }\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + - "----------\n" : + String errorMessage = "----------\n" + "1. ERROR in X.java (at line 3)\n" + " int foo(Collection bar) { return 0; }\n" + @@ -13512,4 +13495,50 @@ "Name clash: The method foo(A) of type Sub has the same erasure as foo(A) of type Super but does not hide it\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=355838 +public void testBug355838() throws Exception { + String output = + "----------\n" + + "1. ERROR in ErasureBug.java (at line 4)\n" + + " public String output(List integers) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method output(List) has the same erasure output(List) as another method in type ErasureBug\n" + + "----------\n" + + "2. ERROR in ErasureBug.java (at line 7)\n" + + " public String output(List doubles) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method output(List) has the same erasure output(List) as another method in type ErasureBug\n" + + "----------\n" + + "3. WARNING in ErasureBug.java (at line 7)\n" + + " public String output(List doubles) {\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "4. WARNING in ErasureBug.java (at line 10)\n" + + " public static void main(String[] args) { new ErasureBug().output(new ArrayList()); }\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The expression of type ArrayList needs unchecked conversion to conform to List\n" + + "----------\n" + + "5. WARNING in ErasureBug.java (at line 10)\n" + + " public static void main(String[] args) { new ErasureBug().output(new ArrayList()); }\n" + + " ^^^^^^^^^\n" + + "ArrayList is a raw type. References to generic type ArrayList should be parameterized\n" + + "----------\n"; + this.runNegativeTest( + new String[] { + "ErasureBug.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "public class ErasureBug {\n" + + " public String output(List integers) {\n" + + " return \"1\";\n" + + " }\n" + + " public String output(List doubles) {\n" + + " return \"2\";\n" + + " }\n" + + " public static void main(String[] args) { new ErasureBug().output(new ArrayList()); }\n" + + "}\n" + }, + output); +} } diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index 90eaf1e..4a0fe46 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -52,7 +52,9 @@

What's new in this drop

Problem Reports Fixed

-349326 +355838 +[compiler] ecj compiles the code that javac6 rejects +
349326 [1.7] new warning for missing try-with-resources
354502 Incorrect Compiler Warning: "Method can be declared as static" diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java index b346908..d1f9cf4 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java @@ -1240,8 +1240,16 @@ int index = pLength; // is erasure of signature of m2 same as signature of m1? for (; --index >= 0;) { - if (params1[index] != params2[index].erasure()) - break; + if (params1[index] != params2[index].erasure()) { + // If one of them is a raw type + if (params1[index] instanceof RawTypeBinding) { + if (params2[index].erasure() != ((RawTypeBinding)params1[index]).actualType()) { + break; + } + } else { + break; + } + } if (params1[index] == params2[index]) { TypeBinding type = params1[index].leafComponentType(); if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) { @@ -1253,8 +1261,16 @@ if (index >= 0 && index < pLength) { // is erasure of signature of m1 same as signature of m2? for (index = pLength; --index >= 0;) - if (params1[index].erasure() != params2[index]) - break; + if (params1[index].erasure() != params2[index]) { + // If one of them is a raw type + if (params2[index] instanceof RawTypeBinding) { + if (params1[index].erasure() != ((RawTypeBinding)params2[index]).actualType()) { + break; + } + } else { + break; + } + } } if (index >= 0) {