82250
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 009daa1..11f74c3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -11362,14 +11362,21 @@
},
""
);
- this.runConformTest(
+ this.runNegativeTest(
new String[] {
"X4.java",
"class X4 <T extends Comparable<Z> & Comparable<Z>> {}\n" +
"abstract class Y extends Z {}\n" +
"abstract class Z implements Comparable<Z> {}",
},
- "" // no complaints about duplicates
+ "----------\n" +
+ "1. ERROR in X4.java (at line 1)\r\n" +
+ " class X4 <T extends Comparable<Z> & Comparable<Z>> {}\r\n" +
+ " ^^^^^^^^^^\n" +
+ "Duplicate bound Comparable<Z>\n" +
+ "----------\n"
+ // no complaints about duplicates if they are both parameterized with same args
+ // but you cannot extend Comparable & Comparable so we'll report an error
);
this.runNegativeTest(
new String[] {
@@ -12113,8 +12120,8 @@
" ^^^^^^^^^^^^^^^\n" +
"Cannot allocate the member type X<String>.Inner<Integer> using a parameterized compound name; use its simple name and an enclosing instance of type X<String>\n" +
"----------\n");
- }
-
+ }
+
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=82187
public void test452() {
this.runConformTest(
@@ -12139,5 +12146,22 @@
"}\n" ,
},
"SUCCESS");
- }
+ }
+
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=82250
+ public void test453() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T extends I & I> {}\n" +
+ "interface I {}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\r\n" +
+ " public class X<T extends I & I> {}\r\n" +
+ " ^\n" +
+ "Duplicate bound I\n" +
+ "----------\n"
+ );
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 1d2bb04..f75a89e 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -61,7 +61,9 @@
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=82432">82432</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=82250">82250</a>
+[5.0] don't allow duplicate interface bounds
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=82432">82432</a>
[1.5] VerifyError with Autoboxing
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=82187">82187</a>
[compiler] [1.5] internal compiler reports bound mismatch
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index ecfbae7..a93b515 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -267,6 +267,14 @@
continue nextVariable;
}
}
+ for (int index = typeVariable.superInterfaces.length; --index >= 0;) {
+ if (superType.erasure() == typeVariable.superInterfaces[index].erasure()) {
+ problemReporter().duplicateBounds(typeRef, superType);
+ typeVariable.tagBits |= HierarchyHasProblems;
+ noProblems = false;
+ continue nextVariable;
+ }
+ }
int size = typeVariable.superInterfaces.length;
System.arraycopy(typeVariable.superInterfaces, 0, typeVariable.superInterfaces = new ReferenceBinding[size + 1], 0, size);
typeVariable.superInterfaces[size] = superType;