Skip to content

Fix #3460: Fix semicolon insertion confusion after enum case #3730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/pos/i2906.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum Foo {
case A
private case B
@deprecated("Will be removed") case C
@deprecated("Will be removed") private case D
}
7 changes: 7 additions & 0 deletions tests/pos/i3460.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enum class Ducks

object Ducks {
case Dewey

def wooohoo: Int = 1
}