Skip to content

Commit

Permalink
Check for open flag on objects
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisL2 authored and KacperFKorban committed Nov 29, 2024
1 parent 9f97997 commit 33f58dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ object Checking {
val mods = mdef.mods
def flagSourcePos(flag: FlagSet) =
mods.mods.find(_.flags == flag).getOrElse(mdef).srcPos
if mods.is(Open) then
report.error(ModifierNotAllowedForDefinition(Open), flagSourcePos(Open))
if mods.is(Abstract) then
report.error(ModifierNotAllowedForDefinition(Abstract), flagSourcePos(Abstract))
if mods.is(Sealed) then
Expand Down
1 change: 1 addition & 0 deletions tests/neg/i21760.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open object O // error

0 comments on commit 33f58dd

Please sign in to comment.