aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-04-15 13:22:47 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-04-15 13:22:47 +0200
commitb38f991ab4948f3358a937604dc28ffa4901270e (patch)
tree85583325cfe25f3635f0cd6ee39f77f837007c76
parent5a0b1918238cb385401f304b22132f51936d795b (diff)
downloadscala-async-b38f991ab4948f3358a937604dc28ffa4901270e.tar.gz
scala-async-b38f991ab4948f3358a937604dc28ffa4901270e.tar.bz2
scala-async-b38f991ab4948f3358a937604dc28ffa4901270e.zip
Rephrase a few pattern matches, fix ANF tracing.
Addresses review comments
-rw-r--r--src/main/scala/scala/async/AnfTransform.scala18
-rw-r--r--src/main/scala/scala/async/TransformUtils.scala2
2 files changed, 9 insertions, 11 deletions
diff --git a/src/main/scala/scala/async/AnfTransform.scala b/src/main/scala/scala/async/AnfTransform.scala
index 82af3c6..da375a5 100644
--- a/src/main/scala/scala/async/AnfTransform.scala
+++ b/src/main/scala/scala/async/AnfTransform.scala
@@ -107,9 +107,7 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
indent += 1
def oneLine(s: Any) = s.toString.replaceAll( """\n""", "\\\\n").take(127)
try {
- AsyncUtils.trace(s"${
- indentString
- }$prefix(${oneLine(args)})")
+ AsyncUtils.trace(s"${indentString}$prefix(${oneLine(args)})")
val result = t
AsyncUtils.trace(s"${indentString}= ${oneLine(result)}")
result
@@ -193,19 +191,19 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
val stats :+ expr = inline.transformToList(qual)
stats :+ attachCopy(tree)(Select(expr, sel).setSymbol(tree.symbol))
- case utils.Applied(fun, targs, argss @ (args :: rest)) if containsAwait =>
+ case Applied(fun, targs, argss) if argss.nonEmpty && containsAwait =>
// we an assume that no await call appears in a by-name argument position,
// this has already been checked.
val funStats :+ simpleFun = inline.transformToList(fun)
def isAwaitRef(name: Name) = name.toString.startsWith(utils.name.await + "$")
val (argStatss, argExprss): (List[List[List[Tree]]], List[List[Tree]]) =
mapArgumentss[List[Tree]](fun, argss) {
- case arg if arg.isByName || isSafeToInline(arg.expr) => (Nil, arg.expr)
- case Arg(arg@Ident(name), _, _) if isAwaitRef(name) => (Nil, arg) // not typed, so it eludes the check in `isSafeToInline`
- case arg =>
- inline.transformToList(arg.expr) match {
- case stats :+ expr =>
- val valDef = defineVal(arg.argName, expr, arg.expr.pos)
+ case Arg(expr, byName, _) if byName || isSafeToInline(expr) => (Nil, expr)
+ case Arg(expr@Ident(name), _, _) if isAwaitRef(name) => (Nil, expr) // not typed, so it eludes the check in `isSafeToInline`
+ case Arg(expr, _, argName) =>
+ inline.transformToList(expr) match {
+ case stats :+ expr1 =>
+ val valDef = defineVal(argName, expr1, expr.pos)
(stats :+ valDef, Ident(valDef.name))
}
}
diff --git a/src/main/scala/scala/async/TransformUtils.scala b/src/main/scala/scala/async/TransformUtils.scala
index 239bea1..7731b83 100644
--- a/src/main/scala/scala/async/TransformUtils.scala
+++ b/src/main/scala/scala/async/TransformUtils.scala
@@ -100,7 +100,7 @@ private[async] final case class TransformUtils[C <: Context](c: C) {
case dd: DefDef => nestedMethod(dd)
case fun: Function => function(fun)
case m@Match(EmptyTree, _) => patMatFunction(m) // Pattern matching anonymous function under -Xoldpatmat of after `restorePatternMatchingFunctions`
- case Applied(fun, targs, argss @ (_ :: _)) =>
+ case Applied(fun, targs, argss) if argss.nonEmpty =>
val isInByName = isByName(fun)
for ((args, i) <- argss.zipWithIndex) {
for ((arg, j) <- args.zipWithIndex) {