boolean (PsiType type, PsiType baseMethodReturnType, PsiSubstitutor methodSubstitutor, PsiElement context) { if (type instanceof PsiMethodReferenceType) { final PsiMethodReferenceExpression expression = ((PsiMethodReferenceType)type).getExpression(); final PsiMethod resolvedMethod = (PsiMethod)expression.resolve(); if (resolvedMethod == null) { return false; } final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters(); if ((parameters.length != 1 && myLambdaRole == LambdaRole.FUNCTION) || (parameters.length != 0 && myLambdaRole == LambdaRole.PREDICATE)) { return false; } final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(expression); return isSuitableLambdaRole(returnType, baseMethodReturnType, methodSubstitutor, context); } else if (type instanceof PsiLambdaExpressionType) { final PsiLambdaExpression expression = ((PsiLambdaExpressionType)type).getExpression(); final PsiType psiType = LambdaUtil.getFunctionalInterfaceReturnType(expression.getFunctionalInterfaceType()); return isSuitableLambdaRole(psiType, baseMethodReturnType, methodSubstitutor, context); } else if (isSuitableFunctionalType(type, baseMethodReturnType, methodSubstitutor, context)) { return true; } return isJavaLangClassType(type) && myLambdaRole == LambdaRole.PREDICATE; }