[5.0] Extend transitive availability checking to initial value expressions #22516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: A declaration marked unavailable on one platform is allowed to use other declarations marked unavailable on the same platform in its definition. This is especially important for the "application extension" platforms, which expose a subset of the API available on the base platform. However, changes to property initial value type-checking in Swift 5 made them fall outside of this rule. This commit (the important, non-refactoring part of Extend transitive availability checking to initial value expressions (better version) #22460) changes the availability checking logic to look for the associated property decl in an enclosing scope, which makes the code in SR-9867 work again.
Scope: Affects properties marked with
@available
that use other declarations marked with@available
.Issue: SR-9867 / rdar://problem/47852718
Risk: Low. This relaxes restrictions rather than adding them. It does search more of the AST, but only in a simple way based on source ranges.
Testing: Added compiler regression tests, passed source compatibility suite.
Reviewed by: @brentdax, @slavapestov