InferenceSession (final PsiCall topLevelCall, final ParameterTypeInferencePolicy policy, MethodCandidateInfo currentMethod) { final JavaResolveResult result = PsiDiamondType.getDiamondsAwareResolveResult(topLevelCall); if (result instanceof MethodCandidateInfo) { final PsiMethod method = ((MethodCandidateInfo)result).getElement(); final PsiParameter[] topLevelParameters = method.getParameterList().getParameters(); final PsiExpressionList topLevelCallArgumentList = topLevelCall.getArgumentList(); LOG.assertTrue(topLevelCallArgumentList != null, topLevelCall); final PsiExpression[] topLevelArguments = topLevelCallArgumentList.getExpressions(); return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(topLevelCall, true, () -> { final InferenceSession topLevelSession = new InferenceSession(method.getTypeParameters(), ((MethodCandidateInfo)result).getSiteSubstitutor(), topLevelCall.getManager(), topLevelCall, policy); topLevelSession.setCurrentMethod(currentMethod); topLevelSession.initExpressionConstraints(topLevelParameters, topLevelArguments, method, ((MethodCandidateInfo)result).isVarargs()); topLevelSession.performGuardedInference(topLevelParameters, topLevelArguments, topLevelCall, ((MethodCandidateInfo)result), PsiSubstitutor.EMPTY, false); return topLevelSession; }); } return null; }