public MutableClassDescriptor(
      @NotNull DeclarationDescriptor containingDeclaration,
      @NotNull JetScope outerScope,
      @NotNull ClassKind kind,
      boolean isInner,
      @NotNull Name name,
      @NotNull SourceElement source) {
    super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
    this.kind = kind;
    this.isInner = isInner;

    RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING;

    setScopeForMemberLookup(
        new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler, "MemberLookup")
            .changeLockLevel(WritableScope.LockLevel.BOTH));
    this.scopeForSupertypeResolution =
        new WritableScopeImpl(outerScope, this, redeclarationHandler, "SupertypeResolution")
            .changeLockLevel(WritableScope.LockLevel.BOTH);
    this.scopeForMemberResolution =
        new WritableScopeImpl(
                scopeForSupertypeResolution, this, redeclarationHandler, "MemberResolution")
            .changeLockLevel(WritableScope.LockLevel.BOTH);

    if (kind == ClassKind.TRAIT) {
      setUpScopeForInitializers(this);
    }

    scopeForMemberResolution.importScope(staticScope);
    scopeForMemberResolution.addLabeledDeclaration(this);
  }
  public void setPrimaryConstructor(@NotNull ConstructorDescriptor constructorDescriptor) {
    assert primaryConstructor == null : "Primary constructor assigned twice " + this;
    primaryConstructor = constructorDescriptor;

    constructors.add(constructorDescriptor);

    ((ConstructorDescriptorImpl) constructorDescriptor)
        .setReturnType(
            new DelegatingType() {
              @Override
              protected JetType getDelegate() {
                return getDefaultType();
              }
            });

    if (constructorDescriptor.isPrimary()) {
      setUpScopeForInitializers(constructorDescriptor);
    }
  }