diff --git a/tests/run/quote-force.check b/tests/run/quote-force.check new file mode 100644 index 000000000000..400dd5ebfcc6 --- /dev/null +++ b/tests/run/quote-force.check @@ -0,0 +1 @@ +foo Location(List(a, b, c, d, e, f)) diff --git a/tests/run/quote-force/quoted_1.scala b/tests/run/quote-force/quoted_1.scala new file mode 100644 index 000000000000..47c01a3c3abf --- /dev/null +++ b/tests/run/quote-force/quoted_1.scala @@ -0,0 +1,18 @@ +import scala.quoted._ + +case class Location(owners: List[String]) + +object Location { + + implicit inline def location: Location = ~impl + + def impl: Expr[Location] = { + val list = List("a", "b", "c", "d", "e", "f") + '(new Location(~list.toExpr)) + } + + private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = { + case x :: xs => '{ ~x.toExpr :: ~xs.toExpr } + case Nil => '{ List.empty[T] } + } +} diff --git a/tests/run/quote-force/quoted_2.scala b/tests/run/quote-force/quoted_2.scala new file mode 100644 index 000000000000..341cab5b2ce1 --- /dev/null +++ b/tests/run/quote-force/quoted_2.scala @@ -0,0 +1,12 @@ +import Location._ + +object Test { + val loc1 = location + def main(args: Array[String]): Unit = { + foo(loc1) + } + + def foo(implicit location: Location): Unit = { + println("foo " + location) + } +}