Skip to content

Commit ae3d217

Browse files
HarrisL2tgodzik
authored andcommitted
Check for open flag on objects
Fixes scala#21760 [Cherry-picked d9b8da5]
1 parent a262313 commit ae3d217

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ object Checking {
593593
val mods = mdef.mods
594594
def flagSourcePos(flag: FlagSet) =
595595
mods.mods.find(_.flags == flag).getOrElse(mdef).srcPos
596+
if mods.is(Open) then
597+
report.error(ModifierNotAllowedForDefinition(Open), flagSourcePos(Open))
596598
if mods.is(Abstract) then
597599
report.error(ModifierNotAllowedForDefinition(Abstract), flagSourcePos(Abstract))
598600
if mods.is(Sealed) then

tests/neg/i21760.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open object O // error

0 commit comments

Comments
 (0)