diff --git a/kotlinx-coroutines-core/native/src/Builders.kt b/kotlinx-coroutines-core/native/src/Builders.kt index 975fc98db7..3554dc604e 100644 --- a/kotlinx-coroutines-core/native/src/Builders.kt +++ b/kotlinx-coroutines-core/native/src/Builders.kt @@ -73,7 +73,7 @@ private class BlockingCoroutine( eventLoop?.decrementUseCount() } // now return result - val state = state + val state = state.unboxState() (state as? CompletedExceptionally)?.let { throw it.cause } state as T } diff --git a/kotlinx-coroutines-core/native/test/RunBlockingTest.kt b/kotlinx-coroutines-core/native/test/RunBlockingTest.kt new file mode 100644 index 0000000000..c5d08af5f3 --- /dev/null +++ b/kotlinx-coroutines-core/native/test/RunBlockingTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.coroutines +import kotlin.test.* + +class RunBlockingTest : TestBase() { + + @Test + fun testIncompleteState() { + val handle = runBlocking { + coroutineContext[Job]!!.invokeOnCompletion { } + } + + handle.dispose() + } +} \ No newline at end of file