PsiType (@NotNull PsiTypeParameter typeParameter, @NotNull PsiSubstitutor beforeSubstitutor) { final PsiClassType[] extendsList = typeParameter.getExtendsList().getReferencedTypes(); if (extendsList.length > 0) { final PsiClass psiClass = extendsList[0].resolve(); if (psiClass instanceof PsiTypeParameter) { Set<PsiClass> visited = new HashSet<>(); visited.add(psiClass); final PsiTypeParameter boundTypeParameter = (PsiTypeParameter)psiClass; if (beforeSubstitutor.getSubstitutionMap().containsKey(boundTypeParameter)) { return erasure(beforeSubstitutor.substitute(boundTypeParameter)); } return typeParameterErasureInner(boundTypeParameter, visited, beforeSubstitutor); } else if (psiClass != null) { return JavaPsiFacade.getElementFactory(typeParameter.getProject()).createType(psiClass); } } return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope()); }