1- // RUN: %target-swift-emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
1+ // RUN: %target-swift-emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -disable-availability-checking | %FileCheck %s
22
33// REQUIRES: objc_interop
4+ // REQUIRES: concurrency
45
56import gizmo
67
@@ -11,9 +12,23 @@ import gizmo
1112// CHECK-NOT: sil hidden [ossa] @$sSo7GenericCfd
1213// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
1314
14- class Generic < T> : NSObject {
15+ class Generic < T> : NSObject , ObjCProtocol {
1516 var x : Int = 10
1617
18+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class7GenericC5evokeyyFTo : $@convention(objc_method) <T> (Generic<T>) -> () {
19+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC5evokeyyF
20+ // CHECK-NEXT: apply [[FN]]<T>
21+ func evoke( ) { }
22+
23+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class7GenericC10evokeAsyncyyYaFTo : $@convention(objc_method) <T> (@convention(block) () -> (), Generic<T>) -> () {
24+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC10evokeAsyncyyYaFyyYacfU_To
25+ // CHECK-NEXT: partial_apply [callee_guaranteed] [[FN]]<T>
26+
27+ // CHECK-LABEL: sil shared [thunk] [ossa] @$s18objc_generic_class7GenericC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <T> (@convention(block) () -> (), Generic<T>) -> ()
28+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC10evokeAsyncyyYaF : $@convention(method) @async <τ_0_0> (@guaranteed Generic<τ_0_0>) -> ()
29+ // CHECK-NEXT: apply [[FN]]<T>
30+ func evokeAsync( ) async { }
31+
1732 // CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class7GenericCfD : $@convention(method) <T> (@owned Generic<T>) -> () {
1833 // CHECK: bb0({{%.*}} : @owned $Generic<T>):
1934 // CHECK: } // end sil function '$s18objc_generic_class7GenericCfD'
@@ -33,6 +48,11 @@ class Generic<T>: NSObject {
3348// CHECK-NOT: sil hidden [ossa] @$s18objc_generic_class7GenericCfd
3449// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
3550
51+ @objc protocol ObjCProtocol {
52+ func evoke( )
53+ func evokeAsync( ) async
54+ }
55+
3656// CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class11SubGeneric1CfD : $@convention(method) <U, V> (@owned SubGeneric1<U, V>) -> () {
3757// CHECK: bb0([[SELF:%.*]] : @owned $SubGeneric1<U, V>):
3858// CHECK: [[SUPER_DEALLOC:%.*]] = objc_super_method [[SELF]] : $SubGeneric1<U, V>, #Generic.deinit!deallocator.foreign : <T> (Generic<T>) -> () -> (), $@convention(objc_method) <τ_0_0> (Generic<τ_0_0>) -> ()
@@ -51,3 +71,19 @@ public extension GenericStruct where T == String {
5171 @objc public func f( ) -> String { " hello " }
5272 }
5373}
74+
75+ // rdar://129187133 - handle generic @objc thunks properly
76+ actor GenericActor < T> : SendableObjCProtocol {
77+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFTo : $@convention(objc_method) <T> (@convention(block) () -> (), @sil_isolated GenericActor<T>) -> ()
78+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <τ_0_0> (@convention(block) () -> (), @sil_isolated GenericActor<τ_0_0>) -> ()
79+ // CHECK-NEXT: partial_apply [callee_guaranteed] [[FN]]<T>
80+ func evokeAsync( ) async { }
81+
82+ // CHECK-LABEL: sil shared [thunk] [ossa] @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <T> (@convention(block) () -> (), @sil_isolated GenericActor<T>) -> ()
83+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaF : $@convention(method) @async <τ_0_0> (@sil_isolated @guaranteed GenericActor<τ_0_0>) -> ()
84+ // CHECK-NEXT: apply [[FN]]<T>
85+ }
86+
87+ @objc protocol SendableObjCProtocol : Sendable {
88+ func evokeAsync( ) async
89+ }
0 commit comments