https://kotlinlang.org logo
Title
y

yatsinar

02/19/2018, 7:27 PM
Are coroutines supposed to work in Native modules? Trying to create my own simple implementation for iOS, this simple declaration alone in Native (or common) module crashes compiler:
fun launchAsync(context: CoroutineContext, block: suspend () -> Unit) {
    TODO()
}
With
exception: java.lang.Error: Invalid module
        at org.jetbrains.kotlin.backend.konan.llvm.IrToBitcodeKt.verifyModule(IrToBitcode.kt:117)
        at org.jetbrains.kotlin.backend.konan.llvm.IrToBitcodeKt.verifyModule$default(IrToBitcode.kt:108)
        at org.jetbrains.kotlin.backend.konan.Context.verifyBitCode(Context.kt:313)
        at org.jetbrains.kotlin.backend.konan.KonanDriverKt$runTopLevelPhases$4.invoke(KonanDriver.kt:99)
👍🏼 1
:youtrack: 1
o

olonho

02/19/2018, 7:51 PM
Yes, they supposed to work, so please file issue. https://github.com/JetBrains/kotlin-native/tree/master/samples/nonBlockingEchoServer is a coroutine example.
👌 1
s

svyatoslav.scherbina

02/20/2018, 8:49 AM
The problem is appears only when compiling code to framework with Kotlin/Native. The bug will be fixed soon. Until that, you can workaround it by making the function
private
.