From fd11949634b6903d28766a87cc5783a0a17c680a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 16 Apr 2015 16:31:48 +0200 Subject: [PATCH] new inference: accept inferred equals bounds even when additional constraints lead to failure to get more appropriate error message (IDEA-139275) --- .../resolve/graphInference/InferenceSession.java | 2 +- ...ariablesBeforeAdditionalConstraintsLeadToFail.java | 11 +++++++++++ .../daemon/lambda/NewLambdaHighlightingTest.java | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AcceptInferredVariablesBeforeAdditionalConstraintsLeadToFail.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index ea18bac35945..a68d83e2346e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -269,7 +269,7 @@ public class InferenceSession { } if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints)) { - return prepareSubstitution(); + return prepareSubstitution().putAll(retrieveNonPrimitiveEqualsBounds(myInferenceVariables)); } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AcceptInferredVariablesBeforeAdditionalConstraintsLeadToFail.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AcceptInferredVariablesBeforeAdditionalConstraintsLeadToFail.java new file mode 100644 index 000000000000..448df99ea3d3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AcceptInferredVariablesBeforeAdditionalConstraintsLeadToFail.java @@ -0,0 +1,11 @@ +import java.io.Reader; +import java.util.Arrays; +import java.util.function.Consumer; + +class Test { + + public static void main(String[] args) { + Iterable> i = Arrays.asList((r) -> r.read()); + Iterable> i1 = Arrays.>asList((r) -> r.read()); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index 6a76895714b4..8e6db15c9bff 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -189,6 +189,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testAcceptInferredVariablesBeforeAdditionalConstraintsLeadToFail() throws Exception { + doTest(false); + } + private void doTest() { doTest(false); }