Skip to content

[SE-0470] Infer nonisolated on conformances #2893

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

Merged
merged 5 commits into from
Jul 9, 2025

Conversation

DougGregor
Copy link
Member

Introduce two inference rules that infer nonisolated when InferIsolatedConformances is enabled. These inference rules ensure that most conformances that should be nonisolated remain nonisolated, particular when we're in the main-actor-by-default mode. The end result is that much less code needs to change when enabling isolated conformance inference (including via main-actor-by-default mode). The two rules are:

  • If the protocol inherits from SendableMetatype (including indirectly, e.g., from Sendable), then the isolated conformance could never be used, so it is inferred to be nonisolated.
  • If all of the declarations used to satisfy protocol requirements are nonisolated, the conformance will be assumed to be nonisolated.

Introduce two inference rules that infer `nonisolated` when
`InferIsolatedConformances` is enabled. These inference rules ensure
that most conformances that should be nonisolated remain nonisolated,
particular when we're in the main-actor-by-default mode. The end
result is that much less code needs to change when enabling isolated
conformance inference (including via main-actor-by-default mode). The
two rules are:

* If the protocol inherits from `SendableMetatype` (including
indirectly, e.g., from `Sendable`), then the isolated conformance
could never be used, so it is inferred to be `nonisolated`.
* If all of the declarations used to satisfy protocol requirements are
`nonisolated`, the conformance will be assumed to be `nonisolated`.
@xwu xwu merged commit 2b01fe1 into swiftlang:main Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants