diff options
author | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-03-24 15:21:32 +0100 |
---|---|---|
committer | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-03-24 15:56:46 +0100 |
commit | fa91b173f7e5e64c2221d50af0684985f046637c (patch) | |
tree | 4ce1ffb4b44edb37aef60cd6e3f93e44460ab146 /test/files/scalacheck/quasiquotes/ErrorProps.scala | |
parent | bcf24ec9ba07408ad9e8745135cc941ac3e76289 (diff) | |
download | scala-fa91b173f7e5e64c2221d50af0684985f046637c.tar.gz scala-fa91b173f7e5e64c2221d50af0684985f046637c.tar.bz2 scala-fa91b173f7e5e64c2221d50af0684985f046637c.zip |
SI-8200 provide an identity liftable for trees
This liftable hasn't been originally included in the set of standard
liftables due to following contradiction:
1. On one hand we can have identity lifting that seems to be quite
consistent with regular unquoting:
q"..${List(1,2)}" <==> q"1; 2"
q"${List(1,2)}" <==> q"s.c.i.List(1, 2)"
q"..${List(q"a", q"b")}” <==> q"a; b"
q"${List(q"a", q"b")}" <==> q"s.c.i.List(a, b)"
This is also consistent with how lisp unquoting works although they
get lifting for free thanks to homoiconicity:
// scala
scala> val x = List(q"a", q"b); q"f($x)"
q"f(s.c.i.List(a, b))"
// scheme
> (let [(x (list a b))] `(f ,x))
'(f (list a b))
2. On the other hand lifting is an operation that converts a value into
a code that when evaluated turns into the same value. In this sense
Liftable[Tree] means reification of a tree into a tree that
represents it, i.e.:
q"${List(q"a", q"b")}"
<==>
q"""s.c.i.List(Ident(TermName("a")), Ident(TermName("b")))"""
But I belive that such lifting will be very confusing for everyone
other than a few very advanced users.
This commit introduces the first option as a default Liftable for trees.
Diffstat (limited to 'test/files/scalacheck/quasiquotes/ErrorProps.scala')
-rw-r--r-- | test/files/scalacheck/quasiquotes/ErrorProps.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala index 3d9b27de77..b07d3d90d5 100644 --- a/test/files/scalacheck/quasiquotes/ErrorProps.scala +++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala @@ -9,9 +9,10 @@ object ErrorProps extends QuasiquoteProperties("errors") { """) property("can't unquote with given rank") = fails( - "Can't unquote List[reflect.runtime.universe.Ident], consider using ..", + "Can't unquote List[StringBuilder], consider using .. or providing an implicit instance of Liftable[List[StringBuilder]]", """ - val xs = List(q"x", q"x") + import java.lang.StringBuilder + val xs: List[StringBuilder] = Nil q"$xs" """) @@ -71,9 +72,10 @@ object ErrorProps extends QuasiquoteProperties("errors") { """) property("use ... rank or provide liftable") = fails( - "Can't unquote List[List[reflect.runtime.universe.Ident]], consider using ...", + "Can't unquote List[List[StringBuilder]], consider using ... or providing an implicit instance of Liftable[List[List[StringBuilder]]]", """ - val xs = List(List(q"x", q"x")) + import java.lang.StringBuilder + val xs: List[List[StringBuilder]] = Nil q"$xs" """) |