From 881cf6849e8fd9ca25c140a15521663c7ec964a1 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Tue, 11 Jan 2022 21:30:04 +0700 Subject: [PATCH] Make multithreadingSupported a property with a getter (#3130) * Make multithreadingSupported a property with a getter This change fixes an issue with the initialization order observed when lazy initialization is disabled (-Xir-property-lazy-initialization= disabled compiler flag) and the new MM is used. The problem is the following: the initialization of DefaultDelay happens before the initialization of multithreadingSupported. Thus the initialization of DefaultDelay gets an uninitialized value of multithreadingSupported and behaves as if the old MM is used. Related issue: #KT-50491. --- kotlinx-coroutines-core/native/src/internal/Concurrent.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kotlinx-coroutines-core/native/src/internal/Concurrent.kt b/kotlinx-coroutines-core/native/src/internal/Concurrent.kt index 1db6c3bd86..f6e18dd5fc 100644 --- a/kotlinx-coroutines-core/native/src/internal/Concurrent.kt +++ b/kotlinx-coroutines-core/native/src/internal/Concurrent.kt @@ -32,6 +32,7 @@ internal open class SuppressSupportingThrowableImpl : Throwable() { } } -@SharedImmutable +// getter instead of a property due to the bug in the initialization dependencies tracking with '-Xir-property-lazy-initialization=disabled' that Ktor uses @OptIn(ExperimentalStdlibApi::class) -internal val multithreadingSupported: Boolean = kotlin.native.isExperimentalMM() +internal val multithreadingSupported: Boolean + get() = kotlin.native.isExperimentalMM()