phldavies
04/22/2020, 12:19 PMinline
but it seems to compile fine without:
typealias ResultCallback<R> = (Result<R>) -> Unit
internal inline operator fun <R> ResultCallback<R>.invoke (
scope: CoroutineScope = GlobalScope,
context: CoroutineContext = EmptyCoroutineContext,
crossinline block: suspend () -> R
) = scope.launch(context) { this@invoke(runCatching { block() }) }
example usage would be
suspend fun greeting(name: String): String {
delay(1000)
return "Hello, $name"
}
fun greeting(name: String, callback: ResultCallback<String>) = callback { greeting(name) }
When `inline`’d I get the following from the compiler: e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated