Skip to content

Forbid case classes without parameter lists? #6969

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
LPTK opened this issue Jul 30, 2019 · 6 comments · Fixed by #6982
Closed

Forbid case classes without parameter lists? #6969

LPTK opened this issue Jul 30, 2019 · 6 comments · Fixed by #6982
Assignees
Labels
area:parser area:reporting Error reporting including formatting, implicit suggestions, etc help wanted itype:bug

Comments

@LPTK
Copy link
Contributor

LPTK commented Jul 30, 2019

Scalac rejects case classes such as:

@ case class A[T]
(console):1: case classes must have a parameter list; try 'case class A()' or 'case object A'
case class A[T]
               ^

Dotty currently accepts them. This can be confusing in pattern matching: it looks like pattern case A => is matching on instances of class A, but it's actually matching on the companion object.

@LPTK LPTK added the itype:bug label Jul 30, 2019
@smarter smarter added area:reporting Error reporting including formatting, implicit suggestions, etc help wanted labels Jul 30, 2019
@smarter
Copy link
Member

smarter commented Jul 30, 2019

Yes, we should emit the same error as scalac here.

@ashwinbhaskar
Copy link
Contributor

ashwinbhaskar commented Jul 31, 2019

@smarter can I give this a shot? If so, can you please assign it to me as well.

@LPTK
Copy link
Contributor Author

LPTK commented Jul 31, 2019

BTW, you should make sure that enum A { case B[C] } has the same treatment.

@ashwinbhaskar
Copy link
Contributor

@LPTK should this be allowed?

enum A { case B }

@LPTK
Copy link
Contributor Author

LPTK commented Aug 6, 2019

@ashwinbhaskar yes, that's just a case value. You refer to it and match it as B, so there is no confusion here.

@ashwinbhaskar
Copy link
Contributor

@OlivierBlanvillain can the fix be merged now?

ashwinbhaskar added a commit to ashwinbhaskar/dotty that referenced this issue Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:parser area:reporting Error reporting including formatting, implicit suggestions, etc help wanted itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants