-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Adopt availability macros #39994
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
@swift-ci test |
Build failed |
Fascinating. This feels unrelated, but it's also not been happening outside of this PR. |
@swift-ci test macOS platform |
@@ -1632,6 +1632,9 @@ Parser::parseAvailabilityMacro(SmallVectorImpl<AvailabilitySpec *> &Specs) { | |||
if (NameMatch == Map.end()) | |||
return makeParserSuccess(); // No match, it could be a standard platform. | |||
|
|||
SyntaxParsingContext VersionRestrictionContext( | |||
SyntaxContext, SyntaxKind::AvailabilityVersionRestriction); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do in practice here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what I'm doing, but it feels like these parsing contexts associate parsed entities with information about the specific grammar rule that was used to parse them (or rather, the underlying syntactic role).
This particular one lets Syntax know that SwiftStdlib 5.3
has the same syntactic role as iOS 12.4
. Otherwise these entities (along with the entire decl the attribute appears on) get classified as unknown, which breaks things (incl. -verify-syntax-tree
). (Perhaps these macros should have their own role, but I don't know enough to say for sure (c.f. 84827672).)
Cc @akyrtzi to tell me how terribly wrong I am. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting I missed this in the past and now I see where this is defined for the classic platform availability. Thanks for fixing it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\cc @ahoppen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[SR-15708] [stdlib] Availability macros aren't defined for Linux? |
In the stdlib codebase, replace explicit platform availability incantations of the form
macOS x.y, iOS x.y, watchOS x.y, tvOS x.y
with the availability macros defined in PR #39962.Unfortunately availability macros do not currently work in
if #available
statements in inlinable function bodies, so leave those in place for now, adding a comment specifying the intended macro. (Fixing this isn't trivial, as it requires transforming code emitted into .swiftinterface files, and we aren't set up for that yet.)