private WritableScope getCurrentIndividualImportScope() {
   if (currentIndividualImportScope == null) {
     WritableScopeImpl writableScope =
         new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING)
             .setDebugName("Individual import scope");
     writableScope.changeLockLevel(LockLevel.BOTH);
     importScope(writableScope);
     currentIndividualImportScope = writableScope;
   }
   return currentIndividualImportScope;
 }
  @NotNull
  public JetScope getScopeForClassHeaderResolution() {
    if (scopeForClassHeaderResolution == null) {
      WritableScopeImpl scope =
          new WritableScopeImpl(
              JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Class Header Resolution");
      for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
        scope.addClassifierDescriptor(typeParameterDescriptor);
      }
      scope.changeLockLevel(WritableScope.LockLevel.READING);

      scopeForClassHeaderResolution =
          new ChainedScope(
              this,
              scope,
              resolveSession.getResolutionScope(
                  declarationProvider.getOwnerInfo().getScopeAnchor()));
    }
    return scopeForClassHeaderResolution;
  }
  public JetScope getScopeForMemberDeclarationResolution() {
    if (scopeForMemberDeclarationResolution == null) {
      WritableScopeImpl scope =
          new WritableScopeImpl(
              JetScope.EMPTY,
              this,
              RedeclarationHandler.DO_NOTHING,
              "Member Declaration Resolution");
      scope.addLabeledDeclaration(this);
      scope.changeLockLevel(WritableScope.LockLevel.READING);

      scopeForMemberDeclarationResolution =
          new ChainedScope(
              this,
              getScopeForMemberLookup().getImplicitReceiver(),
              scope,
              getScopeForMemberLookup(),
              getScopeForClassHeaderResolution());
    }
    return scopeForMemberDeclarationResolution;
  }
  @NotNull
  private JetScope computeScopeForClassHeaderResolution() {
    WritableScopeImpl scope =
        new WritableScopeImpl(
            JetScope.EMPTY,
            this,
            RedeclarationHandler.DO_NOTHING,
            "Scope with type parameters for " + getName());
    for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
      scope.addClassifierDescriptor(typeParameterDescriptor);
    }
    scope.changeLockLevel(WritableScope.LockLevel.READING);

    PsiElement scopeAnchor = declarationProvider.getOwnerInfo().getScopeAnchor();

    return new ChainedScope(
        this,
        "ScopeForClassHeaderResolution: " + getName(),
        scope,
        getScopeProvider().getResolutionScopeForDeclaration(scopeAnchor));
  }
  @NotNull
  private JetScope computeScopeForPropertyInitializerResolution() {
    ConstructorDescriptor primaryConstructor = getUnsubstitutedPrimaryConstructor();
    if (primaryConstructor == null) return getScopeForMemberDeclarationResolution();

    WritableScopeImpl scope =
        new WritableScopeImpl(
            JetScope.EMPTY,
            this,
            RedeclarationHandler.DO_NOTHING,
            "Scope with constructor parameters in " + getName());
    for (ValueParameterDescriptor valueParameterDescriptor :
        primaryConstructor.getValueParameters()) {
      scope.addVariableDescriptor(valueParameterDescriptor);
    }
    scope.changeLockLevel(WritableScope.LockLevel.READING);

    return new ChainedScope(
        this,
        "ScopeForPropertyInitializerResolution: " + getName(),
        scope,
        getScopeForMemberDeclarationResolution());
  }
  @NotNull
  private JetScope computeScopeForMemberDeclarationResolution() {
    WritableScopeImpl thisScope =
        new WritableScopeImpl(
            JetScope.EMPTY,
            this,
            RedeclarationHandler.DO_NOTHING,
            "Scope with 'this' for " + getName());
    thisScope.addLabeledDeclaration(this);
    thisScope.changeLockLevel(WritableScope.LockLevel.READING);

    ClassDescriptor classObject = getClassObjectDescriptor();
    JetScope classObjectAdapterScope =
        (classObject != null) ? new ClassObjectMixinScope(classObject) : JetScope.EMPTY;

    return new ChainedScope(
        this,
        "ScopeForMemberDeclarationResolution: " + getName(),
        thisScope,
        getScopeForMemberLookup(),
        getScopeForClassHeaderResolution(),
        classObjectAdapterScope);
  }
  public JetScope getScopeForPropertyInitializerResolution() {
    ConstructorDescriptor primaryConstructor = getUnsubstitutedPrimaryConstructor();
    if (primaryConstructor == null) return getScopeForMemberDeclarationResolution();

    if (scopeForPropertyInitializerResolution == null) {
      WritableScopeImpl scope =
          new WritableScopeImpl(
              JetScope.EMPTY,
              this,
              RedeclarationHandler.DO_NOTHING,
              "Property Initializer Resolution");

      List<ValueParameterDescriptor> parameters = primaryConstructor.getValueParameters();
      for (ValueParameterDescriptor valueParameterDescriptor : parameters) {
        scope.addVariableDescriptor(valueParameterDescriptor);
      }

      scope.changeLockLevel(WritableScope.LockLevel.READING);

      scopeForPropertyInitializerResolution =
          new ChainedScope(this, scope, getScopeForMemberDeclarationResolution());
    }
    return scopeForPropertyInitializerResolution;
  }