diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index d042966bdc30..89a75e6dcac7 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -209,7 +209,9 @@ class ReifyQuotes extends MacroTransform { } def liftedValue[T](value: T, name: TermName) = - ref(defn.LiftableModule).select(name).select("toExpr".toTermName).appliedTo(Literal(Constant(value))) + ref(defn.LiftableModule) + .select(name).appliedToType(originalTp) + .select("toExpr".toTermName).appliedTo(Literal(Constant(value))) def pickleAsValue[T](value: T) = { value match { diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 0c9595c1521c..e48576738c08 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -19,15 +19,15 @@ trait Liftable[T] { */ object Liftable { - given Liftable_Boolean_delegate as Liftable[Boolean] = new PrimitiveLiftable - given Liftable_Byte_delegate as Liftable[Byte] = new PrimitiveLiftable - given Liftable_Short_delegate as Liftable[Short] = new PrimitiveLiftable - given Liftable_Int_delegate as Liftable[Int] = new PrimitiveLiftable - given Liftable_Long_delegate as Liftable[Long] = new PrimitiveLiftable - given Liftable_Float_delegate as Liftable[Float] = new PrimitiveLiftable - given Liftable_Double_delegate as Liftable[Double] = new PrimitiveLiftable - given Liftable_Char_delegate as Liftable[Char] = new PrimitiveLiftable - given Liftable_String_delegate as Liftable[String] = new PrimitiveLiftable + given Liftable_Boolean_delegate[T <: Boolean] as Liftable[T] = new PrimitiveLiftable + given Liftable_Byte_delegate[T <: Byte] as Liftable[T] = new PrimitiveLiftable + given Liftable_Short_delegate[T <: Short] as Liftable[T] = new PrimitiveLiftable + given Liftable_Int_delegate[T <: Int] as Liftable[T] = new PrimitiveLiftable + given Liftable_Long_delegate[T <: Long] as Liftable[T] = new PrimitiveLiftable + given Liftable_Float_delegate[T <: Float] as Liftable[T] = new PrimitiveLiftable + given Liftable_Double_delegate[T <: Double] as Liftable[T] = new PrimitiveLiftable + given Liftable_Char_delegate[T <: Char] as Liftable[T] = new PrimitiveLiftable + given Liftable_String_delegate[T <: String] as Liftable[T] = new PrimitiveLiftable private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] { /** Lift a primitive value `n` into `'{ n }` */ diff --git a/tests/pos/i7046.scala b/tests/pos/i7046.scala new file mode 100644 index 000000000000..7ebb76479ac5 --- /dev/null +++ b/tests/pos/i7046.scala @@ -0,0 +1,7 @@ +import scala.quoted._ + +inline def mcr: Any = ${mcrImpl} +def mcrImpl given (ctx: QuoteContext): Expr[Any] = { + val tpl: Expr[1] = '{1} + '{()} +}