@@ -8,12 +8,14 @@ import dotty.tools.dotc.core.Contexts._
8
8
import dotty .tools .dotc .core .Decorators ._
9
9
import dotty .tools .dotc .core .StdNames ._
10
10
import dotty .tools .dotc .core .NameKinds
11
+ import dotty .tools .dotc .core .Names ._
11
12
import dotty .tools .dotc .core .Mode
12
13
import dotty .tools .dotc .core .Symbols ._
13
14
import dotty .tools .dotc .core .Types .Type
14
15
import dotty .tools .dotc .core .tasty .TreePickler .Hole
15
16
import dotty .tools .dotc .core .tasty .{PositionPickler , TastyPickler , TastyPrinter , TastyString }
16
17
import dotty .tools .dotc .core .tasty .TreeUnpickler .UnpickleMode
18
+ import scala .collection .mutable
17
19
18
20
import scala .quoted .Types ._
19
21
import scala .quoted .Exprs ._
@@ -40,7 +42,36 @@ object PickledQuotes {
40
42
def traverse (tree : tpd.Tree )(implicit ctx : Context ): Unit = traverseChildren(tree)
41
43
}
42
44
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
44
75
case expr : LiftedExpr [T ] =>
45
76
expr.value match {
46
77
case value : Class [_] => ref(defn.Predef_classOf ).appliedToType(classToType(value))
0 commit comments