Skip to content

AST/Sema: Generalize availability fix-its to support custom availability domains #83168

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Jul 18, 2025

When the compiler emits a diagnostic like

func foo() {
  bar() // error: ‘bar()' is only available in MyFeature
}

there should be a fix-it emitted that suggests adding an @available(MyFeature) attribute to foo() and another fix-it that suggests adding if #available(MyFeature) { … }.

Resolves rdar://156118254.

tshortli added 8 commits July 17, 2025 14:14
It has been replaced by `Decl::isAvailableAsSPI()`.

NFC.
It should be preferred over querying the deployment range from the availability
domain returned by `ASTContext::getTargetAvailabilityDomain()`.

NFC.
Make it easier to debug availability by printing to output streams like
`llvm::errs()`.

NFC.
Use these queries to replace some duplicated code. Also, move the
`attr_inlinable_available.swift` test to the `Availability` sub-directory since
the test has more to do with availability checking than it has to do
specifically with the `@inlinable` attr.
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli
Copy link
Contributor Author

Based on top of #83162.

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