Skip to content

Commit 0359203

Browse files
authored
Fix crashes with the test module on the JVM (#3048)
Now the test module correctly exposes that initially the Main dispatcher is missing, so the default delay mechanism is not rewritten.
1 parent 402006a commit 0359203

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kotlinx-coroutines-core/jvm/src/internal/MainDispatchers.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public fun MainDispatcherFactory.tryCreateDispatcher(factories: List<MainDispatc
6161

6262
/** @suppress */
6363
@InternalCoroutinesApi
64-
public fun MainCoroutineDispatcher.isMissing(): Boolean = this is MissingMainCoroutineDispatcher
64+
public fun MainCoroutineDispatcher.isMissing(): Boolean =
65+
// not checking `this`, as it may be wrapped in a `TestMainDispatcher`, whereas `immediate` never is.
66+
this.immediate is MissingMainCoroutineDispatcher
6567

6668
// R8 optimization hook, not const on purpose to enable R8 optimizations via "assumenosideeffects"
6769
@Suppress("MayBeConstant")

0 commit comments

Comments
 (0)