Skip to content

Commit 05c77dc

Browse files
committed
Add quoted.Liftable[Set[T]] to the stdlib
1 parent ddaf5b6 commit 05c77dc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

library/src/scala/quoted/Liftable.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ object Liftable {
6666
}
6767
}
6868

69+
given [T: Type: Liftable] as Liftable[Set[T]] = new Liftable[Set[T]] {
70+
def toExpr(set: Set[T]): given QuoteContext => Expr[Set[T]] =
71+
'{ Set(${set.toSeq.toExpr}: _*) }
72+
}
73+
6974
given [T: Type: Liftable] as Liftable[Option[T]] = new Liftable[Option[T]] {
7075
def toExpr(x: Option[T]): given QuoteContext => Expr[Option[T]] = x match {
7176
case Some(x) => '{ Some[T](${x.toExpr}) }

tests/run-with-compiler/quote-lib.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ object Test {
3232
val seq: Seq[Int] = Seq(1, 2, 3)
3333
val liftedSeq: Expr[Seq[Int]] = seq
3434

35+
val set: Set[Int] = Set(1, 2, 3)
36+
val liftedSet: Expr[Set[Int]] = set
37+
3538
liftedList.foldLeft[Int](0)('{ (acc: Int, x: Int) => acc + x }).show
3639
liftedList.foreach('{ (x: Int) => println(x) }).show
3740

0 commit comments

Comments
 (0)