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
+ // REQUIRES: concurrency
4
5
5
6
import gizmo
6
7
@@ -11,9 +12,23 @@ import gizmo
11
12
// CHECK-NOT: sil hidden [ossa] @$sSo7GenericCfd
12
13
// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
13
14
14
- class Generic < T> : NSObject {
15
+ class Generic < T> : NSObject , ObjCProtocol {
15
16
var x : Int = 10
16
17
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
+
17
32
// CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class7GenericCfD : $@convention(method) <T> (@owned Generic<T>) -> () {
18
33
// CHECK: bb0({{%.*}} : @owned $Generic<T>):
19
34
// CHECK: } // end sil function '$s18objc_generic_class7GenericCfD'
@@ -33,6 +48,11 @@ class Generic<T>: NSObject {
33
48
// CHECK-NOT: sil hidden [ossa] @$s18objc_generic_class7GenericCfd
34
49
// CHECK-NOT: sil hidden [ossa] @$sSo8NSObjectCfd
35
50
51
+ @objc protocol ObjCProtocol {
52
+ func evoke( )
53
+ func evokeAsync( ) async
54
+ }
55
+
36
56
// CHECK-LABEL: sil hidden [ossa] @$s18objc_generic_class11SubGeneric1CfD : $@convention(method) <U, V> (@owned SubGeneric1<U, V>) -> () {
37
57
// CHECK: bb0([[SELF:%.*]] : @owned $SubGeneric1<U, V>):
38
58
// 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 {
51
71
@objc public func f( ) -> String { " hello " }
52
72
}
53
73
}
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