boolean (PsiType left, PsiMethod method) { if (left instanceof PsiIntersectionType) { for (PsiType conjunct : ((PsiIntersectionType)left).getConjuncts()) { if (isAcceptable(conjunct)) return true; } return false; } final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class); final boolean isExact = isExact(); if (method != null && MethodCandidateInfo.isOverloadCheck(argsList)) { if (isExact && !InferenceSession.isPertinentToApplicability(this, method)) { return true; } if (LambdaUtil.isPotentiallyCompatibleWithTypeParameter(this, argsList, method)) { return true; } } left = getGroundTargetType(left); if (!isPotentiallyCompatible(left)) { return false; } if (MethodCandidateInfo.isOverloadCheck(argsList)) { if (!isExact) { return true; } } // A method reference is congruent with a function type if the following are true: // The function type identifies a single compile-time declaration corresponding to the reference. // One of the following is true: // i)The return type of the function type is void. // ii)The return type of the function type is R; // the result of applying capture conversion (5.1.10) to the return type of the invocation type (15.12.2.6) of the chosen declaration is R', // where R is the target type that may be used to infer R'; neither R nor R' is void; and R' is compatible with R in an assignment context. JavaResolveResult result = LambdaUtil.performWithTargetType(this, left, () -> advancedResolve(false)); if (result instanceof MethodCandidateInfo && !((MethodCandidateInfo)result).isApplicable()) { return false; } final PsiElement resolve = result.getElement(); if (resolve == null) { return false; } return PsiMethodReferenceUtil.isReturnTypeCompatible(this, result, left); }