예제 #1
0
 private static void createAndBindFakeOverrides(
     @NotNull ClassDescriptor current,
     @NotNull Collection<CallableMemberDescriptor> notOverridden,
     @NotNull DescriptorSink sink) {
   Queue<CallableMemberDescriptor> fromSuperQueue =
       new LinkedList<CallableMemberDescriptor>(notOverridden);
   while (!fromSuperQueue.isEmpty()) {
     CallableMemberDescriptor notOverriddenFromSuper =
         VisibilityUtilKt.findMemberWithMaxVisibility(fromSuperQueue);
     Collection<CallableMemberDescriptor> overridables =
         extractMembersOverridableInBothWays(notOverriddenFromSuper, fromSuperQueue, sink);
     createAndBindFakeOverride(overridables, current, sink);
   }
 }
예제 #2
0
  @NotNull
  private static Collection<CallableMemberDescriptor> extractMembersOverridableInBothWays(
      @NotNull CallableMemberDescriptor overrider,
      @NotNull Queue<CallableMemberDescriptor> extractFrom,
      @NotNull DescriptorSink sink) {
    Collection<CallableMemberDescriptor> overridable = new ArrayList<CallableMemberDescriptor>();
    overridable.add(overrider);
    for (Iterator<CallableMemberDescriptor> iterator = extractFrom.iterator();
        iterator.hasNext(); ) {
      CallableMemberDescriptor candidate = iterator.next();
      if (overrider == candidate) {
        iterator.remove();
        continue;
      }

      OverrideCompatibilityInfo.Result result1 =
          DEFAULT.isOverridableBy(candidate, overrider).getResult();
      OverrideCompatibilityInfo.Result result2 =
          DEFAULT.isOverridableBy(overrider, candidate).getResult();
      if (result1 == OVERRIDABLE && result2 == OVERRIDABLE) {
        overridable.add(candidate);
        iterator.remove();
      } else if (result1 == CONFLICT || result2 == CONFLICT) {
        sink.conflict(overrider, candidate);
        iterator.remove();
      }
    }
    return overridable;
  }
예제 #3
0
  private static void createAndBindFakeOverrides(
      @NotNull ClassDescriptor current,
      @NotNull Collection<CallableMemberDescriptor> notOverridden,
      @NotNull OverridingStrategy strategy) {
    // Optimization: If all notOverridden descriptors have the same containing declaration,
    // then we can just create fake overrides for them, because they should be matched correctly in
    // their containing declaration
    if (allHasSameContainingDeclaration(notOverridden)) {
      for (CallableMemberDescriptor descriptor : notOverridden) {
        createAndBindFakeOverride(Collections.singleton(descriptor), current, strategy);
      }
      return;
    }

    Queue<CallableMemberDescriptor> fromSuperQueue =
        new LinkedList<CallableMemberDescriptor>(notOverridden);
    while (!fromSuperQueue.isEmpty()) {
      CallableMemberDescriptor notOverriddenFromSuper =
          VisibilityUtilKt.findMemberWithMaxVisibility(fromSuperQueue);
      Collection<CallableMemberDescriptor> overridables =
          extractMembersOverridableInBothWays(notOverriddenFromSuper, fromSuperQueue, strategy);
      createAndBindFakeOverride(overridables, current, strategy);
    }
  }