File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -701,6 +701,17 @@ object desugar {
701
701
val impl = mdef.impl
702
702
val mods = mdef.mods
703
703
def isEnumCase = mods.isEnumCase
704
+
705
+ def flagSourcePos (flag : FlagSet ) = mods.mods.find(_.flags == flag).fold(mdef.sourcePos)(_.sourcePos)
706
+
707
+ if (mods.is(Abstract ))
708
+ ctx.error(hl """ $Abstract modifier cannot be used for objects """ , flagSourcePos(Abstract ))
709
+ if (mods.is(Sealed ))
710
+ ctx.error(hl """ $Sealed modifier is redundant for objects """ , flagSourcePos(Sealed ))
711
+ // Maybe this should be an error; see https://github.com/scala/bug/issues/11094.
712
+ if (mods.is(Final ) && ! mods.is(Synthetic ))
713
+ ctx.warning(hl """ $Final modifier is redundant for objects """ , flagSourcePos(Final ))
714
+
704
715
if (mods is Package )
705
716
PackageDef (Ident (moduleName), cpy.ModuleDef (mdef)(nme.PACKAGE , impl).withMods(mods &~ Package ) :: Nil )
706
717
else if (isEnumCase)
Original file line number Diff line number Diff line change @@ -2415,16 +2415,6 @@ object Parsers {
2415
2415
2416
2416
def objectDefRest (start : Offset , mods : Modifiers , name : TermName ): ModuleDef = {
2417
2417
val template = templateOpt(emptyConstructor)
2418
-
2419
- def flagSpan (flag : FlagSet ) = mods.mods.find(_.flags == flag).get.span
2420
- if (mods is Abstract )
2421
- syntaxError(hl """ ${Abstract } modifier cannot be used for objects """ , flagSpan(Abstract ))
2422
- if (mods is Sealed )
2423
- syntaxError(hl """ ${Sealed } modifier is redundant for objects """ , flagSpan(Sealed ))
2424
- // Maybe this should be an error; see https://github.com/scala/bug/issues/11094.
2425
- if (mods is Final )
2426
- warning(hl """ ${Final } modifier is redundant for objects """ , source atSpan flagSpan(Final ))
2427
-
2428
2418
finalizeDef(ModuleDef (name, template), mods, start)
2429
2419
}
2430
2420
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ class Namer { typer: Typer =>
270
270
271
271
/** Check that flags are OK for symbol. This is done early to avoid
272
272
* catastrophic failure when we create a TermSymbol with TypeFlags, or vice versa.
273
- * A more complete check is done in checkWellformed .
273
+ * A more complete check is done in checkWellFormed .
274
274
*/
275
275
def checkFlags (flags : FlagSet ) =
276
276
if (flags.isEmpty) flags
You can’t perform that action at this time.
0 commit comments