Skip to content

Commit

Permalink
Disallow open modifier on objects (#21922)
Browse files Browse the repository at this point in the history
Fixes #21760
  • Loading branch information
hamzaremmal authored Nov 11, 2024
2 parents d78516a + d9b8da5 commit 1947828
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 1947828

Please sign in to comment.