diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 6adac05db82a..fdecb3876ac7 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2313,6 +2313,11 @@ object Parsers { def enumCase(start: Offset, mods: Modifiers): DefTree = { val mods1 = mods.withAddedMod(atPos(in.offset)(Mod.EnumCase())) | Case accept(CASE) + + in.adjustSepRegions(ARROW) + // Scanner thinks it is in a pattern match after seeing the `case`. + // We need to get it out of that mode by telling it we are past the `=>` + atPos(start, nameStart) { val id = termIdent() if (in.token == LBRACKET || in.token == LPAREN) diff --git a/tests/pos/i2906.scala b/tests/pos/i2906.scala new file mode 100644 index 000000000000..1de3937ddb93 --- /dev/null +++ b/tests/pos/i2906.scala @@ -0,0 +1,6 @@ +enum Foo { + case A + private case B + @deprecated("Will be removed") case C + @deprecated("Will be removed") private case D +} diff --git a/tests/pos/i3460.scala b/tests/pos/i3460.scala new file mode 100644 index 000000000000..5ba4e6021cdf --- /dev/null +++ b/tests/pos/i3460.scala @@ -0,0 +1,7 @@ +enum class Ducks + +object Ducks { + case Dewey + + def wooohoo: Int = 1 +}