Fix codegen issue of safe-qualified suspension points
#KT-15527 Fixed
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND: JS
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class TestClass {
|
||||
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||
x.resume("K")
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun foo(x: String, y: String?) = x + (y ?: "")
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
var instance: TestClass? = null
|
||||
|
||||
builder {
|
||||
result = foo("OK", instance?.suspendHere())
|
||||
}
|
||||
|
||||
if (result != "OK") return "fail 1: $result"
|
||||
|
||||
result = ""
|
||||
instance = TestClass()
|
||||
builder {
|
||||
result = foo("O", instance?.suspendHere())
|
||||
}
|
||||
|
||||
if (result != "OK") return "fail 2: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND: JS
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class TestClass {
|
||||
suspend fun toInt(): Int = suspendCoroutineOrReturn { x ->
|
||||
x.resume(14)
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = 0
|
||||
|
||||
var instance: TestClass? = null
|
||||
|
||||
builder {
|
||||
result = 42 + (instance?.toInt() ?: 0)
|
||||
}
|
||||
|
||||
if (result != 42) return "fail 1: $result"
|
||||
|
||||
instance = TestClass()
|
||||
builder {
|
||||
result = 42 + (instance?.toInt() ?: 0)
|
||||
}
|
||||
|
||||
if (result != 56) return "fail 2: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user