File tree 3 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc
library/src/scala/runtime/quoted 3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,17 @@ import scala.runtime.quoted.Unpickler.Pickled
16
16
object PickledQuotes {
17
17
import tpd ._
18
18
19
- /** Pickle the quote into a TASTY string */
20
- def pickleQuote (tree : Tree )(implicit ctx : Context ): Pickled = {
21
- if (ctx.reporter.hasErrors) List ( " <error>" )
19
+ /** Pickle the quote into strings */
20
+ def pickleQuote (tree : Tree )(implicit ctx : Context ): Tree = {
21
+ if (ctx.reporter.hasErrors) Literal ( Constant ( " <error>" ) )
22
22
else {
23
23
val encapsulated = encapsulateQuote(tree)
24
24
val pickled = pickle(encapsulated)
25
- TastyString .pickle(pickled)
25
+ TastyString .pickle(pickled).foldRight[Tree ](ref(defn.NilModule )) { (x, acc) =>
26
+ acc.select(" ::" .toTermName)
27
+ .appliedToType(defn.StringType )
28
+ .appliedTo(Literal (Constant (x)))
29
+ }
26
30
}
27
31
}
28
32
Original file line number Diff line number Diff line change @@ -266,11 +266,10 @@ class ReifyQuotes extends MacroTransform {
266
266
makeHole(body1, splices, quote.tpe)
267
267
else {
268
268
val isType = quote.tpe.isRef(defn.QuotedTypeClass )
269
- val strings = PickledQuotes .pickleQuote(body1).map(x => Literal (Constant (x)))
270
269
ref(if (isType) defn.Unpickler_unpickleType else defn.Unpickler_unpickleExpr )
271
270
.appliedToType(if (isType) body1.tpe else body1.tpe.widen)
272
271
.appliedTo(
273
- SeqLiteral (strings.toList, TypeTree (defn. StringType ) ),
272
+ PickledQuotes .pickleQuote(body1 ),
274
273
SeqLiteral (splices, TypeTree (defn.AnyType )))
275
274
}
276
275
}.withPos(quote.pos)
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ import scala.quoted._
5
5
/** Provides methods to unpickle `Expr` and `Type` trees. */
6
6
object Unpickler {
7
7
8
- /** Representation of pickled trees. For now it's String, but it
9
- * should be changed to some kind of TASTY bundle.
8
+ /** Representation of pickled trees. For now a List[ String],
9
+ * but it should be changed to some kind of TASTY bundle.
10
10
*/
11
- type Pickled = Seq [String ]
11
+ type Pickled = List [String ]
12
12
13
13
/** Unpickle `repr` which represents a pickled `Expr` tree,
14
14
* replacing splice nodes with `args`
You can’t perform that action at this time.
0 commit comments