|
5 | 5 |
|
6 | 6 | ## Swift 6.0
|
7 | 7 |
|
| 8 | +* [SE-0423][]: |
| 9 | + You can now use `@preconcurrency` attribute to replace static actor isolation |
| 10 | + checking with dynamic checks for witnesses of synchronous nonisolated protocol |
| 11 | + requirements when the witness is isolated. This is common when Swift programs |
| 12 | + need to interoperate with frameworks written in C/C++/Objective-C whose |
| 13 | + implementations cannot participate in static data race safety. |
| 14 | + |
| 15 | + ```swift |
| 16 | + public protocol ViewDelegateProtocol { |
| 17 | + func respondToUIEvent() |
| 18 | + } |
| 19 | + ``` |
| 20 | + |
| 21 | + It's now possible for a `@MainActor`-isolated type to conform to |
| 22 | + `ViewDelegateProtocol` by marking conformance declaration as `@preconcurrency`: |
| 23 | + |
| 24 | + ```swift |
| 25 | + @MainActor |
| 26 | + class MyViewController: ViewDelegateProtocol { |
| 27 | + func respondToUIEvent() { |
| 28 | + // implementation... |
| 29 | + } |
| 30 | + } |
| 31 | + ``` |
| 32 | + |
| 33 | + The compiler would emit dynamic checks into the `respondToUIEvent()` witness |
| 34 | + to make sure that it's always executed in `@MainActor` isolated context. |
| 35 | + |
| 36 | + Additionally, the compiler would emit dynamic actor isolation checks for: |
| 37 | + |
| 38 | + - `@objc` thunks of synchronous actor-isolated members of classes. |
| 39 | + |
| 40 | + - Synchronous actor-isolated function values passed to APIs that |
| 41 | + erase actor isolation and haven't yet adopted strict concurrency checking. |
| 42 | + |
| 43 | + - Call-sites of synchronous actor-isolated functions imported from Swift 6 libraries. |
| 44 | + |
| 45 | + The dynamic actor isolation checks can be disabled using the flag |
| 46 | + `-disable-dynamic-actor-isolation`. |
| 47 | + |
8 | 48 | * [SE-0418][]:
|
9 | 49 |
|
10 | 50 | The compiler would now automatically employ `Sendable` on functions
|
@@ -10366,6 +10406,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10366 | 10406 | [SE-0429]: https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
|
10367 | 10407 | [SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
|
10368 | 10408 | [SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
|
| 10409 | +[SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md |
10369 | 10410 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10370 | 10411 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
10371 | 10412 | [#42728]: <https://github.com/apple/swift/issues/42728>
|
|
0 commit comments