From 26cec654dab8a1c218914c29538718a79512fde2 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 29 Nov 2018 17:05:44 +0100 Subject: [PATCH 1/2] Move scala.quoted package object to scala 3 sources --- library/{src => src-scala3}/scala/quoted/package.scala | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename library/{src => src-scala3}/scala/quoted/package.scala (100%) diff --git a/library/src/scala/quoted/package.scala b/library/src-scala3/scala/quoted/package.scala similarity index 100% rename from library/src/scala/quoted/package.scala rename to library/src-scala3/scala/quoted/package.scala From 8c0178e85e6f82b3fc3372ce513e082e8a837d3d Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 29 Nov 2018 17:07:45 +0100 Subject: [PATCH 2/2] Add List[Expr[T]] to Expr[List[T]] conversion in the library --- library/src-scala3/scala/quoted/package.scala | 9 +++++++++ .../xml-interpolation-2/XmlQuote_1.scala | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/library/src-scala3/scala/quoted/package.scala b/library/src-scala3/scala/quoted/package.scala index 3a1be2f5f5e1..f7ece4905368 100644 --- a/library/src-scala3/scala/quoted/package.scala +++ b/library/src-scala3/scala/quoted/package.scala @@ -6,4 +6,13 @@ package object quoted { def toExpr(implicit ev: Liftable[T]): Expr[T] = ev.toExpr(x) } + implicit class ListOfExprOps[T](val list: List[Expr[T]]) extends AnyVal { + def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = { + def rec(list: List[Expr[T]]): Expr[List[T]] = list match { + case x :: xs => '{ (~x) :: (~rec(xs)) } + case Nil => '(Nil) + } + rec(list) + } + } } diff --git a/tests/run-separate-compilation/xml-interpolation-2/XmlQuote_1.scala b/tests/run-separate-compilation/xml-interpolation-2/XmlQuote_1.scala index e9f479739f99..39e51aa50ddf 100644 --- a/tests/run-separate-compilation/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-separate-compilation/xml-interpolation-2/XmlQuote_1.scala @@ -56,11 +56,7 @@ object XmlQuote { // [a0, ...]: Any* val args2: Expr[List[Any]] = args.unseal.underlyingArgument match { case Typed(Repeated(args0), _) => // statically known args, make list directly - def liftListOfAny(lst: List[Expr[Any]]): Expr[List[Any]] = lst match { - case x :: xs => '{ ~x :: ~liftListOfAny(xs) } - case Nil => '(Nil) - } - liftListOfAny(args0.map(_.seal[Any])) + args0.map(_.seal[Any]).toExprOfList case _ => '((~args).toList)