Skip to content

NFC: Use enum class for ActionClass. #15446

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
Mar 24, 2018

Conversation

davidungar
Copy link
Contributor

A small driver change inspired by batch mode: replacing an enum with an enum class to better enable future refactoring.

@davidungar davidungar requested a review from jrose-apple March 23, 2018 04:55
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

2 similar comments
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@shahmishal
Copy link
Member

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

:-/ I wish disabling implicit conversions wasn't tied to redundant scoping. Can we rename it to Kind or something so that "Action" isn't in the name twice?

@davidungar
Copy link
Contributor Author

There's already an instance variable called Kind, otherwise Kind would be a great name. I could a) let the names collide, which might be confusing, b) rename the instance variable to MyKind, or c) rename ActionClass to ActionKind, which fails to eliminate the redundancy. Which would fit your stye the best?

@gottesmm
Copy link
Contributor

@davidungar Have you considered making this a struct enum instead? The struct enum pattern allows for one to add methods to enums. Or is this used more as a pure enum?

@jrose-apple
Copy link
Contributor

jrose-apple commented Mar 23, 2018

This is a Kind enum like the ones used for dyn_cast. I don't think the struct enum pattern is relevant here.


For the name, I might suggest cheating by calling the field "RawKind", since it's being stored as an unsigned. It's definitely a downside of this naming style to have types and members conflict like this, though!

@davidungar davidungar force-pushed the PR-18-14-ActionClass branch from dfe5935 to a3ee808 Compare March 23, 2018 20:15
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@gottesmm Thanks for the idea! Will keep it this way for now, since it's @jrose-apple 's code.
@jrose-apple Thanks for the concrete suggestions. Have taken them.

@gottesmm
Copy link
Contributor

gottesmm commented Mar 23, 2018

@davidungar I did not read the code, so I accepted Jordan's explanation. If you guys add a bunch of helper functions, it may make sense to perform that transition to change the helper functions to methods on a struct enum. But if you are only using it for dyn_cast, I feel that there is less strength in the case.

@davidungar davidungar merged commit f8f9dca into swiftlang:master Mar 24, 2018
@davidungar davidungar deleted the PR-18-14-ActionClass branch May 16, 2018 16:59
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.

4 participants