diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 13bcfcb511df..7d27b3ca82b9 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -247,7 +247,7 @@ object Tokens extends TokensCommon { final val modifierTokensOrCase: TokenSet = modifierTokens | BitSet(CASE) - final val modifierFollowers = modifierTokensOrCase | defIntroTokens + final val modifierFollowers = modifierTokens | defIntroTokens /** Is token only legal as start of statement (eof also included)? */ final val mustStartStatTokens: TokenSet = defIntroTokens | modifierTokens | BitSet(IMPORT, EXPORT, PACKAGE) diff --git a/tests/neg-custom-args/erased/i5525.scala b/tests/neg-custom-args/erased/i5525.scala index 108de00bf1a2..abf8488bd38b 100644 --- a/tests/neg-custom-args/erased/i5525.scala +++ b/tests/neg-custom-args/erased/i5525.scala @@ -1,10 +1,9 @@ - erased enum Foo6 {} // error: only access modifiers allowed -enum Foo10 { - erased case C6() // error: only access modifiers allowed +enum Foo10 { // error: Enumerations must contain at least one case + erased case C6() // error // error } -enum Foo11 { - erased case C6 // error: only access modifiers allowed +enum Foo11 { // error: Enumerations must contain at least one case + erased case C6 // error // error } diff --git a/tests/neg/i5525.scala b/tests/neg/i5525.scala index ceec2c90173f..12ffb4704ba9 100644 --- a/tests/neg/i5525.scala +++ b/tests/neg/i5525.scala @@ -29,6 +29,6 @@ enum Foo11 { protected case C9 // ok } -enum Foo12 { +enum Foo12 { // error: Enumerations must contain at least one case inline case C10() // error: only access modifiers allowed } \ No newline at end of file diff --git a/tests/pos/i15960.scala b/tests/pos/i15960.scala new file mode 100644 index 000000000000..0db7da7017f0 --- /dev/null +++ b/tests/pos/i15960.scala @@ -0,0 +1,9 @@ +class Foo(open: String) { + def bar(n: Int) = n match { + case 0 => open + case _ => throw new IndexOutOfBoundsException() + } + def baz() = open +} + +