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 addConstructorParametersToInitializersScope(
     @NotNull Collection<? extends VariableDescriptor> variables) {
   WritableScope scope = getWritableScopeForInitializers();
   for (VariableDescriptor variable : variables) {
     scope.addVariableDescriptor(variable);
   }
 }
 public void lockScopes() {
   getScopeForMemberLookupAsWritableScope().changeLockLevel(WritableScope.LockLevel.READING);
   if (classObjectDescriptor != null) {
     classObjectDescriptor.lockScopes();
   }
   scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
   scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
   getWritableScopeForInitializers().changeLockLevel(WritableScope.LockLevel.READING);
 }
 public void setTypeParameterDescriptors(@NotNull List<TypeParameterDescriptor> typeParameters) {
   if (this.typeParameters != null) {
     throw new IllegalStateException("Type parameters are already set for " + getName());
   }
   this.typeParameters = new ArrayList<TypeParameterDescriptor>(typeParameters);
   for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
     scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor);
   }
   scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
 }
 public void createTypeConstructor() {
   assert typeConstructor == null : typeConstructor;
   this.typeConstructor =
       TypeConstructorImpl.createForClass(
           this,
           Annotations.EMPTY, // TODO : pass annotations from the class?
           !getModality().isOverridable(),
           getName().asString(),
           typeParameters,
           supertypes);
   for (FunctionDescriptor functionDescriptor : getConstructors()) {
     ((ConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
   }
   scopeForMemberResolution.setImplicitReceiver(getThisAsReceiverParameter());
 }