public static PsiSubstitutor calculateMethodReturnTypeSubstitutor(@NotNull PsiMethod method, final @NotNull PsiType expected) {
    PsiType returnType = method.getReturnType();
    if (returnType == null) return PsiSubstitutor.EMPTY;

    PsiResolveHelper helper = JavaPsiFacade.getInstance(method.getProject()).getResolveHelper();
    return helper.inferTypeArguments(method.getTypeParameters(), new PsiType[]{expected}, new PsiType[]{returnType}, LanguageLevel.HIGHEST);
  }
public static PsiSubstitutor calculateMethodReturnTypeSubstitutor(@NotNull PsiMethod method, final @NotNull PsiType expected)