Skip to content

AST: Introduce SemanticAvailableAttr #78284

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 7 commits into from
Dec 19, 2024

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Dec 19, 2024

Currently, an @available attribute's AvailabilityDomain can be resolved eagerly when parsing, but in the future resolving some availability domains will require name lookup which will have to be done lazily after parsing and may also fail. SemanticAvailableAttr is a new type that wraps an AvailableAttr and its resolved AvailabilityDomain. It should be used throughout the compiler for queries and operations that require valid AvailableAttrs that have successfully resolved domains.

This PR only partially adopts SemanticAvailableAttr. The remainder of the adoption should happen piecemeal, driven by moving the majority of the methods on AvailableAttr over to SemanticAvailableAttr until all that's left on AvailableAttr is the raw, parsed representation which is only accessed through SemanticAvailableAttr.

@tshortli
Copy link
Contributor Author

@swift-ci please test

This new attribute iterator returned from the query makes it simpler to
implement algorithms that need access to both the `AvailableAttr *` and its
corresponding `AvailabilityDomain`. This is also work towards making it
possible to return an optional `AvailabilityDomain` from
`Decl::getDomainForAvailableAttr()`.
This convenience returns an optional `SemanticAvailableAttr` (since in the
future, lookup of the `AvailabilityDomain` can fail). It replaces
`Decl::getDomainForAvailableAttr()`, since most callers will need to form a
`SemanticAvailableAttr` with the resulting domain anyways.
@tshortli tshortli force-pushed the semantic-available-attr branch from a4e5f24 to 111661e Compare December 19, 2024 16:40
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli enabled auto-merge December 19, 2024 21:00
@tshortli tshortli merged commit 965ee8f into swiftlang:main Dec 19, 2024
3 checks passed
@tshortli tshortli deleted the semantic-available-attr branch December 19, 2024 21:19
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