Example #1
0
  private void checkOpenMembers(ClassDescriptorWithResolutionScopes classDescriptor) {
    if (classCanHaveOpenMembers(classDescriptor)) return;

    for (CallableMemberDescriptor memberDescriptor : classDescriptor.getDeclaredCallableMembers()) {
      if (memberDescriptor.getKind() != CallableMemberDescriptor.Kind.DECLARATION) continue;
      JetNamedDeclaration member =
          (JetNamedDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor);
      if (member != null && member.hasModifier(JetTokens.OPEN_KEYWORD)) {
        trace.report(NON_FINAL_MEMBER_IN_FINAL_CLASS.on(member));
      }
    }
  }
Example #2
0
 @NotNull
 public static DeclarationDescriptor getEnclosingDescriptor(
     @NotNull BindingContext context, @NotNull JetElement element) {
   JetNamedDeclaration declaration =
       PsiTreeUtil.getParentOfType(element, JetNamedDeclaration.class);
   if (declaration instanceof JetFunctionLiteral) {
     return getEnclosingDescriptor(context, declaration);
   }
   DeclarationDescriptor descriptor = context.get(DECLARATION_TO_DESCRIPTOR, declaration);
   assert descriptor != null
       : "No descriptor for named declaration: "
           + declaration.getText()
           + "\n(of type "
           + declaration.getClass()
           + ")";
   return descriptor;
 }