@@ -206,19 +206,19 @@ class ReifyQuotes extends MacroTransform {
206206 qctx
207207 }
208208
209- def liftedValue [ T ]( const : Constant ) = {
210- val ltp = defn.LiftableClass .typeRef.appliedTo(ConstantType (const))
209+ def liftedLiteral ( lit : Literal ) = {
210+ val ltp = defn.LiftableClass .typeRef.appliedTo(ConstantType (lit. const))
211211 val liftable = ctx.typer.inferImplicitArg(ltp, body.span)
212212 if (liftable.tpe.isInstanceOf [SearchFailureType ])
213213 ctx.error(ctx.typer.missingArgMsg(liftable, ltp, " Could no optimize constant in quote" ), ctx.source.atSpan(body.span))
214- liftable.select(" toExpr" .toTermName).appliedTo(Literal (const) )
214+ liftable.select(" toExpr" .toTermName).appliedTo(lit )
215215 }
216216
217- def pickleAsValue [ T ]( value : T ) =
218- value match {
219- case null => ref(defn.QuotedExprModule ).select(" nullExpr" .toTermName)
220- case _ : Unit => ref(defn.QuotedExprModule ).select(" unitExpr" .toTermName)
221- case _ => liftedValue( Constant (value) )
217+ def pickleAsLiteral ( lit : Literal ) =
218+ lit.const.tag match {
219+ case Constants . NullTag => ref(defn.QuotedExprModule ).select(" nullExpr" .toTermName)
220+ case Constants . UnitTag => ref(defn.QuotedExprModule ).select(" unitExpr" .toTermName)
221+ case _ => liftedLiteral(lit )
222222 }
223223
224224 def pickleAsTasty () = {
@@ -238,8 +238,8 @@ class ReifyQuotes extends MacroTransform {
238238 if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s " ${body.symbol.name}Tag " )
239239 else pickleAsTasty().select(nme.apply).appliedTo(qctx)
240240 }
241- else toValue (body) match {
242- case Some (value ) => pickleAsValue(value )
241+ else getLiteral (body) match {
242+ case Some (lit ) => pickleAsLiteral(lit )
243243 case _ => pickleAsTasty()
244244 }
245245 }
@@ -424,10 +424,10 @@ object ReifyQuotes {
424424
425425 val name : String = " reifyQuotes"
426426
427- def toValue (tree : tpd.Tree ): Option [Any ] = tree match {
428- case Literal ( Constant (c)) => Some (c )
429- case Block (Nil , e) => toValue (e)
430- case Inlined (_, Nil , e) => toValue (e)
427+ def getLiteral (tree : tpd.Tree ): Option [Literal ] = tree match {
428+ case tree : Literal => Some (tree )
429+ case Block (Nil , e) => getLiteral (e)
430+ case Inlined (_, Nil , e) => getLiteral (e)
431431 case _ => None
432432 }
433433
0 commit comments