diff --git a/library/src/scala/quoted/Liftable.scala b/library/src/scala/quoted/Liftable.scala index 026f24287bcd..2a13d6c375b5 100644 --- a/library/src/scala/quoted/Liftable.scala +++ b/library/src/scala/quoted/Liftable.scala @@ -14,6 +14,10 @@ abstract class Liftable[T] { */ object Liftable { + implicit class LiftExprOps[T](val x: T) extends AnyVal { + def toExpr(implicit liftable: Liftable[T]): Expr[T] = liftable.toExpr(x) + } + final class ConstantExpr[T] private[Liftable](val value: T) extends Expr[T] { override def toString: String = s"Expr($value)" } diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala new file mode 100644 index 000000000000..2616b524ccf3 --- /dev/null +++ b/tests/pos/quote-lift.scala @@ -0,0 +1,18 @@ +import scala.quoted._ + +object Test { + '{ ~(1: Expr[Int]) } + + '{ ~implicitly[Liftable[Int]].toExpr(1) } + + { + import Liftable._ + + '{ ~IntIsLiftable.toExpr(1) } + + '{ ~1.toExpr } + + } + + +} \ No newline at end of file