Skip to content

Commit

Permalink
DropBreaks does not track stack changes anymore.
Browse files Browse the repository at this point in the history
The back-end can now handle labeled-returns across stack
differences, so we can emit optimized blocks even in those
situations.
sjrd committed Jan 12, 2023
1 parent 2d67e6b commit 009d623
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/DropBreaks.scala
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ class DropBreaks extends MiniPhase, RecordStackChange:
* source and target of the jump
*/
protected def stackChange(using Context) =
if enclosingBoundaries == 0 then ctx else shadowLabels
ctx // if enclosingBoundaries == 0 then ctx else shadowLabels

/** Need to suppress labeled returns if there is an intervening try
*/
@@ -178,6 +178,10 @@ class DropBreaks extends MiniPhase, RecordStackChange:
case Break(_, _) => ctx
case _ => stackChange

override def prepareForValDef(tree: ValDef)(using Context): Context =
if tree.symbol.is(Lazy) && tree.symbol.owner == ctx.owner.enclosingMethod then shadowLabels
else ctx

// other stack changing operations are handled in RecordStackChange

/** If `tree` is a BreakBoundary, transform it as follows:

0 comments on commit 009d623

Please sign in to comment.