Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2014-05-27 18:15:29 +0000
committerMarkus Keller2014-05-27 18:15:29 +0000
commitf4fc504166df381ca6b1f6852c6f598d05ce2608 (patch)
tree17e66ddf15e4a38f42b1692ec9bdcd5ecc83b6a2
parentf52400ac5289985fb63fad2898c4202926c0d38e (diff)
downloadeclipse.jdt.core-f4fc504166df381ca6b1f6852c6f598d05ce2608.tar.gz
eclipse.jdt.core-f4fc504166df381ca6b1f6852c6f598d05ce2608.tar.xz
eclipse.jdt.core-f4fc504166df381ca6b1f6852c6f598d05ce2608.zip
Bug 435463: StackOverflowError when compiling generic code
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java46
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java6
2 files changed, 51 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index 8a64dba10f..978990d6fa 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -48,7 +48,7 @@ public class GenericsRegressionTest extends AbstractComparableTest {
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "testBug427438c3" };
+// TESTS_NAMES = new String[] { "testBug435643" };
// TESTS_NUMBERS = new int[] { 1465 };
// TESTS_RANGE = new int[] { 1097, -1 };
}
@@ -5231,5 +5231,49 @@ public void testBug434793() {
},
options);
}
+public void testBug435643() {
+ runConformTest(
+ new String[] {
+ "test/Main.java",
+ "package test;\n" +
+ "abstract class ASTNode<T extends ASTNode> implements Iterable<T> {\n" +
+ " public T getChild(int i) { return null; }\n" +
+ "} \n" +
+ "abstract class List<T extends ASTNode> extends ASTNode<T> { }\n" +
+ "class Joiner {\n" +
+ " public static Joiner on(String separator) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " String join(Iterable<?> parts) {\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n" +
+ "class AstFunctions {\n" +
+ " public static <T extends ASTNode<?>> Function<T, String> prettyPrint() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "class Iterables {\n" +
+ " public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable,\n" +
+ " final Function<? super F, ? extends T> function) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "interface Function<F, T> {\n" +
+ " T apply(F input);\n" +
+ "}\n" +
+ "public class Main {\n" +
+ "\n" +
+ " String test(ASTNode<?> node, ASTNode rawNode) {\n" +
+ " rawNode.getChild(0); \n" +
+ " \n" +
+ " @SuppressWarnings(\"unchecked\")\n" +
+ " List<? extends ASTNode<?>> list = (List<? extends ASTNode<?>>) node;\n" +
+ " return Joiner.on(\", \").join(Iterables.transform(list, AstFunctions.prettyPrint()));\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ });
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
index ed78ed45c4..427a92775d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
@@ -195,6 +195,12 @@ public class RawTypeBinding extends ParameterizedTypeBinding {
this.arguments = typeArguments;
}
+ @Override
+ TypeBinding substituteInferenceVariable(InferenceVariable var, TypeBinding substituteType) {
+ // NEVER substitute the type arguments of a raw type
+ return this;
+ }
+
public MethodBinding getSingleAbstractMethod(Scope scope, boolean replaceWildcards) {
int index = replaceWildcards ? 0 : 1;
if (this.singleAbstractMethod != null) {

Back to the top