diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index aafb93ffd8b1b..0827c535af4a9 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -2439,6 +2439,15 @@ static bool isParameterContextGlobalActorIsolated(DeclContext *dc, return false; } +static bool isSendableInferenceOnCompletionHandlerParameterAllowed( + DeclContext *dc, const clang::Decl *parent) { + auto &C = dc->getASTContext(); + if (!C.LangOpts.hasFeature(Feature::SendableCompletionHandlers)) + return false; + + return !isParameterContextGlobalActorIsolated(dc, parent); +} + std::optional ClangImporter::Implementation::importParameterType( DeclContext *dc, const clang::Decl *parent, const clang::ParmVarDecl *param, @@ -2462,10 +2471,9 @@ ClangImporter::Implementation::importParameterType( bool isConsuming = false; bool isParamTypeImplicitlyUnwrapped = false; - if (SwiftContext.LangOpts.hasFeature(Feature::SendableCompletionHandlers) && - paramIsCompletionHandler) { - if (!isParameterContextGlobalActorIsolated(dc, parent)) - attrs |= ImportTypeAttr::DefaultsToSendable; + if (paramIsCompletionHandler && + isSendableInferenceOnCompletionHandlerParameterAllowed(dc, parent)) { + attrs |= ImportTypeAttr::DefaultsToSendable; } if (auto optionSetEnum = importer::findOptionSetEnum(paramTy, *this)) { @@ -3344,11 +3352,19 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType( decomposeCompletionHandlerType(swiftParamTy, *asyncInfo)) { swiftResultTy = replacedSwiftResultTy; + ImportTypeAttrs attrs; + // This is required because a parameter type of a sync variant and + // a completion type of an async variant have to match exactly. + if (isSendableInferenceOnCompletionHandlerParameterAllowed(origDC, + clangDecl)) { + attrs |= ImportTypeAttr::DefaultsToSendable; + } + // Import the original completion handler type without adjustments. Type origSwiftParamTy = importType(paramTy, ImportTypeKind::CompletionHandlerParameter, paramAddDiag, allowNSUIntegerAsIntInParam, - Bridgeability::Full, ImportTypeAttrs(), + Bridgeability::Full, attrs, optionalityOfParam, /*resugarNSErrorPointer=*/!paramIsError, std::nullopt) .getType(); diff --git a/test/ClangImporter/regionbasedisolation.swift b/test/ClangImporter/regionbasedisolation.swift index 0f1529100e073..63a2364dafbb2 100644 --- a/test/ClangImporter/regionbasedisolation.swift +++ b/test/ClangImporter/regionbasedisolation.swift @@ -72,7 +72,7 @@ extension ObjCObject { // CHECK: [[RESULT:%.*]] = alloc_stack $Array // Our method. - // CHECK: [[METHOD:%.*]] = objc_method [[SELF]], #ObjCObject.loadObjects2!foreign : (ObjCObject) -> () async throws -> [NSObject], $@convention(objc_method) (@convention(block) (Optional, Optional) -> (), ObjCObject) -> () + // CHECK: [[METHOD:%.*]] = objc_method [[SELF]], #ObjCObject.loadObjects2!foreign : (ObjCObject) -> () async throws -> [NSObject], $@convention(objc_method) (@convention(block) @Sendable (Optional, Optional) -> (), ObjCObject) -> () // Begin setting up the unsafe continuation for our method. Importantly note // that [[UNSAFE_CONT]] is Sendable, so we lose any connection from the @@ -101,17 +101,18 @@ extension ObjCObject { // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[EXISTENTIAL_BLOCK_STORAGE]] // CHECK: merge_isolation_region [[BLOCK_STORAGE]], [[RESULT]] - // Then create the actual block. NOTE: Since the block is not @Sendable, the block does propagate regions. + // Then create the actual block. NOTE: Since the block is @Sendable, the block + // does not propagate regions. // - // CHECK: [[COMPLETION_HANDLER_BLOCK:%.*]] = function_ref @$sSo7NSArrayCSgSo7NSErrorCSgIeyByy_SaySo8NSObjectCGTz_ : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[COMPLETION_HANDLER_BLOCK:%.*]] = function_ref @$sSo7NSArrayCSgSo7NSErrorCSgIeyBhyy_SaySo8NSObjectCGTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[COMPLETION_BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]], invoke [[COMPLETION_HANDLER_BLOCK]] // - // Since the block is not @Sendable, it does propagate the connection in + // Since the block is @Sendable, it does not propagate the connection in // between self and the block storage when we just call the method. Thus we - // don't need to perform a merge_isolation_region to communicate that the block + // need to perform a merge_isolation_region to communicate that the block // storage and self are part of the same region. // - // CHECK-NOT: merge_isolation_region [[SELF]], [[BLOCK_STORAGE]] + // CHECK: merge_isolation_region [[SELF]], [[BLOCK_STORAGE]] // // Then call the method. // CHECK: apply [[METHOD]]([[COMPLETION_BLOCK]], [[SELF]]) diff --git a/test/SILGen/objc_async.swift b/test/SILGen/objc_async.swift index f5012bc10d86c..bf6eb7a038823 100644 --- a/test/SILGen/objc_async.swift +++ b/test/SILGen/objc_async.swift @@ -10,14 +10,14 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Int // CHECK: [[STRINGINIT:%.*]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF : // CHECK: [[ARG:%.*]] = apply [[STRINGINIT]] - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) (Int) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable (Int) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr Int, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any // CHECK: [[CONT_SLOT:%.*]] = project_block_storage [[BLOCK_STORAGE]] // CHECK: [[CONT_SLOT_ADDR:%.*]] = init_existential_addr [[CONT_SLOT]] // CHECK: store [[WRAPPED]] to [trivial] [[CONT_SLOT_ADDR]] - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Int) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Int) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[ARG]], [[BLOCK]], %0) // CHECK: [[COPY:%.*]] = copy_value [[ARG]] @@ -33,14 +33,14 @@ func testSlowServer(slowServer: SlowServer) async throws { let _: Int = await slowServer.doSomethingSlowNullably("mail") // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $String - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (Optional, Optional) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (Optional, Optional) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr [throws] String, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any // CHECK: [[CONT_SLOT:%.*]] = project_block_storage [[BLOCK_STORAGE]] // CHECK: [[CONT_SLOT_ADDR:%.*]] = init_existential_addr [[CONT_SLOT]] // CHECK: store [[WRAPPED]] to [trivial] [[CONT_SLOT_ADDR]] - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[STRING_COMPLETION_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[STRING_COMPLETION_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: await_async_continuation [[CONT]] {{.*}}, resume [[RESUME:bb[0-9]+]], error [[ERROR:bb[0-9]+]] @@ -50,18 +50,18 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: dealloc_stack [[RESUME_BUF]] let _: String = try await slowServer.findAnswer() - // CHECK: objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) () -> (), SlowServer) -> () - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[VOID_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any) -> () + // CHECK: objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable () -> (), SlowServer) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[VOID_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> () await slowServer.serverRestart("somewhere") - // CHECK: function_ref @[[STRING_NONZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional) -> () + // CHECK: function_ref @[[STRING_NONZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional) -> () let _: String = try await slowServer.doSomethingFlaggy() - // CHECK: function_ref @[[STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, {{.*}}Bool, Optional) -> () + // CHECK: function_ref @[[STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, {{.*}}Bool, Optional) -> () let _: String = try await slowServer.doSomethingZeroFlaggy() - // CHECK: function_ref @[[STRING_STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional, Optional) -> () + // CHECK: function_ref @[[STRING_STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional, Optional) -> () let _: (String, String) = try await slowServer.doSomethingMultiResultFlaggy() - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSSTRING_INT_THROW_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Int, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSSTRING_INT_THROW_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Int, Optional) -> () let (_, _): (String, Int) = try await slowServer.findMultipleAnswers() let (_, _): (Bool, Bool) = try await slowServer.findDifferentlyFlavoredBooleans() @@ -189,14 +189,14 @@ func testSlowServerFromMain(slowServer: SlowServer) async throws { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Int // CHECK: [[STRINGINIT:%.*]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF : // CHECK: [[ARG:%.*]] = apply [[STRINGINIT]] - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) (Int) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable (Int) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr Int, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any // CHECK: [[CONT_SLOT:%.*]] = project_block_storage [[BLOCK_STORAGE]] // CHECK: [[CONT_SLOT_ANY:%.*]] = init_existential_addr [[CONT_SLOT]] // CHECK: store [[WRAPPED]] to [trivial] [[CONT_SLOT_ANY]] - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Int) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Int) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[ARG]], [[BLOCK]], %0) // CHECK: [[COPY:%.*]] = copy_value [[ARG]] @@ -223,10 +223,10 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: [[PROJECTED:%.*]] = project_block_storage [[STORE_ALLOC]] : $*@block_storage // CHECK: [[PROJECTED_ANY:%.*]] = init_existential_addr [[PROJECTED]] // CHECK: store [[CONT]] to [trivial] [[PROJECTED_ANY]] -// CHECK: [[INVOKER:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyByy_SSTz_ +// CHECK: [[INVOKER:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyBhyy_SSTz_ // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[STORE_ALLOC]] {{.*}}, invoke [[INVOKER]] // CHECK: [[OPTIONAL_BLK:%.*]] = enum {{.*}}, #Optional.some!enumelt, [[BLOCK]] -// CHECK: apply [[METH]]([[STRING_ARG]], [[OPTIONAL_BLK]], {{%.*}}) : $@convention(objc_method) (NSString, Optional<@convention(block) (Optional, Optional) -> ()>, SlowServer) -> () +// CHECK: apply [[METH]]([[STRING_ARG]], [[OPTIONAL_BLK]], {{%.*}}) : $@convention(objc_method) (NSString, Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServer) -> () // CHECK: [[STRING_ARG_COPY:%.*]] = copy_value [[STRING_ARG]] : $NSString // CHECK: dealloc_stack [[STORE_ALLOC]] : $*@block_storage Any // CHECK: destroy_value [[STRING_ARG]] : $NSString @@ -340,10 +340,10 @@ extension SlowServer: @retroactive FailableFloatLoader { } // CHECK-LABEL: sil [ossa] @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKF : $@convention(method) @async (@guaranteed SlowServer) -> (Float, @error any Error) -// CHECK-LABEL: sil private [thunk] [ossa] @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKFTo : $@convention(objc_method) (@convention(block) (Float, Optional) -> (), SlowServer) -> () { +// CHECK-LABEL: sil private [thunk] [ossa] @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKFTo : $@convention(objc_method) (@convention(block) @Sendable (Float, Optional) -> (), SlowServer) -> () { // CHECK: function_ref @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKFyyYacfU_To -// CHECK-LABEL: sil shared [thunk] [ossa] @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) (Float, Optional) -> (), SlowServer) -> () +// CHECK-LABEL: sil shared [thunk] [ossa] @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable (Float, Optional) -> (), SlowServer) -> () // CHECK: [[BLOCK:%.*]] = copy_block // CHECK: [[METHOD:%.*]] = function_ref @$sSo10SlowServerC10objc_asyncE16loadFloatOrThrowSfyYaKF : // CHECK: try_apply [[METHOD]]({{%.*}}) : {{.*}}, normal bb1, error bb2 @@ -370,7 +370,7 @@ extension SlowServer: @retroactive FailableFloatLoader { // CHECK: [[SLOWSERVER_ANYOBJECT_M_B:%.*]] = begin_borrow [[SLOWSERVER_ANYOBJECT_M]] // CHECK: [[SLOWSERVER_ANYOBJECT_M_B_O:%.*]] = open_existential_ref [[SLOWSERVER_ANYOBJECT_M_B]] // CHECK: [[SLOWSERVER_ANYOBJECT_M_B_O_C:%.*]] = copy_value [[SLOWSERVER_ANYOBJECT_M_B_O]] -// CHECK: [[METHOD:%.*]] = objc_method [[SLOWSERVER_ANYOBJECT_M_B_O_C]] : $@opened("{{.*}}", AnyObject) Self, #SlowServer.start!foreign : (SlowServer) -> (NSDate?) async -> (), $@convention(objc_method) (Optional, @convention(block) () -> (), @opened("{{.*}}", AnyObject) Self) -> () +// CHECK: [[METHOD:%.*]] = objc_method [[SLOWSERVER_ANYOBJECT_M_B_O_C]] : $@opened("{{.*}}", AnyObject) Self, #SlowServer.start!foreign : (SlowServer) -> (NSDate?) async -> (), $@convention(objc_method) (Optional, @convention(block) @Sendable () -> (), @opened("{{.*}}", AnyObject) Self) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr () // CHECK: [[UNSAFE_CONT:%.*]] = struct $UnsafeContinuation<(), Never> ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK:%.*]] = alloc_stack $@block_storage Any @@ -378,9 +378,9 @@ extension SlowServer: @retroactive FailableFloatLoader { // CHECK: [[BLOCK_PROJECT_EX:%.*]] = init_existential_addr [[BLOCK_PROJECT]] // CHECK: store [[UNSAFE_CONT]] to [trivial] [[BLOCK_PROJECT_EX]] // CHECK: merge_isolation_region [[BLOCK]] : $*@block_storage Any, -// CHECK: [[CONT_HANDLER:%.*]] = function_ref @$sIeyB_ytTz_ : $@convention(c) (@inout_aliasable @block_storage Any) -> () +// CHECK: [[CONT_HANDLER:%.*]] = function_ref @$sIeyBh_ytTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> () // CHECK: [[INIT_BLOCK_STORAGE_HEADER:%.*]] = init_block_storage_header [[BLOCK]] : $*@block_storage Any, invoke [[CONT_HANDLER]] -// CHECK-NOT: merge_isolation_region [[SLOWSERVER_ANYOBJECT_M_B_O_C]] : $@opened("{{.*}}", AnyObject) Self, [[BLOCK]] +// CHECK: merge_isolation_region [[SLOWSERVER_ANYOBJECT_M_B_O_C]] : $@opened("{{.*}}", AnyObject) Self, [[BLOCK]] // CHECK: apply [[METHOD]]({{%.*}}, [[INIT_BLOCK_STORAGE_HEADER]], [[SLOWSERVER_ANYOBJECT_M_B_O_C]]) // CHECK: await_async_continuation [[CONT]] : $Builtin.RawUnsafeContinuation, resume bb1 // CHECK: } // end sil function '$s10objc_async13testAnyObjectyySo10SlowServerCYaF' diff --git a/test/SILGen/objc_async_checked.swift b/test/SILGen/objc_async_checked.swift index 05e45c4345592..d716256c1b974 100644 --- a/test/SILGen/objc_async_checked.swift +++ b/test/SILGen/objc_async_checked.swift @@ -11,7 +11,7 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Int // CHECK: [[STRINGINIT:%.*]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF : // CHECK: [[ARG:%.*]] = apply [[STRINGINIT]] - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) (Int) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable (Int) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr Int, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -21,7 +21,7 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]([[CHECKED_CONT]], [[WRAPPED]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, Never>) -> @out CheckedContinuation<τ_0_0, Never> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Int) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Int) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[ARG]], [[BLOCK]], %0) // CHECK: [[COPY:%.*]] = copy_value [[ARG]] @@ -40,7 +40,7 @@ func testSlowServer(slowServer: SlowServer) async throws { let _: Int = await slowServer.doSomethingSlowNullably("mail") // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $String - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (Optional, Optional) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (Optional, Optional) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr [throws] String, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -50,7 +50,7 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]([[CHECKED_CONT]], [[WRAPPED]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, any Error>) -> @out CheckedContinuation<τ_0_0, any Error> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[STRING_COMPLETION_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[STRING_COMPLETION_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: destroy_addr [[CHECKED_CONT_SLOT]] : $*CheckedContinuation @@ -62,18 +62,18 @@ func testSlowServer(slowServer: SlowServer) async throws { // CHECK: dealloc_stack [[RESUME_BUF]] let _: String = try await slowServer.findAnswer() - // CHECK: objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) () -> (), SlowServer) -> () - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[VOID_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any) -> () + // CHECK: objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable () -> (), SlowServer) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[VOID_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> () await slowServer.serverRestart("somewhere") - // CHECK: function_ref @[[STRING_NONZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional) -> () + // CHECK: function_ref @[[STRING_NONZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional) -> () let _: String = try await slowServer.doSomethingFlaggy() - // CHECK: function_ref @[[STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, {{.*}}Bool, Optional) -> () + // CHECK: function_ref @[[STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, {{.*}}Bool, Optional) -> () let _: String = try await slowServer.doSomethingZeroFlaggy() - // CHECK: function_ref @[[STRING_STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional, Optional) -> () + // CHECK: function_ref @[[STRING_STRING_ZERO_FLAG_THROW_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, {{.*}}Bool, Optional, Optional, Optional) -> () let _: (String, String) = try await slowServer.doSomethingMultiResultFlaggy() - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSSTRING_INT_THROW_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Int, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSSTRING_INT_THROW_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Int, Optional) -> () let (_, _): (String, Int) = try await slowServer.findMultipleAnswers() let (_, _): (Bool, Bool) = try await slowServer.findDifferentlyFlavoredBooleans() @@ -198,7 +198,7 @@ func testSlowServerFromMain(slowServer: SlowServer) async throws { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Int // CHECK: [[STRINGINIT:%.*]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF : // CHECK: [[ARG:%.*]] = apply [[STRINGINIT]] - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) (Int) -> (), SlowServer) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) @Sendable (Int) -> (), SlowServer) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr Int, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -208,7 +208,7 @@ func testSlowServerFromMain(slowServer: SlowServer) async throws { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]([[CHECKED_CONT]], [[WRAPPED]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, Never>) -> @out CheckedContinuation<τ_0_0, Never> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Int) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[INT_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Int) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[ARG]], [[BLOCK]], %0) // CHECK: [[COPY:%.*]] = copy_value [[ARG]] @@ -229,7 +229,7 @@ func testSlowServerFromMain(slowServer: SlowServer) async throws { // CHECK: [[STR:%.*]] = alloc_stack $String // CHECK: [[ERR:%.*]] = alloc_stack [dynamic_lifetime] $Optional // CHECK: inject_enum_addr [[ERR]] : $*Optional, #Optional.none!enumelt -// CHECK: [[METHOD:%.*]] = objc_method %0 : $SlowServer, #SlowServer.findAnswerFailingly!foreign : (SlowServer) -> () async throws -> String, $@convention(objc_method) (Optional>>, @convention(block) (Optional, Optional) -> (), SlowServer) -> ObjCBool +// CHECK: [[METHOD:%.*]] = objc_method %0 : $SlowServer, #SlowServer.findAnswerFailingly!foreign : (SlowServer) -> () async throws -> String, $@convention(objc_method) (Optional>>, @convention(block) @Sendable (Optional, Optional) -> (), SlowServer) -> ObjCBool // CHECK: [[RAW_CONT:%.*]] = get_async_continuation_addr [throws] String, {{.*}} : $*String // CHECK: [[UNSAFE_CONT:%.*]] = struct $UnsafeContinuation ([[RAW_CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -272,10 +272,10 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]([[CHECKED_CONT]], [[CONT]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, any Error>) -> @out CheckedContinuation<τ_0_0, any Error> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation -// CHECK: [[INVOKER:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyByy_SSTz_ +// CHECK: [[INVOKER:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyBhyy_SSTz_ // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[STORE_ALLOC]] {{.*}}, invoke [[INVOKER]] // CHECK: [[OPTIONAL_BLK:%.*]] = enum {{.*}}, #Optional.some!enumelt, [[BLOCK]] -// CHECK: {{.*}} = apply [[METH]]([[STRING_ARG]], [[OPTIONAL_BLK]], {{%.*}}) : $@convention(objc_method) (NSString, Optional<@convention(block) (Optional, Optional) -> ()>, SlowServer) -> () +// CHECK: {{.*}} = apply [[METH]]([[STRING_ARG]], [[OPTIONAL_BLK]], {{%.*}}) : $@convention(objc_method) (NSString, Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServer) -> () // CHECK: [[STRING_ARG_COPY:%.*]] = copy_value [[STRING_ARG]] : $NSString // CHECK: destroy_addr [[CHECKED_CONT_SLOT]] : $*CheckedContinuation // CHECK: dealloc_stack [[CHECKED_CONT]] : $*CheckedContinuation diff --git a/test/SILGen/objc_async_from_swift.swift b/test/SILGen/objc_async_from_swift.swift index 9497397c16592..63e6f97efa4e7 100644 --- a/test/SILGen/objc_async_from_swift.swift +++ b/test/SILGen/objc_async_from_swift.swift @@ -136,7 +136,7 @@ class SlowServerlet: SlowServer { // // @objc thunk closure // - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) (Int) -> ()>, SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (Int) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[NONE:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet @@ -163,7 +163,7 @@ class SlowServerlet: SlowServer { // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF' // @objc closure thunk - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) (NSString) -> ()>, SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (NSString) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet @@ -191,7 +191,7 @@ class SlowServerlet: SlowServer { // @objc thunk closure // - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) (Optional, Optional) -> ()>, SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet @@ -218,7 +218,7 @@ class SlowServerlet: SlowServer { // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF' // @objc closure thunk - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (Optional<@convention(block) (Optional, Optional) -> ()>, SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) @@ -244,7 +244,7 @@ class SlowServerlet: SlowServer { // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF' // @objc thunk closure - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) ({{.*}}, Optional, Optional) -> (), SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable ({{.*}}, Optional, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) @@ -276,7 +276,7 @@ class SlowServerlet: SlowServer { // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF' // // @objc thunk closure - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) (Optional, {{.*}}, Optional) -> (), SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable (Optional, {{.*}}, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) @@ -306,7 +306,7 @@ class SlowServerlet: SlowServer { // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF' // - // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) ({{.*}}, Optional, Optional, Optional) -> (), SlowServerlet) -> () { + // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable ({{.*}}, Optional, Optional, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) @@ -436,8 +436,9 @@ func testAutoclosureInStaticMethod() { // CHECK: [[INIT_PROJ_BLOCK_STORAGE:%.*]] = init_existential_addr [[PROJ_BLOCK_STORAGE]] // CHECK: store [[UNSAFE_CONT]] to [trivial] [[INIT_PROJ_BLOCK_STORAGE]] // CHECK: merge_isolation_region [[BLOCK_STORAGE]] : $*@block_storage Any, [[RESULT]] - // CHECK: [[OBJC_COMPLETION_HANDLER_IMPL:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyByy_SSTz_ : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[OBJC_COMPLETION_HANDLER_IMPL:%.*]] = function_ref @$sSo8NSStringCSgSo7NSErrorCSgIeyBhyy_SSTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] : $*@block_storage Any, invoke [[OBJC_COMPLETION_HANDLER_IMPL]] + // CHECK: merge_isolation_region [[CAPTURE]] : $SlowServer, [[BLOCK_STORAGE]] // CHECK: apply [[OBJC_METHOD]]([[NS_STRING]], [[BLOCK]], [[CAPTURE]]) // CHECK: await_async_continuation [[RAW_UNSAFE_CONT]] : $Builtin.RawUnsafeContinuation, resume [[RESUME_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] // diff --git a/test/SILGen/objc_async_sendable_completion_handlers.swift b/test/SILGen/objc_async_sendable_completion_handlers.swift new file mode 100644 index 0000000000000..fa9d5a15f2c4a --- /dev/null +++ b/test/SILGen/objc_async_sendable_completion_handlers.swift @@ -0,0 +1,37 @@ +// RUN: %empty-directory(%t/src) +// RUN: split-file %s %t/src + +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-sil %t/src/main.swift \ +// RUN: -import-objc-header %t/src/Test.h \ +// RUN: -swift-version 6 \ +// RUN: -module-name main -I %t -verify | %FileCheck %t/src/main.swift + +// REQUIRES: objc_interop + +// rdar://154695053 + +//--- Test.h + +@import Foundation; + +@interface Test ++(void) compute: (void (^)(void)) completion; +@end + +//--- main.swift + +func test(v: Test.Type) async { + _ = await v.compute() +} + +// CHECK-LABEL: sil hidden @$s4main4test1vySo4TestCm_tYaF : $@convention(thin) @async (@thick Test.Type) -> () +// CHECK: [[TEST_TYPE:%.*]] = thick_to_objc_metatype %0 to $@objc_metatype Test.Type +// CHECK: [[METHOD:%.*]] = objc_method %5, #Test.compute!foreign : (Test.Type) -> () async -> (), $@convention(objc_method) (Optional<@convention(block) @Sendable () -> ()>, @objc_metatype Test.Type) -> () +// CHECK: [[BLOCK:%.*]] = alloc_stack $@block_storage Any +// CHECK: [[COMPLETION_HANDLER:%.*]] = function_ref @$sIeyBh_ytTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> () +// CHECK: [[HEADER:%.*]] = init_block_storage_header [[BLOCK]], invoke [[COMPLETION_HANDLER]] +// CHECK: [[OPTIONAL_HEADER:%.*]] = enum $Optional<@convention(block) @Sendable () -> ()>, #Optional.some!enumelt, [[HEADER]] +// CHECK: {{.*}} = apply [[METHOD]]([[OPTIONAL_HEADER]], [[TEST_TYPE]]) +// CHECK: } // end sil function '$s4main4test1vySo4TestCm_tYaF' + +// CHECK-LABEL: sil shared [transparent] [thunk] @$sIeyBh_ytTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> () diff --git a/test/SILGen/objc_effectful_properties.swift b/test/SILGen/objc_effectful_properties.swift index 6f60a8941e832..24dba591ecfae 100644 --- a/test/SILGen/objc_effectful_properties.swift +++ b/test/SILGen/objc_effectful_properties.swift @@ -8,14 +8,14 @@ import EffectfulProperties // CHECK-LABEL: sil {{.*}}@${{.*}}13testJustAsync func testJustAsync(eff : EffProps) async { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $NSObject - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (NSObject) -> (), EffProps) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (NSObject) -> (), EffProps) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr NSObject, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any // CHECK: [[CONT_SLOT:%.*]] = project_block_storage [[BLOCK_STORAGE]] // CHECK: [[CONT_SLOT_ADDR:%.*]] = init_existential_addr [[CONT_SLOT]] // CHECK: store [[WRAPPED]] to [trivial] [[CONT_SLOT_ADDR]] - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, NSObject) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, NSObject) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: await_async_continuation [[CONT]] {{.*}}, resume [[RESUME:bb[0-9]+]] @@ -29,14 +29,14 @@ func testJustAsync(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}15testAsyncThrows func testAsyncThrows(eff : EffProps) async { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Optional - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (Optional, Optional) -> (), EffProps) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (Optional, Optional) -> (), EffProps) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr [throws] Optional, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation, any Error> ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any // CHECK: [[CONT_SLOT:%.*]] = project_block_storage [[BLOCK_STORAGE]] // CHECK: [[CONT_SLOT_ADDR:%.*]] = init_existential_addr [[CONT_SLOT]] // CHECK: store [[WRAPPED]] to [trivial] [[CONT_SLOT_ADDR]] - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: await_async_continuation [[CONT]] {{.*}}, resume [[RESUME:bb[0-9]+]], error [[RESUME_ERROR:bb[0-9]+]] diff --git a/test/SILGen/objc_effectful_properties_checked.swift b/test/SILGen/objc_effectful_properties_checked.swift index 79fa319daff5b..14f891b76b69c 100644 --- a/test/SILGen/objc_effectful_properties_checked.swift +++ b/test/SILGen/objc_effectful_properties_checked.swift @@ -8,7 +8,7 @@ import EffectfulProperties // CHECK-LABEL: sil {{.*}}@${{.*}}13testJustAsync func testJustAsync(eff : EffProps) async { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $NSObject - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (NSObject) -> (), EffProps) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (NSObject) -> (), EffProps) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr NSObject, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -18,7 +18,7 @@ func testJustAsync(eff : EffProps) async { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]([[CHECKED_CONT]], [[WRAPPED]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, Never>) -> @out CheckedContinuation<τ_0_0, Never> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, NSObject) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, NSObject) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: destroy_addr [[CHECKED_CONT_SLOT]] : $*CheckedContinuation @@ -34,7 +34,7 @@ func testJustAsync(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}15testAsyncThrows func testAsyncThrows(eff : EffProps) async { // CHECK: [[RESUME_BUF:%.*]] = alloc_stack $Optional - // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) (Optional, Optional) -> (), EffProps) -> () + // CHECK: [[METHOD:%.*]] = objc_method {{.*}} $@convention(objc_method) (@convention(block) @Sendable (Optional, Optional) -> (), EffProps) -> () // CHECK: [[CONT:%.*]] = get_async_continuation_addr [throws] Optional, [[RESUME_BUF]] // CHECK: [[WRAPPED:%.*]] = struct $UnsafeContinuation, any Error> ([[CONT]] : $Builtin.RawUnsafeContinuation) // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any @@ -44,7 +44,7 @@ func testAsyncThrows(eff : EffProps) async { // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation, any Error> // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN:%.*]]>([[CHECKED_CONT]], [[WRAPPED]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, any Error>) -> @out CheckedContinuation<τ_0_0, any Error> // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation, any Error> - // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) (@inout_aliasable @block_storage Any, Optional, Optional) -> () + // CHECK: [[BLOCK_IMPL:%.*]] = function_ref @[[NSO_COMPLETION_BLOCK:.*]] : $@convention(c) @Sendable (@inout_aliasable @block_storage Any, Optional, Optional) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] {{.*}}, invoke [[BLOCK_IMPL]] // CHECK: apply [[METHOD]]([[BLOCK]], %0) // CHECK: destroy_addr [[CHECKED_CONT_SLOT]] : $*CheckedContinuation, any Error>