Set<String> (@NotNull PsiType base, final Project project) { final Map<String, Set<String>> cache = CachedValuesManager.getManager(project).getCachedValue(project, () -> { final Map<String, Set<String>> result = new ConcurrentHashMap<>(); return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT); }); final PsiClass cls = PsiUtil.resolveClassInType(base); String key; if (cls instanceof PsiTypeParameter) { final PsiClass superClass = cls.getSuperClass(); key = cls.getName() + (superClass == null ? CommonClassNames.JAVA_LANG_OBJECT : superClass.getName()); } else if (base instanceof PsiClassType) { key = TypesUtil.getQualifiedName(base); } else { key = base.getCanonicalText(); } Set<String> result = key == null ? null : cache.get(key); if (result == null) { result = new HashSet<>(); collectSuperTypes(base, result, project); if (key != null) { cache.put(key, result); } } return result; }