|
1 | 1 | // RUN: %target-typecheck-verify-swift |
2 | 2 |
|
3 | | -func wantsError<T: Error>(_: T) {} |
4 | | -// expected-note@-1 {{required by global function 'wantsError' where 'T' = 'any ErrorRefinement'}} |
5 | | -// expected-note@-2 {{required by global function 'wantsError' where 'T' = 'any Error & OtherProtocol'}} |
6 | | -// expected-note@-3 {{required by global function 'wantsError' where 'T' = 'any C & Error'}} |
| 3 | +func opensError<T: Error>(_: T) {} |
| 4 | +func wantsError<T: Error>(_: T, _: T) {} |
| 5 | +// expected-note@-1 3{{required by global function 'wantsError' where 'T' = 'any}} |
7 | 6 |
|
8 | 7 | func testSimple(error: Error) { |
9 | | - wantsError(error) |
| 8 | + opensError(error) |
10 | 9 | } |
11 | 10 |
|
12 | 11 | protocol ErrorRefinement : Error {} |
13 | 12 | func testErrorRefinment(error: ErrorRefinement) { |
14 | | - wantsError(error) // expected-error {{type 'any ErrorRefinement' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
| 13 | + opensError(error) // okay |
| 14 | + wantsError(error, error) // expected-error {{type 'any ErrorRefinement' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
15 | 15 | } |
16 | 16 |
|
17 | 17 | protocol OtherProtocol {} |
18 | 18 | func testErrorComposition(error: Error & OtherProtocol) { |
19 | | - wantsError(error) // expected-error {{type 'any Error & OtherProtocol' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
| 19 | + opensError(error) // okay |
| 20 | + wantsError(error, error) // expected-error {{type 'any Error & OtherProtocol' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
20 | 21 | } |
21 | 22 |
|
22 | 23 | class C {} |
23 | 24 | func testErrorCompositionWithClass(error: Error & C) { |
24 | | - wantsError(error) // expected-error {{type 'any C & Error' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
| 25 | + opensError(error) // okay |
| 26 | + wantsError(error, error) // expected-error {{type 'any C & Error' cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}} |
25 | 27 | } |
0 commit comments