Skip to content

Commit 4fcc58a

Browse files
committed
test coverage for rdar://97646309
1 parent d3f644a commit 4fcc58a

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

test/ClangImporter/objc_async.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,11 @@ extension SomeWrapper: Sendable where T: Sendable {}
397397
}
398398
}
399399
}
400+
401+
// rdar://97646309 -- lookup and direct call of an optional global-actor constrained method would crash in SILGen
402+
@available(SwiftStdlib 5.5, *)
403+
extension CoffeeDelegate {
404+
@MainActor func test() async -> (NSObject?, NSObject, NSObject) {
405+
return await self.icedMochaServiceGenerateMocha!(NSObject())
406+
}
407+
}

test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,12 @@ SENDABLE id StructWithSendableContentsGetSendableComputed(struct StructWithSenda
319319
+ (void)getAsCustomer:(void(^_Nonnull)(NSObject *device))completion;
320320
@end
321321

322+
323+
// rdar://97646309
324+
UI_ACTOR
325+
@protocol CoffeeDelegate <NSObject>
326+
@optional
327+
- (void)icedMochaService:(NSObject *)mochaService generateMochaWithCompletion:(void (^)(NSObject *_Nullable ingredient1, NSObject *ingredient2, NSObject *ingredient3))completionHandler;
328+
@end
329+
322330
#pragma clang assume_nonnull end

test/SILGen/dynamic_lookup.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// RUN: %target-swift-emit-silgen -module-name dynamic_lookup -enable-objc-interop -parse-as-library -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
2-
// RUN: %target-swift-emit-silgen -module-name dynamic_lookup -enable-objc-interop -parse-as-library -disable-objc-attr-requires-foundation-module %s | %FileCheck %s --check-prefix=GUARANTEED
1+
// RUN: %target-swift-emit-silgen -module-name dynamic_lookup -enable-objc-interop -parse-as-library -disable-objc-attr-requires-foundation-module -disable-availability-checking %s | %FileCheck %s
2+
// RUN: %target-swift-emit-silgen -module-name dynamic_lookup -enable-objc-interop -parse-as-library -disable-objc-attr-requires-foundation-module -disable-availability-checking %s | %FileCheck %s --check-prefix=GUARANTEED
3+
4+
// REQUIRES: objc_interop
5+
// REQUIRES: concurrency
36

47
class X {
58
@objc func f() { }
@@ -405,3 +408,25 @@ func testAnyObjectWithDefault(_ x: AnyObject) {
405408
// CHECK: apply [[METHOD]]([[DEFARG]], [[OPENEDX]])
406409
x.hasDefaultParam()
407410
}
411+
412+
413+
// rdar://97646309 -- lookup and direct call of an optional global-actor constrained method would crash in SILGen
414+
@MainActor
415+
@objc protocol OptionalMemberLookups {
416+
@objc optional func generateMaybe() async
417+
}
418+
419+
extension OptionalMemberLookups {
420+
// CHECK-LABEL: sil hidden [ossa] @$s14dynamic_lookup21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF
421+
// CHECK: [[SELF:%[0-9]+]] = copy_value {{.*}} : $Self
422+
// CHECK: [[METH:%[0-9]+]] = objc_method {{.*}} : $Self, #OptionalMemberLookups.generateMaybe!foreign : <Self where Self : OptionalMemberLookups> (Self) -> () async -> (), $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
423+
// CHECK: = function_ref @$sIeyB_yt14dynamic_lookup21OptionalMemberLookupsRzlTz_ : $@convention(c) @pseudogeneric <τ_0_0 where τ_0_0 : OptionalMemberLookups> (@inout_aliasable @block_storage UnsafeContinuation<(), Never>) -> ()
424+
// CHECK: [[BLOCK:%[0-9]+]] = init_block_storage_header {{.*}} : $*@block_storage UnsafeContinuation<(), Never>
425+
// CHECK: = apply [[METH]]([[BLOCK]], [[SELF]]) : $@convention(objc_method) (@convention(block) () -> (), Self) -> ()
426+
// CHECK: await_async_continuation {{.*}} : $Builtin.RawUnsafeContinuation, resume bb1
427+
// CHECK: hop_to_executor {{.*}} : $MainActor
428+
// CHECK: } // end sil function '$s14dynamic_lookup21OptionalMemberLookupsPAAE19testForceDirectCallyyYaF'
429+
func testForceDirectCall() async -> Void {
430+
await self.generateMaybe!()
431+
}
432+
}

0 commit comments

Comments
 (0)