From eab2ed8f0507b0f2538334f7a3ce2cf893aba717 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 19 May 2018 12:02:53 +0200 Subject: [PATCH] Force read unpickled trees to avoid Ycheck failure --- tests/run/quote-force.check | 1 + tests/run/quote-force/quoted_1.scala | 18 ++++++++++++++++++ tests/run/quote-force/quoted_2.scala | 12 ++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 tests/run/quote-force.check create mode 100644 tests/run/quote-force/quoted_1.scala create mode 100644 tests/run/quote-force/quoted_2.scala 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) + } +}