File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/fatal-warnings Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -425,6 +425,7 @@ object Checking {
425425 /** Check that symbol's definition is well-formed. */
426426 def checkWellFormed (sym : Symbol )(using Context ): Unit = {
427427 def fail (msg : Message ) = report.error(msg, sym.srcPos)
428+ def warn (msg : Message ) = report.warning(msg, sym.srcPos)
428429
429430 def checkWithDeferred (flag : FlagSet ) =
430431 if (sym.isOneOf(flag))
@@ -464,8 +465,15 @@ object Checking {
464465 fail(em " only classes can be ${(sym.flags & ClassOnlyFlags ).flagsString}" )
465466 if (sym.is(AbsOverride ) && ! sym.owner.is(Trait ))
466467 fail(AbstractOverrideOnlyInTraits (sym))
467- if (sym.is(Trait ) && sym.is(Final ))
468- fail(TraitsMayNotBeFinal (sym))
468+ if sym.is(Trait ) then
469+ if sym.is(Final ) then
470+ fail(TraitsMayNotBeFinal (sym))
471+ else if sym.is(Open ) then
472+ warn(RedundantModifier (Open ))
473+ if sym.isAllOf(Abstract | Open ) then
474+ warn(RedundantModifier (Open ))
475+ if sym.is(Open ) && sym.isLocal then
476+ warn(RedundantModifier (Open ))
469477 // Skip ModuleVal since the annotation will also be on the ModuleClass
470478 if sym.hasAnnotation(defn.TailrecAnnot ) then
471479 if ! sym.isOneOf(Method | ModuleVal ) then
Original file line number Diff line number Diff line change 1+ open trait Foo // error
Original file line number Diff line number Diff line change 1+ open abstract class Foo // error
Original file line number Diff line number Diff line change 1+ object Test {
2+ def foo : Any = {
3+ open class Bar // error
4+ new Bar
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments