boolean (PsiType lambdaReturnType, PsiType baseMethodReturnType, PsiSubstitutor methodSubstitutor, PsiElement context) { if (lambdaReturnType == null) { return false; } if (myLambdaRole == LambdaRole.PREDICATE) { final PsiClassType boxedBoolean = PsiTypes.booleanType().getBoxedType(context); if (!(PsiTypes.booleanType().equals(lambdaReturnType) || (boxedBoolean != null && boxedBoolean.equals(lambdaReturnType)))) { return false; } } else { LOG.assertTrue(myLambdaRole == LambdaRole.FUNCTION); if (methodSubstitutor != null) { lambdaReturnType = methodSubstitutor.substitute(lambdaReturnType); } if (baseMethodReturnType instanceof PsiClassType) { final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)baseMethodReturnType).resolveGenerics(); final Map<PsiTypeParameter, PsiType> substitutionMap = resolveResult.getSubstitutor().getSubstitutionMap(); if (substitutionMap.size() != 1) { return false; } final PsiType iterableParametrizedType = ContainerUtil.getFirstItem(substitutionMap.values()); if (iterableParametrizedType == null || !TypeConversionUtil.isAssignable(lambdaReturnType, iterableParametrizedType)) { return false; } } else if (baseMethodReturnType instanceof PsiArrayType) { if (!lambdaReturnType.equals(((PsiArrayType)baseMethodReturnType).getComponentType())) { return false; } } } return true; }