R3_4_maintenance - 243820
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 60343db..05cf415 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
@@ -8763,6 +8763,62 @@
"----------\n"
);
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=243820
+public void test169() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " interface I<S> {}\n" +
+ " interface J { A foo(A a, I<String> i); }\n" +
+ " static class A {}\n" +
+ " static class B implements J {\n" +
+ " public R foo(A a, I i) { return null; }\n" +
+ " }\n" +
+ "}\n" +
+ "class R<T> extends X.A {}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 6)\n" +
+ " public R foo(A a, I i) { return null; }\n" +
+ " ^\n" +
+ "R is a raw type. References to generic type R<T> should be parameterized\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 6)\n" +
+ " public R foo(A a, I i) { return null; }\n" +
+ " ^\n" +
+ "X.I is a raw type. References to generic type X<T>.I<S> should be parameterized\n" +
+ "----------\n"
+ );
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=243820
+public void test169a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " abstract class B implements J {\n" +
+ " public R foo(X<String>.B b, I i) { return null; }\n" +
+ " }\n" +
+ "}\n" +
+ "interface I<S> {}\n" +
+ "interface J { A foo(A a, I<String> i); }\n" +
+ "class A {}\n" +
+ "class R<T> extends A {}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " public R foo(X<String>.B b, I i) { return null; }\n" +
+ " ^\n" +
+ "R is a raw type. References to generic type R<T> should be parameterized\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " public R foo(X<String>.B b, I i) { return null; }\n" +
+ " ^\n" +
+ "I is a raw type. References to generic type I<S> should be parameterized\n" +
+ "----------\n"
+ );
+}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249140
public void test174() {
this.runNegativeTest(
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 285bb8b..2477fe6 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -48,7 +48,9 @@
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=249140">249140</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=243820">243820</a>
+[1.5][compiler] Method has same erasure as an interface method but is not considered to implement it
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=249140">249140</a>
[1.5][compiler] asymmetric errors with covariant inherited methods
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=243692">243692</a>
[buildpath] Cannot set Attached Source from Class File Editor
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
index 7aac4cf..5e8ad65 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
@@ -63,7 +63,7 @@
// one parameter type is raw, hence all parameters types must be raw or non generic
// otherwise we have a mismatch check backwards
for (int j = 0; j < i; j++)
- if (oneArgs[j].leafComponentType().isParameterizedType())
+ if (oneArgs[j].leafComponentType().isParameterizedTypeWithActualArguments())
return false;
// switch to all raw mode
break foundRAW;
@@ -79,7 +79,7 @@
if (oneArgs[i].dimensions() == twoArgs[i].dimensions() && oneArgs[i].leafComponentType().isEquivalentTo(twoArgs[i].leafComponentType()))
continue;
return false;
- } else if (oneArgs[i].leafComponentType().isParameterizedType()) {
+ } else if (oneArgs[i].leafComponentType().isParameterizedTypeWithActualArguments()) {
return false; // no remaining parameter can be a Parameterized type (if one has been converted then all RAW types must be converted)
}
}
@@ -125,7 +125,7 @@
// so the parameters are equal and the return type is compatible b/w the currentMethod & the substituted inheritedMethod
MethodBinding originalInherited = abstractMethod.original();
if (originalInherited.returnType != concreteMethod.returnType) {
- if (abstractMethod.returnType.leafComponentType().isParameterizedType()) {
+ if (abstractMethod.returnType.leafComponentType().isParameterizedTypeWithActualArguments()) {
if (concreteMethod.returnType.leafComponentType().isRawType())
problemReporter().unsafeReturnTypeOverride(concreteMethod, originalInherited, this.type);
} else if (abstractMethod.hasSubstitutedReturnType() && originalInherited.returnType.leafComponentType().isTypeVariable()) {
@@ -153,7 +153,8 @@
if (originalInherited.returnType != currentMethod.returnType) {
// if (currentMethod.returnType.needsUncheckedConversion(inheritedMethod.returnType)) {
// problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type);
- if (inheritedMethod.returnType.leafComponentType().isParameterizedType() && currentMethod.returnType.leafComponentType().isRawType()) {
+ if (inheritedMethod.returnType.leafComponentType().isParameterizedTypeWithActualArguments()
+ && currentMethod.returnType.leafComponentType().isRawType()) {
problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type);
} else if (inheritedMethod.hasSubstitutedReturnType() && originalInherited.returnType.leafComponentType().isTypeVariable()) {
if (((TypeVariableBinding) originalInherited.returnType.leafComponentType()).declaringElement == originalInherited) { // see 81618 - type variable from inherited method
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
index 1452a09..a2fce57 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
@@ -483,6 +483,17 @@
}
/**
+ * Returns true if the type is parameterized, e.g. List<String>
+ * Note that some instances of ParameterizedTypeBinding do answer false to {@link #isParameterizedType()}
+ * in case they have no arguments, like for non-generic members of a parameterized type.
+ * i.e. {@link #isParameterizedType()} is not equivalent to testing <code>type.kind() == Binding.PARAMETERIZED_TYPE</code>
+ */
+public final boolean isParameterizedTypeWithActualArguments() {
+ return (kind() == Binding.PARAMETERIZED_TYPE)
+ && ((ParameterizedTypeBinding) this).arguments != null;
+}
+
+/**
* Returns true if the type is parameterized using its own type variables as arguments
*/
public boolean isParameterizedWithOwnVariables() {