diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index b553e00f3740..0541c13f81d8 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -284,7 +284,16 @@ object Parsers { } def acceptStatSepUnlessAtEnd(altEnd: Token = EOF) = - if (!isStatSeqEnd && in.token != altEnd) acceptStatSep() + if (!isStatSeqEnd) + in.token match { + case EOF => + case `altEnd` => + case NEWLINE | NEWLINES => in.nextToken() + case SEMI => in.nextToken() + case _ => + in.nextToken() // needed to ensure progress; otherwise we might cycle forever + accept(SEMI) + } def errorTermTree = atPos(in.offset) { Literal(Constant(null)) } diff --git a/tests/neg/i1779.scala b/tests/neg/i1779.scala index 92100fa06230..cce32b57c89e 100644 --- a/tests/neg/i1779.scala +++ b/tests/neg/i1779.scala @@ -8,6 +8,6 @@ object Test { def f = { val _parent = 3 q"val hello = $_parent" - q"class $_" // error // error - } + q"class $_" // error + } // error }