Skip to content

Commit 009d623

Browse files
committed
DropBreaks does not track stack changes anymore.
The back-end can now handle labeled-returns across stack differences, so we can emit optimized blocks even in those situations.
1 parent 2d67e6b commit 009d623

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class DropBreaks extends MiniPhase, RecordStackChange:
162162
* source and target of the jump
163163
*/
164164
protected def stackChange(using Context) =
165-
if enclosingBoundaries == 0 then ctx else shadowLabels
165+
ctx // if enclosingBoundaries == 0 then ctx else shadowLabels
166166

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

181+
override def prepareForValDef(tree: ValDef)(using Context): Context =
182+
if tree.symbol.is(Lazy) && tree.symbol.owner == ctx.owner.enclosingMethod then shadowLabels
183+
else ctx
184+
181185
// other stack changing operations are handled in RecordStackChange
182186

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

0 commit comments

Comments
 (0)