Skip to content

[5.0] Extend transitive availability checking to initial value expressions #22516

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

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Feb 11, 2019

  • 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

Because initial value expressions aren't actually considered /within/
the VarDecl or PatternBindingDecl they're initializing, the existing
logic to search for availability attributes wasn't kicking in, leading
to errors when a conditionally-unavailable value was used in an
initial value expression for a conditionally-unavailable binding. Fix
this by walking the enclosing type or extension to find the appropriate
PatternBindingDecl.

https://bugs.swift.org/browse/SR-9867
(cherry picked from commit 722cb83)
@jrose-apple jrose-apple requested a review from a team as a code owner February 11, 2019 19:13
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor Author

@swift-ci nominate

@AnnaZaks AnnaZaks merged commit 5060214 into swiftlang:swift-5.0-branch Feb 12, 2019
@jrose-apple jrose-apple deleted the 5.0-i-cannot-contain-my-excitement branch February 12, 2019 01:14
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