Skip to content

Commit 186feba

Browse files
committed
Hardcode the lifters as definitions
1 parent a92cfcb commit 186feba

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,16 @@ class Definitions {
637637
@tu lazy val QuoteContextModule: Symbol = QuoteContextClass.companionModule
638638
@tu lazy val QuoteContext_macroContext: Symbol = QuoteContextModule.requiredMethod("macroContext")
639639

640-
@tu lazy val LiftableClass: ClassSymbol = ctx.requiredClass("scala.quoted.Liftable")
641640
@tu lazy val LiftableModule: Symbol = ctx.requiredModule("scala.quoted.Liftable")
641+
@tu lazy val LiftableModule_BooleanIsLiftable: Symbol = LiftableModule.requiredMethod("BooleanIsLiftable")
642+
@tu lazy val LiftableModule_ByteIsLiftable: Symbol = LiftableModule.requiredMethod("ByteIsLiftable")
643+
@tu lazy val LiftableModule_ShortIsLiftable: Symbol = LiftableModule.requiredMethod("ShortIsLiftable")
644+
@tu lazy val LiftableModule_IntIsLiftable: Symbol = LiftableModule.requiredMethod("IntIsLiftable")
645+
@tu lazy val LiftableModule_LongIsLiftable: Symbol = LiftableModule.requiredMethod("LongIsLiftable")
646+
@tu lazy val LiftableModule_FloatIsLiftable: Symbol = LiftableModule.requiredMethod("FloatIsLiftable")
647+
@tu lazy val LiftableModule_DoubleIsLiftable: Symbol = LiftableModule.requiredMethod("DoubleIsLiftable")
648+
@tu lazy val LiftableModule_CharIsLiftable: Symbol = LiftableModule.requiredMethod("CharIsLiftable")
649+
@tu lazy val LiftableModule_StringIsLiftable: Symbol = LiftableModule.requiredMethod("StringIsLiftable")
642650

643651
@tu lazy val InternalQuotedModule: Symbol = ctx.requiredModule("scala.internal.Quoted")
644652
@tu lazy val InternalQuoted_exprQuote : Symbol = InternalQuotedModule.requiredMethod("exprQuote")

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,23 @@ class ReifyQuotes extends MacroTransform {
206206
qctx
207207
}
208208

209-
def pickleAsLiteral(lit: Literal) =
209+
def pickleAsLiteral(lit: Literal) = {
210+
def liftedValue(lifter: Symbol) =
211+
ref(lifter).appliedToType(originalTp).select(nme.toExpr).appliedTo(lit)
210212
lit.const.tag match {
211213
case Constants.NullTag => ref(defn.QuotedExprModule_nullExpr)
212214
case Constants.UnitTag => ref(defn.QuotedExprModule_unitExpr)
213-
case _ => // Lifted literal
214-
val ltp = defn.LiftableClass.typeRef.appliedTo(ConstantType(lit.const))
215-
val liftable = ctx.typer.inferImplicitArg(ltp, body.span)
216-
if (liftable.tpe.isInstanceOf[SearchFailureType])
217-
ctx.error(ctx.typer.missingArgMsg(liftable, ltp, "Could no optimize constant in quote"), ctx.source.atSpan(body.span))
218-
liftable.select(nme.toExpr).appliedTo(lit)
215+
case Constants.BooleanTag => liftedValue(defn.LiftableModule_BooleanIsLiftable)
216+
case Constants.ByteTag => liftedValue(defn.LiftableModule_ByteIsLiftable)
217+
case Constants.ShortTag => liftedValue(defn.LiftableModule_ShortIsLiftable)
218+
case Constants.IntTag => liftedValue(defn.LiftableModule_IntIsLiftable)
219+
case Constants.LongTag => liftedValue(defn.LiftableModule_LongIsLiftable)
220+
case Constants.FloatTag => liftedValue(defn.LiftableModule_FloatIsLiftable)
221+
case Constants.DoubleTag => liftedValue(defn.LiftableModule_DoubleIsLiftable)
222+
case Constants.CharTag => liftedValue(defn.LiftableModule_CharIsLiftable)
223+
case Constants.StringTag => liftedValue(defn.LiftableModule_StringIsLiftable)
219224
}
225+
}
220226

221227
def pickleAsTasty() = {
222228
val meth =

0 commit comments

Comments
 (0)