Skip to content

Transform nested structs in UseEnumForNamespacing. #138

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
Feb 3, 2020

Conversation

dylansturg
Copy link
Contributor

The rule was not visiting any structs nested in other structs, because it wasn't calling super to visit the node's children.

I tried to combine super.visit with the member enumeration in membersToKeepIfUsedAsNamespace(_:) but that method intentionally returns nil to signal that the decl shouldn't be rewritten which would discard the changes to the nested nodes. Instead, the rule now visits the members and uses the rewritten member list even if it's not converted to an enum to keep any changes to nested structs.

The rule was not visiting any structs nested in other structs, because it wasn't calling super to visit the node's children.

I tried to combine `super.visit` with the member enumeration in `membersToKeepIfUsedAsNamespace(_:)` but that method intentionally returns nil to signal that the decl shouldn't be rewritten which would discard the changes to the nested nodes. Instead, the rule now visits the members and uses the rewritten member list even if it's not converted to an enum to keep any changes to nested structs.
@allevato allevato merged commit 01914f8 into swiftlang:master Feb 3, 2020
@dylansturg dylansturg deleted the use_enums_must_go_deeper branch February 12, 2020 20:34
aaditya-chandrasekhar pushed a commit to val-verde/swift-format that referenced this pull request May 20, 2021
…able declaration code blocks (swiftlang#150)

* Omit initializer expression if closure or function call to ensure reasonable declaration code blocks.

Resolves swiftlang#138

* Add changelog entry for swiftlang#150
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