Skip to content

Commit ddb6fb4

Browse files
authored
Merge pull request #2495 from hborla/0434-alternative
[SE-0434] Add an alternatives considered section to discuss implicit suppression of `Sendable` for isolated subclassing.
2 parents fb76b84 + 3bec323 commit ddb6fb4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

proposals/0434-global-actor-isolated-types-usability.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ An alternative choice would be to introduce an upcoming feature flag that's enab
248248

249249
The existing adoption implications of `@Sendable` and global actor isolation adoption apply when making use of the rules in this proposal. For example, `@Sendable` and `@MainActor` can be staged into existing APIs using `@preconcurrency`. See [SE-0337: Incremental migration to concurrency checking](/proposals/0337-support-incremental-migration-to-concurrency-checking.md) for more information.
250250

251+
## Alternatives considered
252+
253+
Instead of implicitly suppressing a `Sendable` conformance on isolated subclasses of non-`Sendable`, non-isolated superclasses, the compiler could instead require an explicit opt-out, such as `~Sendable` in the conformance clause. This would make it obvious that the subclass does not have a `Sendable` conformance. However, the programmer does not need to understand that the class does not conform to `Sendable` until they use the type in a way that requires `Sendable`, and the reason for the class not conforming to `Sendable` can be explained with notes attached to the diagnostic. It is also not always the case that global actor isolation implies `Sendable`. Notably, `@MainActor` on a protocol does not imply that the protocol refines `Sendable`, so requiring more boilerplate for programmers in the isolated subclass case does not leave the programmer with a simple rule to remember about when `@MainActor` implies a conformance to `Sendable`.
254+
251255
## Acknowledgments
252256

253257
Thank you to Frederick Kellison-Linn for surfacing the problem with global-actor-isolated function types, and to Kabir Oberai for exploring the implications more deeply.

0 commit comments

Comments
 (0)