PsiClassType () { final PsiElement classElement = myClass.getElement(); if (!(classElement instanceof PsiClass)) return null; Map<PsiTypeParameter, PsiType> resurrected = new HashMap<>(); final Set<Map.Entry<SmartPsiElementPointer<PsiTypeParameter>, SmartTypePointer>> set = myMap.entrySet(); for (Map.Entry<SmartPsiElementPointer<PsiTypeParameter>, SmartTypePointer> entry : set) { PsiTypeParameter element = entry.getKey().getElement(); if (element != null) { SmartTypePointer typePointer = entry.getValue(); resurrected.put(element, typePointer == null ? null : typePointer.getType()); } } for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable((PsiClass)classElement)) { if (!resurrected.containsKey(typeParameter)) { resurrected.put(typeParameter, null); } } final PsiSubstitutor resurrectedSubstitutor = PsiSubstitutor.createSubstitutor(resurrected); PsiAnnotation[] resurrectedAnnotations = Stream.of(myAnnotations).map(SmartPsiElementPointer::getElement).filter(Objects::nonNull).toArray(PsiAnnotation[]::new); return new PsiImmediateClassType((PsiClass)classElement, resurrectedSubstitutor, myLevel, resurrectedAnnotations); }