File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -652,6 +652,16 @@ object desugar {
652
652
val impl = mdef.impl
653
653
val mods = mdef.mods
654
654
def isEnumCase = mods.isEnumCase
655
+
656
+ def forbidFlag (flag : FlagSet , msg : String ): Unit =
657
+ if (mods is flag)
658
+ ctx.error(hl """ ${flag} modifier $msg for objects """ , mods.mods.find(_.flags == flag).get.pos)
659
+
660
+ forbidFlag(Abstract , " cannot be used" )
661
+ for (flag <- List (Sealed , Final )) {
662
+ forbidFlag(flag, " is redundant" )
663
+ }
664
+
655
665
if (mods is Package )
656
666
PackageDef (Ident (moduleName), cpy.ModuleDef (mdef)(nme.PACKAGE , impl).withMods(mods &~ Package ) :: Nil )
657
667
else if (isEnumCase)
Original file line number Diff line number Diff line change
1
+ abstract object Foo // error
2
+ sealed final abstract case object Bar // error // error // error
You can’t perform that action at this time.
0 commit comments