aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/TailRec.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-29 17:06:49 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-11 06:39:09 +0200
commitcb18aa3a4ff7eea8626153e27d7266f47851f80c (patch)
tree4c8cc07ce5bac916776bdd91f37f3576337e3d5e /src/dotty/tools/dotc/transform/TailRec.scala
parent5133dfcd00907e96472b14444bd87e0fa62b4dd3 (diff)
downloaddotty-cb18aa3a4ff7eea8626153e27d7266f47851f80c.tar.gz
dotty-cb18aa3a4ff7eea8626153e27d7266f47851f80c.tar.bz2
dotty-cb18aa3a4ff7eea8626153e27d7266f47851f80c.zip
Allow extensions methods to play well with tailrec.
Diffstat (limited to 'src/dotty/tools/dotc/transform/TailRec.scala')
-rw-r--r--src/dotty/tools/dotc/transform/TailRec.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/TailRec.scala b/src/dotty/tools/dotc/transform/TailRec.scala
index 16764de07..82b08ef5f 100644
--- a/src/dotty/tools/dotc/transform/TailRec.scala
+++ b/src/dotty/tools/dotc/transform/TailRec.scala
@@ -84,7 +84,9 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
case dd@DefDef(mods, name, tparams, vparamss0, tpt, rhs0)
if (dd.symbol.isEffectivelyFinal) && !((dd.symbol is Flags.Accessor) || (rhs0 eq EmptyTree) || (dd.symbol is Flags.Label)) =>
val mandatory = dd.symbol.hasAnnotation(defn.TailrecAnnotationClass)
- cpy.DefDef(dd)(rhs = {
+ atGroupEnd { implicit ctx: Context =>
+
+ cpy.DefDef(dd)(rhs = {
val origMeth = tree.symbol
val label = mkLabel(dd.symbol)
@@ -99,7 +101,7 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
// now this speculatively transforms tree and throws away result in many cases
val rhsSemiTransformed = {
val transformer = new TailRecElimination(dd.symbol, owner, thisTpe, mandatory, label)
- val rhs = transformer.transform(rhs0)(ctx.withPhase(ctx.phase.next))
+ val rhs = atGroupEnd(transformer.transform(rhs0)(_))
rewrote = transformer.rewrote
rhs
}
@@ -114,7 +116,8 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
ctx.error("TailRec optimisation not applicable, method not tail recursive", dd.pos)
rhs0
}
- })
+ })
+ }
case d: DefDef if d.symbol.hasAnnotation(defn.TailrecAnnotationClass) =>
ctx.error("TailRec optimisation not applicable, method is neither private nor final so can be overridden", d.pos)
d