PsiType (PsiType t, boolean objectBottom) { if (t instanceof PsiArrayType) { PsiType normType = normalize(((PsiArrayType)t).getComponentType(), objectBottom); return normType == null ? null : normType.createArrayType(); } else if (t instanceof PsiClassType) { PsiClassType.ClassResolveResult result = resolveType(t); PsiClass aclass = result.getElement(); PsiSubstitutor subst = result.getSubstitutor(); PsiManager manager = aclass.getManager(); PsiSubstitutor newbst = PsiSubstitutor.EMPTY; boolean anyBottom = false; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aclass)) { PsiType p = subst.substitute(typeParameter); if (p != null) { PsiType pp = normalize(p, objectBottom); if (pp == null) { return null; } if (pp == Bottom.BOTTOM || (objectBottom && pp.getCanonicalText().equals(CommonClassNames.JAVA_LANG_OBJECT))) { anyBottom = true; } newbst = newbst.put(typeParameter, pp); } else { anyBottom = true; } } if (anyBottom || newbst == PsiSubstitutor.EMPTY) { newbst = JavaPsiFacade.getElementFactory(manager.getProject()).createRawSubstitutor(aclass); } return JavaPsiFacade.getElementFactory(manager.getProject()).createType(aclass, newbst); } else { return t; } }