@@ -170,326 +170,3 @@ final class TypeTests: XCTestCase {
170
170
)
171
171
}
172
172
}
173
-
174
- final class TypeParameterPackTests : XCTestCase {
175
- func testParameterPacks1( ) {
176
- AssertParse (
177
- """
178
- func f1<T...>() -> T... {}
179
- """
180
- )
181
- }
182
- func testParameterPacks2( ) {
183
- AssertParse (
184
- """
185
- func f2<T...>() -> (T...) {}
186
- """
187
- )
188
- }
189
- func testParameterPacks3( ) {
190
- AssertParse (
191
- """
192
- func f3<T...>() -> G<T... > {}
193
- """
194
- )
195
- }
196
- func testParameterPacks4( ) {
197
- AssertParse (
198
- """
199
- protocol P {
200
- associatedtype T1️⃣...
201
- }
202
- """ ,
203
- diagnostics: [
204
- DiagnosticSpec (
205
- message: " associated types cannot be variadic " ,
206
- fixIts: [ " remove '...' " ]
207
- )
208
- ]
209
- )
210
- }
211
- func testParameterPacks5( ) {
212
- AssertParse (
213
- """
214
- typealias Alias<T...> = (T...)
215
- """
216
- )
217
- }
218
- func testParameterPacks6( ) {
219
- AssertParse (
220
- """
221
- struct S<T...> {}
222
- """
223
- )
224
- }
225
- func testParameterPacks7( ) {
226
- AssertParse (
227
- """
228
- struct S<T, U...> {}
229
- """
230
- )
231
- }
232
- func testParameterPacks8( ) {
233
- AssertParse (
234
- """
235
- struct S<T..., U> {}
236
- """
237
- )
238
- }
239
- func testParameterPacks9( ) {
240
- AssertParse (
241
- """
242
- struct S<T...:P, U> {}
243
- """
244
- )
245
- }
246
- func testParameterPacks10( ) {
247
- AssertParse (
248
- """
249
- struct S<T... :P, U> {}
250
- """
251
- )
252
- }
253
- func testParameterPacks11( ) {
254
- AssertParse (
255
- """
256
- struct S<T...: P> {}
257
- """
258
- )
259
- }
260
- func testParameterPacks12( ) {
261
- AssertParse (
262
- """
263
- struct S<T... : P> {}
264
- """
265
- )
266
- }
267
- func testParameterPacks13( ) {
268
- AssertParse (
269
- """
270
- func foo<T...>(_ x: T...) {}
271
- """
272
- )
273
- }
274
- func testParameterPacks14( ) {
275
- AssertParse (
276
- """
277
- func foo<T...:P>(_ x: T...) {}
278
- """
279
- )
280
- }
281
- func testParameterPacks15( ) {
282
- AssertParse (
283
- """
284
- func foo<T... :P>(_ x: T...) {}
285
- """
286
- )
287
- }
288
- func testParameterPacks16( ) {
289
- AssertParse (
290
- """
291
- func foo<T... : P>(_ x: T...) {}
292
- """
293
- )
294
- }
295
- func testParameterPacks17( ) {
296
- AssertParse (
297
- """
298
- func foo<T...: P>(_ x: T...) {}
299
- """
300
- )
301
- }
302
- func testParameterPacks18( ) {
303
- AssertParse (
304
- """
305
- func foo<T, U, V...>(x: T, y: U, z: V...) { }
306
- """
307
- )
308
- }
309
- func testParameterPacks19( ) {
310
- AssertParse (
311
- """
312
- func foo<T, U..., V>(x: T, y: U..., z: V) { }
313
- """
314
- )
315
- }
316
- func testParameterPacks20( ) {
317
- AssertParse (
318
- """
319
- func foo<T..., U..., V...>(x: T..., y: U..., z: V...) { }
320
- """
321
- )
322
- }
323
- func testParameterPacks21( ) {
324
- AssertParse (
325
- """
326
- enum E<T...> {
327
- case f1(_: T...)
328
- }
329
- """
330
- )
331
- }
332
- func testParameterPacks22( ) {
333
- AssertParse (
334
- """
335
- enum E<T...> {
336
- case f2(_: G<T... >)
337
- }
338
- """
339
- )
340
- }
341
- func testParameterPacks23( ) {
342
- AssertParse (
343
- """
344
- enum E<T...> {
345
- var x: T... { fatalError() }
346
- }
347
- """
348
- )
349
- }
350
- func testParameterPacks24( ) {
351
- AssertParse (
352
- """
353
- enum E<T...> {
354
- var x: (T...) { fatalError() }
355
- }
356
- """
357
- )
358
- }
359
- func testParameterPacks25( ) {
360
- AssertParse (
361
- """
362
- enum E<T...> {
363
- subscript(_: T...) -> Int { fatalError() }
364
- }
365
- """
366
- )
367
- }
368
- func testParameterPacks26( ) {
369
- AssertParse (
370
- """
371
- enum E<T...> {
372
- subscript() -> T... { fatalError() }
373
- }
374
- """
375
- )
376
- }
377
- func testParameterPacks27( ) {
378
- AssertParse (
379
- """
380
- enum E<T...> {
381
- subscript() -> (T...) { fatalError() }
382
- }
383
- """
384
- )
385
- }
386
- func testParameterPacks28( ) {
387
- // We allow whitespace between the generic parameter and the '...', this is
388
- // consistent with regular variadic parameters.
389
- AssertParse (
390
- """
391
- func f1<T ...>(_ x: T ...) -> (T ...) {}
392
- """
393
- )
394
- }
395
- func testVariadicTypes( ) {
396
- AssertParse (
397
- """
398
- let _: G< > = G()
399
- let _: G<T... > = G()
400
- let _: G<Int, T... > = G()
401
- let _ = G< >.self
402
- let _ = G<T... >.self
403
- let _ = G<Int, T... >.self
404
- """
405
- )
406
-
407
- }
408
-
409
- func testMissingCommaInType( ) throws {
410
- AssertParse (
411
- """
412
- var foo: (Int)
413
- """
414
- )
415
-
416
- AssertParse (
417
- """
418
- var foo: (Int, Int)
419
- """
420
- )
421
-
422
- AssertParse (
423
- """
424
- var foo: (bar: Int 1️⃣bar2: Int)
425
- """ ,
426
- diagnostics: [
427
- DiagnosticSpec ( message: " expected ',' in tuple type " )
428
- ]
429
- )
430
-
431
- AssertParse (
432
- """
433
- var foo: (bar: Int 1️⃣Int)
434
- """ ,
435
- diagnostics: [
436
- DiagnosticSpec ( message: " expected ',' in tuple type " )
437
- ]
438
- )
439
-
440
- AssertParse (
441
- """
442
- var foo: (a 1️⃣Int)
443
- """ ,
444
- diagnostics: [
445
- DiagnosticSpec ( message: " expected ':' in tuple type " )
446
- ]
447
- )
448
-
449
- AssertParse (
450
- """
451
- var foo: (A 1️⃣Int)
452
- """ ,
453
- diagnostics: [
454
- DiagnosticSpec ( message: " expected ',' in tuple type " )
455
- ]
456
- )
457
-
458
- AssertParse (
459
- """
460
- var foo: (_ 1️⃣a 2️⃣Int)
461
- """ ,
462
- diagnostics: [
463
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected ':' in tuple type " ) ,
464
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected ',' in tuple type " ) ,
465
- ]
466
- )
467
-
468
- AssertParse (
469
- """
470
- var foo: (Array<Foo> 1️⃣Array<Bar>)
471
- """ ,
472
- diagnostics: [
473
- DiagnosticSpec ( message: " expected ',' in tuple type " )
474
- ]
475
- )
476
-
477
- AssertParse (
478
- """
479
- var foo: (a 1️⃣Array<Bar>)
480
- """ ,
481
- diagnostics: [
482
- DiagnosticSpec ( message: " expected ':' in tuple type " )
483
- ]
484
- )
485
-
486
- AssertParse (
487
- """
488
- var foo: (Array<Foo> 1️⃣a)
489
- """ ,
490
- diagnostics: [
491
- DiagnosticSpec ( message: " expected ',' in tuple type " )
492
- ]
493
- )
494
- }
495
- }
0 commit comments