Skip to content

Commit 5dfe7d2

Browse files
committed
Add do/while double definition tests and reoptimize
1 parent b5714ec commit 5dfe7d2

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ object Parsers {
13531353
}
13541354
patch(source, cond.span.endPos, "}) ()")
13551355
}
1356-
WhileDo(Block(Block(Nil, body), Block(Nil, cond)), Literal(Constant(())))
1356+
WhileDo(Block(body, cond), Literal(Constant(())))
13571357
}
13581358
case TRY =>
13591359
val tryOffset = in.offset

tests/pos-scala2/doWhile.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Test {
2+
do {
3+
val x = 1
4+
println(x)
5+
} while {
6+
val x = "a"
7+
println(x)
8+
true
9+
}
10+
11+
do {
12+
val x = 1
13+
} while {
14+
val x = "a"
15+
true
16+
}
17+
18+
val x: Int = 3
19+
do {
20+
val x = ""
21+
} while (x == 2)
22+
23+
do (x == 3)
24+
while {
25+
val x = "a"
26+
true
27+
}
28+
29+
}

0 commit comments

Comments
 (0)