PsiType (PsiExpression functionExpression) { if (functionExpression instanceof PsiFunctionalExpression) { return LambdaUtil.getFunctionalInterfaceReturnType((PsiFunctionalExpression)functionExpression); } PsiType currentType = functionExpression.getType(); if (currentType == null) return null; while (true) { if (LambdaUtil.isFunctionalType(currentType)) { return LambdaUtil.getFunctionalInterfaceReturnType(currentType); } final PsiType[] superTypes = currentType.getSuperTypes(); currentType = null; for (PsiType type : superTypes) { final PsiClass aClass = PsiTypesUtil.getPsiClass(type); if (aClass != null && InheritanceUtil.isInheritor(aClass, GuavaLambda.FUNCTION.getClassQName())) { currentType = type; break; } } if (currentType == null) { return null; } } }