File tree 2 files changed +10
-9
lines changed
compiler/src/dotty/tools/dotc 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -19,16 +19,12 @@ object PickledQuotes {
19
19
import tpd ._
20
20
21
21
/** Pickle the quote into strings */
22
- def pickleQuote (tree : Tree )(implicit ctx : Context ): Tree = {
23
- if (ctx.reporter.hasErrors) Literal ( Constant ( " <error> " ))
22
+ def pickleQuote (tree : Tree )(implicit ctx : Context ): scala.runtime.quoted. Unpickler . Pickled = {
23
+ if (ctx.reporter.hasErrors) Nil
24
24
else {
25
25
val encapsulated = encapsulateQuote(tree)
26
26
val pickled = pickle(encapsulated)
27
- TastyString .pickle(pickled).foldRight[Tree ](ref(defn.NilModule )) { (x, acc) =>
28
- acc.select(" ::" .toTermName)
29
- .appliedToType(defn.StringType )
30
- .appliedTo(Literal (Constant (x)))
31
- }
27
+ TastyString .pickle(pickled)
32
28
}
33
29
}
34
30
Original file line number Diff line number Diff line change @@ -265,12 +265,17 @@ class ReifyQuotes extends MacroTransform {
265
265
if (inSplice)
266
266
makeHole(body1, splices, quote.tpe)
267
267
else {
268
+ def liftList (list : List [Tree ], tpe : Type ): Tree = {
269
+ list.foldRight[Tree ](ref(defn.NilModule )) { (x, acc) =>
270
+ acc.select(" ::" .toTermName).appliedToType(tpe).appliedTo(x)
271
+ }
272
+ }
268
273
val isType = quote.tpe.isRef(defn.QuotedTypeClass )
269
274
ref(if (isType) defn.Unpickler_unpickleType else defn.Unpickler_unpickleExpr )
270
275
.appliedToType(if (isType) body1.tpe else body1.tpe.widen)
271
276
.appliedTo(
272
- PickledQuotes .pickleQuote(body1),
273
- SeqLiteral (splices, TypeTree ( defn.AnyType ) ))
277
+ liftList( PickledQuotes .pickleQuote(body1).map(x => Literal ( Constant (x))), defn. StringType ),
278
+ liftList (splices, defn.AnyType ))
274
279
}
275
280
}.withPos(quote.pos)
276
281
You can’t perform that action at this time.
0 commit comments