You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not initialize non-mocked Dispatchers.Main unnecessarily (#4301)
Before this change, the following could happen on the JVM:
* `kotlinx.coroutines.test` accesses `Dispatchers.Main` before
`setMain` is called.
* `Dispatchers.Main` attempts to initialize *some other* Main
dispatcher in addition to the `kotlinx-coroutines-test` Main
dispatcher, if there is one.
* If the `kotlinx-coroutines-android` artifact is present + its
R8 rules are used to minify the tests, it's illegal to
attempt to fail to create a `Main` dispatcher.
`SUPPORT_MISSING = false` ensures that attempting to create a
Main dispatcher fails immediately, in the call frame that
attempts the creation, not waiting for `Dispatchers.Main` to
be meaningfully used.
In total, `kotlinx-coroutines-test` + `kotlinx-coroutines-android`
+ R8 minification of tests leads to some patterns of
`kotlinx-coroutines-test` usage to crash.
It turns out, though, that the problem originally reported was
simply because of incorrect `kotlinx-coroutines-test` usage.
The error message got improved to guide the programmer in
such scenarios better.
Fixes#4297
0 commit comments