File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -1486,6 +1486,9 @@ trait Checking {
14861486 report.error(ClassCannotExtendEnum (cls, firstParent), cdef.srcPos)
14871487 if cls.isEnumClass && ! isJavaEnum then
14881488 checkExistingOrdinal
1489+ if cls.isEnum && cls.is(Abstract ) then
1490+ if cls.children.exists(! _.isClass) && cls.info.decls.exists(_.is(Deferred )) then
1491+ report.error(em " enum $cls has an abstract member and an unparameterized case " , cdef.srcPos)
14891492 }
14901493
14911494 /** Check that the firstParent for an enum case derives from the declaring enum class, if not, adds it as a parent
Original file line number Diff line number Diff line change 1- -- Error: tests/neg/i22734.scala:3:7 -----------------------------------------------------------------------------------
2- 3 |object X extends T // error status quo
3- | ^
4- | object creation impossible, since def item: String in trait T is not defined
5- -- Error: tests/neg/i22734.scala:6:7 -----------------------------------------------------------------------------------
6- 6 | case Empty // error
7- | ^
8- | object creation impossible, since def item: String in class Foo is not defined
1+ -- Error: tests/neg/i22734.scala:5:5 -----------------------------------------------------------------------------------
2+ 5 |enum Foo { // error
3+ |^
4+ |enum class Foo has an abstract member and an unparameterized case
5+ 6 | case Empty // refchecks error
6+ 7 | case NonEmpty(item: String)
7+ 8 | case Decoy // hopefully not here
8+ 9 | def item: String
9+ 10 |}
Original file line number Diff line number Diff line change 11trait T :
22 def item : String
3- object X extends T // error status quo
3+ object X extends T // refchecks error status quo
44
5- enum Foo {
6- case Empty // error
5+ enum Foo { // error
6+ case Empty // refchecks error
77 case NonEmpty (item : String )
88 case Decoy // hopefully not here
99
You can’t perform that action at this time.
0 commit comments