2
2
3
3
// REQUIRES: asserts
4
4
5
- struct TupleStruct < First, Rest... > {
6
- var first : First
7
- var rest : ( Rest . . . )
8
- }
9
-
10
- func directAliases( ) {
11
- typealias Tuple < Ts... > = ( Ts . . . )
5
+ func bindAll( ) {
6
+ struct Bind < U... > { }
12
7
13
- typealias Many < T, U, V, Ws... > = Tuple < T , U , V , Ws . . . >
14
-
15
- let _: Many < Int , String , Double , Void , Void , Void , Void > = 42 // expected-error {{cannot convert value of type 'Int' to specified type}}
8
+ typealias Zero = Bind < > // OK
9
+ typealias One = Bind < Int > // OK
10
+ typealias Two = Bind < Int , String > // OK
11
+ typealias Three = Bind < Int , String , Float > // OK
16
12
}
17
13
18
14
func bindPrefix( ) {
19
- struct Bind < Prefix, U... > { }
15
+ struct Bind < Prefix, U... > { } // expected-note {{generic type 'Bind' declared here}}
20
16
21
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
22
- typealias TooFew1 = Bind < String > // OK
23
- typealias TooFew2 = Bind < String , String > // OK
24
- typealias JustRight = Bind < String , String , String > // OK
25
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
17
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 1)}}
18
+ typealias One = Bind < Int > // OK
19
+ typealias Two = Bind < Int , String > // OK
20
+ typealias Three = Bind < Int , String , Float > // OK
26
21
}
27
22
28
23
func bindSuffix( ) {
29
- struct Bind < U... , Suffix> { }
24
+ struct Bind < U... , Suffix> { } // expected-note {{generic type 'Bind' declared here}}
30
25
31
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
32
- typealias TooFew1 = Bind < String > // OK
33
- typealias TooFew2 = Bind < String , String > // OK
34
- typealias JustRight = Bind < String , String , String > // OK
35
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
26
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 1)}}
27
+ typealias One = Bind < Int > // OK
28
+ typealias Two = Bind < Int , String > // OK
29
+ typealias Three = Bind < Int , String , Float > // OK
36
30
}
37
31
38
32
func bindPrefixAndSuffix( ) {
39
- struct Bind < Prefix, U... , Suffix> { } // expected-note {{generic type 'Bind' declared here}}
33
+ struct Bind < Prefix, U... , Suffix> { } // expected-note 2{{generic type 'Bind' declared here}}
34
+
35
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 2)}}
36
+ typealias One = Bind < Int > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
37
+ typealias Two = Bind < Int , String > // OK
38
+ typealias Three = Bind < Int , String , Float > // OK
39
+ typealias Four = Bind < Int , String , Float , Bool > // OK
40
+ }
41
+
42
+ func bindAliasAll( ) {
43
+ typealias Bind < U... > = ( U . . . )
44
+
45
+ typealias Zero = Bind < > // OK
46
+ typealias One = Bind < Int > // OK
47
+ typealias Two = Bind < Int , String > // OK
48
+ typealias Three = Bind < Int , String , Float > // OK
49
+ }
50
+
51
+ func bindAliasPrefix( ) {
52
+ typealias Bind < Prefix, U... > = ( Prefix , U . . . ) // expected-note {{generic type 'Bind' declared here}}
40
53
41
- typealias TooFew0 = Bind < > // expected-error {{expected type}}
42
- typealias TooFew1 = Bind < String > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
43
- typealias TooFew2 = Bind < String , String > // OK
44
- typealias JustRight = Bind < String , String , String > // OK
45
- typealias Oversaturated = Bind < String , String , String , String , String , String , String , String > // OK
54
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 1)}}
55
+ typealias One = Bind < Int > // OK
56
+ typealias Two = Bind < Int , String > // OK
57
+ typealias Three = Bind < Int , String , Float > // OK
46
58
}
59
+
60
+ func bindAliasSuffix( ) {
61
+ typealias Bind < U... , Suffix> = ( U . . . , Suffix ) // expected-note {{generic type 'Bind' declared here}}
62
+
63
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 1)}}
64
+ typealias One = Bind < Int > // OK
65
+ typealias Two = Bind < Int , String > // OK
66
+ typealias Three = Bind < Int , String , Float > // OK
67
+ }
68
+
69
+ func bindAliasPrefixAndSuffix( ) {
70
+ typealias Bind < Prefix, U... , Suffix> = ( Prefix , U . . . , Suffix ) // expected-note 2{{generic type 'Bind' declared here}}
71
+
72
+ typealias Zero = Bind < > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 0, but expected at least 2)}}
73
+ typealias One = Bind < Int > // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
74
+ typealias Two = Bind < Int , String > // OK
75
+ typealias Three = Bind < Int , String , Float > // OK
76
+ typealias Four = Bind < Int , String , Float , Bool > // OK
77
+ }
0 commit comments