private static PsiSubstitutor inferTypeParametersForStaticFactory(
      @NotNull PsiMethod staticFactoryMethod,
      PsiNewExpression expression,
      final PsiElement parent,
      final boolean varargs) {
    final PsiExpressionList argumentList = expression.getArgumentList();
    if (argumentList != null) {
      final MethodCandidateInfo staticFactoryCandidateInfo =
          new MethodCandidateInfo(
              staticFactoryMethod,
              PsiSubstitutor.EMPTY,
              false,
              false,
              argumentList,
              parent,
              argumentList.getExpressionTypes(),
              null) {
            @Override
            public boolean isVarargs() {
              return varargs;
            }

            @Override
            protected PsiElement getParent() {
              return parent;
            }

            @Override
            protected PsiElement getMarkerList() {
              return parent instanceof PsiNewExpression
                  ? ((PsiNewExpression) parent).getArgumentList()
                  : super.getMarkerList();
            }
          };
      if (!varargs
          && staticFactoryMethod.isVarArgs()
          && staticFactoryCandidateInfo.getPertinentApplicabilityLevel()
              < MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
        return inferTypeParametersForStaticFactory(staticFactoryMethod, expression, parent, true);
      }
      return staticFactoryCandidateInfo.getSubstitutor();
    } else {
      return PsiSubstitutor.EMPTY;
    }
  }
 protected int getPertinentApplicabilityLevel(@NotNull MethodCandidateInfo conflict) {
   return conflict.getPertinentApplicabilityLevel();
 }