From d0e09004ad04aba86bbe94e1f4651f21812dceff Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Fri, 19 Feb 2021 13:02:35 +0300 Subject: [PATCH] Backport "Fix cache service for resolution anchors" Use project cache correctly instead of storing values in instance fields Move logger from instance field Original commit: 59a10424e6a9be45fd25ad926957223e1b3b6744 (kotlin-ide) --- .../resolve/ResolutionAnchorCacheService.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt index 0b39cd2f30179..269c9dcbceae4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt @@ -50,8 +50,6 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : var moduleNameToAnchorName: Map = emptyMap() ) - private val logger = logger() - @JvmField @Volatile var myState: State = State() @@ -65,14 +63,13 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : object ResolutionAnchorMappingCacheKey object ResolutionAnchorDependenciesCacheKey - override val resolutionAnchorsForLibraries: Map by lazy { - project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) { + override val resolutionAnchorsForLibraries: Map + get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) { mapResolutionAnchorForLibraries() } - } - private val resolutionAnchorDependenciesCache: MutableMap> = - project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) { + private val resolutionAnchorDependenciesCache: MutableMap> + get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) { ContainerUtil.createConcurrentWeakMap() } @@ -118,4 +115,8 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : library to anchor }.toMap() } + + companion object { + private val logger = logger() + } }