@@ -206,24 +206,19 @@ class ReifyQuotes extends MacroTransform {
206
206
qctx
207
207
}
208
208
209
- def liftedValue [T ](value : T , name : TermName ) =
210
- ref(defn.LiftableModule )
211
- .select(name).appliedToType(originalTp)
212
- .select(" toExpr" .toTermName).appliedTo(Literal (Constant (value)))
209
+ def liftedValue [T ](const : Constant ) = {
210
+ val ltp = defn.LiftableClass .typeRef.appliedTo(ConstantType (const))
211
+ val liftable = ctx.typer.inferImplicitArg(ltp, body.span)
212
+ if (liftable.tpe.isInstanceOf [SearchFailureType ])
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))
215
+ }
213
216
214
217
def pickleAsValue [T ](value : T ) =
215
218
value match {
216
219
case null => ref(defn.QuotedExprModule ).select(" nullExpr" .toTermName)
217
220
case _ : Unit => ref(defn.QuotedExprModule ).select(" unitExpr" .toTermName)
218
- case _ : Boolean => liftedValue(value, " Liftable_Boolean_delegate" .toTermName)
219
- case _ : Byte => liftedValue(value, " Liftable_Byte_delegate" .toTermName)
220
- case _ : Short => liftedValue(value, " Liftable_Short_delegate" .toTermName)
221
- case _ : Int => liftedValue(value, " Liftable_Int_delegate" .toTermName)
222
- case _ : Long => liftedValue(value, " Liftable_Long_delegate" .toTermName)
223
- case _ : Float => liftedValue(value, " Liftable_Float_delegate" .toTermName)
224
- case _ : Double => liftedValue(value, " Liftable_Double_delegate" .toTermName)
225
- case _ : Char => liftedValue(value, " Liftable_Char_delegate" .toTermName)
226
- case _ : String => liftedValue(value, " Liftable_String_delegate" .toTermName)
221
+ case _ => liftedValue(Constant (value))
227
222
}
228
223
229
224
def pickleAsTasty () = {
0 commit comments