PsiClassType (PsiClass containingClass, PsiType sType, boolean capture) { if (sType instanceof PsiIntersectionType) { for (PsiType conjunct : ((PsiIntersectionType)sType).getConjuncts()) { if (conjunct instanceof PsiClassType) { final PsiClassType.ClassResolveResult conjunctResult = ((PsiClassType)conjunct).resolveGenerics(); if (InheritanceUtil.isInheritorOrSelf(conjunctResult.getElement(), containingClass, true)) { return (PsiClassType)conjunct; } } } } else if (sType instanceof PsiClassType) { return (PsiClassType)sType; } else if (sType instanceof PsiCapturedWildcardType) { final PsiType upperBound = ((PsiCapturedWildcardType)sType).getUpperBound(capture); if (upperBound instanceof PsiClassType) { return (PsiClassType)upperBound; } else if (upperBound instanceof PsiIntersectionType) { return getSubclassType(containingClass, upperBound, capture); } } return null; }