Why donesn't this compile? ``` fun functionImpl(a:...
# coroutines
p
Why donesn't this compile?
Copy code
fun functionImpl(a: Int, b: String) {}

fun nonSuspending(function: (Int, String) -> Unit) {}
fun suspending(function: suspend (Int, String) -> Unit) {}

fun test() {
  nonSuspending(::functionImpl)
  suspending(::functionImpl)
}
m
fun suspending
requires a
suspend
function but you pass
functionImpl
which is not a
suspend
function The following code works for example:
Copy code
fun functionImpl(a: Int, b: String) {}
suspend fun functionImplSuspending(a: Int, b: String) {}

fun nonSuspending(function: (Int, String) -> Unit) {}
fun suspending(function: suspend (Int, String) -> Unit) {}

fun test() {
    nonSuspending(::functionImpl)
    suspending(::functionImplSuspending)
}
p
I know; but why?
The design resolution is that conversion from regular functions to suspending function will be supported.
Looks like it will be implemented. But it's from '17. I just refactored several classes from rxjava to flow and this made the migration a pain @elizarov
e
Tentatively in 1.4.0. It requires a new type inference engine.