File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 2 files changed +14
-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 flagPos (flag : FlagSet ) = mods.mods.find(_.flags == flag).get.pos
657
+
658
+ if (mods is Abstract )
659
+ ctx.error(hl """ ${" abstract" } modifier cannot be used for objects """ , flagPos(Abstract ))
660
+ for (flag <- List (Sealed , Final )) {
661
+ if (mods is flag)
662
+ ctx.warning(hl """ ${flag.toString} modifier is redundant for objects """ , flagPos(flag))
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
3
+
4
+ abstract override object Baz // error
You can’t perform that action at this time.
0 commit comments