forked from JetBrains/kotlin-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect code generation for Nothing-returning suspend calls
#KT-30642 Fixed
- Loading branch information
1 parent
b22fa98
commit b870ce9
Showing
3 changed files
with
46 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
backend.native/tests/codegen/coroutines/returnsNothing1.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license | ||
* that can be found in the LICENSE file. | ||
*/ | ||
|
||
package codegen.coroutines.returnsNothing1 | ||
|
||
import kotlin.test.* | ||
|
||
import kotlin.coroutines.* | ||
import kotlin.coroutines.intrinsics.* | ||
|
||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> { | ||
companion object : EmptyContinuation() | ||
override fun resumeWith(result: Result<Any?>) { result.getOrThrow() } | ||
} | ||
|
||
suspend fun suspendForever(): Int = suspendCoroutineUninterceptedOrReturn { | ||
COROUTINE_SUSPENDED | ||
} | ||
|
||
suspend fun foo(): Nothing { | ||
suspendForever() | ||
throw Error() | ||
} | ||
|
||
suspend fun bar() { | ||
foo() | ||
} | ||
|
||
fun builder(c: suspend () -> Unit) { | ||
c.startCoroutine(EmptyContinuation) | ||
} | ||
|
||
@Test fun runTest() { | ||
builder { | ||
bar() | ||
} | ||
println("OK") | ||
} |