@@ -51,23 +51,23 @@ object PickledQuotes {
51
51
}
52
52
53
53
/** Unpickle the tree contained in the TastyExpr */
54
- def unpickleTerm (pickled : String | List [String ], fillHole : Int => Seq [Any ] => Any )(using Context ): Tree = {
54
+ def unpickleTerm (pickled : String | List [String ], typeHole : Int => Seq [Any ] => scala.quoted. Type [ ? ], termHole : Int => Seq [ Any ] => scala.quoted. QuoteContext => scala.quoted. Expr [ ? ] )(using Context ): Tree = {
55
55
val unpickled = withMode(Mode .ReadPositions )(unpickle(pickled, isType = false ))
56
56
val Inlined (call, Nil , expnasion) = unpickled
57
57
val inlineCtx = inlineContext(call)
58
- val expansion1 = spliceTypes(expnasion, fillHole )(using inlineCtx)
59
- val expansion2 = spliceTerms(expansion1, fillHole )(using inlineCtx)
58
+ val expansion1 = spliceTypes(expnasion, typeHole, termHole )(using inlineCtx)
59
+ val expansion2 = spliceTerms(expansion1, typeHole, termHole )(using inlineCtx)
60
60
cpy.Inlined (unpickled)(call, Nil , expansion2)
61
61
}
62
62
63
63
/** Unpickle the tree contained in the TastyType */
64
- def unpickleTypeTree (pickled : String | List [String ], fillHole : Int => Seq [Any ] => Any )(using Context ): Tree = {
64
+ def unpickleTypeTree (pickled : String | List [String ], typeHole : Int => Seq [Any ] => scala.quoted. Type [ ? ], termHole : Int => Seq [ Any ] => scala.quoted. QuoteContext => scala.quoted. Expr [ ? ] )(using Context ): Tree = {
65
65
val unpickled = withMode(Mode .ReadPositions )(unpickle(pickled, isType = true ))
66
- spliceTypes(unpickled, fillHole )
66
+ spliceTypes(unpickled, typeHole, termHole )
67
67
}
68
68
69
69
/** Replace all term holes with the spliced terms */
70
- private def spliceTerms (tree : Tree , fillHole : Int => Seq [Any ] => Any )(using Context ): Tree = {
70
+ private def spliceTerms (tree : Tree , typeHole : Int => Seq [Any ] => scala.quoted. Type [ ? ], termHole : Int => Seq [ Any ] => scala.quoted. QuoteContext => scala.quoted. Expr [ ? ] )(using Context ): Tree = {
71
71
val evaluateHoles = new TreeMap {
72
72
override def transform (tree : tpd.Tree )(using Context ): tpd.Tree = tree match {
73
73
case Hole (isTerm, idx, args) =>
@@ -76,7 +76,7 @@ object PickledQuotes {
76
76
else new scala.internal.quoted.Type (arg, QuoteContextImpl .scopeId)
77
77
}
78
78
if isTerm then
79
- val quotedExpr = fillHole (idx)(reifiedArgs). asInstanceOf [ QuoteContext => scala.quoted. Expr [ Any ]] (dotty.tools.dotc.quoted.QuoteContextImpl ())
79
+ val quotedExpr = termHole (idx)(reifiedArgs)(dotty.tools.dotc.quoted.QuoteContextImpl ())
80
80
val filled = PickledQuotes .quotedExprToTree(quotedExpr)
81
81
82
82
// We need to make sure a hole is created with the source file of the surrounding context, even if
@@ -86,7 +86,7 @@ object PickledQuotes {
86
86
else
87
87
// Replaces type holes generated by ReifyQuotes (non-spliced types).
88
88
// These are types defined in a quote and used at the same level in a nested quote.
89
- val quotedType = fillHole (idx)(reifiedArgs). asInstanceOf [scala.quoted. Type [ ? ]]
89
+ val quotedType = typeHole (idx)(reifiedArgs)
90
90
PickledQuotes .quotedTypeToTree(quotedType)
91
91
case tree : Select =>
92
92
// Retain selected members
@@ -121,15 +121,15 @@ object PickledQuotes {
121
121
}
122
122
123
123
/** Replace all type holes generated with the spliced types */
124
- private def spliceTypes (tree : Tree , fillHole : Int => Seq [Any ] => Any )(using Context ): Tree = {
124
+ private def spliceTypes (tree : Tree , typeHole : Int => Seq [ Any ] => scala.quoted. Type [ ? ], termHole : Int => Seq [Any ] => Any )(using Context ): Tree = {
125
125
tree match
126
126
case Block (stat :: rest, expr1) if stat.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot ) =>
127
127
val typeSpliceMap = (stat :: rest).iterator.map {
128
128
case tdef : TypeDef =>
129
129
assert(tdef.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot ))
130
130
val tree = tdef.rhs match
131
131
case TypeBoundsTree (_, Hole (_, idx, args), _) =>
132
- val quotedType = fillHole (idx)(args). asInstanceOf [scala.quoted. Type [ ? ]]
132
+ val quotedType = typeHole (idx)(args)
133
133
PickledQuotes .quotedTypeToTree(quotedType)
134
134
case TypeBoundsTree (_, tpt, _) =>
135
135
tpt
0 commit comments