boolean (PsiMethodReferenceExpression refPlace, PsiMethod method, @NotNull PsiType expectedType) { PsiMethodReferenceExpression referenceExpression = createMethodReferenceExpression(method, refPlace); return LambdaUtil.performWithTargetType(referenceExpression, expectedType, () -> { JavaResolveResult result = referenceExpression.advancedResolve(false); return method.getManager().areElementsEquivalent(method, result.getElement()) && PsiMethodReferenceUtil.isReturnTypeCompatible(referenceExpression, result, expectedType) && PsiMethodReferenceHighlightingUtil.checkMethodReferenceContext(referenceExpression, method, expectedType) == null; }); }