@@ -19,9 +19,7 @@ import dotty.tools.dotc.report
1919
2020import scala .reflect .ClassTag
2121
22- import scala .internal .quoted .PickledExpr
23- import scala .internal .quoted .PickledSplices
24- import scala .internal .quoted .PickledType
22+ import scala .internal .quoted .PickledQuote
2523import scala .quoted .QuoteContext
2624import scala .collection .mutable
2725
@@ -52,25 +50,25 @@ object PickledQuotes {
5250 }
5351
5452 /** Unpickle the tree contained in the TastyExpr */
55- def unpickleTerm (tastyBytes : Array [ Byte ], splices : PickledSplices )(using Context ): Tree = {
53+ def unpickleTerm (pickledQuote : PickledQuote )(using Context ): Tree = {
5654 val unpickled = withMode(Mode .ReadPositions )(
57- unpickle(tastyBytes, splices , isType = false ))
55+ unpickle(pickledQuote , isType = false ))
5856 val Inlined (call, Nil , expnasion) = unpickled
5957 val inlineCtx = inlineContext(call)
60- val expansion1 = spliceTypes(expnasion, splices )(using inlineCtx)
61- val expansion2 = spliceTerms(expansion1, splices )(using inlineCtx)
58+ val expansion1 = spliceTypes(expnasion, pickledQuote )(using inlineCtx)
59+ val expansion2 = spliceTerms(expansion1, pickledQuote )(using inlineCtx)
6260 cpy.Inlined (unpickled)(call, Nil , expansion2)
6361 }
6462
6563 /** Unpickle the tree contained in the TastyType */
66- def unpickleTypeTree (tastyBytes : Array [ Byte ], splices : PickledSplices )(using Context ): Tree = {
64+ def unpickleTypeTree (pickledQuote : PickledQuote )(using Context ): Tree = {
6765 val unpickled = withMode(Mode .ReadPositions )(
68- unpickle(tastyBytes, splices , isType = true ))
69- spliceTypes(unpickled, splices )
66+ unpickle(pickledQuote , isType = true ))
67+ spliceTypes(unpickled, pickledQuote )
7068 }
7169
7270 /** Replace all term holes with the spliced terms */
73- private def spliceTerms (tree : Tree , splices : PickledSplices )(using Context ): Tree = {
71+ private def spliceTerms (tree : Tree , pickledQuote : PickledQuote )(using Context ): Tree = {
7472 val evaluateHoles = new TreeMap {
7573 override def transform (tree : tpd.Tree )(using Context ): tpd.Tree = tree match {
7674 case Hole (isTerm, idx, args) =>
@@ -79,7 +77,7 @@ object PickledQuotes {
7977 else new scala.internal.quoted.Type (arg, QuoteContextImpl .scopeId)
8078 }
8179 if isTerm then
82- val quotedExpr = splices .exprSplice(idx)(reifiedArgs)(dotty.tools.dotc.quoted.QuoteContextImpl ())
80+ val quotedExpr = pickledQuote .exprSplice(idx)(reifiedArgs)(dotty.tools.dotc.quoted.QuoteContextImpl ())
8381 val filled = PickledQuotes .quotedExprToTree(quotedExpr)
8482
8583 // We need to make sure a hole is created with the source file of the surrounding context, even if
@@ -89,7 +87,7 @@ object PickledQuotes {
8987 else
9088 // Replaces type holes generated by ReifyQuotes (non-spliced types).
9189 // These are types defined in a quote and used at the same level in a nested quote.
92- val quotedType = splices .typeSplice(idx)(reifiedArgs)
90+ val quotedType = pickledQuote .typeSplice(idx)(reifiedArgs)
9391 PickledQuotes .quotedTypeToTree(quotedType)
9492 case tree : Select =>
9593 // Retain selected members
@@ -124,15 +122,15 @@ object PickledQuotes {
124122 }
125123
126124 /** Replace all type holes generated with the spliced types */
127- private def spliceTypes (tree : Tree , splices : PickledSplices )(using Context ): Tree = {
125+ private def spliceTypes (tree : Tree , pickledQuote : PickledQuote )(using Context ): Tree = {
128126 tree match
129127 case Block (stat :: rest, expr1) if stat.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot ) =>
130128 val typeSpliceMap = (stat :: rest).iterator.map {
131129 case tdef : TypeDef =>
132130 assert(tdef.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot ))
133131 val tree = tdef.rhs match
134132 case TypeBoundsTree (_, Hole (_, idx, args), _) =>
135- val quotedType = splices .typeSplice(idx)(args)
133+ val quotedType = pickledQuote .typeSplice(idx)(args)
136134 PickledQuotes .quotedTypeToTree(quotedType)
137135 case TypeBoundsTree (_, tpt, _) =>
138136 tpt
@@ -178,7 +176,8 @@ object PickledQuotes {
178176 }
179177
180178 /** Unpickle TASTY bytes into it's tree */
181- private def unpickle (bytes : Array [Byte ], splices : PickledSplices , isType : Boolean )(using Context ): Tree = {
179+ private def unpickle (pickledQuote : PickledQuote , isType : Boolean )(using Context ): Tree = {
180+ val bytes = pickledQuote.bytes()
182181 quotePickling.println(s " **** unpickling quote from TASTY \n ${new TastyPrinter (bytes).printContents()}" )
183182
184183 val mode = if (isType) UnpickleMode .TypeTree else UnpickleMode .Term
0 commit comments