protected static Pair<PsiType, ConstraintType> inferConstraint(PsiTypeParameter typeParameter,
                                                                 PsiExpression innerMethodCall,
                                                                 int parameterIdx,
                                                                 PsiType innerReturnType,
                                                                 JavaResolveResult result,
                                                                 final PsiSubstitutor substitutor) {
    final PsiElement element = result.getElement();
    if (element instanceof PsiMethod) {
      final PsiMethod method = (PsiMethod)element;
      final PsiParameter[] parameters = method.getParameterList().getParameters();
      PsiParameter parameter = null;
      if (parameters.length > parameterIdx) {
        parameter = parameters[parameterIdx];
      }
      else if (method.isVarArgs()) {
        parameter = parameters[parameters.length - 1];
      }
      if (parameter != null) {
        final PsiParameter finalParameter = parameter;
        PsiType type = PsiResolveHelper.ourGuard.doPreventingRecursion(innerMethodCall, true,
                                                                       () -> substitutor.substitute(finalParameter.getType()));
        final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(finalParameter);
        final Pair<PsiType, ConstraintType> constraint =
          new PsiOldInferenceHelper(element.getManager()).getSubstitutionForTypeParameterConstraint(typeParameter, innerReturnType, type, false, languageLevel);
        if (constraint != null) return constraint;
      }
    }
    return null;
  }
protected static Pair<PsiType, ConstraintType> inferConstraint(PsiTypeParameter typeParameter,
                                                                 PsiExpression innerMethodCall,
                                                                 int parameterIdx,
                                                                 PsiType innerReturnType,
                                                                 JavaResolveResult result,
                                                                 final PsiSubstitutor substitutor)