Skip to content

Commit

Permalink
Make multithreadingSupported a property with a getter (#3130)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
ilmat192 committed Jan 11, 2022
1 parent ed3445f commit 881cf68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kotlinx-coroutines-core/native/src/internal/Concurrent.kt
Expand Up @@ -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()

0 comments on commit 881cf68

Please sign in to comment.