Skip to content

Commit 758e99b

Browse files
Clarify/simplify preconcurrency conformance #29 (#53)
1 parent b3c83dc commit 758e99b

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

Guide.docc/CommonProblems.md

+10-16
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,10 @@ and interoperate with code that has not yet begun using concurrency at all.
304304
These tools can be helpful both for code you do not own, as well as code you
305305
do own, but cannot easily change.
306306

307-
```swift
308-
@MainActor
309-
class WindowStyler: Styler {
310-
nonisolated func applyStyle() {
311-
MainActor.assumeIsolated {
312-
// implementation body
313-
}
314-
}
315-
}
307+
Annotating a protocol conformance with `@preconcurrency` makes it possible to
308+
suppress errors about any isolation mismatches.
316309

317-
// Improved ergonomics and safety with Swift 6's DynamicActorIsolation
310+
```swift
318311
@MainActor
319312
class WindowStyler: @preconcurrency Styler {
320313
func applyStyle() {
@@ -323,12 +316,13 @@ class WindowStyler: @preconcurrency Styler {
323316
}
324317
```
325318

326-
This technique involves two steps.
327-
It first removes any static isolation that is causing the mismatch.
328-
Then, it re-introduces the isolation dynamically, to allow useful
329-
work within the function body.
330-
This keeps the solution localized to the source of the compiler error.
331-
It is also a great option for making isolation changes incrementally.
319+
This inserts runtime checks to ensure that that static isolation
320+
of the conforming class is always enforced.
321+
322+
> Note: To learn more about incremental adoption and dynamic isolation,
323+
see [Dynamic Isolation][]
324+
325+
[Dynamic Isolation]: incrementaladoption#Dynamic-Isolation
332326

333327
### Isolated Conforming Type
334328

0 commit comments

Comments
 (0)