Generate debug metadata for lambdas which capture crossinline lambdas

After cold stream related fixes, we do not generate state machine until
the very last transformation of the lambda. Thus, it is safe to
generate debug metadata for that lambda.
 #KT-30694 Fixed
This commit is contained in:
Ilmir Usmanov
2019-03-28 22:16:01 +03:00
parent f09457c569
commit 3bfee39995
3 changed files with 15 additions and 6 deletions
@@ -23,6 +23,10 @@ inline suspend fun <T : Any> Flow<T>.collect(crossinline action: suspend (T) ->
override suspend fun emit(value: T) = action(value)
})
inline suspend fun inlineMe(crossinline block: suspend () -> Unit) = suspend {
block()
}
// FILE: Test.kt
import flow.*
@@ -45,5 +49,13 @@ fun box(): String {
}
}
if ("(Test.kt:" !in str) return str
builder {
inlineMe {
var continuation: Continuation<Unit>? = null
suspendCoroutineUninterceptedOrReturn<Unit> { continuation = it; Unit }
str = "$continuation"
}()
}
if ("(Test.kt:" !in str) return str
return "OK"
}