Skip to content

Commit ddf57c9

Browse files
committed
Fix #196. Errorneus tail-optimization of inner DefDef's
Unless a DefDef is a result of desugaring an exception handler it shouldn't be optimized by tailrec. There's a potential improvement here: to detect that a DefDef is a label def which itself is called only in tail position. This is a requirement to implement #194
1 parent 5f05c4b commit ddf57c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
311311

312312
case Return(expr, from) =>
313313
tpd.cpy.Return(tree)(noTailTransform(expr), from)
314-
314+
case t: DefDef =>
315+
t // todo: could improve to handle DefDef's with a label flag calls to which are in tail position
315316
case _ =>
316317
super.transform(tree)
317318
}

0 commit comments

Comments
 (0)