PsiType (@NotNull PsiExpression predicate) { final PsiType expectedType = ExpectedTypeUtils.findExpectedType(predicate, true); if (!(expectedType instanceof PsiClassType classType)) { return null; } if (classType.getParameterCount() != 1 || !PsiTypesUtil.classNameEquals(classType, JAVA_UTIL_FUNCTION_PREDICATE)) { return null; } PsiType parameter = classType.getParameters()[0]; //Object can be cast to any if (parameter == null || parameter.equalsToText(JAVA_LANG_OBJECT)) { return null; } if (parameter instanceof PsiWildcardType psiWildcardType) { parameter = psiWildcardType.isSuper() ? psiWildcardType.getSuperBound() : parameter; } return parameter; }