| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
ScalaCheck ever being under partest in the first place is ancient
history, from back in the Ant build days (shudder)
ScalaCheck support was removed from partest 1.1.0, which we already
upgraded to in a recent commit
also upgrades ScalaCheck from 1.11.6 to 1.13.4, since we might
as well. no source changes were necessary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously it was impossible to match a block that was constructed as
Block(Nil, term)
Due to the fact that quasiquotes always flatten those into just term. This is
a correct behaviour for construction (for sake of consistency with parser) but
doing it in deconstruction mode make it impossible to match such blocks which
could have been constructed manually somewhere.
To fix this we just disable block flattening in deconstruction mode.
Interestingly enough this doesn't break existing code due to the fact that
quasiquote's block matcher also matches expressions as single-element blocks.
This allows to match single-element blocks with patterns like q"{ $foo }".
|
| |
|
|
|
|
|
| |
q"new C" and q"new C()" have identical trees after parsing. This
commit adds knowledge of this invariant to SyntacticNew.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously one could match a partial function with match quasiquote:
scala> val q"$scrutinee match { case ..$cases }" = q"{ case Foo => Bar
}"
scrutinee: universe.Tree = <empty>
cases: List[universe.CaseDef] = List(case Foo => Bar)
This was quite annoying as it leaked encoding of partial functions as
Match trees with empty tree in place of scrutinee.
This commit make sure that matches and partial functions are disjoint
and don't match one another (while preserving original encoding under
the hood out of sight of the end user.)
|
|
|
|
|
|
| |
Due to tree re-use it used to be the fact that type quasiquotes could
match term trees. This commit makes sure selections and applied type and
type applied are all non-overlapping between q and tq.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Deconstruction of blocks in case clauses uncovered asymmetry between
construction and deconstruction of blocks:
tree match { case cq"$pat => ..$cases" => cq"$pat => ..$cases" }
Such an identity-like transformation used to produce an incorrect tree due
to the fact that zero-element block was mistakingly associated with
empty tree. Such association was used as a solution to block flatenning:
val ab = q"a; b"
q"..$ab; c" // ==> q"a; b; c"
val a = q"a"
q"..$a; c" // ==> q"a; c"
val empty = q""
q"..$empty; c" // ==> q"c"
This commit changes meaning of zero-element block to a be a synthetic unit
instead. This is consistent with parsing of `{}`, cases, ifs and
non-abstract empty-bodied methods. A local tweak to block flattenning is
used to flatten empty tree as empty list instead.
|
|
|
|
|
| |
Due to the fact that blocks in cases are implicit one might expect to be
able to extract its contents with `..$`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds support for patterns like:
val q"{ ..$init; $last }" = q"{ a; b; c }"
// init == List(q"a", q"b")
// last == q"c"
Which under the hood get compiled as `:+` patterns:
SyntacticBlock(init :+ last)
|
|
|
|
|
|
|
|
|
|
| |
Previously it also matched other nodes but returned Nil as value of xs.
This behavior was added for sake of consistentcy with q”f[..$ts]”. On
the other hand q”f[..$Nil]” == q”f” but q”f(..$Nil)” == q”f()” not q”f”.
Due to this deconstruction/construction symmetry was broken.
On the other hand applications also have q"f(...$xss)" option which is
infact similar to q"f[..$ts]". Splicing Nil into it also results in q"f".
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
During parsing some names are generated artificially using freshTermName & freshTypeName (e.g. `x$1`). Such names should be reified in a different way because they are assumed to be always fresh and non-overlapping with the environment. So `x$1` should reify down to equivalent of `freshTermName("x$")` rather than `TermName("x$1")`.
But this is not enough. One name can be used more than once in a tree. E.g. `q"_ + 1"` desugars into `q"x$1 => x$1 + 1"`. So we need to ensure that every place where `x$1` is used gets the same fresh name. Hence the need for `withFreshTermName` that lets q"_ + 1" quasiquote desugare into equivalent of `withFreshTermName("x$") { freshx => q"$freshx => $freshx + 1" }`.
For pattern quasiquotes it's a bit different. Due to the fact that end-result must be a pattern we need to represent fresh names as patterns too. A natural way to express that something is fresh is to represent it as a free variable (e.g. any name will do in that place). But due to possible use of the same name in multiple places we need to make sure that all such places have the same values by adding a sequence of guards to the pattern.
Previously such names were reified naively and it could have caused name collision problems and inability to properly much on trees that contain such names.
|
|
|
|
|
|
|
|
|
|
|
| |
There are three kinds of assign-like trees:
1. Assign(lhs, rhs) // $lhs = $rhs
3. AssignOrNamedArg(lhs, rhs) // $lhs = $rhs
2. Apply(Select(f, nme.update), args :+ rhs) // $f(..$args) = $rhs
New syntactic combinator unifies all of them and lets users not to think
about these implementations details.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. blocks now match single term-level expressions to account for
automatic block elimination. E.g.
val q"{ ..$stats }" = q"foo"
will match into stats = List(q"foo"). This is useful to uniformly
deal with blocks on term level.
2. blocks in quasiquotes collapse into single expressions
3. Applied and TypeApplied now have constructors too which helps
to unify matching and extraction in quasiquote reifier
4. TypeApplied now matches AppliedTypeTree too
5. Add Syntactic prefix to Applied and TypeApplied
|
| |
|
|
Introduces an extensive ScalaCheck-based test suite for recently
implemented quasiquotes. Provides tools for syntactic tree comparison
and verifying compilation error messages.
|