Fix accessor generation for suspend functions
1. JVM view of suspend accessors must be also an instance of AccessorForFunctionDescriptor, thus `createSubstitutedCopy` should be correctly overidden. 2. accessibleFunctionDescriptor should unwap the initial suspend descriptor, for the same reasons as for type aliases constructors and etc: these descriptors are used as keys of the map of accessors, so to avoid duplication for suspend view and initial suspend descriptor, we always use the latter one as a key. #KT-15907 Fixed #KT-15935 Fixed
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class X {
|
||||
var res = ""
|
||||
suspend fun execute() {
|
||||
a()
|
||||
b()
|
||||
}
|
||||
|
||||
private suspend fun a() {
|
||||
res += suspendThere("O")
|
||||
res += suspendThere("K")
|
||||
}
|
||||
|
||||
private suspend fun b() {
|
||||
res += suspendThere("5")
|
||||
res += suspendThere("6")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
|
||||
x.resume(v)
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
|
||||
fun builder(c: suspend X.() -> Unit) {
|
||||
c.startCoroutine(X(), EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
builder {
|
||||
execute()
|
||||
result = res
|
||||
}
|
||||
|
||||
if (result != "OK56") return "fail 1: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
|
||||
var x = true
|
||||
private suspend fun foo(): String {
|
||||
if (x) {
|
||||
return suspendCoroutineOrReturn<String> {
|
||||
it.resume("OK")
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
}
|
||||
|
||||
return "fail"
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
res = foo()
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user