Skip to content

Support IfConfigDecl clauses in UseEnumForNamespacing #113

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
Jan 10, 2020

Conversation

klaaspieter
Copy link
Contributor

@klaaspieter klaaspieter commented Dec 20, 2019

Anything inside a IfConfigDecl was ignored when determining if a struct
could be an enum. This looks for IfConfigDeclSyntax in the
MemberDeclListSyntax and only turns the struct into an enum when all of
the clauses have namespace compatible members.

Fixes: https://bugs.swift.org/browse/SR-11830

Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this!

The implementation looks good. For completeness' sake, can you add a couple more tests to make sure we've covered everything?

  • A test that uses an #else instead of an #elseif
  • A test that involves two nested #if blocks in some fashion to verify that we recurse through them properly.

Based on the implementation I think both of those should work, but it'll be good to have the extra test coverage for potential future changes.

@klaaspieter klaaspieter force-pushed the fix-use-enum-if-config branch from d159057 to 722e36d Compare January 6, 2020 12:30
@allevato
Copy link
Member

allevato commented Jan 6, 2020

It looks like the commit history here has commits from the 5.1 branch included in it, which may be the case if you were doing work there. Can you clean that up?

Anything inside a IfConfigDecl was ignored when determining if a struct
could be an enum. This looks for IfConfigDeclSyntax in the
MemberDeclListSyntax and only turns the struct into an enum when all of
the clauses have namespace compatible members.

Fixes: https://bugs.swift.org/browse/SR-11830
@klaaspieter
Copy link
Contributor Author

@allevato Yeah. I'm in the middle of adding those extra tests. I wanted to actually try and test against master so I've been trying to get the swift-DEVELOPMENT-SNAPSHOT-2019-09-26-a toolchain.

Is the only way to get it to build it from source?

@klaaspieter klaaspieter force-pushed the fix-use-enum-if-config branch from 722e36d to 54e5a51 Compare January 7, 2020 15:04
@klaaspieter
Copy link
Contributor Author

Should be fixed now. Although I still haven't been able to test this against master 😞

@dylansturg
Copy link
Contributor

@allevato Yeah. I'm in the middle of adding those extra tests. I wanted to actually try and test against master so I've been trying to get the swift-DEVELOPMENT-SNAPSHOT-2019-09-26-a toolchain.

Is the only way to get it to build it from source?

You can still download that snapshot from Swift.org, it's just hard to find since the link has long-since been removed from the UI. You can just change the date in the download URL to match any snapshot. For example, here's the link for 2019-09-26-a snapshot for use in Xcode:
https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2019-09-26-a/swift-DEVELOPMENT-SNAPSHOT-2019-09-26-a-osx.pkg

@klaaspieter
Copy link
Contributor Author

klaaspieter commented Jan 9, 2020

@dylansturg is it worth updating the README with that link?

@klaaspieter klaaspieter requested a review from allevato January 9, 2020 20:13
@dylansturg
Copy link
Contributor

@dylansturg is it worth updating the README with that link?

I think we want to get away from that old snapshot and onto a newer one that supports the latest Swift-Syntax soonish™️ so it may not be relevant for too much longer.

Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

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

Sorry for the delay—the new tests look great, thanks!

I just pulled the change down myself and tested it against 09-26 to verify, and everything checks out, so this is good to merge.

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