|
| 1 | +// RUN: %target-swift-emit-silgen -enable-experimental-feature VariadicGenerics %s | %FileCheck %s |
| 2 | +// REQUIRES: asserts |
| 3 | + |
| 4 | +func mutateInt(_ arg: inout Int) {} |
| 5 | + |
| 6 | +struct Sub { |
| 7 | + subscript<each T>(variadic args: repeat each T) -> Int { |
| 8 | + get { return 0 } |
| 9 | + set {} |
| 10 | + } |
| 11 | + |
| 12 | + subscript<each T>(simpleTuple args: (repeat each T)) -> Int { |
| 13 | + get { return 0 } |
| 14 | + set {} |
| 15 | + } |
| 16 | + |
| 17 | + subscript<each T>(compoundTuple args: (String, repeat each T)) -> Int { |
| 18 | + get { return 0 } |
| 19 | + set {} |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +func testVariadic<each T>(sub: inout Sub, args: repeat each T) { |
| 24 | + mutateInt(&sub[variadic: repeat each args]) |
| 25 | +} |
| 26 | + |
| 27 | +func testVariadicWithExtra<each T>(sub: inout Sub, args: repeat each T, extra: String) { |
| 28 | + mutateInt(&sub[variadic: repeat each args, extra]) |
| 29 | +} |
| 30 | + |
| 31 | +func testVariadicConcrete(sub: inout Sub, first: String, second: Int) { |
| 32 | + mutateInt(&sub[variadic: first, second]) |
| 33 | +} |
| 34 | + |
| 35 | +func testSimpleTupleSubscript<each T>(sub: inout Sub, args: repeat each T) { |
| 36 | + mutateInt(&sub[simpleTuple: (repeat each args)]) |
| 37 | +} |
| 38 | + |
| 39 | +func testSimpleTupleWithExtra<each T>(sub: inout Sub, args: repeat each T, extra: String) { |
| 40 | + mutateInt(&sub[simpleTuple: (repeat each args, extra)]) |
| 41 | +} |
| 42 | + |
| 43 | +func testSimpleTupleConcrete(sub: inout Sub, first: String, second: Int) { |
| 44 | + mutateInt(&sub[simpleTuple: (first, second)]) |
| 45 | +} |
| 46 | + |
| 47 | +func testCompoundTupleSubscript<each T>(sub: inout Sub, args: repeat each T, first: String) { |
| 48 | + mutateInt(&sub[compoundTuple: (first, repeat each args)]) |
| 49 | +} |
| 50 | + |
| 51 | +func testCompoundTupleWithExtra<each T>(sub: inout Sub, args: repeat each T, first: String, extra: String) { |
| 52 | + mutateInt(&sub[compoundTuple: (first, repeat each args, extra)]) |
| 53 | +} |
| 54 | + |
| 55 | +func testSimpleTupleConcrete(sub: inout Sub, first: String, second: String, third: Int) { |
| 56 | + mutateInt(&sub[compoundTuple: (first, second, third)]) |
| 57 | +} |
| 58 | + |
0 commit comments