Change PUBLICATION lazy to a storageManager one

Lazy computation in publication mode may lead to running of init code
many times in parallel, and it actually happens in IDE.
Instead, we stick to the option which is used for lazy computations
all across compiler code.
This commit is contained in:
Ilya Muradyan
2022-10-12 00:31:47 +02:00
parent b8260257fb
commit 4a58274056
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
import org.jetbrains.kotlin.storage.NotNullLazyValue
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.util.collectionUtils.concat
import org.jetbrains.kotlin.utils.Printer
@@ -126,7 +127,7 @@ open class LazyImportResolver<I : KtImportInfo>(
return importedScopesProvider(directive) ?: ImportingScope.Empty
}
val allNames: Set<Name>? by lazy(LazyThreadSafetyMode.PUBLICATION) {
val allNames: Set<Name>? by components.storageManager.createNullableLazyValue {
indexedImports.imports.asIterable().flatMapToNullable(THashSet()) { getImportScope(it).computeImportedNames() }
}