Example #1
0
  private void checkClass(
      BodiesResolveContext c,
      JetClass aClass,
      ClassDescriptorWithResolutionScopes classDescriptor) {
    checkOpenMembers(classDescriptor);
    checkTypeParameters(aClass);

    if (aClass.isInterface()) {
      ASTNode traitKeyword = aClass.getNode().findChildByType(JetTokens.TRAIT_KEYWORD);
      if (traitKeyword != null) {
        trace.report(Errors.DEPRECATED_TRAIT_KEYWORD.on(traitKeyword.getPsi()));
      }

      checkTraitModifiers(aClass);
      checkConstructorInTrait(aClass);
    } else if (aClass.isAnnotation()) {
      checkAnnotationClassWithBody(aClass);
      checkValOnAnnotationParameter(aClass);
    } else if (aClass.isEnum()) {
      checkEnumModifiers(aClass);
      if (aClass.isLocal()) {
        trace.report(LOCAL_ENUM_NOT_ALLOWED.on(aClass, classDescriptor));
      }
    } else if (aClass.hasModifier(JetTokens.SEALED_KEYWORD)) {
      checkSealedModifiers(aClass);
    } else if (aClass instanceof JetEnumEntry) {
      checkEnumEntry((JetEnumEntry) aClass, classDescriptor);
    }
  }
Example #2
0
 private void checkNestedClassAllowed(
     @NotNull JetModifierListOwner modifierListOwner,
     @NotNull DeclarationDescriptor descriptor) {
   if (modifierListOwner.hasModifier(INNER_KEYWORD)) return;
   if (modifierListOwner instanceof JetClass && !(modifierListOwner instanceof JetEnumEntry)) {
     JetClass aClass = (JetClass) modifierListOwner;
     boolean localEnumError = aClass.isLocal() && aClass.isEnum();
     if (!localEnumError && isIllegalNestedClass(descriptor)) {
       trace.report(NESTED_CLASS_NOT_ALLOWED.on(aClass));
     }
   }
 }