Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-05-18 17:42:00 -0400
committerStephan Herrmann2019-05-18 17:42:00 -0400
commit5147f38abb400d33a4aa49de5af5318835c60b88 (patch)
tree711a0f8cc6a30a3b951b1b7577c56219a0ef552e
parent3bfcbfdb646353b49a162b1ce4b2d12369297cbd (diff)
downloadeclipse.jdt.core-5147f38abb400d33a4aa49de5af5318835c60b88.tar.gz
eclipse.jdt.core-5147f38abb400d33a4aa49de5af5318835c60b88.tar.xz
eclipse.jdt.core-5147f38abb400d33a4aa49de5af5318835c60b88.zip
Bug 545420 - [1.8][inference] Receiving The target type of this
expression must be a functional interface Change-Id: Ia55c7f0399cdea0c4448a15bf835406ceb828977
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java30
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java2
2 files changed, 32 insertions, 0 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 0b7af701e4..18ae2dd83b 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
@@ -9825,4 +9825,34 @@ public void testBug508834_comment0() {
"}\n"
});
}
+ public void testBug545420() {
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "public class Main {\n" +
+ " public static void main(String[] args) { \n" +
+ " System.out.println(new Main().getDetailCellCssFactory().getReturn());\n" +
+ " }\n" +
+ "\n" +
+ " public FIReturnType getDetailCellCssFactory() {\n" +
+ " \n" +
+ " return method1(()-> {\n" +
+ " return () ->{\n" +
+ " return \"something\";\n" +
+ " };\n" +
+ " });\n" +
+ " }\n" +
+ " \n" +
+ " public <X> X method1(FIWithGenerics<X> init) {\n" +
+ " return init.init(); \n" +
+ " }\n" +
+ "}\n" +
+ "interface FIReturnType {\n" +
+ " String getReturn();\n" +
+ "}\n" +
+ "interface FIWithGenerics<X> {\n" +
+ " X init();\n" +
+ "}\n"
+ });
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
index 4e5e921e3d..c47c7249d8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
@@ -157,6 +157,8 @@ class ConstraintExpressionFormula extends ConstraintFormula {
} else if (this.left instanceof LambdaExpression) {
LambdaExpression lambda = (LambdaExpression) this.left;
BlockScope scope = lambda.enclosingScope;
+ if (this.right instanceof InferenceVariable)
+ return TRUE; // assume inner inference will handle the fine print
if (!this.right.isFunctionalInterface(scope))
return FALSE;

Back to the top