|
2 | 2 |
|
3 | 3 | // REQUIRES: asserts
|
4 | 4 |
|
5 |
| -func testArg(_ x: sending String) { |
| 5 | +class NonSendable { |
| 6 | + init(){} |
6 | 7 | }
|
7 | 8 |
|
8 |
| -func testResult() -> sending String { |
9 |
| - "" |
| 9 | +func testArg(_ x: sending NonSendable) { |
10 | 10 | }
|
11 | 11 |
|
12 |
| -func testArgResult(_ x: sending String) -> sending String { |
| 12 | +func testResult() -> sending NonSendable { |
| 13 | + return NonSendable() |
| 14 | +} |
| 15 | + |
| 16 | +func testArgResult(_ x: sending NonSendable) -> sending NonSendable { |
13 | 17 | }
|
14 | 18 |
|
15 | 19 | func testVarDeclDoesntWork() {
|
16 |
| - var x: sending String // expected-error {{'sending' may only be used on parameter}} |
| 20 | + var x: sending NonSendable // expected-error {{'sending' may only be used on parameter}} |
17 | 21 | }
|
18 | 22 |
|
19 |
| -func testVarDeclTupleElt() -> (sending String, String) {} // expected-error {{'sending' cannot be applied to tuple elements}} |
| 23 | +func testVarDeclTupleElt() -> (sending NonSendable, NonSendable) {} // expected-error {{'sending' cannot be applied to tuple elements}} |
20 | 24 |
|
21 |
| -func testVarDeclTuple2(_ x: (sending String)) {} |
22 |
| -func testVarDeclTuple2(_ x: (sending String, String)) {} // expected-error {{'sending' cannot be applied to tuple elements}} |
| 25 | +func testVarDeclTuple2(_ x: (sending NonSendable)) {} |
| 26 | +func testVarDeclTuple2(_ x: (sending NonSendable, NonSendable)) {} // expected-error {{'sending' cannot be applied to tuple elements}} |
23 | 27 |
|
24 |
| -func testArgWithConsumingWrongOrder(_ x: sending consuming String, _ y: sending inout String) {} |
| 28 | +func testArgWithConsumingWrongOrder(_ x: sending consuming NonSendable, _ y: sending inout NonSendable) {} |
25 | 29 | // expected-error @-1 {{'sending' must be placed after specifier 'consuming'}}
|
26 | 30 | // expected-error @-2 {{'sending' must be placed after specifier 'inout'}}
|
27 | 31 |
|
28 |
| -func testArgWithConsumingWrongOrderType(_ x: (sending consuming String, sending inout String) -> ()) {} |
| 32 | +func testArgWithConsumingWrongOrderType(_ x: (sending consuming NonSendable, sending inout NonSendable) -> ()) {} |
29 | 33 | // expected-error @-1 {{'sending' must be placed after specifier 'consuming'}}
|
30 | 34 | // expected-error @-2 {{'sending' must be placed after specifier 'inout'}}
|
31 | 35 |
|
32 |
| -func testBorrowSending(_ x: borrowing sending String) {} |
| 36 | +func testBorrowSending(_ x: borrowing sending NonSendable) {} |
33 | 37 | // expected-error @-1 {{'sending' cannot be used together with 'borrowing'}}
|
0 commit comments