-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[Proposal] ~Sendable Conformance for Suppressing Sendable Inference #3030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This proposal introduces `~Sendable` conformance syntax to explicitly suppress a conformance to Sendable, which would prevent automatic `Sendable` inference on types, and provide an alternative way to mark types as non-`Sendable` without inheritance impact.
9278e71 to
570bff1
Compare
…red `Sendable` conformances
| ```swift | ||
| // Actors are always `Sendable`. | ||
| actor A: ~Sendable { // error: cannot both conform to and suppress conformance to 'Sendable' | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've included this case already as well as GAITs below, based on pitch feedback. It would be good to assure ourselves that the text is now complete in terms of covering how the feature interacts with all of the inference rules applicable to Sendable and not found on BitwiseCopyable (or other suppressible protocols).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you propose we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of a foolproof way, but as a starting point I'd imagine one could go through each of the inference rules for Sendable in SE-0302 and SE-0418 [edit: as references to read and consider, not to repeat in this text], then following through to other inference rules incorporated by reference (for example: given actors imply Sendable, then look to actor inference rules).
Looking at SE-0302, for example, it occurs to me that for completeness one might want to state that tuples cannot have their inferred Sendable conformance disabled. And since this proposal prohibits using ~Sendable in scenarios such as generic constraints, one thing we might want to be certain of is that the inference rules for those constraints don't infer Sendable (e.g., for key paths) in a way that a user might want to disable and cannot.
Even if it can't be 100%, that some effort has been made along these lines would no doubt help to round out the completeness of the proposal text by pointing out scenarios where some subtlety is underspecified or just worth clarifying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I added a paragraph to that matter in cd10dee.
This proposal introduces
~Sendableconformance syntax to explicitly suppress a conformance to Sendable, which would prevent automaticSendableinference on types, and provide an alternative way to mark types as non-Sendablewithout inheritance impact.