diff --git a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala index afeb44bb153a..06b75faaa770 100644 --- a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala @@ -19,16 +19,12 @@ object PickledQuotes { import tpd._ /** Pickle the quote into strings */ - def pickleQuote(tree: Tree)(implicit ctx: Context): Tree = { - if (ctx.reporter.hasErrors) Literal(Constant("")) + def pickleQuote(tree: Tree)(implicit ctx: Context): scala.runtime.quoted.Unpickler.Pickled = { + if (ctx.reporter.hasErrors) Nil else { val encapsulated = encapsulateQuote(tree) val pickled = pickle(encapsulated) - TastyString.pickle(pickled).foldRight[Tree](ref(defn.NilModule)) { (x, acc) => - acc.select("::".toTermName) - .appliedToType(defn.StringType) - .appliedTo(Literal(Constant(x))) - } + TastyString.pickle(pickled) } } diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 03e818e0de79..8b02aa8e63fb 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -265,12 +265,17 @@ class ReifyQuotes extends MacroTransform { if (inSplice) makeHole(body1, splices, quote.tpe) else { + def liftList(list: List[Tree], tpe: Type): Tree = { + list.foldRight[Tree](ref(defn.NilModule)) { (x, acc) => + acc.select("::".toTermName).appliedToType(tpe).appliedTo(x) + } + } val isType = quote.tpe.isRef(defn.QuotedTypeClass) ref(if (isType) defn.Unpickler_unpickleType else defn.Unpickler_unpickleExpr) .appliedToType(if (isType) body1.tpe else body1.tpe.widen) .appliedTo( - PickledQuotes.pickleQuote(body1), - SeqLiteral(splices, TypeTree(defn.AnyType))) + liftList(PickledQuotes.pickleQuote(body1).map(x => Literal(Constant(x))), defn.StringType), + liftList(splices, defn.AnyType)) } }.withPos(quote.pos)