1
1
// RUN: %target-typecheck-verify-swift -enable-experimental-variadic-generics
2
2
3
- struct TupleStruct < First, Rest... > {
4
- var first : First
5
- var rest : ( Rest . . . )
6
- }
7
-
8
3
func debugPrint< T... > ( _ items: T ... )
9
4
where T: CustomDebugStringConvertible
10
5
{
@@ -23,44 +18,6 @@ func min<T...: Comparable>(_ values: T...) -> T? {
23
18
return nil
24
19
}
25
20
26
- func directAliases( ) {
27
- typealias Tuple < Ts... > = ( Ts . . . )
28
-
29
- typealias Many < T, U, V, Ws... > = Tuple < T , U , V , Ws . . . >
30
-
31
- let _: Many < Int , String , Double , Void , Void , Void , Void > = 42 // expected-error {{cannot convert value of type 'Int' to specified type}}
32
- }
33
-
34
- func bindPrefix( ) {
35
- struct Bind < Prefix, U... > { }
36
-
37
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
38
- typealias TooFew1 = Bind < String > // OK
39
- typealias TooFew2 = Bind < String , String > // OK
40
- typealias JustRight = Bind < String , String , String > // OK
41
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
42
- }
43
-
44
- func bindSuffix( ) {
45
- struct Bind < U... , Suffix> { }
46
-
47
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
48
- typealias TooFew1 = Bind < String > // OK
49
- typealias TooFew2 = Bind < String , String > // OK
50
- typealias JustRight = Bind < String , String , String > // OK
51
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
52
- }
53
-
54
- func bindPrefixAndSuffix( ) {
55
- struct Bind < Prefix, U... , Suffix> { } // expected-note {{generic type 'Bind' declared here}}
56
-
57
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
58
- typealias TooFew1 = Bind < String > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
59
- typealias TooFew2 = Bind < String , String > // OK
60
- typealias JustRight = Bind < String , String , String > // OK
61
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
62
- }
63
-
64
21
func invalidPacks( ) {
65
22
func monovariadic1( ) -> ( String . . . ) { } // expected-error {{variadic expansion 'String' must contain at least one variadic generic parameter}}
66
23
func monovariadic2< T> ( ) -> ( T . . . ) { } // expected-error {{variadic expansion 'T' must contain at least one variadic generic parameter}}
0 commit comments