PsiSubstitutor (@NotNull PsiMethod method, @NotNull final 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); }