Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ object Checking {
/** Check that symbol's definition is well-formed. */
def checkWellFormed(sym: Symbol)(using Context): Unit = {
def fail(msg: Message) = report.error(msg, sym.srcPos)
def warn(msg: Message) = report.warning(msg, sym.srcPos)

def checkWithDeferred(flag: FlagSet) =
if (sym.isOneOf(flag))
Expand Down Expand Up @@ -464,8 +465,15 @@ object Checking {
fail(em"only classes can be ${(sym.flags & ClassOnlyFlags).flagsString}")
if (sym.is(AbsOverride) && !sym.owner.is(Trait))
fail(AbstractOverrideOnlyInTraits(sym))
if (sym.is(Trait) && sym.is(Final))
fail(TraitsMayNotBeFinal(sym))
if sym.is(Trait) then
if sym.is(Final) then
fail(TraitsMayNotBeFinal(sym))
else if sym.is(Open) then
warn(RedundantModifier(Open))
if sym.isAllOf(Abstract | Open) then
warn(RedundantModifier(Open))
if sym.is(Open) && sym.isLocal then
warn(RedundantModifier(Open))
// Skip ModuleVal since the annotation will also be on the ModuleClass
if (sym.hasAnnotation(defn.TailrecAnnot) && !sym.isOneOf(Method | ModuleVal))
fail(TailrecNotApplicable(sym))
Expand Down
1 change: 1 addition & 0 deletions tests/neg-custom-args/fatal-warnings/i11963a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open trait Foo // error
1 change: 1 addition & 0 deletions tests/neg-custom-args/fatal-warnings/i11963b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open abstract class Foo // error
6 changes: 6 additions & 0 deletions tests/neg-custom-args/fatal-warnings/i11963c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {
def foo: Any = {
open class Bar // error
new Bar
}
}