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
2
2
3
3
// REQUIRES: objc_interop
4
4
@@ -11,9 +11,23 @@ import gizmo
11
11
// CHECK-NOT: sil hidden [ossa] @$sSo7GenericCfd
12
12
// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
13
13
14
- class Generic < T> : NSObject {
14
+ class Generic < T> : NSObject , ObjCProtocol {
15
15
var x : Int = 10
16
16
17
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class7GenericC5evokeyyFTo : $@convention(objc_method) <T> (Generic<T>) -> () {
18
+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC5evokeyyF
19
+ // CHECK-NEXT: apply [[FN]]<T>
20
+ func evoke( ) { }
21
+
22
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class7GenericC10evokeAsyncyyYaFTo : $@convention(objc_method) <T> (@convention(block) () -> (), Generic<T>) -> () {
23
+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC10evokeAsyncyyYaFyyYacfU_To
24
+ // CHECK-NEXT: partial_apply [callee_guaranteed] [[FN]]<T>
25
+
26
+ // CHECK-LABEL: sil shared [thunk] [ossa] @$s18objc_generic_class7GenericC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <T> (@convention(block) () -> (), Generic<T>) -> ()
27
+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class7GenericC10evokeAsyncyyYaF : $@convention(method) @async <τ_0_0> (@guaranteed Generic<τ_0_0>) -> ()
28
+ // CHECK-NEXT: apply [[FN]]<T>
29
+ func evokeAsync( ) async { }
30
+
17
31
// CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class7GenericCfD : $@convention(method) <T> (@owned Generic<T>) -> () {
18
32
// CHECK: bb0({{%.*}} : @owned $Generic<T>):
19
33
// CHECK: } // end sil function '$s18objc_generic_class7GenericCfD'
@@ -33,6 +47,11 @@ class Generic<T>: NSObject {
33
47
// CHECK-NOT: sil hidden [ossa] @$s18objc_generic_class7GenericCfd
34
48
// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
35
49
50
+ @objc protocol ObjCProtocol {
51
+ func evoke( )
52
+ func evokeAsync( ) async
53
+ }
54
+
36
55
// CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class11SubGeneric1CfD : $@convention(method) <U, V> (@owned SubGeneric1<U, V>) -> () {
37
56
// CHECK: bb0([[SELF:%.*]] : @owned $SubGeneric1<U, V>):
38
57
// 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 +70,19 @@ public extension GenericStruct where T == String {
51
70
@objc public func f( ) -> String { " hello " }
52
71
}
53
72
}
73
+
74
+ // rdar://129187133 - handle generic @objc thunks properly
75
+ actor GenericActor < T> : SendableObjCProtocol {
76
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFTo : $@convention(objc_method) <T> (@convention(block) () -> (), @sil_isolated GenericActor<T>) -> ()
77
+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <τ_0_0> (@convention(block) () -> (), @sil_isolated GenericActor<τ_0_0>) -> ()
78
+ // CHECK-NEXT: partial_apply [callee_guaranteed] [[FN]]<T>
79
+ func evokeAsync( ) async { }
80
+
81
+ // CHECK-LABEL: sil shared [thunk] [ossa] @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaFyyYacfU_To : $@convention(thin) @Sendable @async <T> (@convention(block) () -> (), @sil_isolated GenericActor<T>) -> ()
82
+ // CHECK: [[FN:%.*]] = function_ref @$s18objc_generic_class12GenericActorC10evokeAsyncyyYaF : $@convention(method) @async <τ_0_0> (@sil_isolated @guaranteed GenericActor<τ_0_0>) -> ()
83
+ // CHECK-NEXT: apply [[FN]]<T>
84
+ }
85
+
86
+ @objc protocol SendableObjCProtocol : Sendable {
87
+ func evokeAsync( ) async
88
+ }
0 commit comments