@Override
  public PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                                 PsiParameter @NotNull [] parameters,
                                                 PsiExpression @NotNull [] arguments,
                                                 @NotNull PsiSubstitutor partialSubstitutor,
                                                 @Nullable PsiElement parent,
                                                 @NotNull ParameterTypeInferencePolicy policy) {
    final PsiSubstitutor substitutor;
    if (parent != null) {
      substitutor = inferTypeArguments(new PsiTypeParameter[]{typeParameter},
                                       parameters,
                                       arguments,
                                       null, partialSubstitutor,
                                       parent,
                                       policy,
                                       PsiUtil.getLanguageLevel(parent)
      );
    }
    else {
      InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager, null, policy);
      inferenceSession.initExpressionConstraints(parameters, arguments, null, false);
      substitutor = inferenceSession.infer();
    }
    return substitutor.substitute(typeParameter);
  }
@Override
  public PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                                 PsiParameter @NotNull [] parameters,
                                                 PsiExpression @NotNull [] arguments,
                                                 @NotNull PsiSubstitutor partialSubstitutor,
                                                 @Nullable PsiElement parent,
                                                 @NotNull ParameterTypeInferencePolicy policy)