From c544c1795e70b76b7a76c483077479ed9cfe48ce Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 27 Jul 2019 17:57:08 +0200 Subject: [PATCH] Add `quoted.Liftable[TupleN]` with N > 22 to the stdlib --- library/src/scala/quoted/Liftable.scala | 5 +++++ tests/run-with-compiler/quote-lib.scala | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library/src/scala/quoted/Liftable.scala b/library/src/scala/quoted/Liftable.scala index dd6cf91b5d84..b350962d140b 100644 --- a/library/src/scala/quoted/Liftable.scala +++ b/library/src/scala/quoted/Liftable.scala @@ -239,6 +239,11 @@ object Liftable { } } + given [H: Type: Liftable, T <: Tuple: Type: Liftable] as Liftable[H *: T] = new { + def toExpr(tup: H *: T): given QuoteContext => Expr[H *: T] = + '{ ${tup.head.toExpr} *: ${tup.tail.toExpr} } + } + given as Liftable[BigInt] = new Liftable[BigInt] { def toExpr(x: BigInt): given QuoteContext => Expr[BigInt] = '{ BigInt(${x.toByteArray.toExpr}) } diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index a59122ad65fa..4e036949d001 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -43,9 +43,9 @@ object Test { (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20).toExpr (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21).toExpr (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22).toExpr -// (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23).toExpr -// (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).toExpr -// (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).toExpr + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23).toExpr + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).toExpr + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).toExpr val list: List[Int] = List(1, 2, 3) val liftedList: Expr[List[Int]] = list