From db72cccc971c11152b4b64d2260faa377b3c3eab Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 21 May 2015 11:24:34 +0200 Subject: [PATCH] method refs: missed qualifier substitution for return type (IDEA-140539) --- .../PsiMethodReferenceCompatibilityConstraint.java | 2 +- ...ForReturnTypeConstraintsForTargetGenericMethod.java | 10 ++++++++++ .../daemon/lambda/NewMethodRefHighlightingTest.java | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SubstitutionForReturnTypeConstraintsForTargetGenericMethod.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java index 45af0e97b55e..de0aaf4d912f 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java @@ -184,7 +184,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm //the constraint reduces to the bound set B3 which would be used to determine the method reference's invocation type //when targeting the return type of the function type, as defined in 18.5.2. session.collectApplicabilityConstraints(myExpression, ((MethodCandidateInfo)resolve), groundTargetType); - session.registerReturnTypeConstraints(referencedMethodReturnType, returnType); + session.registerReturnTypeConstraints(psiSubstitutor.substitute(referencedMethodReturnType), returnType); return true; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SubstitutionForReturnTypeConstraintsForTargetGenericMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SubstitutionForReturnTypeConstraintsForTargetGenericMethod.java new file mode 100644 index 000000000000..ac30f218223a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SubstitutionForReturnTypeConstraintsForTargetGenericMethod.java @@ -0,0 +1,10 @@ +import java.util.function.Function; + +class Test { + + private void foo(final Function steps) { + map(steps::compose); + } + + void map(Function, U> mapper) {} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index da2e8e16ed31..b6b232062c51 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -402,6 +402,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testSubstitutionForReturnTypeConstraintsForTargetGenericMethod() throws Exception { + doTest(); + } + private void doTest() { doTest(false); }