diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt index b03f8a00095..11e92eb641b 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt @@ -342,7 +342,9 @@ private class InteropLoweringPart1(val generationState: NativeGenerationState) : val newFunction = IrFunctionImpl( function.startOffset, function.endOffset, - IrDeclarationOrigin.DEFINED, + // The generated function is called by ObjC and contains Kotlin code, so + // it must switch thread state and potentially initialize runtime on this thread. + CBridgeOrigin.C_TO_KOTLIN_BRIDGE, IrSimpleFunctionSymbolImpl(), ("imp:$selector").synthesizedName, DescriptorVisibilities.PRIVATE,