Skip to content

Commit 1c3029d

Browse files
committed
Fix #7046: Support lifting for literal constant types
1 parent 0c7dac7 commit 1c3029d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ class ReifyQuotes extends MacroTransform {
209209
}
210210

211211
def liftedValue[T](value: T, name: TermName) =
212-
ref(defn.LiftableModule).select(name).select("toExpr".toTermName).appliedTo(Literal(Constant(value)))
212+
ref(defn.LiftableModule)
213+
.select(name).appliedToType(originalTp)
214+
.select("toExpr".toTermName).appliedTo(Literal(Constant(value)))
213215

214216
def pickleAsValue[T](value: T) = {
215217
value match {

library/src-bootstrapped/scala/quoted/Liftable.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ trait Liftable[T] {
1919
*/
2020
object Liftable {
2121

22-
given Liftable_Boolean_delegate as Liftable[Boolean] = new PrimitiveLiftable
23-
given Liftable_Byte_delegate as Liftable[Byte] = new PrimitiveLiftable
24-
given Liftable_Short_delegate as Liftable[Short] = new PrimitiveLiftable
25-
given Liftable_Int_delegate as Liftable[Int] = new PrimitiveLiftable
26-
given Liftable_Long_delegate as Liftable[Long] = new PrimitiveLiftable
27-
given Liftable_Float_delegate as Liftable[Float] = new PrimitiveLiftable
28-
given Liftable_Double_delegate as Liftable[Double] = new PrimitiveLiftable
29-
given Liftable_Char_delegate as Liftable[Char] = new PrimitiveLiftable
30-
given Liftable_String_delegate as Liftable[String] = new PrimitiveLiftable
22+
given Liftable_Boolean_delegate[T <: Boolean] as Liftable[T] = new PrimitiveLiftable
23+
given Liftable_Byte_delegate[T <: Byte] as Liftable[T] = new PrimitiveLiftable
24+
given Liftable_Short_delegate[T <: Short] as Liftable[T] = new PrimitiveLiftable
25+
given Liftable_Int_delegate[T <: Int] as Liftable[T] = new PrimitiveLiftable
26+
given Liftable_Long_delegate[T <: Long] as Liftable[T] = new PrimitiveLiftable
27+
given Liftable_Float_delegate[T <: Float] as Liftable[T] = new PrimitiveLiftable
28+
given Liftable_Double_delegate[T <: Double] as Liftable[T] = new PrimitiveLiftable
29+
given Liftable_Char_delegate[T <: Char] as Liftable[T] = new PrimitiveLiftable
30+
given Liftable_String_delegate[T <: String] as Liftable[T] = new PrimitiveLiftable
3131

3232
private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] {
3333
/** Lift a primitive value `n` into `'{ n }` */

0 commit comments

Comments
 (0)