From ddf57c9366bdec1e38cff9f6f2c9d72edcdce24a Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 22 Oct 2014 13:41:20 +0200 Subject: [PATCH] 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 --- src/dotty/tools/dotc/transform/TailRec.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/transform/TailRec.scala b/src/dotty/tools/dotc/transform/TailRec.scala index 82b08ef5fb59..71eedadab782 100644 --- a/src/dotty/tools/dotc/transform/TailRec.scala +++ b/src/dotty/tools/dotc/transform/TailRec.scala @@ -311,7 +311,8 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete case Return(expr, from) => tpd.cpy.Return(tree)(noTailTransform(expr), from) - + case t: DefDef => + t // todo: could improve to handle DefDef's with a label flag calls to which are in tail position case _ => super.transform(tree) }