@@ -296,3 +296,32 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String {
296296func checkCostcoMembership( ) async -> Bool {
297297 return await CostcoManager . shared ( ) . isCustomerEnrolled ( inExecutiveProgram: Person . asCustomer ( ) )
298298}
299+
300+ // rdar://97646309 -- lookup and direct call of an optional global-actor constrained method would crash in SILGen
301+ @MainActor
302+ @objc protocol OptionalMemberLookups {
303+ @objc optional func generateMaybe( ) async
304+ }
305+
306+ extension OptionalMemberLookups {
307+ // CHECK-LABEL: sil hidden [ossa] @$s18objc_async_checked21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF
308+ // CHECK: [[SELF:%[0-9]+]] = copy_value {{.*}} : $Self
309+ // CHECK: [[METH:%[0-9]+]] = objc_method {{.*}} : $Self, #OptionalMemberLookups.generateMaybe!foreign : <Self where Self : OptionalMemberLookups> (Self) -> () async -> (), $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
310+ // CHECK: [[UNSAFE_CONT:%.*]] = struct $UnsafeContinuation<(), Never> ({{.*}} : $Builtin.RawUnsafeContinuation)
311+ // CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage Any
312+ // CHECK: [[PROJECTED:%.*]] = project_block_storage [[BLOCK_STORAGE]] : $*@block_storage Any
313+ // CHECK: [[CHECKED_CONT_SLOT:%.*]] = init_existential_addr [[PROJECTED]] : $*Any, $CheckedContinuation<(), Never>
314+ // CHECK: [[CHECKED_CONT_INIT_FN:%.*]] = function_ref @$ss26_createCheckedContinuationyScCyxs5NeverOGSccyxACGnlF : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, Never>) -> @out CheckedContinuation<τ_0_0, Never>
315+ // CHECK: [[CHECKED_CONT:%.*]] = alloc_stack $CheckedContinuation<(), Never>
316+ // CHECK: {{.*}} = apply [[CHECKED_CONT_INIT_FN]]<()>([[CHECKED_CONT]], [[UNSAFE_CONT]]) : $@convention(thin) <τ_0_0> (UnsafeContinuation<τ_0_0, Never>) -> @out CheckedContinuation<τ_0_0, Never>
317+ // CHECK: copy_addr [take] [[CHECKED_CONT]] to [init] [[CHECKED_CONT_SLOT]] : $*CheckedContinuation<(), Never>
318+ // CHECK: = function_ref @$sIeyB_yt18objc_async_checked21OptionalMemberLookupsRzlTz_ : $@convention(c) @pseudogeneric <τ_0_0 where τ_0_0 : OptionalMemberLookups> (@inout_aliasable @block_storage Any) -> ()
319+ // CHECK: [[BLOCK:%[0-9]+]] = init_block_storage_header {{.*}} : $*@block_storage Any
320+ // CHECK: = apply [[METH]]([[BLOCK]], [[SELF]]) : $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
321+ // CHECK: await_async_continuation {{.*}} : $Builtin.RawUnsafeContinuation, resume bb1
322+ // CHECK: hop_to_executor {{.*}} : $MainActor
323+ // CHECK: } // end sil function '$s18objc_async_checked21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF'
324+ func testForceDirectCall( ) async -> Void {
325+ await self . generateMaybe!( )
326+ }
327+ }
0 commit comments