PsiType (PsiClassType classType, PsiExpression expression) { final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(classType); final PsiClass psiClass = classResolveResult.getElement(); if (psiClass != null) { final GlobalSearchScope allScope = GlobalSearchScope.allScope(psiClass.getProject()); final PsiClass collectionClass = JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, allScope); if (collectionClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, collectionClass, true)) { final PsiSubstitutor derivedSubstitutor = classResolveResult.getSubstitutor(); if (PsiUtil.isRawSubstitutor(psiClass, derivedSubstitutor)) return null; final PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(collectionClass, psiClass, derivedSubstitutor); assert substitutor != null; final PsiType type = substitutor.substitute(collectionClass.getTypeParameters()[0]); assert type != null; return PsiImplUtil.normalizeWildcardTypeByPosition(type, expression); } } return null; }