3
3
protocol P { }
4
4
5
5
func invalid< let N> ( ) { } // expected-error {{value generic 'N' must have an explicit value type declared}}
6
+ // expected-error@-1 {{generic parameter 'N' is not used in function signature}}
7
+ func invalid< let N> ( _: A < N > ) { } // expected-error {{value generic 'N' must have an explicit value type declared}}
8
+ // expected-error@-1 {{cannot pass type 'N' as a value for generic value 'N'}}
6
9
7
10
struct A < let N: Int > {
8
11
var int : Int {
@@ -21,11 +24,11 @@ struct A<let N: Int> {
21
24
N . self // OK
22
25
}
23
26
24
- var n : N { // expected-error {{using value generic 'let N' here is not allowed}}
27
+ var n : N { // expected-error {{using value generic 'N' here is not allowed}}
25
28
fatalError ( )
26
29
}
27
30
28
- var nType : N . Type { // expected-error {{using value generic 'let N' here is not allowed}}
31
+ var nType : N . Type { // expected-error {{using value generic 'N' here is not allowed}}
29
32
fatalError ( )
30
33
}
31
34
@@ -34,47 +37,47 @@ struct A<let N: Int> {
34
37
}
35
38
}
36
39
37
- extension A where N: P { } // expected-error {{value generic type 'let N' cannot conform to protocol 'P'}}
40
+ extension A where N: P { } // expected-error {{value generic type 'N' cannot conform to protocol 'P'}}
38
41
39
- extension A where N == Int { } // expected-error {{cannot constrain value parameter 'let N' to be type 'Int'}}
42
+ extension A where N == Int { } // expected-error {{cannot constrain value parameter 'N' to be type 'Int'}}
40
43
41
44
func b( with a: A < 123 > ) { } // OK
42
45
func c< let M: Int > ( with a: A < M > ) { } // OK
43
- func d< T> ( with a: A < T > ) { } // expected-error {{cannot pass type 'T' as a value for generic value 'let N'}}
44
- func e( with a: A < Int > ) { } // expected-error {{cannot pass type 'Int' as a value for generic value 'let N'}}
46
+ func d< T> ( with a: A < T > ) { } // expected-error {{cannot pass type 'T' as a value for generic value 'N'}}
47
+ func e( with a: A < Int > ) { } // expected-error {{cannot pass type 'Int' as a value for generic value 'N'}}
45
48
46
49
struct Generic< T : ~ Copyable & ~ Escapable> { }
47
50
struct GenericWithIntParam < T: ~ Copyable & ~ Escapable, let N: Int > { }
48
51
49
52
func f( _: Generic < 123 > ) { } // expected-error {{integer unexpectedly used in a type position}}
50
- func g< let N: Int > ( _: Generic < N > ) { } // expected-error {{cannot use value type 'let N' for generic argument 'T'}}
53
+ func g< let N: Int > ( _: Generic < N > ) { } // expected-error {{cannot use value type 'N' for generic argument 'T'}}
51
54
func h( _: ( Int , 123 ) ) { } // expected-error {{integer unexpectedly used in a type position}}
52
55
func i( _: ( ) -> 123 ) { } // expected-error {{integer unexpectedly used in a type position}}
53
56
func j( _: ( A < 123 > ) -> ( ) ) { } // OK
54
57
func k( _: some 123 ) { } // expected-error {{integer unexpectedly used in a type position}}
55
- func l( _: GenericWithIntParam < 123 , Int> ) { } // expected-error {{cannot pass type 'Int' as a value for generic value 'let N'}}
58
+ func l( _: GenericWithIntParam < 123 , Int> ) { } // expected-error {{cannot pass type 'Int' as a value for generic value 'N'}}
56
59
func m( _: GenericWithIntParam < Int , 123 > ) { } // OK
57
60
58
61
typealias One = 1 // expected-error {{integer unexpectedly used in a type position}}
59
62
60
- struct B < let N: UInt8 > { } // expected-error {{'UInt8' is not a supported value type for 'let N'}}
63
+ struct B < let N: UInt8 > { } // expected-error {{'UInt8' is not a supported value type for 'N'}}
61
64
62
65
struct C < let N: Int , let M: Int > { }
63
66
64
- extension C where N == 123 { // expected-note {{where 'let N' = '0'}}
65
- // expected-note@-1 {{where 'let N' = '0'}}
66
- // expected-note@-2 {{where 'let N' = 'let T'}}
67
+ extension C where N == 123 { // expected-note {{where 'N' = '0'}}
68
+ // expected-note@-1 {{where 'N' = '0'}}
69
+ // expected-note@-2 {{where 'N' = 'T'}}
67
70
func nIs123( ) { }
68
71
}
69
72
70
- extension C where M == 321 { // expected-note {{where 'let M' = '0'}}
71
- // expected-note@-1 {{where 'let M' = '0'}}
72
- // expected-note@-2 {{where 'let M' = 'let T'}}
73
+ extension C where M == 321 { // expected-note {{where 'M' = '0'}}
74
+ // expected-note@-1 {{where 'M' = '0'}}
75
+ // expected-note@-2 {{where 'M' = 'T'}}
73
76
func mIs123( ) { }
74
77
}
75
78
76
- extension C where N == M { // expected-note {{where 'let N' = '123', 'let M' = '0'}}
77
- // expected-note@-1 {{where 'let N' = '0', 'let M' = '321'}}
79
+ extension C where N == M { // expected-note {{where 'N' = '123', 'M' = '0'}}
80
+ // expected-note@-1 {{where 'N' = '0', 'M' = '321'}}
78
81
func nAndMAreBothEqual( ) { }
79
82
}
80
83
@@ -97,8 +100,8 @@ func testC3(with c: C<0, 321>) {
97
100
}
98
101
99
102
func testC4< let T: Int > ( with c: C < T , T > ) {
100
- c. nIs123 ( ) // expected-error {{referencing instance method 'nIs123()' on 'C' requires the types 'let T' and '123' be equivalent}}
101
- c. mIs123 ( ) // expected-error {{referencing instance method 'mIs123()' on 'C' requires the types 'let T' and '321' be equivalent}}
103
+ c. nIs123 ( ) // expected-error {{referencing instance method 'nIs123()' on 'C' requires the types 'T' and '123' be equivalent}}
104
+ c. mIs123 ( ) // expected-error {{referencing instance method 'mIs123()' on 'C' requires the types 'T' and '321' be equivalent}}
102
105
c. nAndMAreBothEqual ( ) // OK
103
106
}
104
107
0 commit comments