Skip to content

Commit 1450c4f

Browse files
committed
[Tests] NFC: Move a test from dynamic lookup to objc_async* because it's using async continuations
(cherry picked from commit 7d6c4b7)
1 parent 6774c0a commit 1450c4f

File tree

3 files changed

+54
-22
lines changed

3 files changed

+54
-22
lines changed

test/SILGen/dynamic_lookup.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -404,25 +404,3 @@ func testAnyObjectWithDefault(_ x: AnyObject) {
404404
// CHECK: apply [[METHOD]]([[DEFARG]], [[OPENEDX]])
405405
x.hasDefaultParam()
406406
}
407-
408-
409-
// rdar://97646309 -- lookup and direct call of an optional global-actor constrained method would crash in SILGen
410-
@MainActor
411-
@objc protocol OptionalMemberLookups {
412-
@objc optional func generateMaybe() async
413-
}
414-
415-
extension OptionalMemberLookups {
416-
// CHECK-LABEL: sil hidden [ossa] @$s14dynamic_lookup21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF
417-
// CHECK: [[SELF:%[0-9]+]] = copy_value {{.*}} : $Self
418-
// CHECK: [[METH:%[0-9]+]] = objc_method {{.*}} : $Self, #OptionalMemberLookups.generateMaybe!foreign : <Self where Self : OptionalMemberLookups> (Self) -> () async -> (), $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
419-
// CHECK: = function_ref @$sIeyB_yt14dynamic_lookup21OptionalMemberLookupsRzlTz_ : $@convention(c) @pseudogeneric <τ_0_0 where τ_0_0 : OptionalMemberLookups> (@inout_aliasable @block_storage UnsafeContinuation<(), Never>) -> ()
420-
// CHECK: [[BLOCK:%[0-9]+]] = init_block_storage_header {{.*}} : $*@block_storage UnsafeContinuation<(), Never>
421-
// CHECK: = apply [[METH]]([[BLOCK]], [[SELF]]) : $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
422-
// CHECK: await_async_continuation {{.*}} : $Builtin.RawUnsafeContinuation, resume bb1
423-
// CHECK: hop_to_executor {{.*}} : $MainActor
424-
// CHECK: } // end sil function '$s14dynamic_lookup21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF'
425-
func testForceDirectCall() async -> Void {
426-
await self.generateMaybe!()
427-
}
428-
}

test/SILGen/objc_async.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,28 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String {
276276
func checkCostcoMembership() async -> Bool {
277277
return await CostcoManager.shared().isCustomerEnrolled(inExecutiveProgram: Person.asCustomer())
278278
}
279+
280+
// rdar://97646309 -- lookup and direct call of an optional global-actor constrained method would crash in SILGen
281+
@MainActor
282+
@objc protocol OptionalMemberLookups {
283+
@objc optional func generateMaybe() async
284+
}
285+
286+
extension OptionalMemberLookups {
287+
// CHECK-LABEL: sil hidden [ossa] @$s10objc_async21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF
288+
// CHECK: [[SELF:%[0-9]+]] = copy_value {{.*}} : $Self
289+
// CHECK: [[METH:%[0-9]+]] = objc_method {{.*}} : $Self, #OptionalMemberLookups.generateMaybe!foreign : <Self where Self : OptionalMemberLookups> (Self) -> () async -> (), $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
290+
// CHECK: [[CONT:%.*]] = struct $UnsafeContinuation<(), Never> (%10 : $Builtin.RawUnsafeContinuation)
291+
// CHECK: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage UnsafeContinuation<(), Never>
292+
// CHECK: [[PROJECTED:%.*]] = project_block_storage [[BLOCK_STORAGE]] : $*@block_storage UnsafeContinuation<(), Never>
293+
// CHECK: store [[CONT]] to [trivial] [[PROJECTED]] : $*UnsafeContinuation<(), Never>
294+
// CHECK: = function_ref @$sIeyB_yt10objc_async21OptionalMemberLookupsRzlTz_ : $@convention(c) @pseudogeneric <τ_0_0 where τ_0_0 : OptionalMemberLookups> (@inout_aliasable @block_storage UnsafeContinuation<(), Never>) -> ()
295+
// CHECK: [[BLOCK:%[0-9]+]] = init_block_storage_header {{.*}} : $*@block_storage UnsafeContinuation<(), Never>
296+
// CHECK: = apply [[METH]]([[BLOCK]], [[SELF]]) : $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
297+
// CHECK: await_async_continuation {{.*}} : $Builtin.RawUnsafeContinuation, resume bb1
298+
// CHECK: hop_to_executor {{.*}} : $MainActor
299+
// CHECK: } // end sil function '$s10objc_async21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF'
300+
func testForceDirectCall() async -> Void {
301+
await self.generateMaybe!()
302+
}
303+
}

test/SILGen/objc_async_checked.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,32 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String {
296296
func 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

Comments
 (0)