Skip to content

Commit 2ddb6b9

Browse files
arainkombovel
authored andcommitted
fix: disallow infix objects
Disallow `infix` objects by checking for the `infix` modifier in `Checking.scala`. Part of #17738
1 parent ac2879e commit 2ddb6b9

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-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
@@ -584,6 +584,8 @@ object Checking {
584584
report.error(ModifierNotAllowedForDefinition(Sealed), flagSourcePos(Sealed))
585585
if mods.is(Final, butNot = Synthetic) then
586586
report.warning(RedundantModifier(Final), flagSourcePos(Final))
587+
if mods.is(Infix) then
588+
report.error(ModifierNotAllowedForDefinition(Infix), flagSourcePos(Infix))
587589

588590
/** Check the type signature of the symbol `M` defined by `tree` does not refer
589591
* to a private type or value which is invisible at a point where `M` is still
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
object ToplevelObject:
2+
infix object NestedInfixObject // error
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
infix object ToplevelInfixObject // error

0 commit comments

Comments
 (0)