From c427b2638087cbd2f3eec500bafb469bca59d326 Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Thu, 30 Jan 2020 14:27:44 +0300 Subject: [PATCH] [Workspace Model] orderEntries should be calculated on every access because libraryTable class is not immutable GitOrigin-RevId: 73afd4bbe79512530e8885f1246c92562e95a319 --- .../module/RootModelViaTypedEntityImpl.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/workspaceModel-ide/src/com/intellij/workspace/legacyBridge/typedModel/module/RootModelViaTypedEntityImpl.kt b/platform/workspaceModel-ide/src/com/intellij/workspace/legacyBridge/typedModel/module/RootModelViaTypedEntityImpl.kt index d517dcb6d0d3..31d59df20ca8 100644 --- a/platform/workspaceModel-ide/src/com/intellij/workspace/legacyBridge/typedModel/module/RootModelViaTypedEntityImpl.kt +++ b/platform/workspaceModel-ide/src/com/intellij/workspace/legacyBridge/typedModel/module/RootModelViaTypedEntityImpl.kt @@ -38,12 +38,15 @@ internal class RootModelViaTypedEntityImpl(internal val moduleEntityId: Persiste val moduleEntity: ModuleEntity? = storage.resolve(moduleEntityId) - private val orderEntriesArray by lazy { - val moduleEntity = storage.resolve(moduleEntityId) ?: return@lazy emptyArray() - moduleEntity.dependencies.mapIndexed { index, e -> - toOrderEntry(e, index) - }.toTypedArray() - } + private val orderEntriesArray: Array + get() { + // This variable should not be cached unless + // com.intellij.workspace.legacyBridge.intellij.LegacyBridgeModuleRootComponent.moduleLibraries is mutable + val moduleEntity = storage.resolve(moduleEntityId) ?: return emptyArray() + return moduleEntity.dependencies.mapIndexed { index, e -> + toOrderEntry(e, index) + }.toTypedArray() + } val contentEntities: List by lazy { val moduleEntity = storage.resolve(moduleEntityId) ?: return@lazy emptyList()