@@ -452,6 +452,53 @@ func check_default_subscripts() {
452
452
_ = \SubscriptDefaults5 . [ x: " " , y: " " ]
453
453
}
454
454
455
+ struct SubscriptVariadic1 {
456
+ subscript( x: Int ... ) -> Int { x [ 0 ] }
457
+ }
458
+
459
+ struct SubscriptVariadic2 {
460
+ subscript< T : ExpressibleByStringLiteral > ( x: T ... ) -> T { x [ 0 ] }
461
+ }
462
+
463
+ struct SubscriptVariadic3 < T : ExpressibleByStringLiteral > {
464
+ subscript( x: T ... ) -> T { x [ 0 ] }
465
+ }
466
+
467
+ // CHECK-LABEL: sil hidden [ossa] @{{.*}}test_variadics
468
+ func test_variadics( ) {
469
+ // CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 3
470
+ // CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
471
+ // CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
472
+ // CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
473
+ // CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
474
+ _ = \SubscriptVariadic1 . [ 1 , 2 , 3 ]
475
+ // CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 1
476
+ // CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
477
+ // CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
478
+ // CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
479
+ // CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
480
+ _ = \SubscriptVariadic1 . [ 1 ]
481
+ // CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 0
482
+ // CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
483
+ // CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
484
+ // CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
485
+ // CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
486
+ _ = \SubscriptVariadic1 . [ ]
487
+
488
+ _ = \SubscriptVariadic2 . [ " " , " 1 " ]
489
+ _ = \SubscriptVariadic2 . [ " " ]
490
+ // CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 2
491
+ // CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
492
+ // CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<String>([[ARR_COUNT]])
493
+ // CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<String>, Builtin.RawPointer)
494
+ // CHECK: keypath $KeyPath<SubscriptVariadic2, String>, (root $SubscriptVariadic2; gettable_property $String, id @$s8keypaths18SubscriptVariadic2Vyxxd_tcs26ExpressibleByStringLiteralRzluig : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByStringLiteral> (@guaranteed Array<τ_0_0>, SubscriptVariadic2) -> @out τ_0_0, getter @$s8keypaths18SubscriptVariadic2Vyxxd_tcs26ExpressibleByStringLiteralRzluipACSSTK : $@convention(thin) (@in_guaranteed SubscriptVariadic2, UnsafeRawPointer) -> @out String, indices [%$0 : $Array<String> : $Array<String>], indices_equals @$sSaySSGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySSGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
495
+ _ = \SubscriptVariadic2 . [ " " , #function]
496
+
497
+ _ = \SubscriptVariadic3 < String > . [ " " ]
498
+ _ = \SubscriptVariadic3 < String > . [ " " , " 1 " ]
499
+ _ = \SubscriptVariadic3 < String > . [ ]
500
+ }
501
+
455
502
// CHECK-LABEL: sil hidden [ossa] @{{.*}}subclass_generics
456
503
func subclass_generics< T: C < Int > , U: C < V > , V/*: PoC*/> ( _: T , _: U , _: V ) {
457
504
_ = \T . x
0 commit comments