diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index 6306d2535e18..e79a8cc55df7 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -1332,7 +1332,7 @@ object Parsers {
case DO =>
in.errorOrMigrationWarning(
i"""`do
while ' is no longer supported,
- |use `while { ; } do ()' instead.
+ |use `while ({ ; }) ()' instead.
|The statement can be rewritten automatically under -language:Scala2 -migration -rewrite.
""")
val start = in.skipToken()
@@ -1353,7 +1353,7 @@ object Parsers {
}
patch(source, cond.span.endPos, "}) ()")
}
- WhileDo(Block(body :: Nil, cond), Literal(Constant(())))
+ WhileDo(Block(body, cond), Literal(Constant(())))
}
case TRY =>
val tryOffset = in.offset
diff --git a/tests/pos-scala2/doWhile.scala b/tests/pos-scala2/doWhile.scala
new file mode 100644
index 000000000000..1e70923381c3
--- /dev/null
+++ b/tests/pos-scala2/doWhile.scala
@@ -0,0 +1,29 @@
+class Test {
+ do {
+ val x = 1
+ println(x)
+ } while {
+ val x = "a"
+ println(x)
+ true
+ }
+
+ do {
+ val x = 1
+ } while {
+ val x = "a"
+ true
+ }
+
+ val x: Int = 3
+ do {
+ val x = ""
+ } while (x == 2)
+
+ do (x == 3)
+ while {
+ val x = "a"
+ true
+ }
+
+}