|
117 | 117 | let old = self.id // <- partial consumption of 'self'
|
118 | 118 | self = .init(id: new, name: self.name)
|
119 | 119 | return old
|
120 |
| - } |
| 120 | + } |
| 121 | + } |
| 122 | + ``` |
| 123 | + |
| 124 | +* [SE-0430][]: |
| 125 | + |
| 126 | + Region Based Isolation is now extended to enable the application of an |
| 127 | + explicit `sending` annotation to function parameters and results. A function |
| 128 | + parameter or result that is annotated with `sending` is required to be |
| 129 | + disconnected at the function boundary and thus possesses the capability of |
| 130 | + being safely sent across an isolation domain or merged into an actor-isolated |
| 131 | + region in the function's body or the function's caller respectively. Example: |
| 132 | + |
| 133 | + ```swift |
| 134 | + func parameterWithoutSending(_ x: NonSendableType) async { |
| 135 | + // Error! Cannot send a task-isolated value to the main actor! |
| 136 | + await transferToMainActor(x) |
| 137 | + } |
| 138 | + |
| 139 | + func parameterWithSending(_ x: sending NonSendableType) async { |
| 140 | + // Ok since `x` is `sending` and thus disconnected. |
| 141 | + await transferToMainActor(x) |
| 142 | + } |
| 143 | + ``` |
| 144 | + |
| 145 | +* [SE-0414][]: |
| 146 | + |
| 147 | + The compiler is now capable of determining whether or not a value that does |
| 148 | + not conform to the `Sendable` protocol can safely be sent over an isolation |
| 149 | + boundary. This is done by introducing the concept of *isolation regions* that |
| 150 | + allows the compiler to reason conservatively if two values can affect each |
| 151 | + other. Through the usage of isolation regions, the compiler can now prove that |
| 152 | + sending a value that does not conform to the `Sendable` protocol over an |
| 153 | + isolation boundary cannot result in races because the value (and any other |
| 154 | + value that might reference it) is not used in the caller after the point of |
| 155 | + sending allowing code like the following to compile: |
| 156 | + |
| 157 | + ```swift |
| 158 | + actor MyActor { |
| 159 | + init(_ x: NonSendableType) { ... } |
| 160 | + } |
| 161 | + |
| 162 | + func useValue() { |
| 163 | + let x = NonSendableType() |
| 164 | + let a = await MyActor(x) // Error without Region Based Isolation! |
121 | 165 | }
|
122 | 166 | ```
|
123 | 167 |
|
@@ -10405,6 +10449,8 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10405 | 10449 | [SE-0427]: https://github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
|
10406 | 10450 | [SE-0429]: https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
|
10407 | 10451 | [SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
|
| 10452 | +[SE-0414]: https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md |
| 10453 | +[SE-0430]: https://github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md |
10408 | 10454 | [SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
|
10409 | 10455 | [SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md
|
10410 | 10456 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
|
0 commit comments