diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-24 12:26:32 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-24 12:26:32 +0100 |
commit | d301bea1ca478652ae86397ee3655bc6e4332589 (patch) | |
tree | 3badcf79e3f930eb02364678e3dbdb5271a29d48 /src/main/scala/scala/async/TransformUtils.scala | |
parent | ad75c04daa8521b066c755f2b3cf0b130441adbe (diff) | |
download | scala-async-d301bea1ca478652ae86397ee3655bc6e4332589.tar.gz scala-async-d301bea1ca478652ae86397ee3655bc6e4332589.tar.bz2 scala-async-d301bea1ca478652ae86397ee3655bc6e4332589.zip |
Favouring composition over inheritance.
Diffstat (limited to 'src/main/scala/scala/async/TransformUtils.scala')
-rw-r--r-- | src/main/scala/scala/async/TransformUtils.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/scala/scala/async/TransformUtils.scala b/src/main/scala/scala/async/TransformUtils.scala index 0eca5db..b7bb2ce 100644 --- a/src/main/scala/scala/async/TransformUtils.scala +++ b/src/main/scala/scala/async/TransformUtils.scala @@ -9,11 +9,11 @@ import reflect.ClassTag /** * Utilities used in both `ExprBuilder` and `AnfTransform`. */ -private[async] class TransformUtils[C <: Context](val c: C) { +private[async] final case class TransformUtils[C <: Context](val c: C) { import c.universe._ - private[async] object name { + object name { def suffix(string: String) = string + "$async" def suffixedName(prefix: String) = newTermName(suffix(prefix)) @@ -37,7 +37,7 @@ private[async] class TransformUtils[C <: Context](val c: C) { def fresh(name: String): String = if (name.toString.contains("$")) name else c.fresh("" + name + "$") } - protected def defaultValue(tpe: Type): Literal = { + def defaultValue(tpe: Type): Literal = { val defaultValue: Any = if (tpe <:< definitions.BooleanTpe) false else if (definitions.ScalaNumericValueClasses.exists(tpe <:< _.toType)) 0 @@ -46,7 +46,7 @@ private[async] class TransformUtils[C <: Context](val c: C) { Literal(Constant(defaultValue)) } - protected def isAwait(fun: Tree) = + def isAwait(fun: Tree) = fun.symbol == defn.Async_await /** Descends into the regions of the tree that are subject to the @@ -96,7 +96,7 @@ private[async] class TransformUtils[C <: Context](val c: C) { Set(Boolean_&&, Boolean_||) } - protected def isByName(fun: Tree): (Int => Boolean) = { + def isByName(fun: Tree): (Int => Boolean) = { if (Boolean_ShortCircuits contains fun.symbol) i => true else fun.tpe match { case MethodType(params, _) => @@ -106,12 +106,12 @@ private[async] class TransformUtils[C <: Context](val c: C) { } } - protected def statsAndExpr(tree: Tree): (List[Tree], Tree) = tree match { + def statsAndExpr(tree: Tree): (List[Tree], Tree) = tree match { case Block(stats, expr) => (stats, expr) case _ => (List(tree), Literal(Constant(()))) } - private[async] object defn { + object defn { def mkList_apply[A](args: List[Expr[A]]): Expr[List[A]] = { c.Expr(Apply(Ident(definitions.List_apply), args.map(_.tree))) } |