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 {
425
425
/** Check that symbol's definition is well-formed. */
426
426
def checkWellFormed (sym : Symbol )(using Context ): Unit = {
427
427
def fail (msg : Message ) = report.error(msg, sym.srcPos)
428
+ def warn (msg : Message ) = report.warning(msg, sym.srcPos)
428
429
429
430
def checkWithDeferred (flag : FlagSet ) =
430
431
if (sym.isOneOf(flag))
@@ -464,8 +465,15 @@ object Checking {
464
465
fail(em " only classes can be ${(sym.flags & ClassOnlyFlags ).flagsString}" )
465
466
if (sym.is(AbsOverride ) && ! sym.owner.is(Trait ))
466
467
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 ))
469
477
// Skip ModuleVal since the annotation will also be on the ModuleClass
470
478
if sym.hasAnnotation(defn.TailrecAnnot ) then
471
479
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