Collection<PsiClass> (@NotNull PsiParameter parameter, @NotNull Collection<PsiClass> candidates) { PsiElement parent = parameter.getParent(); if (parent instanceof PsiParameterList) { PsiElement granny = parent.getParent(); if (granny instanceof PsiMethod method && method.getModifierList().hasAnnotation(CommonClassNames.JAVA_LANG_OVERRIDE)) { PsiClass aClass = method.getContainingClass(); Set<PsiClass> probableTypes = new HashSet<>(); InheritanceUtil.processSupers(aClass, false, psiClass -> { for (PsiMethod psiMethod : psiClass.findMethodsByName(method.getName(), false)) { for (PsiParameter psiParameter : psiMethod.getParameterList().getParameters()) { ContainerUtil.addIfNotNull(probableTypes, PsiUtil.resolveClassInClassTypeOnly(psiParameter.getType())); } } return true; }); List<PsiClass> filtered = ContainerUtil.filter(candidates, psiClass -> probableTypes.contains(psiClass)); if (!filtered.isEmpty()) { return filtered; } } } return candidates; }