1
- // RUN: %target-typecheck-verify-swift
1
+ // RUN: %target-typecheck-verify-swift -verify-additional-prefix swift5-
2
+ // RUN: %target-typecheck-verify-swift -swift-version 6 -verify-additional-prefix swift6-
2
3
3
4
extension Int {
4
- func foo( ) -> Int { }
5
+ func foo( ) -> Int { } // expected-note 2 {{'foo()' declared here}}
5
6
var bar : Int {
6
7
get { }
7
8
}
@@ -14,28 +15,53 @@ extension Int {
14
15
15
16
// https://github.com/swiftlang/swift/issues/74857
16
17
func test( i: Int ) {
17
- let _ = i . foo < Int > ( ) // expected-error {{cannot specialize non-generic type '() -> Int'}}
18
+ let _ = i . foo < Int > ( )
19
+ // expected-swift5-warning@-1 {{cannot explicitly specialize instance method 'foo()'}}
20
+ // expected-swift6-error@-2 {{cannot explicitly specialize instance method 'foo()'}}
18
21
19
- let _ = i . gen < Int > ( ) // expected-error {{cannot explicitly specialize a generic function}}
20
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
22
+ let _ = i . gen < Int > ( )
23
+ // expected-swift5-warning@-1 {{cannot explicitly specialize instance method 'gen()'}}
24
+ // expected-swift6-error@-2 {{cannot explicitly specialize instance method 'gen()'}}
25
+ // expected-error@-3 {{generic parameter 'T' could not be inferred}}
21
26
22
- let _ = 0 . foo< Int> ( ) // expected-error {{cannot specialize non-generic type '() -> Int'}}
27
+ let _ = 0 . foo< Int> ( )
28
+ // expected-swift5-warning@-1 {{cannot explicitly specialize instance method 'foo()'}}
29
+ // expected-swift6-error@-2 {{cannot explicitly specialize instance method 'foo()'}}
23
30
24
- let _ = i. gen< Int> // expected-error {{cannot explicitly specialize a generic function}}
25
- // expected-error@-1 {{generic parameter 'T' could not be inferred}}
26
- let _ = i. bar< Int> // expected-error {{cannot specialize non-generic type 'Int'}}
27
- let _ = 0 . bar< Int> // expected-error {{cannot specialize non-generic type 'Int'}}
31
+ let _ = i. gen< Int>
32
+ // expected-swift5-warning@-1 {{cannot explicitly specialize instance method 'gen()'}}
33
+ // expected-swift6-error@-2 {{cannot explicitly specialize instance method 'gen()'}}
34
+ // expected-error@-3 {{generic parameter 'T' could not be inferred}}
35
+ let _ = i. bar< Int>
36
+ // expected-swift5-error@-1 {{cannot specialize non-generic type 'Int'}}
37
+ // expected-swift6-error@-2 {{cannot specialize non-generic type 'Int'}}
38
+ let _ = 0 . bar< Int>
39
+ // expected-swift5-error@-1 {{cannot specialize non-generic type 'Int'}}
40
+ // expected-swift6-error@-2 {{cannot specialize non-generic type 'Int'}}
28
41
}
29
42
30
43
extension Bool {
31
44
func foo< T> ( ) -> T { } // expected-note {{'foo()' declared here}}
32
45
}
33
46
34
- let _: ( ) -> Bool = false . foo< Int> // expected-error {{cannot explicitly specialize a generic function}}
47
+ let _: ( ) -> Bool = false . foo< Int>
48
+ // expected-swift5-warning@-1 {{cannot explicitly specialize instance method 'foo()'}}
49
+ // expected-swift6-error@-2 {{cannot explicitly specialize instance method 'foo()'}}
35
50
36
51
func foo( _ x: Int) {
37
52
_ = {
38
- _ = x < String > // expected-error {{cannot specialize non-generic type 'Int'}}
53
+ _ = x < String >
54
+ // expected-swift5-error@-1 {{cannot specialize non-generic type 'Int'}}
55
+ // expected-swift6-error@-2 {{cannot specialize non-generic type 'Int'}}
39
56
}
40
57
}
41
58
59
+ do {
60
+ struct Test < T> {
61
+ init ( _: ( T ) -> Void ) { } // expected-note {{'init(_:)' declared here}}
62
+ }
63
+
64
+ _ = Test . init< Int> ( { ( _: Int ) -> Void in } )
65
+ // expected-swift5-warning@-1 {{cannot explicitly specialize initializer 'init(_:)'}}
66
+ // expected-swift6-error@-2 {{cannot explicitly specialize initializer 'init(_:)'}}
67
+ }
0 commit comments