Skip to content

[6.2] Sema: Expand isolated conformance inference to consider conformances to inherited protocols #82384

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

@slavapestov slavapestov commented Jun 20, 2025

6.2 cherry-pick of #82383

  • Description: This change expands isolated conformance inference to consider conformances 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, forcing the user to write an explicit @MainActor.

  • Scope of the issue: Usability problem with -enable-upcoming-feature IsolatedConformanceInference.

  • Issue: Fixes Default main actor isolation fails to deeply apply to some protocol hierarchies #82222.

  • Radar: Fixes rdar://153219831.

  • Risk: Medium, because it might introduce new request cycles, but only when this feature is enabled. This should be weighted against the usability improvement here.

  • Reviewed by: TBD

@slavapestov slavapestov requested a review from a team as a code owner June 20, 2025 18:39
@slavapestov slavapestov force-pushed the implied-isolated-conformance-6.2 branch 2 times, most recently from bfffb9d to 66eee21 Compare June 23, 2025 03:22
…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-6.2 branch from 66eee21 to f9a6432 Compare June 23, 2025 19:20
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

if (isa<TypeDecl>(requirement))

// Also check the value witnesses of each implied conformance to every
// inherited protocol, recursively.

Choose a reason for hiding this comment

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

Didn't want this to get lost; see Doug Gregor's feedback on this code comment here: #82383 (comment)

auto isolation = assocConf->getIsolation();
if (isolation.isGlobalActor())
return isolation;
}

Choose a reason for hiding this comment

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

Also a question raised by Doug Gregor here regarding the above if: #82383 (comment)

@DougGregor
Copy link
Member

We can handle my feedback in a follow-up

@DougGregor DougGregor merged commit e744e35 into swiftlang:release/6.2 Jun 25, 2025
5 checks passed
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.

3 participants