@@ -10,6 +10,7 @@ protocol P {
10
10
func covariantSelfMethod5( ) -> Array < Self >
11
11
func covariantSelfMethod6( ) -> [ String : Self ]
12
12
func covariantSelfMethod7( _: ( Self ) -> Void )
13
+ func covariantSelfMethod8( _: ( Self . . . ) -> Void )
13
14
14
15
func covariantAssocMethod1( ) -> A
15
16
func covariantAssocMethod2( ) -> A ?
@@ -18,6 +19,7 @@ protocol P {
18
19
func covariantAssocMethod5( ) -> Array < A >
19
20
func covariantAssocMethod6( ) -> [ String : A ]
20
21
func covariantAssocMethod7( _: ( A ) -> Void )
22
+ func covariantAssocMethod8( _: ( A . . . ) -> Void )
21
23
22
24
var covariantSelfProperty1 : Self { get }
23
25
var covariantSelfProperty2 : Self ? { get }
@@ -26,6 +28,7 @@ protocol P {
26
28
var covariantSelfProperty5 : Array < Self > { get }
27
29
var covariantSelfProperty6 : [ String : Self ] { get }
28
30
var covariantSelfProperty7 : ( ( Self ) -> Void ) -> Void { get }
31
+ var covariantSelfProperty8 : ( ( Self . . . ) -> Void ) -> Void { get }
29
32
30
33
var covariantAssocProperty1 : A { get }
31
34
var covariantAssocProperty2 : A ? { get }
@@ -34,6 +37,7 @@ protocol P {
34
37
var covariantAssocProperty5 : Array < A > { get }
35
38
var covariantAssocProperty6 : [ String : A ] { get }
36
39
var covariantAssocProperty7 : ( ( A ) -> Void ) -> Void { get }
40
+ var covariantAssocProperty8 : ( ( A . . . ) -> Void ) -> Void { get }
37
41
38
42
subscript( covariantSelfSubscript1 _: Void ) -> Self { get }
39
43
subscript( covariantSelfSubscript2 _: Void ) -> Self ? { get }
@@ -42,6 +46,7 @@ protocol P {
42
46
subscript( covariantSelfSubscript5 _: Void ) -> Array < Self > { get }
43
47
subscript( covariantSelfSubscript6 _: Void ) -> [ String : Self ] { get }
44
48
subscript( covariantSelfSubscript7 _: ( Self ) -> Void ) -> Void { get }
49
+ subscript( covariantSelfSubscript8 _: ( Self . . . ) -> Void ) -> Void { get }
45
50
46
51
subscript( covariantAssocSubscript1 _: Void ) -> A { get }
47
52
subscript( covariantAssocSubscript2 _: Void ) -> A ? { get }
@@ -50,6 +55,7 @@ protocol P {
50
55
subscript( covariantAssocSubscript5 _: Void ) -> Array < A > { get }
51
56
subscript( covariantAssocSubscript6 _: Void ) -> [ String : A ] { get }
52
57
subscript( covariantAssocSubscript7 _: ( A ) -> Void ) -> Void { get }
58
+ subscript( covariantAssocSubscript8 _: ( A . . . ) -> Void ) -> Void { get }
53
59
}
54
60
55
61
// -----------------------------------------------------------------------------
@@ -124,6 +130,22 @@ func testCovariantSelfMethod6(p: any P) {
124
130
func testCovariantSelfMethod7( p: any P ) {
125
131
p. covariantSelfMethod7 { _ in }
126
132
}
133
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype24testCovariantSelfMethod81pyAA1P_p_tF
134
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
135
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[SELF_ARRAY_THUNK_NAME:\$[0-9a-zA-Z_]+]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed Array<τ_0_0>, @noescape @callee_guaranteed (@guaranteed Array<P>) -> ()) -> ()
136
+ // CHECK: [[STEP1:%[0-9]+]] = partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>
137
+ // CHECK: [[STEP2:%[0-9]+]] = convert_function [[STEP1]] : $@callee_guaranteed (@guaranteed Array<[[OPENED_TY]]>) -> () to $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <[[OPENED_TY]], [[OPENED_TY]]>
138
+ // CHECK: [[STEP3:%[0-9]+]] = convert_escape_to_noescape [not_guaranteed] [[STEP2]]
139
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.covariantSelfMethod8 : <Self where Self : P> (Self) -> ((Self...) -> ()) -> ()
140
+ // CHECK: apply [[WITNESS]]<[[OPENED_TY]]>([[STEP3]], [[OPENED]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>, @in_guaranteed τ_0_0) -> ()
141
+
142
+ // CHECK: sil shared [transparent] [serializable] [reabstraction_thunk] [ossa] @[[SELF_ARRAY_THUNK_NAME]]
143
+ // CHECK: [[ARRAY_UPCAST:%[0-9]+]] = function_ref @$ss15_arrayForceCastySayq_GSayxGr0_lF
144
+ // CHECK: apply [[ARRAY_UPCAST]]<τ_0_0, P>
145
+ // CHECK: } // end sil function '[[SELF_ARRAY_THUNK_NAME]]'
146
+ func testCovariantSelfMethod8( p: any P ) {
147
+ p. covariantSelfMethod8 { _ in }
148
+ }
127
149
128
150
// CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype26testCovariantSelfProperty11pyAA1P_p_tF
129
151
// CHECK: [[LET:%[0-9]+]] = alloc_stack [lexical] $P, let, name "x"
@@ -208,6 +230,24 @@ func testCovariantSelfProperty6(p: any P) {
208
230
func testCovariantSelfProperty7( p: any P ) {
209
231
let x = p. covariantSelfProperty7
210
232
}
233
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype26testCovariantSelfProperty81pyAA1P_p_tF
234
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
235
+ // CHECK: [[OPENED_COPY:%[0-9]+]] = alloc_stack $[[OPENED_TY]]
236
+ // CHECK: copy_addr [[OPENED]] to [initialization] [[OPENED_COPY]] : $*[[OPENED_TY]]
237
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.covariantSelfProperty8!getter : <Self where Self : P> (Self) -> () -> ((Self...) -> ()) -> ()
238
+ // CHECK: [[RESULT_FN:%[0-9]+]] = apply [[WITNESS]]<[[OPENED_TY]]>([[OPENED_COPY]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @owned @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>) -> () for <τ_0_0, τ_0_0>
239
+ // CHECK: [[STEP1:%[0-9]+]] = convert_function [[RESULT_FN]] : $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>) -> () for <[[OPENED_TY]], [[OPENED_TY]]> to $@callee_guaranteed (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <[[OPENED_TY]], [[OPENED_TY]]>) -> ()
240
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[THUNK_NAME:\$[0-9a-zA-Z_]+]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed (@guaranteed Array<P>) -> (), @guaranteed @callee_guaranteed (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>) -> ()) -> ()
241
+ // CHECK: partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>([[STEP1]])
242
+ // CHECK: debug_value %{{[0-9]+}} : $@callee_guaranteed (@noescape @callee_guaranteed (@guaranteed Array<P>) -> ()) -> (), let, name "x"
243
+ // CHECK: } // end sil function '$s42existential_member_accesses_self_assoctype26testCovariantSelfProperty81pyAA1P_p_tF'
244
+
245
+ // CHECK: sil shared [transparent] [serializable] [reabstraction_thunk] [ossa] @[[THUNK_NAME]]
246
+ // CHECK: function_ref @[[SELF_ARRAY_THUNK_NAME]]
247
+ // CHECK: } // end sil function '[[THUNK_NAME]]'
248
+ func testCovariantSelfProperty8( p: any P ) {
249
+ let x = p. covariantSelfProperty8
250
+ }
211
251
212
252
// CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype27testCovariantSelfSubscript11pyAA1P_p_tF
213
253
// CHECK: [[LET:%[0-9]+]] = alloc_stack [lexical] $P, let, name "x"
@@ -291,6 +331,19 @@ func testCovariantSelfSubscript6(p: any P) {
291
331
func testCovariantSelfSubscript7( p: any P ) {
292
332
_ = p [ covariantSelfSubscript7: { _ in } ]
293
333
}
334
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype27testCovariantSelfSubscript81pyAA1P_p_tF
335
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
336
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[SELF_ARRAY_THUNK_NAME]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed Array<τ_0_0>, @noescape @callee_guaranteed (@guaranteed Array<P>) -> ()) -> ()
337
+ // CHECK: [[STEP1:%[0-9]+]] = partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>
338
+ // CHECK: [[STEP2:%[0-9]+]] = convert_function [[STEP1]] : $@callee_guaranteed (@guaranteed Array<[[OPENED_TY]]>) -> () to $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <[[OPENED_TY]], [[OPENED_TY]]>
339
+ // CHECK: [[STEP3:%[0-9]+]] = convert_escape_to_noescape [not_guaranteed] [[STEP2]]
340
+ // CHECK: [[OPENED_COPY:%[0-9]+]] = alloc_stack $[[OPENED_TY]]
341
+ // CHECK: copy_addr [[OPENED]] to [initialization] [[OPENED_COPY]] : $*[[OPENED_TY]]
342
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.subscript!getter : <Self where Self : P> (Self) -> ((Self...) -> ()) -> ()
343
+ // CHECK: apply [[WITNESS]]<[[OPENED_TY]]>([[STEP3]], [[OPENED_COPY]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>, @in_guaranteed τ_0_0) -> ()
344
+ func testCovariantSelfSubscript8( p: any P ) {
345
+ _ = p [ covariantSelfSubscript8: { _ in } ]
346
+ }
294
347
295
348
// CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype25testCovariantAssocMethod11pyAA1P_p_tF
296
349
// CHECK: [[LET:%[0-9]+]] = alloc_stack [lexical] $Any, let, name "x"
@@ -361,6 +414,22 @@ func testCovariantAssocMethod6(p: any P) {
361
414
func testCovariantAssocMethod7( p: any P ) {
362
415
p. covariantAssocMethod7 { _ in }
363
416
}
417
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype25testCovariantAssocMethod81pyAA1P_p_tF
418
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
419
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[ASSOCTYPE_ARRAY_THUNK_NAME:\$[0-9a-zA-Z_]+]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed Array<τ_0_0.A>, @noescape @callee_guaranteed (@guaranteed Array<Any>) -> ()) -> ()
420
+ // CHECK: [[STEP1:%[0-9]+]] = partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>
421
+ // CHECK: [[STEP2:%[0-9]+]] = convert_function [[STEP1]] : $@callee_guaranteed (@guaranteed Array<([[OPENED_TY]]).A>) -> () to $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <([[OPENED_TY]]).A, ([[OPENED_TY]]).A>
422
+ // CHECK: [[STEP3:%[0-9]+]] = convert_escape_to_noescape [not_guaranteed] [[STEP2]]
423
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.covariantAssocMethod8 : <Self where Self : P> (Self) -> ((Self.A...) -> ()) -> ()
424
+ // CHECK: apply [[WITNESS]]<[[OPENED_TY]]>([[STEP3]], [[OPENED]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0.A, τ_0_0.A>, @in_guaranteed τ_0_0) -> ()
425
+
426
+ // CHECK: sil shared [transparent] [serializable] [reabstraction_thunk] [ossa] @[[ASSOCTYPE_ARRAY_THUNK_NAME]]
427
+ // CHECK: [[ARRAY_UPCAST:%[0-9]+]] = function_ref @$ss15_arrayForceCastySayq_GSayxGr0_lF
428
+ // CHECK: apply [[ARRAY_UPCAST]]<τ_0_0.A, Any>
429
+ // CHECK: } // end sil function '[[ASSOCTYPE_ARRAY_THUNK_NAME]]'
430
+ func testCovariantAssocMethod8( p: any P ) {
431
+ p. covariantAssocMethod8 { _ in }
432
+ }
364
433
365
434
// CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype27testCovariantAssocProperty11pyAA1P_p_tF
366
435
// CHECK: [[LET:%[0-9]+]] = alloc_stack [lexical] $Any, let, name "x"
@@ -444,6 +513,24 @@ func testCovariantAssocProperty6(p: any P) {
444
513
func testCovariantAssocProperty7( p: any P ) {
445
514
let x = p. covariantAssocProperty7
446
515
}
516
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype27testCovariantAssocProperty81pyAA1P_p_tF
517
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
518
+ // CHECK: [[OPENED_COPY:%[0-9]+]] = alloc_stack $[[OPENED_TY]]
519
+ // CHECK: copy_addr [[OPENED]] to [initialization] [[OPENED_COPY]] : $*[[OPENED_TY]]
520
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.covariantAssocProperty8!getter : <Self where Self : P> (Self) -> () -> ((Self.A...) -> ()) -> ()
521
+ // CHECK: [[RESULT_FN:%[0-9]+]] = apply [[WITNESS]]<[[OPENED_TY]]>([[OPENED_COPY]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @owned @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>) -> () for <τ_0_0.A, τ_0_0.A>
522
+ // CHECK: [[STEP1:%[0-9]+]] = convert_function [[RESULT_FN]] : $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0, τ_0_0>) -> () for <([[OPENED_TY]]).A, ([[OPENED_TY]]).A> to $@callee_guaranteed (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <([[OPENED_TY]]).A, ([[OPENED_TY]]).A>) -> ()
523
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[THUNK_NAME:\$[0-9a-zA-Z_]+]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed (@guaranteed Array<Any>) -> (), @guaranteed @callee_guaranteed (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0.A, τ_0_0.A>) -> ()) -> ()
524
+ // CHECK: partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>([[STEP1]])
525
+ // CHECK: debug_value %{{[0-9]+}} : $@callee_guaranteed (@noescape @callee_guaranteed (@guaranteed Array<Any>) -> ()) -> (), let, name "x"
526
+ // CHECK: } // end sil function '$s42existential_member_accesses_self_assoctype27testCovariantAssocProperty81pyAA1P_p_tF'
527
+
528
+ // CHECK: sil shared [transparent] [serializable] [reabstraction_thunk] [ossa] @[[THUNK_NAME]]
529
+ // CHECK: function_ref @[[ASSOCTYPE_ARRAY_THUNK_NAME]]
530
+ // CHECK: } // end sil function '[[THUNK_NAME]]'
531
+ func testCovariantAssocProperty8( p: any P ) {
532
+ let x = p. covariantAssocProperty8
533
+ }
447
534
448
535
// CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype28testCovariantAssocSubscript11pyAA1P_p_tF
449
536
// CHECK: [[LET:%[0-9]+]] = alloc_stack [lexical] $Any, let, name "x"
@@ -527,6 +614,19 @@ func testCovariantAssocSubscript6(p: any P) {
527
614
func testCovariantAssocSubscript7( p: any P ) {
528
615
_ = p [ covariantAssocSubscript7: { _ in } ]
529
616
}
617
+ // CHECK-LABEL: sil hidden [ossa] @$s42existential_member_accesses_self_assoctype28testCovariantAssocSubscript81pyAA1P_p_tF
618
+ // CHECK: [[OPENED:%[0-9]+]] = open_existential_addr immutable_access %0 : $*P to $*[[OPENED_TY:@opened\("[0-9A-F-]+"\) P]]
619
+ // CHECK: [[THUNK:%[0-9]+]] = function_ref @[[ASSOCTYPE_ARRAY_THUNK_NAME]] : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed Array<τ_0_0.A>, @noescape @callee_guaranteed (@guaranteed Array<Any>) -> ()) -> ()
620
+ // CHECK: [[STEP1:%[0-9]+]] = partial_apply [callee_guaranteed] [[THUNK]]<[[OPENED_TY]]>
621
+ // CHECK: [[STEP2:%[0-9]+]] = convert_function [[STEP1]] : $@callee_guaranteed (@guaranteed Array<([[OPENED_TY]]).A>) -> () to $@callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <([[OPENED_TY]]).A, ([[OPENED_TY]]).A>
622
+ // CHECK: [[STEP3:%[0-9]+]] = convert_escape_to_noescape [not_guaranteed] [[STEP2]]
623
+ // CHECK: [[OPENED_COPY:%[0-9]+]] = alloc_stack $[[OPENED_TY]]
624
+ // CHECK: copy_addr [[OPENED]] to [initialization] [[OPENED_COPY]] : $*[[OPENED_TY]]
625
+ // CHECK: [[WITNESS:%[0-9]+]] = witness_method $[[OPENED_TY]], #P.subscript!getter : <Self where Self : P> (Self) -> ((Self.A...) -> ()) -> ()
626
+ // CHECK: apply [[WITNESS]]<[[OPENED_TY]]>([[STEP3]], [[OPENED_COPY]]) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1 where τ_0_0 == τ_0_1> (@guaranteed Array<τ_0_0>) -> () for <τ_0_0.A, τ_0_0.A>, @in_guaranteed τ_0_0) -> ()
627
+ func testCovariantAssocSubscript8( p: any P ) {
628
+ _ = p [ covariantAssocSubscript8: { _ in } ]
629
+ }
530
630
531
631
// -----------------------------------------------------------------------------
532
632
// Covariant dependent member type erasure
0 commit comments