From 917f64c8939878821f1bad9b6776238d4f09b675 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Wed, 3 May 2023 17:26:09 +0200 Subject: [PATCH] [K/N] Fix ObjCAction, ObjCOutlet not switching state. ^KT-58441 --- .../jetbrains/kotlin/backend/konan/lower/InteropLowering.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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,