PsiType (@NotNull final PsiClassType classType) { final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics(); final PsiClass aClass = resolveResult.getElement(); if (aClass == null) return classType; PsiUtilCore.ensureValid(aClass); if (aClass instanceof PsiTypeParameter) { final PsiTypeParameter typeParameter = (PsiTypeParameter)aClass; final PsiType result = getFromMap(typeParameter); if (PsiTypes.voidType().equals(result)) { return classType; } if (result != null) { PsiUtil.ensureValidType(result); if (result instanceof PsiClassType || result instanceof PsiArrayType || result instanceof PsiWildcardType) { return result.annotate(getMergedProvider(classType, result)); } } return result; } final Map<PsiTypeParameter, PsiType> hashMap = new HashMap<>(2); if (!processClass(aClass, resolveResult.getSubstitutor(), hashMap)) { return null; } PsiClassType result = JavaPsiFacade.getElementFactory(aClass.getProject()) .createType(aClass, PsiSubstitutor.createSubstitutor(hashMap), classType.getLanguageLevel()); PsiUtil.ensureValidType(result); return result.annotate(classType.getAnnotationProvider()); }