@Nullable
  private DeclarationDescriptor findCurrentDescriptorForMember(
      @NotNull MemberDescriptor originalDescriptor) {
    if (!isFromBuiltinModule(originalDescriptor)) return null;

    DeclarationDescriptor containingDeclaration =
        findCurrentDescriptor(originalDescriptor.getContainingDeclaration());
    JetScope memberScope = getMemberScope(containingDeclaration);
    if (memberScope == null) return null;

    String renderedOriginal = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(originalDescriptor);
    Collection<? extends DeclarationDescriptor> descriptors;
    if (originalDescriptor instanceof ConstructorDescriptor
        && containingDeclaration instanceof ClassDescriptor) {
      descriptors = ((ClassDescriptor) containingDeclaration).getConstructors();
    } else {
      descriptors = memberScope.getAllDescriptors();
    }
    for (DeclarationDescriptor member : descriptors) {
      if (renderedOriginal.equals(DescriptorRenderer.FQ_NAMES_IN_TYPES.render(member))) {
        return member;
      }
    }
    return null;
  }
示例#2
0
 public static boolean isVisibleForOverride(
     @NotNull MemberDescriptor overriding, @NotNull MemberDescriptor fromSuper) {
   return !Visibilities.isPrivate(fromSuper.getVisibility())
       && Visibilities.isVisibleIgnoringReceiver(fromSuper, overriding);
 }