-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
f8c0304
commit 8f83057
Showing
3 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters