PsiType (int typeParamIndex, boolean eraseTypeParameter, PsiClassType.ClassResolveResult classResolveResult, PsiClass psiClass, PsiClass baseClass) { if (!psiClass.isEquivalentTo(baseClass) && !psiClass.isInheritor(baseClass, true)) return null; PsiTypeParameter[] parameters = baseClass.getTypeParameters(); if (parameters.length <= typeParamIndex) return PsiType.getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope()); PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, psiClass, classResolveResult.getSubstitutor()); PsiType type = substitutor.substitute(parameters[typeParamIndex]); if (type == null && eraseTypeParameter) { return TypeConversionUtil.typeParameterErasure(parameters[typeParamIndex]); } return type; }