diff options
Diffstat (limited to 'src/continuations/plugin')
-rw-r--r-- | src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala | 22 | ||||
-rw-r--r-- | src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala | 8 |
2 files changed, 12 insertions, 18 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index 585dc3fbe8..cea558d2d3 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -215,13 +215,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with case ldef @ LabelDef(name, params, rhs) => if (hasAnswerTypeAnn(tree.tpe)) { - val sym = currentOwner.newMethod(tree.pos, name) - .setInfo(ldef.symbol.info) - .setFlag(Flags.SYNTHETIC) - - val rhs1 = new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs) - val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe)) - new ChangeOwnerTraverser(currentOwner, sym) traverse rhsVal + val sym = currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info + val rhs1 = new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs) + val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe)) changeOwner (currentOwner -> sym) val stm1 = localTyper.typed(DefDef(sym, rhsVal)) val expr = localTyper.typed(Apply(Ident(sym), List())) @@ -355,12 +351,12 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with val valueTpe = removeAllCPSAnnotations(expr.tpe) - val sym = currentOwner.newValue(tree.pos, newTermName(unit.fresh.newName("tmp"))) - .setInfo(valueTpe) - .setFlag(Flags.SYNTHETIC) - .setAnnotations(List(AnnotationInfo(MarkerCPSSym.tpe, Nil, Nil))) - - new ChangeOwnerTraverser(currentOwner, sym) traverse expr + val sym: Symbol = ( + currentOwner.newValue(newTermName(unit.fresh.newName("tmp")), tree.pos, Flags.SYNTHETIC) + setInfo valueTpe + setAnnotations List(AnnotationInfo(MarkerCPSSym.tpe, Nil, Nil)) + ) + expr.changeOwner(currentOwner -> sym) (stms ::: List(ValDef(sym, expr) setType(NoType)), Ident(sym) setType(valueTpe) setPos(tree.pos), linearize(spc, spcVal)(unit, tree.pos)) diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala index 09aa1b05f7..b2a1546b4e 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala @@ -200,8 +200,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with val expr2 = localTyper.typed(atPos(pos) { Apply(Select(expr1, expr1.tpe.member(cpsNames.flatMapCatch)), List(Ident(funSym))) }) argSym.owner = fun.symbol - val chown = new ChangeOwnerTraverser(currentOwner, fun.symbol) - chown.traverse(rhs) + rhs.changeOwner(currentOwner -> fun.symbol) val exSym = currentOwner.newValueParameter(cpsNames.ex, pos).setInfo(ThrowableClass.tpe) val catch2 = { localTyper.typedCases(tree, List( @@ -263,8 +262,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with val tpe = vd.symbol.tpe val rhs1 = atOwner(vd.symbol) { transform(rhs) } - - new ChangeOwnerTraverser(vd.symbol, currentOwner).traverse(rhs1) // TODO: don't traverse twice + rhs1.changeOwner(vd.symbol -> currentOwner) // TODO: don't traverse twice log("valdef symbol " + vd.symbol + " has type " + tpe) log("right hand side " + rhs1 + " has type " + rhs1.tpe) @@ -306,7 +304,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with val body1 = (new TreeSymSubstituter(List(vd.symbol), List(arg)))(body) val fun = localTyper.typed(atPos(vd.symbol.pos) { Function(List(ValDef(arg)), body1) }) // types body as well arg.owner = fun.symbol - new ChangeOwnerTraverser(currentOwner, fun.symbol).traverse(body1) + body1.changeOwner(currentOwner -> fun.symbol) // see note about multiple traversals above |