@@ -8,12 +8,14 @@ import dotty.tools.dotc.core.Contexts._
88import dotty .tools .dotc .core .Decorators ._
99import dotty .tools .dotc .core .StdNames ._
1010import dotty .tools .dotc .core .NameKinds
11+ import dotty .tools .dotc .core .Names ._
1112import dotty .tools .dotc .core .Mode
1213import dotty .tools .dotc .core .Symbols ._
1314import dotty .tools .dotc .core .Types .Type
1415import dotty .tools .dotc .core .tasty .TreePickler .Hole
1516import dotty .tools .dotc .core .tasty .{PositionPickler , TastyPickler , TastyPrinter , TastyString }
1617import dotty .tools .dotc .core .tasty .TreeUnpickler .UnpickleMode
18+ import scala .collection .mutable
1719
1820import scala .quoted .Types ._
1921import scala .quoted .Exprs ._
@@ -40,7 +42,36 @@ object PickledQuotes {
4042 def traverse (tree : tpd.Tree )(implicit ctx : Context ): Unit = traverseChildren(tree)
4143 }
4244 force.traverse(unpickled)
43- unpickled
45+
46+ val mapper = new TreeMap {
47+
48+ override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
49+ case Block (stats, expr) if expr.isType => {
50+ val substMap : mutable.HashMap [Symbol , Tree ] = new mutable.HashMap [Symbol , Tree ]
51+
52+ stats.foreach(s => s match {
53+ case tf : TypeDef => {
54+ substMap.put(tf.symbol, tf.rhs)
55+ }
56+ })
57+
58+ val t = new TreeTypeMap (
59+ treeMap = tree => substMap.getOrElse(tree.symbol, tree),
60+ typeMap = tpe => {
61+ println(tpe.show)
62+ substMap.get(tpe.typeSymbol).fold(tpe)(_.tpe)
63+ })
64+
65+ val ret = t.transform(expr)
66+ println(" >>> transformed: " + ret.show)
67+ ret
68+ }
69+ case _ => super .transform(tree)
70+ }
71+ }
72+
73+ mapper.transform(unpickled)
74+ // unpickled
4475 case expr : LiftedExpr [T ] =>
4576 expr.value match {
4677 case value : Class [_] => ref(defn.Predef_classOf ).appliedToType(classToType(value))
0 commit comments