Skip to content

Commit 0897f2e

Browse files
committed
Cast the while(true) loop to Nothing instead of throw null.
In fact, since we are after erasure, we have to materialize a `BoxedUnit.UNIT`, and cast that to `Nothing`.
1 parent b3b59d5 commit 0897f2e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/transform/TailRec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import reporting.diagnostic.messages.TailrecNotApplicable
7575
* }
7676
* }
7777
* }
78-
* throw null // unreachable
78+
* BoxedUnit.UNIT.asInstanceOf[Nothing] // unreachable
7979
* }
8080
* }}}
8181
*
@@ -170,7 +170,7 @@ class TailRec extends MiniPhase {
170170
})
171171
}) ::
172172
Nil,
173-
Throw(Literal(Constant(null))) // unreachable code
173+
ref(defn.BoxedUnit_UNIT).asInstance(defn.NothingType) // unreachable code
174174
)
175175
} else {
176176
if (mandatory) ctx.error(

0 commit comments

Comments
 (0)