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()));
   }
 }
Exemplo n.º 2
0
 @Nullable
 private static Visibility computeVisibilityToInherit(
     @NotNull CallableMemberDescriptor memberDescriptor) {
   Collection<? extends CallableMemberDescriptor> overriddenDescriptors =
       memberDescriptor.getOverriddenDescriptors();
   Visibility maxVisibility = findMaxVisibility(overriddenDescriptors);
   if (maxVisibility == null) {
     return null;
   }
   if (memberDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
     for (CallableMemberDescriptor overridden : overriddenDescriptors) {
       // An implementation (a non-abstract overridden member) of a fake override should have the
       // maximum possible visibility
       if (overridden.getModality() != Modality.ABSTRACT
           && !overridden.getVisibility().equals(maxVisibility)) {
         return null;
       }
     }
     return maxVisibility;
   }
   return maxVisibility.normalize();
 }