Exemple #1
0
  private static Collection<CallableMemberDescriptor> extractAndBindOverridesForMember(
      @NotNull CallableMemberDescriptor fromCurrent,
      @NotNull Collection<? extends CallableMemberDescriptor> descriptorsFromSuper,
      @NotNull ClassDescriptor current,
      @NotNull DescriptorSink sink) {
    Collection<CallableMemberDescriptor> bound =
        new ArrayList<CallableMemberDescriptor>(descriptorsFromSuper.size());
    for (CallableMemberDescriptor fromSupertype : descriptorsFromSuper) {
      OverrideCompatibilityInfo.Result result =
          DEFAULT.isOverridableBy(fromSupertype, fromCurrent).getResult();

      boolean isVisible =
          Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSupertype, current);
      switch (result) {
        case OVERRIDABLE:
          if (isVisible) {
            fromCurrent.addOverriddenDescriptor(fromSupertype);
          }
          bound.add(fromSupertype);
          break;
        case CONFLICT:
          if (isVisible) {
            sink.conflict(fromSupertype, fromCurrent);
          }
          bound.add(fromSupertype);
          break;
        case INCOMPATIBLE:
          break;
      }
    }
    return bound;
  }
 private static void checkVisibility(
     @NotNull DeclarationDescriptorWithVisibility descriptor,
     @NotNull BindingTrace trace,
     @NotNull JetSimpleNameExpression referenceExpression,
     @NotNull JetScope scopeToCheckVisibility) {
   if (!Visibilities.isVisible(
       ReceiverValue.IRRELEVANT_RECEIVER,
       descriptor,
       scopeToCheckVisibility.getContainingDeclaration())) {
     Visibility visibility = descriptor.getVisibility();
     if (PsiTreeUtil.getParentOfType(referenceExpression, JetImportDirective.class) != null
         && !visibility.mustCheckInImports()) return;
     //noinspection ConstantConditions
     trace.report(
         INVISIBLE_REFERENCE.on(
             referenceExpression, descriptor, visibility, descriptor.getContainingDeclaration()));
   }
 }