File tree Expand file tree Collapse file tree 3 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc
library/src/scala/runtime/quoted Expand file tree Collapse file tree 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
1616object PickledQuotes {
1717 import tpd ._
1818
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>" ) )
2222 else {
2323 val encapsulated = encapsulateQuote(tree)
2424 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+ }
2630 }
2731 }
2832
Original file line number Diff line number Diff line change @@ -266,11 +266,10 @@ class ReifyQuotes extends MacroTransform {
266266 makeHole(body1, splices, quote.tpe)
267267 else {
268268 val isType = quote.tpe.isRef(defn.QuotedTypeClass )
269- val strings = PickledQuotes .pickleQuote(body1).map(x => Literal (Constant (x)))
270269 ref(if (isType) defn.Unpickler_unpickleType else defn.Unpickler_unpickleExpr )
271270 .appliedToType(if (isType) body1.tpe else body1.tpe.widen)
272271 .appliedTo(
273- SeqLiteral (strings.toList, TypeTree (defn. StringType ) ),
272+ PickledQuotes .pickleQuote(body1 ),
274273 SeqLiteral (splices, TypeTree (defn.AnyType )))
275274 }
276275 }.withPos(quote.pos)
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ import scala.quoted._
55/** Provides methods to unpickle `Expr` and `Type` trees. */
66object Unpickler {
77
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.
1010 */
11- type Pickled = Seq [String ]
11+ type Pickled = List [String ]
1212
1313 /** Unpickle `repr` which represents a pickled `Expr` tree,
1414 * replacing splice nodes with `args`
You can’t perform that action at this time.
0 commit comments