3
3
// REQUIRES: asserts
4
4
5
5
func returnTuple1< each T > ( ) -> ( repeat each T ) { fatalError ( ) }
6
- // expected-note@-1 3 {{in call to function 'returnTuple1()'}}
6
+ // expected-note@-1 {{in call to function 'returnTuple1()'}}
7
7
8
8
func returnTuple2< each T > ( ) -> ( Int , repeat each T ) { fatalError ( ) }
9
- // expected-note@-1 3 {{in call to function 'returnTuple2()'}}
9
+ // expected-note@-1 2 {{in call to function 'returnTuple2()'}}
10
10
11
11
func returnTupleLabel1< each T > ( ) -> ( x: repeat each T ) { fatalError ( ) }
12
12
// expected-error@-1 {{cannot use label with pack expansion tuple element}}
@@ -28,16 +28,10 @@ func returnTupleLabel6<each T, each U>() -> (Int, x: repeat each T, y: repeat ea
28
28
29
29
func concreteReturnTupleValid( ) {
30
30
let _: ( ) = returnTuple1 ( )
31
- // FIXME: consider propagating 'Int' through the conversion constraint
32
- // as a binding for the parameter pack expanded in the tuple return type.
33
31
let _: Int = returnTuple1 ( )
34
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
35
- // expected-error@-2 {{cannot convert value of type '(repeat each T)' to specified type 'Int'}}
36
32
let _: ( Int , String ) = returnTuple1 ( )
37
33
38
34
let _: Int = returnTuple2 ( )
39
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
40
- // expected-error@-2 {{cannot convert value of type '(Int, repeat each T)' to specified type 'Int'}}
41
35
let _: ( Int , String ) = returnTuple2 ( )
42
36
let _: ( Int , String , Float ) = returnTuple2 ( )
43
37
@@ -74,8 +68,6 @@ func concreteReturnTupleValid() {
74
68
75
69
func concreteReturnTypeInvalid( ) {
76
70
let _: Int = returnTuple1 ( )
77
- // expected-error@-1 {{cannot convert value of type '(repeat each T)' to specified type 'Int'}}
78
- // expected-error@-2 {{generic parameter 'T' could not be inferred}}
79
71
80
72
let _: ( ) = returnTuple2 ( )
81
73
// expected-error@-1 {{'(Int, repeat each T)' is not convertible to '()', tuples have a different number of elements}}
@@ -220,28 +212,20 @@ func concreteReturnFunctionInvalid() {
220
212
}
221
213
222
214
func patternInstantiationTupleTest1< each T > ( ) -> ( repeat Array < each T > ) { }
223
- // expected-note@-1 3 {{in call to function 'patternInstantiationTupleTest1()'}}
215
+ // expected-note@-1 2 {{in call to function 'patternInstantiationTupleTest1()'}}
224
216
func patternInstantiationTupleTest2< each T , each U > ( ) -> ( repeat Dictionary < each T , each U > ) { }
225
- // expected-note@-1 {{in call to function 'patternInstantiationTupleTest2()'}}
226
217
227
218
func patternInstantiationFunctionTest1< each T > ( ) -> ( repeat Array < each T > ) -> ( ) { }
228
219
func patternInstantiationFunctionTest2< each T , each U > ( ) -> ( repeat Dictionary < each T , each U > ) -> ( ) { }
229
220
230
221
func patternInstantiationConcreteValid( ) {
231
222
let _: ( ) = patternInstantiationTupleTest1 ( )
232
- // FIXME
233
223
let _: Array < Int > = patternInstantiationTupleTest1 ( )
234
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
235
- // expected-error@-2 {{cannot convert value of type '(repeat Array<each T>)' to specified type 'Array<Int>'}}
236
224
let _: ( Array < Int > , Array < String > ) = patternInstantiationTupleTest1 ( )
237
225
let _: ( Array < Int > , Array < String > , Array < Float > ) = patternInstantiationTupleTest1 ( )
238
226
239
227
let _: ( ) = patternInstantiationTupleTest2 ( )
240
- // FIXME
241
228
let _: Dictionary < Int , String > = patternInstantiationTupleTest2 ( )
242
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
243
- // expected-error@-2 {{generic parameter 'U' could not be inferred}}
244
- // expected-error@-3 {{cannot convert value of type '(repeat Dictionary<each T, each U>)' to specified type 'Dictionary<Int, String>'}}
245
229
let _: ( Dictionary < Int , String > , Dictionary < Float , Bool > ) = patternInstantiationTupleTest2 ( )
246
230
let _: ( Dictionary < Int , String > , Dictionary < Float , Bool > , Dictionary < Double , Character > ) = patternInstantiationTupleTest2 ( )
247
231
@@ -293,3 +277,26 @@ func patternInstantiationGenericInvalid<each T: Hashable>(t: repeat each T) {
293
277
294
278
let _: ( repeat Array < each T > , Set < String > ) = patternInstantiationTupleTest1 ( ) // expected-error {{type of expression is ambiguous without more context}}
295
279
}
280
+
281
+ // rdar://107996926 - Vanishing metatype of tuple not supported
282
+ func test_one_element_tuple_vs_non_tuple_matching( ) {
283
+ struct S {
284
+ func test< each T > ( _: ( repeat each T ) . Type) -> ( repeat each T ) { fatalError ( ) }
285
+ func testVanishing< each T > ( _: ( Int , repeat each T ) ) { }
286
+ }
287
+
288
+ let _ = S ( ) . test ( Int . self) // Ok
289
+ let _: Int = S ( ) . test ( Int . self) // Ok
290
+ let _ = S ( ) . test ( ( Int, String) . self) // Ok
291
+ let _ = S ( ) . testVanishing ( 42 ) // Ok
292
+
293
+ do {
294
+ struct V < T> { }
295
+
296
+ func test< each T > ( _: V < ( repeat each T ) > ? ) { }
297
+ func test< each T > ( _: V < ( repeat each T ) > . Type ) { }
298
+
299
+ test ( V < Int > ( ) ) // Ok
300
+ test ( V< Int> . self ) // Ok
301
+ }
302
+ }
0 commit comments