Join Slack
Powered by
In bytecode, does a `suspend fun` only ever return...
# announcements
l
luke
01/29/2020, 9:03 AM
In bytecode, does a
suspend fun
only ever return a
java/lang/Object
? Can't seem to make it typed.
m
Marc Knaup
01/29/2020, 9:05 AM
Yes, because it will return a special value in case the function gets suspended. Would it be type then coroutines won’t work at all.
l
luke
01/29/2020, 9:08 AM
OK, thank you. So when writing Java interop with Kotlin suspend functions, I'll just have to cast the object as my class?
m
Marc Knaup
01/29/2020, 9:23 AM
Unfortunately it’s not that simple. I suggest looking online for various options how you can interface with Kotlin coroutines from Java code.
k
Kroppeb
01/29/2020, 9:37 AM
You probably want a wrapper function in Kotlin
5
Views
Open in Slack
Previous
Next