https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

v0ldem0rt

01/17/2020, 3:51 AM
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

octylFractal

01/17/2020, 3:59 AM
I'm pretty sure if you use the Kotlin reflection info, you can look at the return type
v

v0ldem0rt

01/17/2020, 4:00 AM
Any snippet will be helpful
o

octylFractal

01/17/2020, 4:06 AM
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
7 Views