Skip to content

Commit eb125d5

Browse files
committed
Add quoted.Liftable[Either[L, R]] to the stdlib
1 parent a6048a7 commit eb125d5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

library/src/scala/quoted/Liftable.scala

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

69+
given [L: Type: Liftable, R: Type: Liftable] as Liftable[Either[L, R]] = new Liftable[Either[L, R]] {
70+
def toExpr(x: Either[L, R]): given QuoteContext => Expr[Either[L, R]] = x match {
71+
case Left(x) => '{ Left[L, R](${x.toExpr}) }
72+
case Right(x) => '{ Right[L, R](${x.toExpr}) }
73+
}
74+
}
75+
6976
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ object Test {
4343
val liftedSome: Expr[Option[Int]] = some
4444
val liftedNone: Expr[Option[Int]] = none
4545

46+
val left: Either[Int, Long] = Left(1)
47+
val right: Either[Int, Long] = Right(2L)
48+
left.toExpr
49+
right.toExpr
50+
4651
println("quote lib ok")
4752
}
4853
}

0 commit comments

Comments
 (0)