Skip to content

Further adoption of SemanticAvailableAttr #78454

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

tshortli
Copy link
Contributor

@tshortli tshortli commented Jan 7, 2025

Adopt SemanticAvailableAttr as a replacement for AvailableAttr more thoroughly in much of the compiler. Builds on #78308.

NFC.

@tshortli
Copy link
Contributor Author

tshortli commented Jan 7, 2025

@swift-ci please test

@tshortli
Copy link
Contributor Author

tshortli commented Jan 7, 2025

@swift-ci please build macOS toolchain

@tshortli tshortli enabled auto-merge January 7, 2025 02:35
@tshortli tshortli force-pushed the adopt-semantic-available-attr-part-2 branch from d2c2c63 to 77141c5 Compare January 7, 2025 15:31
@tshortli
Copy link
Contributor Author

tshortli commented Jan 7, 2025

@swift-ci please smoke test

@tshortli
Copy link
Contributor Author

tshortli commented Jan 7, 2025

@swift-ci please build macOS toolchain

@QuietMisdreavus
Copy link
Contributor

SymbolGraphGen updates look good. Thanks for pushing this out!

@tshortli tshortli merged commit 28ef3ed into swiftlang:main Jan 7, 2025
3 checks passed
@tshortli tshortli deleted the adopt-semantic-available-attr-part-2 branch January 7, 2025 19:26
tshortli added a commit to tshortli/swift that referenced this pull request Jan 25, 2025
…ions.

In swiftlang#78454 queries for the platform
availability of decl were consolidated into
`Decl::getAvailableAttrForPlatformIntroduction()`. In addition to checking the
attributes directly attached to the decl, this method also checks whether the
decl is a member directly contained inside of an extension and checks for
attributes attached to the extension as well. Previously, this logic was only
used for availability checking diagnostics, where special casing extension
members was a requirement. As a result of the consolidation, though, the logic
is now also shared by the query that determines whether to weakly link symbols
associated with a decl. That determination already had its own way of handling
members of extensions but it seemed like consolidating the logic would stil be
a net improvement that would reduce overall complexity.

Unfortunately, the existing approach to getting the availability of the
enclosing extension had a subtle bug for both AccessorDecl and OpaqueTypeDecl.
If an AvailableAttr was not directly attached to the immediate decl, then
`Decl::getAvailableAttrForPlatformIntroduction()` would check if the enclosing
decl context was an extension and look at its attributes as well. For
AccessorDecl and OpaqueTypeDecl, checking the enclosing decl context would
accidentally skip over the VarDecl and AbstractFunctionDecl that are formally
the parents of those decls for the purposes of attribute inheritance. As a
result, the availability of the enclosing property or function could be ignored
if the enclosing extension had explicit availability attributes.

The fix is to use `AvailabilityInference::parentDeclForInferredAvailability()`
instead of `getDeclContext()` when looking for the immediately enclosing
extension.

Resolves rdar://143139472.
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