summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-04 18:12:21 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-04 18:12:21 -0700
commit937e27ace7ad9ab071082f3dcdaa14f07437754a (patch)
tree92cc64a84e60365827cf53f31d4e8ce32a316c9d /core/src/main
parent7360d060f8da122cf233f6b761cc49044574d2fc (diff)
downloadmill-937e27ace7ad9ab071082f3dcdaa14f07437754a.tar.gz
mill-937e27ace7ad9ab071082f3dcdaa14f07437754a.tar.bz2
mill-937e27ace7ad9ab071082f3dcdaa14f07437754a.zip
Swap over to `typingTransformer`
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/scala/forge/Target.scala29
1 files changed, 14 insertions, 15 deletions
diff --git a/core/src/main/scala/forge/Target.scala b/core/src/main/scala/forge/Target.scala
index 681d9d2f..635acb8e 100644
--- a/core/src/main/scala/forge/Target.scala
+++ b/core/src/main/scala/forge/Target.scala
@@ -53,22 +53,21 @@ object Target{
import c.universe._
val bound = collection.mutable.Buffer.empty[(c.Tree, Symbol)]
val OptionGet = c.universe.typeOf[Target[_]].member(TermName("apply"))
- object transformer extends c.universe.Transformer {
- // Derived from @olafurpg's
- // https://gist.github.com/olafurpg/596d62f87bf3360a29488b725fbc7608
- override def transform(tree: c.Tree): c.Tree = tree match {
- case t @ q"$fun.apply()" if t.symbol == OptionGet =>
- val tempName = c.freshName(TermName("tmp"))
- val tempSym = c.internal.newTermSymbol(c.internal.enclosingOwner, tempName)
- c.internal.setInfo(tempSym, t.tpe)
- val tempIdent = Ident(tempSym)
- c.internal.setType(tempIdent, t.tpe)
- bound.append((fun, tempSym))
- tempIdent
- case _ => super.transform(tree)
- }
+ // Derived from @olafurpg's
+ // https://gist.github.com/olafurpg/596d62f87bf3360a29488b725fbc7608
+
+ val transformed = c.internal.typingTransform(t.tree) {
+ case (t @ q"$fun.apply()", api) if t.symbol == OptionGet =>
+ val tempName = c.freshName(TermName("tmp"))
+ val tempSym = c.internal.newTermSymbol(api.currentOwner, tempName)
+ c.internal.setInfo(tempSym, t.tpe)
+ val tempIdent = Ident(tempSym)
+ c.internal.setType(tempIdent, t.tpe)
+ bound.append((fun, tempSym))
+ tempIdent
+ case (t, api) => api.default(t)
}
- val transformed = transformer.transform(t.tree)
+
val (exprs, symbols) = bound.unzip
val bindings = symbols.map(c.internal.valDef(_))