Skip to content

Commit 710fe34

Browse files
authored
Merge pull request #3730 from dotty-staging/fix-#3460
Fix #3460: Fix semicolon insertion confusion after enum case
2 parents 9dea057 + 40a2760 commit 710fe34

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,11 @@ object Parsers {
23132313
def enumCase(start: Offset, mods: Modifiers): DefTree = {
23142314
val mods1 = mods.withAddedMod(atPos(in.offset)(Mod.EnumCase())) | Case
23152315
accept(CASE)
2316+
2317+
in.adjustSepRegions(ARROW)
2318+
// Scanner thinks it is in a pattern match after seeing the `case`.
2319+
// We need to get it out of that mode by telling it we are past the `=>`
2320+
23162321
atPos(start, nameStart) {
23172322
val id = termIdent()
23182323
if (in.token == LBRACKET || in.token == LPAREN)

tests/pos/i2906.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
enum Foo {
2+
case A
3+
private case B
4+
@deprecated("Will be removed") case C
5+
@deprecated("Will be removed") private case D
6+
}

tests/pos/i3460.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enum class Ducks
2+
3+
object Ducks {
4+
case Dewey
5+
6+
def wooohoo: Int = 1
7+
}

0 commit comments

Comments
 (0)