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-
23
34extension Int {
4- func foo( ) -> Int { }
5+ func foo( ) -> Int { } // expected-note 2 {{'foo()' declared here}}
56 var bar : Int {
67 get { }
78 }
@@ -14,28 +15,53 @@ extension Int {
1415
1516// https://github.com/swiftlang/swift/issues/74857
1617func 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()'}}
1821
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}}
2126
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()'}}
2330
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'}}
2841}
2942
3043extension Bool {
3144 func foo< T> ( ) -> T { } // expected-note {{'foo()' declared here}}
3245}
3346
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()'}}
3550
3651func foo( _ x: Int) {
3752 _ = {
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'}}
3956 }
4057}
4158
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