I am writing a Proxy handler for `suspend` functio...
# coroutines
v
I am writing a Proxy handler for
suspend
function. How can I get return
Class<*>
of a suspend function. So far I know the last parameter of
suspend
function is a
Continuation<T>
. How can I get
Class<T>
from
Continuation<T>
o
I'm pretty sure if you use the Kotlin reflection info, you can look at the return type
v
Any snippet will be helpful
o
Copy code
fun main() {
    val testMethod = ::test
    println("Despite being suspend: ${testMethod.isSuspend}")
    println("It returns: ${testMethod.returnType}")
    println("Or, as a JVM Class: ${testMethod.returnType.jvmErasure.java}")
}

suspend fun test(): String {
    yield()
    return ""
}
❤️ 2
Copy code
Despite being suspend: true
It returns: kotlin.String
Or, as a JVM Class: class java.lang.String
❤️ 2