diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-07-25 00:14:04 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-07-25 00:14:04 +1000 |
commit | 3b9d72928738f34449b1e67a18623458bdcd16d5 (patch) | |
tree | 56cd3e782632b11a8bc4921b91f937be6c98f192 /src/main/scala | |
parent | 6721d1825e3bedac7585b1b7a35059ef6adb07c0 (diff) | |
download | scala-async-3b9d72928738f34449b1e67a18623458bdcd16d5.tar.gz scala-async-3b9d72928738f34449b1e67a18623458bdcd16d5.tar.bz2 scala-async-3b9d72928738f34449b1e67a18623458bdcd16d5.zip |
Preserve ApplyImplicitView / ApplyImplicitArgs in AnfTransform.
Diffstat (limited to 'src/main/scala')
-rw-r--r-- | src/main/scala/scala/async/internal/AnfTransform.scala | 21 | ||||
-rw-r--r-- | src/main/scala/scala/async/internal/TransformUtils.scala | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/main/scala/scala/async/internal/AnfTransform.scala b/src/main/scala/scala/async/internal/AnfTransform.scala index 6434315..d98aaa3 100644 --- a/src/main/scala/scala/async/internal/AnfTransform.scala +++ b/src/main/scala/scala/async/internal/AnfTransform.scala @@ -187,15 +187,24 @@ private[async] trait AnfTransform { val valDef = defineVal(argName, expr1, expr1.pos) require(valDef.tpe != null, valDef) val stats1 = stats :+ valDef - //stats1.foreach(changeOwner(_, currentOwner, currentOwner.owner)) - (stats1, gen.stabilize(gen.mkAttributedIdent(valDef.symbol))) + (stats1, atPos(tree.pos.makeTransparent)(gen.stabilize(gen.mkAttributedIdent(valDef.symbol)))) } } - val applied = treeInfo.dissectApplied(tree) - val core = if (targs.isEmpty) simpleFun else treeCopy.TypeApply(applied.callee, simpleFun, targs) - val newApply = argExprss.foldLeft(core)(Apply(_, _)).setSymbol(tree.symbol) - val typedNewApply = localTyper.typedPos(tree.pos)(newApply).setType(tree.tpe) + + def copyApplied(tree: Tree, depth: Int): Tree = { + tree match { + case TypeApply(_, targs) => treeCopy.TypeApply(tree, simpleFun, targs) + case _ if depth == 0 => simpleFun + case Apply(fun, args) => + val newTypedArgs = map2(args.map(_.pos), argExprss(depth - 1))((pos, arg) => localTyper.typedPos(pos)(arg)) + treeCopy.Apply(tree, copyApplied(fun, depth - 1), newTypedArgs) + } + } + + val typedNewApply = copyApplied(tree, treeInfo.dissectApplied(tree).applyDepth) + funStats ++ argStatss.flatten.flatten :+ typedNewApply + case Block(stats, expr) => (stats :+ expr).flatMap(linearize.transformToList) diff --git a/src/main/scala/scala/async/internal/TransformUtils.scala b/src/main/scala/scala/async/internal/TransformUtils.scala index 2582c91..70237bc 100644 --- a/src/main/scala/scala/async/internal/TransformUtils.scala +++ b/src/main/scala/scala/async/internal/TransformUtils.scala @@ -111,7 +111,7 @@ private[async] trait TransformUtils { args match { case args :+ Typed(tree, Ident(tpnme.WILDCARD_STAR)) => val (a, argExprs :+ lastArgExpr) = (args :+ tree).zipWithIndex.map(f.tupled).unzip - val exprs = argExprs :+ Typed(lastArgExpr, Ident(tpnme.WILDCARD_STAR)).setPos(lastArgExpr.pos) + val exprs = argExprs :+ atPos(lastArgExpr.pos.makeTransparent)(Typed(lastArgExpr, Ident(tpnme.WILDCARD_STAR))) (a, exprs) case args => args.zipWithIndex.map(f.tupled).unzip |