Skip to content

Commit e8361dd

Browse files
committed
[Variadic Generics] fix tests incorrect pack expansion syntax in some tests, but also disable them due to triggering a constraints checker assertion
1 parent 0e99f9c commit e8361dd

10 files changed

+31
-24
lines changed

test/Constraints/pack_expansion_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func patternInstantiationConcreteInvalid() {
257257
let _: (Array<Int>, Set<String>) = patternInstantiationTupleTest1() // expected-error {{type of expression is ambiguous without more context}}
258258
}
259259

260-
func patternInstantiationGenericValid<T..., U...>(t: repeat each T, u: repeat each U) where (repeat (each T, each U)): Any, T: Hashable {
260+
func patternInstantiationGenericValid<T..., U...>(t: repeat each T, u: repeat each U) where (repeat (each T, each U)): Any, each T: Hashable {
261261
let _: (repeat Array<each T>) = patternInstantiationTupleTest1()
262262
let _: (repeat Array<each T>, Array<String>) = patternInstantiationTupleTest1()
263263
let _: (Array<String>, repeat Array<each T>) = patternInstantiationTupleTest1()
@@ -279,7 +279,7 @@ func patternInstantiationGenericValid<T..., U...>(t: repeat each T, u: repeat ea
279279
let _: (Dictionary<Int, String>, repeat Dictionary<each T, each U>, Dictionary<Double, Character>) -> () = patternInstantiationFunctionTest2()
280280
}
281281

282-
func patternInstantiationGenericInvalid<T...>(t: repeat each T) where T: Hashable {
282+
func patternInstantiationGenericInvalid<T...>(t: repeat each T) where each T: Hashable {
283283
let _: (repeat Set<each T>) = patternInstantiationTupleTest1() // expected-error {{cannot convert value of type '(repeat Array<each T>)' to specified type '(repeat Set<each T>)}}
284284
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
285285

test/Constraints/variadic_generic_constraints.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ takesAnyObject(C(), S(), C()) // expected-error {{type of expression is ambiguo
4747

4848
// Same-type requirements
4949

50-
func takesParallelSequences<T..., U...>(t: repeat each T, u: repeat each U) where T: Sequence, U: Sequence, T.Element == U.Element {}
50+
func takesParallelSequences<T..., U...>(t: repeat each T, u: repeat each U) where each T: Sequence, each U: Sequence, each T.Element == each U.Element {}
5151
// expected-note@-1 {{where 'T.Element' = 'String', 'U.Element' = 'Int'}}
5252

5353
takesParallelSequences() // ok

test/Constraints/variadic_generic_functions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// REQUIRES: asserts
44

55
func debugPrint<T...>(_ items: repeat each T)
6-
where T: CustomDebugStringConvertible
6+
where each T: CustomDebugStringConvertible
77
{
88
/*for (item: T) in items {
99
stdout.write(item.debugDescription)
1010
}*/
1111
}
1212

1313
func max<T...>(_ values: repeat each T) -> T?
14-
where T: Comparable
14+
where each T: Comparable
1515
{
1616
return nil
1717
}

test/Constraints/variadic_generic_types.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: rdar104716322
2+
13
// RUN: %target-typecheck-verify-swift -enable-experimental-feature VariadicGenerics
24

35
// REQUIRES: asserts
@@ -9,17 +11,16 @@ func f<T...>(_: repeat each T) {
911
_ = G< >.self
1012
_ = G<Int>.self
1113
_ = G<Int, String>.self
12-
_ = G<repeat T>.self
13-
_ = G<Int, repeat Array<T>>.self
14+
_ = G<repeat each T>.self
15+
_ = G<Int, repeat Array<each T>>.self
1416
}
1517

1618
// Forming PackExpansionTypeReprs in simplifyTypeExpr()
1719
func g<T...>(_: repeat each T) {
18-
_ = (repeat T).self
19-
_ = (Int, repeat T).self
20-
_ = ((repeat T) -> ()).self
21-
_ = ((Int, repeat Array<T>) -> ()).self
20+
_ = (repeat each T).self
21+
_ = (Int, repeat each T).self
22+
_ = ((repeat each T) -> ()).self
23+
_ = ((Int, repeat Array<each T>) -> ()).self
2224

23-
_ = (repeat Int).self // expected-error {{variadic expansion 'Int' must contain at least one variadic generic parameter}}
25+
_ = (repeat each Int).self // expected-error {{variadic expansion 'Int' must contain at least one variadic generic parameter}}
2426
}
25-

test/Generics/pack-shape-requirements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func inferSameShape<T..., U...>(ts t: repeat each T, us u: repeat each U) where
1313

1414
// CHECK-LABEL: desugarSameShape(ts:us:)
1515
// CHECK-NEXT: Generic signature: <T..., U... where T : P, ((T, U)...) : Any, U : P>
16-
func desugarSameShape<T..., U...>(ts t: repeat each T, us u: repeat each U) where T: P, U: P, (repeat (each T.A, each U.A)): Any {
16+
func desugarSameShape<T..., U...>(ts t: repeat each T, us u: repeat each U) where each T: P, each U: P, (repeat (each T.A, each U.A)): Any {
1717
}
1818

1919
// CHECK-LABEL: multipleSameShape1(ts:us:vs:)

test/Generics/tuple-conformances.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ protocol P {
1111
func f()
1212
}
1313

14-
extension Builtin.TheTupleType: P where Elements: P {
14+
extension Builtin.TheTupleType: P where each Elements: P {
1515
typealias A = (repeat each Elements.A)
1616
typealias B = Float
1717
func f() {}

test/IRGen/variadic_generic_types.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: rdar104716322
2+
13
// RUN: %target-swift-frontend -emit-ir -primary-file %s -enable-experimental-feature VariadicGenerics | %FileCheck %s
24

35
// Because of -enable-experimental-feature VariadicGenerics
@@ -18,7 +20,7 @@ struct G<T...> {
1820
}
1921

2022
func makeTuple1() -> (repeat each T).Type {
21-
return (repeat T).self
23+
return (repeat each T).self
2224
}
2325

2426
func makeTuple2() -> (repeat Array<each T>).Type {

test/Interpreter/variadic_generic_types.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: rdar104716322
2+
13
// RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics) | %FileCheck %s
24

35
// REQUIRES: executable_test
@@ -7,7 +9,7 @@
79

810
struct G<T...> {
911
func makeTuple() {
10-
print((repeat (Array<T>)).self)
12+
print((repeat (Array<each T>)).self)
1113
}
1214
}
1315

test/SILGen/pack_expansion_type.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: rdar104716322
2+
13
// RUN: %target-swift-emit-silgen %s -enable-experimental-feature VariadicGenerics | %FileCheck %s
24

35
// Experimental features require an asserts compiler
@@ -36,10 +38,10 @@ func variadicMetatypes<T...>(_: repeat each T) {
3638
_ = VariadicType< >.self
3739
_ = VariadicType<Int>.self
3840
_ = VariadicType<Int, String>.self
39-
_ = VariadicType<repeat T>.self
40-
_ = VariadicType<Int, repeat Array<T>>.self
41-
_ = (repeat T).self
42-
_ = (Int, repeat Array<T>).self
43-
_ = ((repeat T) -> ()).self
44-
_ = ((Int, repeat Array<T>) -> ()).self
41+
_ = VariadicType<repeat each T>.self
42+
_ = VariadicType<Int, repeat Array<each T>>.self
43+
_ = (repeat each T).self
44+
_ = (Int, repeat Array<each T>).self
45+
_ = ((repeat each T) -> ()).self
46+
_ = ((Int, repeat Array<each T>) -> ()).self
4547
}

test/type/pack_expansion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct Outer<T...> {
6161
}
6262

6363
struct AlsoGood<U...> {
64-
typealias Value = (repeat (T, E<repeat each U>))
64+
typealias Value = (repeat (each T, E<repeat each U>))
6565
}
6666
}
6767

0 commit comments

Comments
 (0)