PsiType (@NotNull PsiTypeParameter typeParameter) { final PsiType substituted = substitute(typeParameter); if (substituted instanceof PsiWildcardType && !((PsiWildcardType)substituted).isSuper()) { final PsiWildcardType wildcardType = (PsiWildcardType)substituted; final PsiType glb = PsiCapturedWildcardType.captureUpperBound(typeParameter, wildcardType, this); if (glb instanceof PsiWildcardType) { return glb; } if (glb instanceof PsiCapturedWildcardType) { PsiWildcardType wildcard = ((PsiCapturedWildcardType)glb).getWildcard(); if (!wildcard.isSuper()) return wildcard; } if (glb != null) { return PsiWildcardType.createExtends(typeParameter.getManager(), glb); } } return substituted; }