void () { myFixture.configureByFiles("Anonymouses.java", "Foo1.java", "Foo2.java", "Foo3.java", "Foo4.java", "Foo5.java", "Foo6.java"); rebuildProject(); PsiClass[] classes = IntStream .range(1, 7) .mapToObj(idx -> "Foo" + idx) .map(className -> myFixture.findClass(className)) .toArray(PsiClass[]::new); assertSize(6, classes); for (PsiClass aClass : classes) { List<PsiClass> inheritors = getDirectInheritorsFor(aClass) .getHierarchyChildren() .map(PsiClass.class::cast) .collect(Collectors.toList()); PsiClass inheritor = assertOneElement(inheritors); PsiAnonymousClass anonymousInheritor = assertInstanceOf(inheritor, PsiAnonymousClass.class); PsiClass superFromReference = PsiUtil.resolveClassInType(anonymousInheritor.getBaseClassType()); assertEquals(superFromReference, aClass); } }