File tree 2 files changed +6
-2
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1711,7 +1711,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1711
1711
traverse(stats ++ rest)
1712
1712
case stat :: rest =>
1713
1713
val stat1 = typed(stat)(ctx.exprContext(stat, exprOwner))
1714
- if (! ctx.isAfterTyper && isPureExpr(stat1))
1714
+ if (! ctx.isAfterTyper && isPureExpr(stat1) && ! stat1.tpe.isRef(defn. UnitClass ) )
1715
1715
ctx.warning(em " a pure expression does nothing in statement position " , stat.pos)
1716
1716
buf += stat1
1717
1717
traverse(rest)
Original file line number Diff line number Diff line change @@ -4,4 +4,8 @@ object xfatalWarnings {
4
4
opt match { // error when running with -Xfatal-warnings
5
5
case None =>
6
6
}
7
- }
7
+
8
+ object Test {
9
+ while (true ) {} // should be ok. no "pure expression does nothing in statement position" issued.
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments