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 8906acd20834..ecaa8736d001 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 @@ -1231,7 +1231,9 @@ public class InferenceSession { final PsiMethodReferenceUtil.QualifierResolveResult qualifierResolveResult = PsiMethodReferenceUtil.getQualifierResolveResult(reference); final PsiClass containingClass = qualifierResolveResult.getContainingClass(); - LOG.assertTrue(containingClass != null, myContext); + if (containingClass == null) { + return resolveSubset(myInferenceVariables, mySiteSubstitutor); + } final PsiParameter[] functionalMethodParameters = interfaceMethod.getParameterList().getParameters(); final PsiParameter[] parameters = method.getParameterList().getParameters(); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncompleteCodeWithMethodReferenceOverLambdaParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncompleteCodeWithMethodReferenceOverLambdaParameter.java new file mode 100644 index 000000000000..9f7e191ecd6f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncompleteCodeWithMethodReferenceOverLambdaParameter.java @@ -0,0 +1,12 @@ + +import java.util.function.Function; +class Test { + { + foo(s -> { + foo(s::concat); + return s; + }); + } + + void foo(Function f){} +} 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 05e475a286a7..00c60425f436 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 @@ -418,6 +418,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIncompleteCodeWithMethodReferenceOverLambdaParameter() throws Exception { + doTest(); + } + private void doTest() { doTest(false); }