Skip to content

Commit a4eb10a

Browse files
authored
Merge pull request #85 from scala/backport-lts-3.3-21922
Backport "Disallow open modifier on objects" to 3.3 LTS
2 parents d39b4aa + ae3d217 commit a4eb10a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Checking.scala

+2
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

Diff for: 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)