Search in sources :

Example 1 with NonReportingOverrideStrategy

use of org.jetbrains.kotlin.resolve.NonReportingOverrideStrategy in project kotlin by JetBrains.

the class DescriptorResolverUtils method resolveOverrides.

@NotNull
private static <D extends CallableMemberDescriptor> Collection<D> resolveOverrides(@NotNull Name name, @NotNull Collection<D> membersFromSupertypes, @NotNull Collection<D> membersFromCurrent, @NotNull ClassDescriptor classDescriptor, @NotNull final ErrorReporter errorReporter, final boolean isStaticContext) {
    final Set<D> result = new LinkedHashSet<D>();
    OverridingUtil.generateOverridesInFunctionGroup(name, membersFromSupertypes, membersFromCurrent, classDescriptor, new NonReportingOverrideStrategy() {

        @Override
        @SuppressWarnings("unchecked")
        public void addFakeOverride(@NotNull CallableMemberDescriptor fakeOverride) {
            OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, new Function1<CallableMemberDescriptor, Unit>() {

                @Override
                public Unit invoke(@NotNull CallableMemberDescriptor descriptor) {
                    errorReporter.reportCannotInferVisibility(descriptor);
                    return Unit.INSTANCE;
                }
            });
            result.add((D) fakeOverride);
        }

        @Override
        public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
        // nop
        }

        @Override
        public void setOverriddenDescriptors(@NotNull CallableMemberDescriptor member, @NotNull Collection<? extends CallableMemberDescriptor> overridden) {
            // do not set overridden descriptors for declared static fields and methods from java
            if (isStaticContext && member.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
                return;
            }
            super.setOverriddenDescriptors(member, overridden);
        }
    });
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Function1(kotlin.jvm.functions.Function1) NonReportingOverrideStrategy(org.jetbrains.kotlin.resolve.NonReportingOverrideStrategy) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 Function1 (kotlin.jvm.functions.Function1)1 NotNull (org.jetbrains.annotations.NotNull)1 NonReportingOverrideStrategy (org.jetbrains.kotlin.resolve.NonReportingOverrideStrategy)1