@@ -387,7 +387,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
387
387
if (isStage0Value(body.symbol)) {
388
388
// Optimization: avoid the full conversion when capturing inlined `x`
389
389
// in '{ x } to '{ x$1.toExpr.unary_~ } and go directly to `x$1.toExpr`
390
- liftValue (capturers(body.symbol)(body))
390
+ liftInlineParamValue (capturers(body.symbol)(body))
391
391
} else {
392
392
// Optimization: avoid the full conversion when capturing `x`
393
393
// in '{ x } to '{ x$1.unary_~ } and go directly to `x$1`
@@ -577,7 +577,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
577
577
splice(t.select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~ ))
578
578
if (! isStage0Value(tree.symbol)) captureAndSplice(capturer(tree))
579
579
else if (level == 0 ) capturer(tree)
580
- else captureAndSplice(liftValue (capturer(tree)))
580
+ else captureAndSplice(liftInlineParamValue (capturer(tree)))
581
581
case Block (stats, _) =>
582
582
val last = enteredSyms
583
583
stats.foreach(markDef)
@@ -632,19 +632,22 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
632
632
}
633
633
}
634
634
635
- private def liftValue (tree : Tree )(implicit ctx : Context ): Tree = {
636
- val reqType = defn.QuotedLiftableType .appliedTo(tree.tpe.widen)
637
- val liftable = ctx.typer.inferImplicitArg(reqType, tree.pos)
638
- liftable.tpe match {
639
- case fail : SearchFailureType =>
640
- ctx.error(i """
641
- |
642
- | The access would be accepted with the right Liftable, but
643
- | ${ctx.typer.missingArgMsg(liftable, reqType, " " )}""" )
644
- EmptyTree
645
- case _ =>
646
- liftable.select(" toExpr" .toTermName).appliedTo(tree)
647
- }
635
+ /** Takes a reference to an inline parameter `tree` and lifts it to an Expr */
636
+ private def liftInlineParamValue (tree : Tree )(implicit ctx : Context ): Tree = {
637
+ val tpSym = tree.tpe.widenDealias.classSymbol
638
+
639
+ val lifter =
640
+ if (tpSym eq defn.BooleanClass ) defn.QuotedLiftable_BooleanIsLiftable
641
+ else if (tpSym eq defn.ByteClass ) defn.QuotedLiftable_ByteLiftable
642
+ else if (tpSym eq defn.CharClass ) defn.QuotedLiftable_CharIsLiftable
643
+ else if (tpSym eq defn.ShortClass ) defn.QuotedLiftable_ShortIsLiftable
644
+ else if (tpSym eq defn.IntClass ) defn.QuotedLiftable_IntIsLiftable
645
+ else if (tpSym eq defn.LongClass ) defn.QuotedLiftable_LongIsLiftable
646
+ else if (tpSym eq defn.FloatClass ) defn.QuotedLiftable_FloatIsLiftable
647
+ else if (tpSym eq defn.DoubleClass ) defn.QuotedLiftable_DoubleIsLiftable
648
+ else defn.QuotedLiftable_StringIsLiftable
649
+
650
+ ref(lifter).select(" toExpr" .toTermName).appliedTo(tree)
648
651
}
649
652
650
653
private def isStage0Value (sym : Symbol )(implicit ctx : Context ): Boolean =
0 commit comments