summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/LiftableProps.scala
Commit message (Collapse)AuthorAgeFilesLines
* SI-8466 fix quasiquote crash on recursively iterable unliftingDenys Shabalin2014-04-021-0/+7
| | | | | | | | | | | | | 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.
* SI-8200 provide an identity liftable for treesDenys Shabalin2014-03-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix quasiquote terminology to be consistent with SchemeDenys Shabalin2014-02-201-10/+10
| | | | | | | | | | | | | | | 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
* Make handling of tuples more consistent in quasi-quotesDenys Shabalin2014-02-101-1/+0
| | | | | | | | | | | | | | 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).
* Test edge cases of literal liftingDen Shabalin2014-01-161-0/+11
| | | | | | | Previously in some corner situation proper Liftable instance might not have been resolved. In particular q"${true}" and q"${""}" used to fail.
* Lift Some, None, Nil, Left, Right not just supertypesDenys Shabalin2014-01-161-1/+38
| | | | | | | | | 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
* Test tuple lifting and unliftingDen Shabalin2013-12-101-0/+25
|
* Refactor Holes and Reifiers slices of Quasiquotes cakeDen Shabalin2013-12-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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]]
* simplify imports in quasiquotes scalacheck testsDen Shabalin2013-11-121-7/+2
|
* tests for quasiquotesDen Shabalin2013-07-081-0/+84
Introduces an extensive ScalaCheck-based test suite for recently implemented quasiquotes. Provides tools for syntactic tree comparison and verifying compilation error messages.