Skip to content

AST: Build availability scopes for custom domain conditionals #80428

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 6 commits into from
Apr 1, 2025

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Apr 1, 2025

When building the AvailabilityScope tree, construct scopes correctly for queries like this:

if #available(CustomDomain) {
  // CustomDomain is available at compiletime/runtime.
} else {
  // CustomDomain is unavailable.
}

This ensures the regions inside the then and the else branches are type-checked correctly. Also, update SILGen to handle these conditionals. If the availability of the custom domain is known at compile time, then the branches of the conditional must be compiled accordingly by constant-folding the branches.

Resolves rdar://138441307 and rdar://138441298.

@tshortli
Copy link
Contributor Author

tshortli commented Apr 1, 2025

@swift-ci please test

tshortli added 5 commits April 1, 2025 07:46
…yContext`.

Preparation for building availability scopes for `if #available` statements
that query non-platform availability domains.
…ptional.

Rather than representing a missing availability range on `PoundAvailableInfo`
with a default-constructed `AvailabilityRange` (empty), store the ranges as
optionals instead. This allows an empty range to represent an availability
condition which is known to be false at compile time, which will be necessary
when generating SIL for `if #available` queries that check custom availability
domains.
@tshortli tshortli force-pushed the custom-availability-domain-scopes branch 2 times, most recently from bb7fbf5 to 1bfd367 Compare April 1, 2025 15:54
…mains.

Resolves rdar://138441298 and rdar://138441307.
@tshortli tshortli force-pushed the custom-availability-domain-scopes branch from 1bfd367 to 303f7d8 Compare April 1, 2025 16:03
@tshortli tshortli changed the title Custom availability domain scopes AST: Build availability scopes for custom domain conditionals Apr 1, 2025
@tshortli
Copy link
Contributor Author

tshortli commented Apr 1, 2025

@swift-ci please smoke test

@tshortli
Copy link
Contributor Author

tshortli commented Apr 1, 2025

@swift-ci please smoke test macOS

@tshortli tshortli enabled auto-merge April 1, 2025 20:30
@tshortli tshortli merged commit 14147bf into swiftlang:main Apr 1, 2025
3 checks passed
@tshortli tshortli deleted the custom-availability-domain-scopes branch April 1, 2025 23:53
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