|
5 | 5 |
|
6 | 6 | ## Swift 6.0
|
7 | 7 |
|
| 8 | +* [SE-0430][]: |
| 9 | + |
| 10 | + Region Based Isolation is now extended to enable the application of an |
| 11 | + explicit `sending` annotation to function parameters and results. A function |
| 12 | + parameter or result that is annotated with `sending` is required to be |
| 13 | + disconnected at the function boundary and thus possesses the capability of |
| 14 | + being safely sent across an isolation domain or merged into an actor-isolated |
| 15 | + region in the function's body or the function's caller respectively. Example: |
| 16 | + |
| 17 | + ```swift |
| 18 | + func parameterWithoutSending(_ x: NonSendableType) async { |
| 19 | + // Error! Cannot send a task-isolated value to the main actor! |
| 20 | + await transferToMainActor(x) |
| 21 | + } |
| 22 | + |
| 23 | + func parameterWithSending(_ x: sending NonSendableType) async { |
| 24 | + // Ok since `x` is `sending` and thus disconnected. |
| 25 | + await transferToMainActor(x) |
| 26 | + } |
| 27 | + ``` |
| 28 | + |
| 29 | +* [SE-0414][]: |
| 30 | + |
| 31 | + The compiler is now capable of determining whether or not a value that does |
| 32 | + not conform to the `Sendable` protocol can safely be sent over an isolation |
| 33 | + boundary. This is done by introducing the concept of *isolation regions* that |
| 34 | + allows the compiler to reason conservatively if two values can affect each |
| 35 | + other. Through the usage of isolation regions, the compiler can now prove that |
| 36 | + sending a value that does not conform to the `Sendable` protocol over an |
| 37 | + isolation boundary cannot result in races because the value (and any other |
| 38 | + value that might reference it) is not used in the caller after the point of |
| 39 | + sending allowing code like the following to compile: |
| 40 | + |
| 41 | + ```swift |
| 42 | + actor MyActor { |
| 43 | + init(_ x: NonSendableType) { ... } |
| 44 | + } |
| 45 | + |
| 46 | + func useValue() { |
| 47 | + let x = NonSendableType() |
| 48 | + let a = await MyActor(x) // Error without Region Based Isolation! |
| 49 | + } |
| 50 | + ``` |
| 51 | + |
8 | 52 | * [SE-0427][]:
|
9 | 53 | You can now suppress `Copyable` on protocols, generic parameters,
|
10 | 54 | and existentials:
|
@@ -10287,6 +10331,8 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10287 | 10331 | [SE-0413]: https://github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
|
10288 | 10332 | [SE-0422]: https://github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
|
10289 | 10333 | [SE-0427]: https://github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
|
| 10334 | +[SE-0414]: https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md |
| 10335 | +[SE-0430]: https://github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md |
10290 | 10336 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10291 | 10337 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
10292 | 10338 | [#42728]: <https://github.com/apple/swift/issues/42728>
|
|
0 commit comments