Exemplo n.º 1
0
    @Override
    public void visitClassObject(@NotNull JetClassObject classObject) {
      JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();

      DeclarationDescriptor container = owner.getOwnerForChildren();

      MutableClassDescriptor classObjectDescriptor =
          createClassDescriptorForSingleton(
              objectDeclaration, getClassObjectName(container.getName()), ClassKind.CLASS_OBJECT);

      PackageLikeBuilder.ClassObjectStatus status =
          isEnumEntry(container)
                  || isObject(container)
                  || c.getTopDownAnalysisParameters().isDeclaredLocally()
              ? PackageLikeBuilder.ClassObjectStatus.NOT_ALLOWED
              : owner.setClassObjectDescriptor(classObjectDescriptor);

      switch (status) {
        case DUPLICATE:
          trace.report(MANY_CLASS_OBJECTS.on(classObject));
          break;
        case NOT_ALLOWED:
          trace.report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
          break;
        case OK:
          // Everything is OK so no errors to trace.
          break;
      }
    }
Exemplo n.º 2
0
 public static boolean isError(@NotNull DeclarationDescriptor candidate) {
   return candidate == getErrorClass()
       || candidate.getContainingDeclaration() == getErrorClass()
       || candidate == ERROR_MODULE;
 }