Skip to content

If a node’s child has node_choices or a collection has element_choices use an enum to ensure there are only matching child nodes #1010

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
merged 1 commit into from
Oct 24, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 23, 2022

This is based on #765 but rebased on main and with all tests passing.

Previously, we relied on runtime checks to make sure only supported node types were used for a child with node_choices. If we explicitly model the set of supported nodes as an enum, we get compile-time safety.

rdar://101200491

@ahoppen ahoppen requested a review from rintaro October 23, 2022 10:09
@ahoppen ahoppen force-pushed the ahoppen/choices-enum branch from 0f0c420 to 80a0b40 Compare October 23, 2022 10:10
@ahoppen
Copy link
Member Author

ahoppen commented Oct 23, 2022

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Oct 23, 2022

swiftlang/swift-stress-tester#206

@swift-ci Please test macOS

…ices` use an enum to ensure there are only matching child nodes

Previously, we relied on runtime checks to make sure only supported node types were used for a child with `node_choices`. If we explicitly model the set of supported nodes as an enum, we get compile-time safety.

rdar://101200491

Co-authored-by: Rintaro Ishizaki <[email protected]>
@ahoppen ahoppen force-pushed the ahoppen/choices-enum branch from 80a0b40 to d3471fd Compare October 24, 2022 07:20
@ahoppen
Copy link
Member Author

ahoppen commented Oct 24, 2022

swiftlang/swift-stress-tester#206

@swift-ci Please test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Thank you for doing this!

@ahoppen ahoppen merged commit 07aa98a into swiftlang:main Oct 24, 2022
@ahoppen ahoppen deleted the ahoppen/choices-enum branch October 24, 2022 22:00
allevato added a commit to allevato/swift-format that referenced this pull request Oct 24, 2022
That swift-syntax change switched many accessors that degraded to `Syntax`
type to return enums of their possibilities instead.

DO NOT MERGE this still has one failing test.
allevato added a commit to allevato/swift-format that referenced this pull request Oct 25, 2022
That swift-syntax change switched many accessors that degraded to `Syntax`
type to return enums of their possibilities instead.
allevato added a commit to swiftlang/swift-format that referenced this pull request Oct 25, 2022
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