Skip to content

[5.10] AST: Fix macCatalyst availability for synthesized declarations #70534

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

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Dec 19, 2023

  • Explanation: The macCatalyst platform availability of a declaration may be inferred from the iOS platform availability of that declaration in the absence of an explicit macCatalyst availability attribute. This means that when inheriting macCatalyst platform availability, the explict iOS availability of an inner ancestor should take precedence over explicit macCatalyst availability of an outer ancestor. The algorithm that computes inferred availability attributes for synthesized declarations was treating macCatalyst and iOS as independent platforms, though, sometimes yielding inapproparite macCatalyst availability.
  • Radar: rdar://107766644
  • Scope: This PR changes the algorithm for generating availability annotations for synthesized declarations. Affected kinds of declarations include the unownedExecutor requirement for actors, implicit _read and _modify accessors, and inherited designated initializers. The change to the algorithm is narrow in that it only suppresses the addition of @available attributes for platforms that inherit availability from other root platforms. Today, the only platforms that meet that criteria are macCatalyst and the platform Extension variants.
  • Risk: Low. Incorrect synthesis of availability attributes could make some derived declarations available when they should not be, leading to missing symbol crashes at runtime when running back deployed apps that reference the inappropriately available. However, the core functionality of existing availability inference behavior is well tested and the scope of the change is limited to less common platforms.
  • Testing: Added tests for synthesis of unownedExecutor decls that, without the fix, demonstrated inappropriate macCatalyst availability.
  • Reviewed By: @xymus, @nkcsgexi, @artemcm
  • main PR: AST: Fix macCatalyst availability for synthesized declarations #70533

The macCatalyst platform availability of a declaration may be inferred from the
iOS platform availability of that declaration in the absence of an explicit
macCatalyst availability attribute. This means that when inheriting macCatalyst
platform availability, the explict iOS availability of an inner ancestor should
take precedence over explicit macCatalyst availability of an outer ancestor.
The algorithm that computes inferred availability attributes for synthesized
declarations was treating macCatalyst and iOS as independent platforms, though,
sometimes yielding inapproparite macCatalyst availability.

Resolves rdar://107766644
@tshortli tshortli added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.10 labels Dec 19, 2023
@tshortli tshortli requested a review from a team as a code owner December 19, 2023 07:53
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli tshortli changed the title [5.10] Catalyst modify accessor inferred availability 5.10 [5.10] AST: Fix macCatalyst availability for synthesized declarations Dec 19, 2023
@airspeedswift airspeedswift merged commit 4f5bbc1 into swiftlang:release/5.10 Dec 19, 2023
@tshortli tshortli deleted the catalyst-modify-accessor-inferred-availability-5.10 branch December 19, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants