Skip to content

Forbid enum extending enum #5008

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

Closed
Blaisorblade opened this issue Aug 24, 2018 · 2 comments · Fixed by #5014
Closed

Forbid enum extending enum #5008

Blaisorblade opened this issue Aug 24, 2018 · 2 comments · Fixed by #5014

Comments

@Blaisorblade
Copy link
Contributor

We should forbid this code (discovered in #4961), we already forbid case classes/objects extending enum:

object enumTest {
  enum Test {
    case A
    case B
    case C
  }

  enum Test2 extends Test {
    case D
  }
}
@Blaisorblade Blaisorblade added area:reporting Error reporting including formatting, implicit suggestions, etc area:refchecks labels Aug 24, 2018
@Blaisorblade
Copy link
Contributor Author

I'm guessing refchecks because we can't necessarily resolve Test in the extends clause before typer (beware cycles!), but another phase (typer/posttyper) might be appropriate.

@Blaisorblade Blaisorblade added itype:bug and removed area:reporting Error reporting including formatting, implicit suggestions, etc labels Aug 24, 2018
skvithalani added a commit to skvithalani/dotty that referenced this issue Aug 25, 2018
@Blaisorblade Blaisorblade reopened this Aug 25, 2018
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Aug 25, 2018
Check if we inherit from scala.Enum both directly (as a result of the
desugaring) and indirectly.
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Aug 25, 2018
@Blaisorblade
Copy link
Contributor Author

@hrhino also asks about

enum A ; class B extends A { val enumTag = 1 }

which doesn't seem any better.

Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Aug 26, 2018
Check if we inherit from scala.Enum both directly (as a result of the
desugaring) and indirectly.
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2019
Blaisorblade added a commit that referenced this issue Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant