[native-mt, 1.5.0-RC] Fix withTimeout throwing InvalidMutabilityException. #2689
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2688.
TimeoutCoroutine
subclassesScopeCoroutine
and adds a backing fieldtime
.Since
ScopeCoroutine
may potentially freeze itself during its init block (by adding itself to a frozen job as a child), the init steps ofTimeoutCoroutine
as a subclass may consequentially fail, due to the object now potentially failingMutationCheck()
.Introduced a
useInitNativeKludge
constructor parameter inScopeCoroutine
to control whether the init kludge for native is enabled.Fixed InvalidMutabilityException raised by
withTimeout {}
when the scope is frozen (1.5.0-RC-native-mt) #2688 by changingTimeoutCoroutine
to disable the superclass' kludge, in favour of having the kludge as its own init block.Added a failing test case.
withTimeout {}
when the scope is frozen (1.5.0-RC-native-mt) #2688 though, that the test runner should have been reporting theInvalidMutabilityException
. But instead,runBlocking()
eats the exception and continues to spin indefinitely.I didn't dig into why this happens.It looks like a consequence of (unexpectedly?) failing during initialisation, which failed child does not remove itself from the parent.