Skip to content

Sema: Expand isolated conformance inference to consider conformances to inherited protocols #82383

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

Conversation

slavapestov
Copy link
Contributor

Otherwise, if PDerived inherits from P and P's requirements are witnessed by @MainActor-isolated members, we fail to infer @mainactor isolation on the conformance to PDerived.

@slavapestov slavapestov changed the title Sema: Expand isolated conformance isolation to consider conformances to inherited protocols Sema: Expand isolated conformance inference to consider conformances to inherited protocols Jun 20, 2025
@slavapestov slavapestov force-pushed the implied-isolated-conformance branch from d5ebf6c to b1234b3 Compare June 20, 2025 18:39
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov force-pushed the implied-isolated-conformance branch from b1234b3 to e5819c7 Compare June 22, 2025 02:18
…to inherited protocols

Otherwise, if PDerived inherits from P and P's requirements are
witnessed by @MainActor-isolated members, we fail to infer
@mainactor isolation on the conformance to PDerived.

- Fixes swiftlang#82222.
- Fixes rdar://153219831.
@slavapestov slavapestov force-pushed the implied-isolated-conformance branch from e5819c7 to b0b23a0 Compare June 23, 2025 03:21
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov enabled auto-merge June 23, 2025 03:22
@slavapestov slavapestov merged commit a9819a6 into swiftlang:main Jun 23, 2025
3 checks passed
Comment on lines +8160 to +8161
// Also check the value witnesses of each implied conformance to every
// inherited protocol, recursively.
Copy link
Member

@DougGregor DougGregor Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment nit: this isn't checking the value witnesses specifically, it's considering the isolation of the inherited conformances.

Comment on lines +8170 to +8171
if (isolation.isGlobalActor())
return isolation;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we infer isolation for from multiple sources elsewhere (for example, inferring type isolation from the protocols it conforms to), we refuse to infer isolation when there are conflicting inferences.. for example, @MainActor from one source and @SomeOtherGlobalActor from another source. Should we do the same here, rather than eagerly returning the first global actor isolation we find?

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.

Default main actor isolation fails to deeply apply to some protocol hierarchies
2 participants