Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit 74a0a1e

Browse files
retronymadriaanm
authored andcommitted
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.
1 parent f0b8aa5 commit 74a0a1e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ abstract class SelectiveCPSTransform extends PluginComponent with
330330
}
331331
}
332332

333+
// TODO use gen.mkBlock after 2.11.0-M6. Why wait? It allows us to still build in development
334+
// mode with `ant -DskipLocker=1`
335+
def mkBlock(stms: List[Tree], expr: Tree) = if (stms.nonEmpty) Block(stms, expr) else expr
336+
333337
try {
334338
if (specialCaseTrivial) {
335339
debuglog("will optimize possible tail call: " + bodyExpr)
@@ -348,17 +352,17 @@ abstract class SelectiveCPSTransform extends PluginComponent with
348352
val argSym = currentOwner.newValue(vd.symbol.name.toTermName).setInfo(tpe)
349353
val argDef = localTyper.typed(ValDef(argSym, Select(ctxRef, ctxRef.tpe.member(cpsNames.getTrivialValue))))
350354
val switchExpr = localTyper.typedPos(vd.symbol.pos) {
351-
val body2 = gen.mkBlock(bodyStms :+ bodyExpr).duplicate // dup before typing!
355+
val body2 = mkBlock(bodyStms, bodyExpr).duplicate // dup before typing!
352356
If(Select(ctxRef, ctxSym.tpe.member(cpsNames.isTrivial)),
353-
applyTrivial(argSym, gen.mkBlock((argDef :: bodyStms) :+ bodyExpr)),
357+
applyTrivial(argSym, mkBlock(argDef::bodyStms, bodyExpr)),
354358
applyCombinatorFun(ctxRef, body2))
355359
}
356360
(List(ctxDef), switchExpr)
357361
} else {
358362
// ctx.flatMap { <lhs> => ... }
359363
// or
360364
// ctx.map { <lhs> => ... }
361-
(Nil, applyCombinatorFun(rhs1, gen.mkBlock(bodyStms :+ bodyExpr)))
365+
(Nil, applyCombinatorFun(rhs1, mkBlock(bodyStms, bodyExpr)))
362366
}
363367
} catch {
364368
case ex:TypeError =>

0 commit comments

Comments
 (0)