Skip to content

Commit b4aa856

Browse files
committed
Don't recognize newlines as statement separators in if-then, while-do
1 parent e4caaf5 commit b4aa856

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ object Parsers {
574574
}
575575

576576
/** Drop (...) or { ... }, replacing the closing element with `endStr` */
577-
def dropParensOrBraces(start: Offset, endStr: String) = {
577+
def dropParensOrBraces(start: Offset, endStr: String): Unit = {
578578
patch(source, Span(start, start + 1), "")
579579
val filler = if (in.lastOffset == in.offset) " " else ""
580580
val closingStartsLine = testChar(skipBlanks(in.lastOffset - 2, -1), Chars.LF)
@@ -1356,7 +1356,7 @@ object Parsers {
13561356
dropParensOrBraces(t.span.start, s" ${tokenString(altToken)}")
13571357
t
13581358
} else {
1359-
val t = expr()
1359+
val t = inSepRegion(LPAREN, RPAREN)(expr())
13601360
accept(altToken)
13611361
if (in.revertCleanRewrite) revertToParens(t)
13621362
t
@@ -1992,7 +1992,9 @@ object Parsers {
19921992

19931993
/*if (in.token == INDENT) inBracesOrIndented(enumerators())
19941994
else*/ {
1995-
val ts = enumerators()
1995+
val ts = // If we use indent syntax, the distinction below should no longer be necessary
1996+
if (in.isAfterLineEnd()) enumerators()
1997+
else inSepRegion(LPAREN, RPAREN)(enumerators())
19961998
if (in.revertCleanRewrite && ts.nonEmpty) {
19971999
patch(source, ts.head.span.startPos, "(")
19982000
patch(source, ts.last.span.endPos, ")")

0 commit comments

Comments
 (0)