Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-02-25 17:52:20 -0500
committerManoj Palat2019-02-26 00:51:37 -0500
commit51935ee9d486419f4f1f74060e0b14409482d023 (patch)
treec563e3e28d1f6b14a97d31725da6346319189b64
parent9e75292b526e3af0dcce727eaeb336591779395c (diff)
downloadeclipse.jdt.core-51935ee9d486419f4f1f74060e0b14409482d023.tar.gz
eclipse.jdt.core-51935ee9d486419f4f1f74060e0b14409482d023.tar.xz
eclipse.jdt.core-51935ee9d486419f4f1f74060e0b14409482d023.zip
Bug 536860 - JDT compiler fails to infer correctly generic types in
Eclipse Photon Change-Id: I9281f9defffb344edc5195a64988fc6378d22384 Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java40
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java12
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_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index c57ea95c8e..1504327072 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
@@ -9532,4 +9532,44 @@ public void testBug508834_comment0() {
};
runner.runConformTest();
}
+ public void testBug536860() {
+ runConformTest(
+ new String[] {
+ "Snippet.java",
+ "import java.io.IOException;\n" +
+ "import java.io.InputStream;\n" +
+ "import java.nio.file.Path;\n" +
+ "import java.util.Map;\n" +
+ "import java.util.concurrent.Callable;\n" +
+ "import java.util.function.Function;\n" +
+ "\n" +
+ "interface EntityReader<T, S> { }\n" +
+ "class ExtraIOUtils {\n" +
+ " public static Callable<InputStream> getInputStreamProvider() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "public class Snippet {\n" +
+ " public <T> EntityReader<T, Path> createEntityReader(\n" +
+ " Function<? super String, ? extends String> colNameMapper,\n" +
+ " Function<? super String[], ? extends T> instantiator,\n" +
+ " Map<String, ?> runtimeValues)\n" +
+ " throws IOException {\n" +
+ " EntityReader<T, ?> streamReader =\n" +
+ " createEntityStreamReader(\n" +
+ " ExtraIOUtils.getInputStreamProvider(),\n" +
+ " colNameMapper, instantiator, runtimeValues);\n" +
+ " return null;\n" +
+ " }\n" +
+ " public <T> EntityReader<T, Callable<InputStream>> createEntityStreamReader(\n" +
+ " Callable<InputStream> streamProvider,\n" +
+ " Function<? super String, ? extends String> colNameMapper, Function<? super String[], ? extends T> instantiator,\n" +
+ " Map<String, ?> runtimeValues)\n" +
+ " throws IOException {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n"
+ });
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
index 6510e346c9..8c298b9264 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -341,6 +341,16 @@ public boolean isSubtypeOf(TypeBinding otherType, boolean simulatingBugJDK802652
return false;
}
return true;
+ case Binding.TYPE_PARAMETER:
+ // check compatibility with capture of ? super X
+ if (otherType.isCapture()) {
+ CaptureBinding otherCapture = (CaptureBinding) otherType;
+ TypeBinding otherLowerBound;
+ if ((otherLowerBound = otherCapture.lowerBound) != null) {
+ if (!otherLowerBound.isArrayType()) return false;
+ return isSubtypeOf(otherLowerBound, simulatingBugJDK8026527);
+ }
+ }
}
switch (otherType.leafComponentType().id) {
case TypeIds.T_JavaLangObject :

Back to the top