/** * @return overridden real descriptors (not fake overrides). Note that most usages of this method * should be followed by calling {@link #filterOutOverridden(Set)}, because some of the * declarations can override the other. */ @NotNull public static Set<CallableMemberDescriptor> getOverriddenDeclarations( @NotNull CallableMemberDescriptor descriptor) { Set<CallableMemberDescriptor> result = new LinkedHashSet<CallableMemberDescriptor>(); collectOverriddenDeclarations(descriptor, result); return result; }
private static void collectOverriddenDeclarations( @NotNull CallableMemberDescriptor descriptor, @NotNull Set<CallableMemberDescriptor> result) { if (descriptor.getKind().isReal()) { result.add(descriptor); } else { if (descriptor.getOverriddenDescriptors().isEmpty()) { throw new IllegalStateException( "No overridden descriptors found for (fake override) " + descriptor); } for (CallableMemberDescriptor overridden : descriptor.getOverriddenDescriptors()) { collectOverriddenDeclarations(overridden, result); } } }