Skip to content

Commit 8a17dc4

Browse files
Merge pull request #4547 from dotty-staging/force-quote-trees
Add regression test
2 parents bd6f24c + eab2ed8 commit 8a17dc4

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

tests/run/quote-force.check

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo Location(List(a, b, c, d, e, f))

tests/run/quote-force/quoted_1.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.quoted._
2+
3+
case class Location(owners: List[String])
4+
5+
object Location {
6+
7+
implicit inline def location: Location = ~impl
8+
9+
def impl: Expr[Location] = {
10+
val list = List("a", "b", "c", "d", "e", "f")
11+
'(new Location(~list.toExpr))
12+
}
13+
14+
private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = {
15+
case x :: xs => '{ ~x.toExpr :: ~xs.toExpr }
16+
case Nil => '{ List.empty[T] }
17+
}
18+
}

tests/run/quote-force/quoted_2.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Location._
2+
3+
object Test {
4+
val loc1 = location
5+
def main(args: Array[String]): Unit = {
6+
foo(loc1)
7+
}
8+
9+
def foo(implicit location: Location): Unit = {
10+
println("foo " + location)
11+
}
12+
}

0 commit comments

Comments
 (0)