| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order to handle unquoting quasiquotes needs to know if type is
iterable and whats the depth of the iterable nesting which is called
rank. (e.g. List[List[Tree]] is rank 2 iterable of Tree)
The logic that checks depth of iterable nesting didn't take a situation
where T is in fact Iterable[T] which caused infinite recursion in
stripIterable function.
In order to fix it stripIterable now always recurs no more than
non-optional limit times.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. Rename cardinality into rank. Shorter word, easier to
understand, more appropriate in our context.
2. Previously we called any dollar substitution splicing
but this is not consistent with Scheme where splicing
is substitution with non-zero rank.
So now $foo is unquoting and ..$foo and ...$foo is
unquote splicing or just splicing. Correspondingly
splicee becomes unquotee.
3. Rename si7980 test into t7980
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On one hand we know that q"($expr)" is the same as q"$expr". On the
other if we wrap it into a list and splice as q"(..$expr)" we get a
Tuple1 constructor call which is inconsistent.
This pull request fixes this inconsistency by making q"(..$expr)" being
equivalent q"(${expr.head})" for single-element list.
We also add support for matching of expressions as single-element tuples
(similarly to blocks) and remove liftables and unliftables for Tuple1
(which aren't clearly defined any longer due to q"(foo)" == q"foo"
invariant).
|
|
|
|
|
|
|
| |
Previously in some corner situation proper Liftable instance
might not have been resolved.
In particular q"${true}" and q"${""}" used to fail.
|
|
|
|
|
|
|
|
|
| |
Previously leaf concrete types were not lifted which
could have caused weird problems when types is too
precise:
val s1 = Some(2)
q"$s1" // used to fail
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit performs a number of preliminary refactoring needed to
implement unliftable:
1. Replace previous inheritance-heavy implementation of Holes with
similar but much simpler one. Holes are now split into two different
categories: ApplyHole and UnapplyHole which correspondingly represent
information about holes in construction and deconstruction quasiquotes.
2. Make Placeholders extract holes rather than their field values. This
is required to be able to get additional mode-specific information
from holes (e.g. only ApplyHoles have types).
3. Bring ApplyReifier & UnapplyReifier even closer to the future where
there is just a single base Reifier with mode parameter.
Along the way a few bugs were fixed:
1. SI-7980 SI-7996 fail with nice error on bottom types splices
2. Use asSeenFrom instead of typeArguments in parseCardinality.
This fixes a crash if T <:< Iterable[Tree] but does not itself
have any type arguments.
3. Fix spurious error message on splicing of Lists through Liftable[List[T]]
|
| |
|
|
Introduces an extensive ScalaCheck-based test suite for recently
implemented quasiquotes. Provides tools for syntactic tree comparison
and verifying compilation error messages.
|