boolean (@NotNull PsiClass expectedQualifierClass, @NotNull PsiClass receiverClass) { if (areClassesDirectlyRelated(expectedQualifierClass, receiverClass)) { return true; } if (receiverClass instanceof PsiTypeParameter) { // in case of "T extends S", it should be related to SImpl, even though T is not superclass of SImpl for (PsiClass receiverExtends : PsiClassImplUtil.getAllSuperClassesRecursively(receiverClass)) { if (areClassesDirectlyRelated(expectedQualifierClass, receiverExtends)) { return true; } } } return false; }