Set<InferenceVariable> (InferenceSession session) { final PsiExpression psiExpression = getExpression(); final PsiType type = myT; if (psiExpression instanceof PsiFunctionalExpression) { final InferenceVariable inferenceVariable = session.getInferenceVariable(type); if (inferenceVariable != null) { final HashSet<InferenceVariable> result = new HashSet<>(); result.add(inferenceVariable); return result; } if (LambdaUtil.isFunctionalType(type)) { final PsiType functionType = psiExpression instanceof PsiLambdaExpression ? FunctionalInterfaceParameterizationUtil.getGroundTargetType(type, (PsiLambdaExpression)psiExpression, false) : type; final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionType); final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult); if (interfaceMethod != null) { final Set<InferenceVariable> result = new HashSet<>(); final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult); if (psiExpression instanceof PsiLambdaExpression && !((PsiLambdaExpression)psiExpression).hasFormalParameterTypes() || psiExpression instanceof PsiMethodReferenceExpression && !((PsiMethodReferenceExpression)psiExpression).isExact()) { for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) { session.collectDependencies(substitutor.substitute(parameter.getType()), result); } } final PsiType returnType = interfaceMethod.getReturnType(); if (returnType != null) { collectReturnTypeVariables(session, psiExpression, substitutor.substitute(returnType), result); } return result; } } } if (psiExpression instanceof PsiParenthesizedExpression) { final PsiExpression expression = ((PsiParenthesizedExpression)psiExpression).getExpression(); return expression != null ? createSelfConstraint(type, expression).getInputVariables(session) : null; } if (psiExpression instanceof PsiConditionalExpression) { final PsiExpression thenExpression = ((PsiConditionalExpression)psiExpression).getThenExpression(); final PsiExpression elseExpression = ((PsiConditionalExpression)psiExpression).getElseExpression(); final Set<InferenceVariable> thenResult = thenExpression != null ? createSelfConstraint(type, thenExpression).getInputVariables(session) : null; final Set<InferenceVariable> elseResult = elseExpression != null ? createSelfConstraint(type, elseExpression).getInputVariables(session) : null; if (thenResult == null) { return elseResult; } else if (elseResult == null) { return thenResult; } else { thenResult.addAll(elseResult); return thenResult; } } if (psiExpression instanceof PsiSwitchExpression) { Set<InferenceVariable> variables = PsiUtil.getSwitchResultExpressions((PsiSwitchExpression)psiExpression).stream().flatMap(expression -> { Set<InferenceVariable> inputVariables = createSelfConstraint(type, expression).getInputVariables(session); return inputVariables != null ? inputVariables.stream() : Stream.empty(); }).collect(Collectors.toSet()); return variables.isEmpty() ? null : variables; } return null; }