Keep DebugMetadata annotation when regenerate lambda with state-machine
When a suspend lambda does not capture crossinline lambda, it is generated with as state-machine, since it does not inline anything. However, when regenerating, the inliner used to remove all DebugMetadata annotations to avoid duplication. This lead to missing annotation if the lambda is regenerated, but state-machine is not regenerated. This change fixes the blind spot by readding the annotation after regeneration. #KT-41789 Fixed
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// FILE: inline.kt
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun runBlocking(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext){})
|
||||
}
|
||||
|
||||
inline fun <reified E> foo(noinline block: (String) -> Unit) = runBlocking {
|
||||
runCatching {
|
||||
runBlocking {
|
||||
var c: Continuation<Unit>? = null
|
||||
suspendCoroutineUninterceptedOrReturn<Unit> { c = it; Unit }
|
||||
block(c!!.toString())
|
||||
}
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
foo<Exception> {
|
||||
res = it
|
||||
}
|
||||
return if (res.contains(".invokeSuspend(inline.kt:")) "OK" else res
|
||||
}
|
||||
Reference in New Issue
Block a user