PsiType (@NotNull PsiParameter param) { PsiElement paramParent = param.getParent(); if (paramParent instanceof PsiParameterList) { int parameterIndex = ((PsiParameterList)paramParent).getParameterIndex(param); if (parameterIndex > -1) { PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class); if (lambdaExpression != null) { PsiType functionalInterfaceType = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(param, false, () -> LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true)); PsiType type = lambdaExpression.getGroundTargetType(functionalInterfaceType); if (type instanceof PsiIntersectionType) { PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts(); for (PsiType conjunct : conjuncts) { PsiType lambdaParameterFromType = LambdaUtil.getLambdaParameterFromType(conjunct, parameterIndex); if (lambdaParameterFromType != null) { return lambdaParameterFromType; } } } else { PsiType lambdaParameterFromType = LambdaUtil.getLambdaParameterFromType(type, parameterIndex); if (lambdaParameterFromType != null) { return lambdaParameterFromType; } } } } } return new PsiLambdaParameterType(param); }