Skip to content

Add enum exhaustivity checking #2197

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 5 commits into from
Apr 10, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 5, 2017

This PR adds exhaustivity checking for enum values on top of #1958. The first new commit is b34a95a. It adds child annotations for sealed enum classes that refer to their enum values. What's new is that the symbols referenced by such annotations can be term symbols. Currently the exhaustivity checking does not deal with term symbols, so some tests fail.

@liufengyun Can you take this PR over and adapt exhaustivity checking?

@liufengyun
Copy link
Contributor

Thanks @odersky , I'll take over and make it work.

private def transformMemberDef(tree: MemberDef)(implicit ctx: Context): Unit = {
val sym = tree.symbol
if (sym.is(CaseVal, butNot = Module | Method)) registerChild(sym, sym.info)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice we have this flag, it simplifies a lot of things 👍

odersky and others added 2 commits April 6, 2017 15:38
A new kind of child annotation that points to the term symbol representing an
enum value.
@liufengyun liufengyun force-pushed the add-enum-exhaustiveness branch from a6ee3d7 to 0c4a06f Compare April 6, 2017 13:38
@liufengyun liufengyun changed the title [WIP] Add enum exhaustivity checking Add enum exhaustivity checking Apr 6, 2017
@odersky
Copy link
Contributor Author

odersky commented Apr 10, 2017

Very nice simplifications! LGTM

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