From d235fc4dbe730e9dce77a0408f3db6e412b4202c Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Thu, 3 Feb 2022 16:53:08 +0300 Subject: [PATCH] Native: add thread state switches to blockToKotlinImp --- kotlin-native/runtime/src/main/cpp/ObjCExport.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm index 83d69ebd449..a9f63a1947c 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm +++ b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm @@ -493,6 +493,7 @@ static OBJ_GETTER(blockToKotlinImp, id block, SEL cmd) { for (int i = 1; i <= parameterCount; ++i) { const char* argEncoding = [signature getArgumentTypeAtIndex:i]; if (argEncoding[0] != '@') { + kotlin::ThreadStateGuard guard(kotlin::ThreadState::kNative); [NSException raise:NSGenericException format:@"Converting Obj-C blocks with non-reference-typed arguments to kotlin.Any is not supported (%s)", argEncoding]; } @@ -500,6 +501,7 @@ static OBJ_GETTER(blockToKotlinImp, id block, SEL cmd) { const char* returnTypeEncoding = signature.methodReturnType; if (returnTypeEncoding[0] != '@') { + kotlin::ThreadStateGuard guard(kotlin::ThreadState::kNative); [NSException raise:NSGenericException format:@"Converting Obj-C blocks with non-reference-typed return value to kotlin.Any is not supported (%s)", returnTypeEncoding]; }