Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-03-21 07:37:43 +0000
committerStephan Herrmann2016-09-29 14:06:51 +0000
commit372105883c90f57f2c7a8992de070fba3f4f7974 (patch)
tree707db73580ee61e78aae0f1910c0691e049b920f
parentd9d65be9d26af0b39d447ff1d0022c585b5850aa (diff)
downloadeclipse.jdt.core-372105883c90f57f2c7a8992de070fba3f4f7974.tar.gz
eclipse.jdt.core-372105883c90f57f2c7a8992de070fba3f4f7974.tar.xz
eclipse.jdt.core-372105883c90f57f2c7a8992de070fba3f4f7974.zip
Bug 502350 - Eclipse compiler gets stuck in infinite loop
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java41
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java24
2 files changed, 57 insertions, 8 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index c6aaf5e6e2..e53c45149b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
@@ -6914,4 +6914,45 @@ public void testBug472851() {
"The method test(List<L>) in the type Test is not applicable for the arguments (List<capture#1-of ? extends List<?>>)\n" +
"----------\n");
}
+public void testBug502350() {
+ runNegativeTest(
+ new String[] {
+ "makeCompilerFreeze/EclipseJava8Bug.java",
+ "package makeCompilerFreeze;\n" +
+ "\n" +
+ "interface Comparable<E> {} \n" +
+ "\n" +
+ "interface Comparator<A> {\n" +
+ " public static <B extends Comparable<B>> Comparator<B> naturalOrder() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "\n" +
+ "class Stuff {\n" +
+ " public static <T, S extends T> Object func(Comparator<T> comparator) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "public class EclipseJava8Bug {\n" +
+ " static final Object BORKED =\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ "}\n" +
+ "\n" +
+ "",
+ },
+ "----------\n" +
+ "1. ERROR in makeCompilerFreeze\\EclipseJava8Bug.java (at line 20)\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ " ^^^^\n" +
+ "The method func(Comparator<T>) in the type Stuff is not applicable for the arguments (Comparator<Comparable<Comparable<B>>>)\n" +
+ "----------\n" +
+ "2. ERROR in makeCompilerFreeze\\EclipseJava8Bug.java (at line 20)\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Comparator<Comparable<Comparable<B>>> to Comparator<T>\n" +
+ "----------\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
index a004158365..b8ebe83982 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
@@ -849,19 +849,27 @@ class BoundSet {
// α = S and T <: α imply ⟨T <: S⟩
InferenceVariable alpha = boundS.left;
TypeBinding s = boundS.right;
- if (TypeBinding.equalsEquals(alpha,boundT.left))
- return ConstraintTypeFormula.create(s, boundT.right, boundT.relation, boundT.isSoft||boundS.isSoft);
- if (TypeBinding.equalsEquals(alpha, boundT.right))
- return ConstraintTypeFormula.create(boundT.right, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ if (TypeBinding.equalsEquals(alpha, boundT.left)) {
+ TypeBinding t = boundT.right;
+ return ConstraintTypeFormula.create(s, t, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
+ if (TypeBinding.equalsEquals(alpha, boundT.right)) {
+ TypeBinding t = boundT.left;
+ return ConstraintTypeFormula.create(t, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
if (boundS.right instanceof InferenceVariable) {
// reverse:
alpha = (InferenceVariable) boundS.right;
s = boundS.left;
- if (TypeBinding.equalsEquals(alpha, boundT.left))
- return ConstraintTypeFormula.create(s, boundT.right, boundT.relation, boundT.isSoft||boundS.isSoft);
- if (TypeBinding.equalsEquals(alpha, boundT.right))
- return ConstraintTypeFormula.create(boundT.right, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ if (TypeBinding.equalsEquals(alpha, boundT.left)) {
+ TypeBinding t = boundT.right;
+ return ConstraintTypeFormula.create(s, t, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
+ if (TypeBinding.equalsEquals(alpha, boundT.right)) {
+ TypeBinding t = boundT.left;
+ return ConstraintTypeFormula.create(t, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
}
// α = U and S <: T imply ⟨S[α:=U] <: T[α:=U]⟩

Back to the top