@@ -206,19 +206,19 @@ class ReifyQuotes extends MacroTransform {
206
206
qctx
207
207
}
208
208
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))
211
211
val liftable = ctx.typer.inferImplicitArg(ltp, body.span)
212
212
if (liftable.tpe.isInstanceOf [SearchFailureType ])
213
213
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 )
215
215
}
216
216
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 )
222
222
}
223
223
224
224
def pickleAsTasty () = {
@@ -238,8 +238,8 @@ class ReifyQuotes extends MacroTransform {
238
238
if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s " ${body.symbol.name}Tag " )
239
239
else pickleAsTasty().select(nme.apply).appliedTo(qctx)
240
240
}
241
- else toValue (body) match {
242
- case Some (value ) => pickleAsValue(value )
241
+ else getLiteral (body) match {
242
+ case Some (lit ) => pickleAsLiteral(lit )
243
243
case _ => pickleAsTasty()
244
244
}
245
245
}
@@ -424,10 +424,10 @@ object ReifyQuotes {
424
424
425
425
val name : String = " reifyQuotes"
426
426
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)
431
431
case _ => None
432
432
}
433
433
0 commit comments