Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2014-01-25 20:47:36 +0000
committerStephan Herrmann2014-01-25 20:47:36 +0000
commitb25ae5a7f576e7bd1b9d0730e14ef7742dcae3eb (patch)
treec67a2934c0d55facc0946bd24c855108de329843
parent4ccb1aecc41fbe7a3a6c99e67b5a284a32eff23b (diff)
downloadeclipse.jdt.core-b25ae5a7f576e7bd1b9d0730e14ef7742dcae3eb.tar.gz
eclipse.jdt.core-b25ae5a7f576e7bd1b9d0730e14ef7742dcae3eb.tar.xz
eclipse.jdt.core-b25ae5a7f576e7bd1b9d0730e14ef7742dcae3eb.zip
Bug 426652 - [1.8][inference] inference loops infinitely on
unconstrained inference variable
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java25
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java7
3 files changed, 32 insertions, 4 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 a67a2fb134..c78a09c6e3 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
@@ -19,7 +19,7 @@ import junit.framework.Test;
public class GenericsRegressionTest_1_8 extends AbstractRegressionTest {
static {
-// TESTS_NAMES = new String[] { "testBug424415c" };
+// TESTS_NAMES = new String[] { "testBug426540" };
// TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 };
// TESTS_RANGE = new int[] { 11, -1 };
}
@@ -1317,4 +1317,27 @@ public void testBug426048() {
"Syntax error on token \"(\", , expected\n" +
"----------\n");
}
+public void _testBug426540() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.stream.Stream;\n" +
+ "import java.util.Collections;\n" +
+ "import static java.util.stream.Collectors.collectingAndThen;\n" +
+ "import static java.util.stream.Collectors.toList;\n" +
+ "public class X {\n" +
+ " Object o = ((Stream<Integer>) null).collect(collectingAndThen(toList(), Collections::unmodifiableList));\n" +
+ "}\n"
+ });
+}
+public void testBug426652() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import static java.util.stream.Collectors.toList;\n" +
+ "public class X {\n" +
+ " Object o = toList();\n" +
+ "}\n"
+ });
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
index 076c774ce5..0861bf8cab 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
@@ -65,6 +65,10 @@ public class CaptureBinding18 extends CaptureBinding {
return true;
}
+ public void initializeBounds(Scope scope, ParameterizedTypeBinding capturedParameterizedType) {
+ // nothing to initialize here (and cannot use super methods which requires wildcard to be set).
+ }
+
public TypeBinding clone(TypeBinding enclosingType) {
return new CaptureBinding18(this.sourceType, this.sourceName, this.originalName, this.captureID, this.environment);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
index 16731ca4a8..60d07807a7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
@@ -478,7 +478,8 @@ public class InferenceContext18 {
boolean haveProperTargetType = targetType != null && targetType.isProperType(true);
if (haveProperTargetType) {
MethodBinding original = method.originalMethod;
- BoundSet result = (BoundSet) this.solutionsPerTargetType.get(targetType);
+ Solution solution = (Solution) this.solutionsPerTargetType.get(targetType);
+ BoundSet result = solution != null ? solution.bounds : null;
if (result == null) {
// start over from a previous candidate but discard its type variable instantiations
// TODO: should we retain any instantiations of type variables not owned by the method?
@@ -667,8 +668,8 @@ public class InferenceContext18 {
tmpBoundSet.addBound(new TypeBound(variable, runtimeException, ReductionResult.SAME));
} else {
// try upper bounds:
+ TypeBinding glb = this.object;
if (upperBounds != Binding.NO_TYPES) {
- TypeBinding glb;
if (upperBounds.length == 1) {
glb = upperBounds[0];
} else {
@@ -680,8 +681,8 @@ public class InferenceContext18 {
else
glb = new IntersectionCastTypeBinding(glbs, this.environment);
}
- tmpBoundSet.addBound(new TypeBound(variable, glb, ReductionResult.SAME));
}
+ tmpBoundSet.addBound(new TypeBound(variable, glb, ReductionResult.SAME));
}
}
}

Back to the top