https://kotlinlang.org logo
u

uli

03/11/2021, 10:51 PM
Hi all, is it possible to call a kotlin function from swift that expects a suspend lambda parameter? i.e. in kotlin you can pass non-suspending functions where suspending ones are expected. Seems this is not possible from swift and we can not write suspend swift blocks ;-)
e

ephemient

03/11/2021, 11:28 PM
e.g. you can't write
Copy code
suspend fun wrap(f: suspend () -> Unit) = f()
val f: () -> Unit = {} // non-suspend
wrap(f)
u

uli

03/11/2021, 11:43 PM
thanks, but then i need to wrap on kotlin side. I have a swift lambda though
e

ephemient

03/11/2021, 11:44 PM
basically there's no auto-conversion on either side
u

uli

03/11/2021, 11:54 PM
thanks. i see
2 Views