Skip to content

Commit 1947828

Browse files
authored
Disallow open modifier on objects (scala#21922)
Fixes scala#21760
2 parents d78516a + d9b8da5 commit 1947828

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ object Checking {
611611
val mods = mdef.mods
612612
def flagSourcePos(flag: FlagSet) =
613613
mods.mods.find(_.flags == flag).getOrElse(mdef).srcPos
614+
if mods.is(Open) then
615+
report.error(ModifierNotAllowedForDefinition(Open), flagSourcePos(Open))
614616
if mods.is(Abstract) then
615617
report.error(ModifierNotAllowedForDefinition(Abstract), flagSourcePos(Abstract))
616618
if mods.is(Sealed) then

tests/neg/i21760.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open object O // error

0 commit comments

Comments
 (0)