Youssef Shoaib [MOD]
07/11/2024, 4:18 PMsuspend fun foo(a: Any): Any =
bar { k ->
baz(k, a)
}
suspend fun bar(body: (Any) -> Any): Any
suspend fun baz(k: Any, a: Any): Any
both k
and a
stick around in the generated suspend lambda for the argument to bar
, even though clearly after the call to baz, k
and a
would never get used again.
Also, TCO isn't kicking in for some reason, and so that generated suspend lambda has 2 states, and it calls baz
with this
as the continuation instead of using completion
which is what I'd expect with TCO (according to some issue I saw TCO should be fully implemented for JVM, but here it doesn't work weirdly)dmitriy.novozhilov
07/12/2024, 6:18 AM