Skip to content

Parse: Require a "before: " label in @_backDeploy attribute #41893

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

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Mar 18, 2022

Require a "before: " label in the first item of the list in the @_backDeploy attribute in order to match the pitched syntax for the attribute:

@available(macOS 11.0, *)
@_backDeploy(before: macOS 12.0)
public func foo() {}

The previous implementation of parsing the @_backDeploy attribute body used the parseList() utility. With the addition of the "before:" label, it was no longer possible to use that utility unchanged because the necessary syntax node creation could not be nested properly to match the following grammar:

back-deploy-attr-spec-list -> 'before' ':' back-deploy-version-list
back-deploy-version-list   -> back-deploy-version-entry back-deploy-version-list?
back-deploy-version-entry  -> availability-version-restriction ','?

I refactored the loop body out of parseList() into a separate parseListItem() function that could be used by the attribute parsing implementation, avoiding duplication of much of the list parsing logic while also allowing more control over syntax node creation.

Resolves rdar://90374640

@tshortli tshortli force-pushed the add-before-label-to-back-deploy-attr branch from 17f5fab to 8855edb Compare March 18, 2022 18:10
…e @_backDeploy attribute in order to match the pitched syntax for the attribute. Refactor existing comma separated list parsing code to take advantage of part of it in the attribute parsing.
@tshortli tshortli force-pushed the add-before-label-to-back-deploy-attr branch from 8855edb to 2a646dc Compare March 18, 2022 18:31
@tshortli tshortli marked this pull request as ready for review March 18, 2022 18:41
@tshortli tshortli requested review from xymus and nkcsgexi March 18, 2022 18:42
@tshortli
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

@tshortli
Copy link
Contributor Author

swiftlang/swift-syntax#376

@swift-ci please test

@tshortli
Copy link
Contributor Author

swiftlang/swift-syntax#376

@swift-ci please test Linux

2 similar comments
@tshortli
Copy link
Contributor Author

swiftlang/swift-syntax#376

@swift-ci please test Linux

@tshortli
Copy link
Contributor Author

swiftlang/swift-syntax#376

@swift-ci please test Linux

@tshortli tshortli merged commit 1f39f27 into swiftlang:main Mar 21, 2022
@tshortli tshortli deleted the add-before-label-to-back-deploy-attr branch March 29, 2022 21:26
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.

3 participants