From 2c9e051b0c152d6dbc19d3bdad6ed60c096df213 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 11 Sep 2013 10:17:02 +0200 Subject: Revert a tiny recent refactoring in SelectiveCPSTransform The refactoring in 7e6c723df means that we can't build the CPS plugin if we skip locker in development mode. This commit backs out the refactoring and leaves a TODO comment to perform it at a later date. --- .../scala/tools/selectivecps/SelectiveCPSTransform.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala index a2c2ebc3e3..0210ad3459 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala @@ -330,6 +330,10 @@ abstract class SelectiveCPSTransform extends PluginComponent with } } + // TODO use gen.mkBlock after 2.11.0-M6. Why wait? It allows us to still build in development + // mode with `ant -DskipLocker=1` + def mkBlock(stms: List[Tree], expr: Tree) = if (stms.nonEmpty) Block(stms, expr) else expr + try { if (specialCaseTrivial) { debuglog("will optimize possible tail call: " + bodyExpr) @@ -348,9 +352,9 @@ abstract class SelectiveCPSTransform extends PluginComponent with val argSym = currentOwner.newValue(vd.symbol.name.toTermName).setInfo(tpe) val argDef = localTyper.typed(ValDef(argSym, Select(ctxRef, ctxRef.tpe.member(cpsNames.getTrivialValue)))) val switchExpr = localTyper.typedPos(vd.symbol.pos) { - val body2 = gen.mkBlock(bodyStms :+ bodyExpr).duplicate // dup before typing! + val body2 = mkBlock(bodyStms, bodyExpr).duplicate // dup before typing! If(Select(ctxRef, ctxSym.tpe.member(cpsNames.isTrivial)), - applyTrivial(argSym, gen.mkBlock((argDef :: bodyStms) :+ bodyExpr)), + applyTrivial(argSym, mkBlock(argDef::bodyStms, bodyExpr)), applyCombinatorFun(ctxRef, body2)) } (List(ctxDef), switchExpr) @@ -358,7 +362,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with // ctx.flatMap { => ... } // or // ctx.map { => ... } - (Nil, applyCombinatorFun(rhs1, gen.mkBlock(bodyStms :+ bodyExpr))) + (Nil, applyCombinatorFun(rhs1, mkBlock(bodyStms, bodyExpr))) } } catch { case ex:TypeError => -- cgit v1.2.3