From 4095b411aafa11c09cdf2393231b0dbcfaa91578 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 12 Aug 2014 19:03:01 +0400 Subject: [PATCH] new inference: proceed with additional constraints when no nested calls available (IDEA-124424) --- .../resolve/graphInference/InferenceSession.java | 3 ++- .../tree/java/PsiConditionalExpressionImpl.java | 2 +- .../lambda/newLambda/IDEA124424.java | 12 ++++++++++++ .../daemon/lambda/NewLambdaHighlightingTest.java | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.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 c04daa826daa..e2e57abdabbc 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 @@ -221,7 +221,8 @@ public class InferenceSession { return prepareSubstitution(); } - if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) { + if (parameters != null && args != null && + !MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(parent.getParent()))) { final Set additionalConstraints = new LinkedHashSet(); if (parameters.length > 0) { collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs(), true); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java index 73639b26c945..5bf3addded5f 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java @@ -92,7 +92,7 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement if (PsiUtil.isLanguageLevel8OrHigher(this) && PsiPolyExpressionUtil.isPolyExpression(this) && - !MethodCandidateInfo.ourOverloadGuard.currentStack().contains(this.getParent())) { + !MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(this.getParent()))) { //15.25.3 Reference Conditional Expressions // The type of a poly reference conditional expression is the same as its target type. return InferenceSession.getTargetType(this); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java new file mode 100644 index 000000000000..369804623026 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA124424.java @@ -0,0 +1,12 @@ +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + +class Main { + void bar(final Stream objectStream) { + foo(objectStream.map(o -> "str").collect(toList())); + } + + void foo(Iterable k){} + void foo(String s){} +} 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 92eb0daa09f9..1411249b3dcc 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 @@ -92,6 +92,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA124961() { doTest(); } public void testIDEA126109() { doTest(); } public void testIDEA126809() { doTest(); } + public void testIDEA124424() { doTest(); } public void testIDEA127596() throws Exception { doTest();