Skip to content

AST: Improve accuracy of inferred availability for synthesized declarations #64310

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 2 commits into from
Mar 14, 2023

Conversation

tshortli
Copy link
Contributor

Previously, when creating availability attributes for synthesized declarations we would identify some set of reference declarations that the synthesized declaration should be as-available-as. The availability attributes of the reference declarations would then be merged together to create the attributes for the synthesized declaration. The problem with this approach is that the reference declarations themselves may implicitly inherit availability from their enclosing scopes, so the resulting merged attributes could be incomplete. The fix is to walk though the enclosing scopes of the reference declarations, merging the availability attributes found at each level.

Additionally, the merging algorithm that produces inferred availability attributes failed to deal with conflicts between platform specific and platform agnostic availability. Now the merging algorithm notices when platform agnostic availability should take precedence and avoids generating conflicting platform specific attributes.

Resolves rdar://106575142

Previously, when creating availability attributes for synthesized declarations
we would identify some set of reference declarations that the synthesized
declaration should be as-available-as. The availability attributes of the
reference declarations would then be merged together to create the attributes
for the synthesized declaration. The problem with this approach is that the
reference declarations themselves may implicitly inherit availability from their
enclosing scopes, so the resulting merged attributes could be incomplete. The
fix is to walk though the enclosing scopes of the reference declarations,
merging the availability attributes found at each level.

Additionally, the merging algorithm that produces inferred availability
attributes failed to deal with conflicts between platform specific and platform
agnostic availability. Now the merging algorithm notices when platform agnostic
availability should take precedence and avoids generating conflicting platform
specific attributes.

Resolves rdar://106575142
@tshortli tshortli force-pushed the availability-inference branch from 82e7403 to 4058ad1 Compare March 14, 2023 01:27
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli tshortli merged commit 34f4e39 into swiftlang:main Mar 14, 2023
@tshortli tshortli deleted the availability-inference branch March 21, 2023 20:20
tshortli added a commit to tshortli/swift that referenced this pull request Mar 21, 2023
…tainer.

It turns out that we must allow declarations with `introduced:` availability
nested inside of other declarations that are `unavailable` in order to
influence weak linking. Stop diagnosing declarations as being more available
than their unavailable containers and revert some changes to availability
inference that were designed to avoid creating these nestings but caused
regressions for declarations marked `@_spi_available.`

Reverts parts of swiftlang#64310,
swiftlang#64015, and
swiftlang#62900.
etcwilde pushed a commit to etcwilde/swift that referenced this pull request Apr 19, 2023
…tainer.

It turns out that we must allow declarations with `introduced:` availability
nested inside of other declarations that are `unavailable` in order to
influence weak linking. Stop diagnosing declarations as being more available
than their unavailable containers and revert some changes to availability
inference that were designed to avoid creating these nestings but caused
regressions for declarations marked `@_spi_available.`

Reverts parts of swiftlang#64310,
swiftlang#64015, and
swiftlang#62900.
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.

1 participant