|
2 | 2 |
|
3 | 3 | // REQUIRES: asserts
|
4 | 4 |
|
5 |
| -func returnTuple1<T...>() -> (T...) { fatalError() } |
| 5 | +func returnTuple1<T...>() -> (repeat each T) { fatalError() } |
6 | 6 |
|
7 |
| -func returnTuple2<T...>() -> (Int, T...) { fatalError() } |
| 7 | +func returnTuple2<T...>() -> (Int, repeat each T) { fatalError() } |
8 | 8 |
|
9 |
| -func returnTupleLabel1<T...>() -> (x: T...) { fatalError() } |
| 9 | +func returnTupleLabel1<T...>() -> (x: repeat each T) { fatalError() } |
10 | 10 |
|
11 |
| -func returnTupleLabel2<T...>() -> (Int, x: T...) { fatalError() } |
| 11 | +func returnTupleLabel2<T...>() -> (Int, x: repeat each T) { fatalError() } |
12 | 12 |
|
13 |
| -func returnTupleLabel3<T...>() -> (Int, T..., y: Float) { fatalError() } |
| 13 | +func returnTupleLabel3<T...>() -> (Int, repeat each T, y: Float) { fatalError() } |
14 | 14 |
|
15 |
| -func returnTupleLabel4<T...>() -> (Int, x: T..., y: Float) { fatalError() } // expected-note {{in call to function 'returnTupleLabel4()'}} |
| 15 | +func returnTupleLabel4<T...>() -> (Int, x: repeat each T, y: Float) { fatalError() } // expected-note {{in call to function 'returnTupleLabel4()'}} |
16 | 16 |
|
17 |
| -func returnTupleLabel5<T..., U...>() -> (Int, T..., y: U...) { fatalError() } |
| 17 | +func returnTupleLabel5<T..., U...>() -> (Int, repeat each T, y: repeat each U) { fatalError() } |
18 | 18 |
|
19 |
| -func returnTupleLabel6<T..., U...>() -> (Int, x: T..., y: U...) { fatalError() } // expected-note {{in call to function 'returnTupleLabel6()'}} |
| 19 | +func returnTupleLabel6<T..., U...>() -> (Int, x: repeat each T, y: repeat each U) { fatalError() } // expected-note {{in call to function 'returnTupleLabel6()'}} |
20 | 20 |
|
21 | 21 | func concreteReturnTupleValid() {
|
22 | 22 | let _: () = returnTuple1()
|
@@ -66,70 +66,70 @@ func concreteReturnTypeInvalid() {
|
66 | 66 | let _: () = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}}
|
67 | 67 | }
|
68 | 68 |
|
69 |
| -func genericReturnTupleValid<T...>(_: T...) { |
70 |
| - let _: (T...) = returnTuple1() |
71 |
| - let _: (Int, T...) = returnTuple1() |
| 69 | +func genericReturnTupleValid<T...>(_: repeat each T) { |
| 70 | + let _: (repeat each T) = returnTuple1() |
| 71 | + let _: (Int, repeat each T) = returnTuple1() |
72 | 72 |
|
73 |
| - let _: (Int, T...) = returnTuple2() |
74 |
| - let _: (Int, String, T...) = returnTuple2() |
| 73 | + let _: (Int, repeat each T) = returnTuple2() |
| 74 | + let _: (Int, String, repeat each T) = returnTuple2() |
75 | 75 |
|
76 |
| - let _: (x: T...) = returnTupleLabel1() |
77 |
| - let _: (x: Int, T...) = returnTupleLabel1() |
| 76 | + let _: (x: repeat each T) = returnTupleLabel1() |
| 77 | + let _: (x: Int, repeat each T) = returnTupleLabel1() |
78 | 78 |
|
79 |
| - let _: (Int, x: T...) = returnTupleLabel2() |
80 |
| - let _: (Int, x: String, T...) = returnTupleLabel2() |
| 79 | + let _: (Int, x: repeat each T) = returnTupleLabel2() |
| 80 | + let _: (Int, x: String, repeat each T) = returnTupleLabel2() |
81 | 81 |
|
82 |
| - let _: (Int, T..., y: Float) = returnTupleLabel3() |
83 |
| - let _: (Int, String, T..., y: Float) = returnTupleLabel3() |
| 82 | + let _: (Int, repeat each T, y: Float) = returnTupleLabel3() |
| 83 | + let _: (Int, String, repeat each T, y: Float) = returnTupleLabel3() |
84 | 84 |
|
85 |
| - let _: (Int, x: T..., y: Float) = returnTupleLabel4() |
86 |
| - let _: (Int, x: String, T..., y: Float) = returnTupleLabel4() |
| 85 | + let _: (Int, x: repeat each T, y: Float) = returnTupleLabel4() |
| 86 | + let _: (Int, x: String, repeat each T, y: Float) = returnTupleLabel4() |
87 | 87 |
|
88 |
| - let _: (Int, T..., y: T...) = returnTupleLabel5() |
89 |
| - let _: (Int, String, T..., y: Float, T...) = returnTupleLabel5() |
| 88 | + let _: (Int, repeat each T, y: repeat each T) = returnTupleLabel5() |
| 89 | + let _: (Int, String, repeat each T, y: Float, repeat each T) = returnTupleLabel5() |
90 | 90 |
|
91 |
| - let _: (Int, x: T..., y: T...) = returnTupleLabel6() |
92 |
| - let _: (Int, x: String, T..., y: Float, T...) = returnTupleLabel6() |
| 91 | + let _: (Int, x: repeat each T, y: repeat each T) = returnTupleLabel6() |
| 92 | + let _: (Int, x: String, repeat each T, y: Float, repeat each T) = returnTupleLabel6() |
93 | 93 | }
|
94 | 94 |
|
95 |
| -func genericReturnTupleInvalid<T...>(_: T...) { |
96 |
| - let _: (x: T...) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
97 |
| - let _: (x: Int, T...) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
| 95 | +func genericReturnTupleInvalid<T...>(_: repeat each T) { |
| 96 | + let _: (x: repeat each T) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
| 97 | + let _: (x: Int, repeat each T) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
98 | 98 |
|
99 |
| - let _: (Int, x: T...) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
100 |
| - let _: (Int, x: String, T...) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
| 99 | + let _: (Int, x: repeat each T) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
| 100 | + let _: (Int, x: String, repeat each T) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
101 | 101 |
|
102 |
| - let _: (y: T...) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
103 |
| - let _: (y: Int, T...) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
| 102 | + let _: (y: repeat each T) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
| 103 | + let _: (y: Int, repeat each T) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
104 | 104 |
|
105 |
| - let _: (x: T...) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
106 |
| - let _: (Int, y: String, T...) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
| 105 | + let _: (x: repeat each T) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
| 106 | + let _: (Int, y: String, repeat each T) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
107 | 107 |
|
108 |
| - let _: (T..., y: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
| 108 | + let _: (repeat each T, y: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
109 | 109 |
|
110 |
| - let _: (Int, String, T..., x: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
| 110 | + let _: (Int, String, repeat each T, x: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
111 | 111 |
|
112 |
| - let _: (T..., y: Float) = returnTupleLabel4() // expected-error {{'(Int, x: T..., y: Float)' is not convertible to '(T..., y: Float)', tuples have a different number of elements}} |
| 112 | + let _: (repeat each T, y: Float) = returnTupleLabel4() // expected-error {{'(Int, x: T..., y: Float)' is not convertible to '(T..., y: Float)', tuples have a different number of elements}} |
113 | 113 | // expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
114 | 114 |
|
115 |
| - let _: (Int, x: String, y: T...) = returnTupleLabel4() // expected-error {{cannot convert value of type '(Int, x: String, y: Float)' to specified type '(Int, x: String, y: T...)'}} |
| 115 | + let _: (Int, x: String, y: repeat each T) = returnTupleLabel4() // expected-error {{cannot convert value of type '(Int, x: String, y: Float)' to specified type '(Int, x: String, y: T...)'}} |
116 | 116 |
|
117 |
| - let _: (Int, T..., x: T...) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
| 117 | + let _: (Int, repeat each T, x: repeat each T) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
118 | 118 |
|
119 |
| - let _: (T..., y: Float, T...) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
| 119 | + let _: (repeat each T, y: Float, repeat each T) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
120 | 120 |
|
121 |
| - let _: (T..., y: Int) = returnTupleLabel6() // expected-error {{'(Int, x: T..., y: U...)' is not convertible to '(T..., y: Int)', tuples have a different number of elements}} |
| 121 | + let _: (repeat each T, y: Int) = returnTupleLabel6() // expected-error {{'(Int, x: T..., y: U...)' is not convertible to '(T..., y: Int)', tuples have a different number of elements}} |
122 | 122 | // expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
123 | 123 | // expected-error@-2 {{generic parameter 'U' could not be inferred}}
|
124 | 124 | }
|
125 | 125 |
|
126 |
| -func returnFunction1<T...>() -> (T...) -> () {} |
| 126 | +func returnFunction1<T...>() -> (repeat each T) -> () {} |
127 | 127 |
|
128 |
| -func returnFunction2<T...>() -> (Int, T...) -> () {} // expected-note {{in call to function 'returnFunction2()'}} |
| 128 | +func returnFunction2<T...>() -> (Int, repeat each T) -> () {} // expected-note {{in call to function 'returnFunction2()'}} |
129 | 129 |
|
130 |
| -func returnFunction3<T...>() -> (T..., Float) -> () {} // expected-note {{in call to function 'returnFunction3()'}} |
| 130 | +func returnFunction3<T...>() -> (repeat each T, Float) -> () {} // expected-note {{in call to function 'returnFunction3()'}} |
131 | 131 |
|
132 |
| -func returnFunction4<T...>() -> (Int, T..., Float) -> () {} // expected-note 2{{in call to function 'returnFunction4()'}} |
| 132 | +func returnFunction4<T...>() -> (Int, repeat each T, Float) -> () {} // expected-note 2{{in call to function 'returnFunction4()'}} |
133 | 133 |
|
134 | 134 | func concreteReturnFunctionValid() {
|
135 | 135 | let _: () -> () = returnFunction1()
|
@@ -171,11 +171,11 @@ func concreteReturnFunctionInvalid() {
|
171 | 171 | let _: (Float, Int) -> () = returnFunction4() // expected-error {{cannot convert value of type '(Int, Float) -> ()' to specified type '(Float, Int) -> ()'}}
|
172 | 172 | }
|
173 | 173 |
|
174 |
| -func patternInstantiationTupleTest1<T...>() -> (Array<T>...) {} // expected-note {{in call to function 'patternInstantiationTupleTest1()'}} |
175 |
| -func patternInstantiationTupleTest2<T..., U...>() -> (Dictionary<T, U>...) {} |
| 174 | +func patternInstantiationTupleTest1<T...>() -> (repeat Array<each T>) {} // expected-note {{in call to function 'patternInstantiationTupleTest1()'}} |
| 175 | +func patternInstantiationTupleTest2<T..., U...>() -> (repeat Dictionary<each T, each U>) {} |
176 | 176 |
|
177 |
| -func patternInstantiationFunctionTest1<T...>() -> (Array<T>...) -> () {} |
178 |
| -func patternInstantiationFunctionTest2<T..., U...>() -> (Dictionary<T, U>...) -> () {} |
| 177 | +func patternInstantiationFunctionTest1<T...>() -> (repeat Array<each T>) -> () {} |
| 178 | +func patternInstantiationFunctionTest2<T..., U...>() -> (repeat Dictionary<each T, each U>) -> () {} |
179 | 179 |
|
180 | 180 | func patternInstantiationConcreteValid() {
|
181 | 181 | let _: () = patternInstantiationTupleTest1()
|
@@ -204,31 +204,31 @@ func patternInstantiationConcreteInvalid() {
|
204 | 204 | let _: (Array<Int>, Set<String>) = patternInstantiationTupleTest1() // expected-error {{type of expression is ambiguous without more context}}
|
205 | 205 | }
|
206 | 206 |
|
207 |
| -func patternInstantiationGenericValid<T..., U...>(t: T..., u: U...) where ((T, U)...): Any, T: Hashable { |
208 |
| - let _: (Array<T>...) = patternInstantiationTupleTest1() |
209 |
| - let _: (Array<T>..., Array<String>) = patternInstantiationTupleTest1() |
210 |
| - let _: (Array<String>, Array<T>...) = patternInstantiationTupleTest1() |
211 |
| - let _: (Array<Int>, Array<T>..., Array<Float>) = patternInstantiationTupleTest1() |
212 |
| - |
213 |
| - let _: (Dictionary<T, U>...) = patternInstantiationTupleTest2() |
214 |
| - let _: (Dictionary<T, U>..., Dictionary<Float, Bool>) = patternInstantiationTupleTest2() |
215 |
| - let _: (Dictionary<Int, String>, Dictionary<T, U>...) = patternInstantiationTupleTest2() |
216 |
| - let _: (Dictionary<Int, String>, Dictionary<T, U>..., Dictionary<Double, Character>) = patternInstantiationTupleTest2() |
217 |
| - |
218 |
| - let _: (Array<T>...) -> () = patternInstantiationFunctionTest1() |
219 |
| - let _: (Array<T>..., Array<String>) -> () = patternInstantiationFunctionTest1() |
220 |
| - let _: (Array<String>, Array<T>...) -> () = patternInstantiationFunctionTest1() |
221 |
| - let _: (Array<Int>, Array<T>..., Array<Float>) -> () = patternInstantiationFunctionTest1() |
222 |
| - |
223 |
| - let _: (Dictionary<T, U>...) -> () = patternInstantiationFunctionTest2() |
224 |
| - let _: (Dictionary<T, U>..., Dictionary<Float, Bool>) -> () = patternInstantiationFunctionTest2() |
225 |
| - let _: (Dictionary<Int, String>, Dictionary<T, U>...) -> () = patternInstantiationFunctionTest2() |
226 |
| - let _: (Dictionary<Int, String>, Dictionary<T, U>..., Dictionary<Double, Character>) -> () = patternInstantiationFunctionTest2() |
| 207 | +func patternInstantiationGenericValid<T..., U...>(t: repeat each T, u: repeat each U) where (repeat (each T, each U)): Any, T: Hashable { |
| 208 | + let _: (repeat Array<each T>) = patternInstantiationTupleTest1() |
| 209 | + let _: (repeat Array<each T>, Array<String>) = patternInstantiationTupleTest1() |
| 210 | + let _: (Array<String>, repeat Array<each T>) = patternInstantiationTupleTest1() |
| 211 | + let _: (Array<Int>, repeat Array<each T>, Array<Float>) = patternInstantiationTupleTest1() |
| 212 | + |
| 213 | + let _: (repeat Dictionary<each T, each U>) = patternInstantiationTupleTest2() |
| 214 | + let _: (repeat Dictionary<each T, each U>, Dictionary<Float, Bool>) = patternInstantiationTupleTest2() |
| 215 | + let _: (Dictionary<Int, String>, repeat Dictionary<each T, each U>) = patternInstantiationTupleTest2() |
| 216 | + let _: (Dictionary<Int, String>, repeat Dictionary<each T, each U>, Dictionary<Double, Character>) = patternInstantiationTupleTest2() |
| 217 | + |
| 218 | + let _: (repeat Array<each T>) -> () = patternInstantiationFunctionTest1() |
| 219 | + let _: (repeat Array<each T>, Array<String>) -> () = patternInstantiationFunctionTest1() |
| 220 | + let _: (Array<String>, repeat Array<each T>) -> () = patternInstantiationFunctionTest1() |
| 221 | + let _: (Array<Int>, repeat Array<each T>, Array<Float>) -> () = patternInstantiationFunctionTest1() |
| 222 | + |
| 223 | + let _: (repeat Dictionary<each T, each U>) -> () = patternInstantiationFunctionTest2() |
| 224 | + let _: (repeat Dictionary<each T, each U>, Dictionary<Float, Bool>) -> () = patternInstantiationFunctionTest2() |
| 225 | + let _: (Dictionary<Int, String>, repeat Dictionary<each T, each U>) -> () = patternInstantiationFunctionTest2() |
| 226 | + let _: (Dictionary<Int, String>, repeat Dictionary<each T, each U>, Dictionary<Double, Character>) -> () = patternInstantiationFunctionTest2() |
227 | 227 | }
|
228 | 228 |
|
229 |
| -func patternInstantiationGenericInvalid<T...>(t: T...) where T: Hashable { |
230 |
| - let _: (Set<T>...) = patternInstantiationTupleTest1() // expected-error {{cannot convert value of type '(Array<T>...)' to specified type '(Set<T>...)}} |
| 229 | +func patternInstantiationGenericInvalid<T...>(t: repeat each T) where T: Hashable { |
| 230 | + let _: (repeat Set<each T>) = patternInstantiationTupleTest1() // expected-error {{cannot convert value of type '(Array<T>...)' to specified type '(Set<T>...)}} |
231 | 231 | // expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
232 | 232 |
|
233 |
| - let _: (Array<T>..., Set<String>) = patternInstantiationTupleTest1() // expected-error {{type of expression is ambiguous without more context}} |
| 233 | + let _: (repeat Array<each T>, Set<String>) = patternInstantiationTupleTest1() // expected-error {{type of expression is ambiguous without more context}} |
234 | 234 | }
|
0 commit comments