We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
quoted.Liftable[Option[T]]
1 parent 3340db1 commit d5f7999Copy full SHA for d5f7999
library/src/scala/quoted/Liftable.scala
@@ -59,4 +59,11 @@ object Liftable {
59
}
60
61
62
+ given [T: Type: Liftable] as Liftable[Option[T]] = new Liftable[Option[T]] {
63
+ def toExpr(x: Option[T]): given QuoteContext => Expr[Option[T]] = x match {
64
+ case Some(x) => '{ Some[T](${x.toExpr}) }
65
+ case None => '{ None: Option[T] }
66
+ }
67
68
+
69
tests/run-with-compiler/quote-lib.scala
@@ -38,6 +38,11 @@ object Test {
38
val iarray: IArray[Int] = IArray(1, 2, 3)
39
val liftedIArray: Expr[IArray[Int]] = iarray
40
41
+ val some: Option[Int] = Some(2)
42
+ val none: Option[Int] = Some(2)
43
+ val liftedSome: Expr[Option[Int]] = some
44
+ val liftedNone: Expr[Option[Int]] = none
45
46
println("quote lib ok")
47
48
0 commit comments