Permalink
Browse files

SI-8008 Make q”f(..$xs)” only match trees with Apply node

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".
  • Loading branch information...
1 parent b345b42 commit 8bde124040f3e053d6312702f2cd722ac92fc132 @densh densh committed Dec 2, 2013
@@ -161,9 +161,6 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticForYield, enums, body)
case SyntacticAssign(lhs, rhs) =>
reifyBuildCall(nme.SyntacticAssign, lhs, rhs)
- case SyntacticApplied(fun, List(args))
- if args.forall { case Placeholder(_, _, DotDotDot) => false case _ => true } =>
- reifyBuildCall(nme.SyntacticApply, fun, args)
case SyntacticApplied(fun, argss) if argss.nonEmpty =>
reifyBuildCall(nme.SyntacticApplied, fun, argss)
case SyntacticTypeApplied(fun, targs) if targs.nonEmpty =>
@@ -122,13 +122,6 @@ private[reflect] trait BuildUtils { self: Universe =>
def unapply(tree: Tree): Some[(Tree, List[List[Tree]])]
}
- val SyntacticApply: SyntacticApplyExtractor
-
- trait SyntacticApplyExtractor {
- def apply(tree: Tree, args: List[Tree]): Tree
- def unapply(tree: Tree): Some[(Tree, List[Tree])]
- }
-
val SyntacticClassDef: SyntacticClassDefExtractor
trait SyntacticClassDefExtractor {
@@ -165,15 +165,6 @@ trait BuildUtils { self: SymbolTable =>
}
}
- object SyntacticApply extends SyntacticApplyExtractor {
- def apply(tree: Tree, args: List[Tree]): Tree = SyntacticApplied(tree, List(args))
-
- def unapply(tree: Tree): Some[(Tree, List[Tree])] = tree match {
- case Apply(fun, args) => Some((fun, args))
- case other => Some((other, Nil))
- }
- }
-
// recover constructor contents generated by gen.mkTemplate
protected object UnCtor {
def unapply(tree: Tree): Option[(Modifiers, List[List[ValDef]], List[Tree])] = tree match {
@@ -588,7 +588,6 @@ trait StdNames {
val Select: NameType = "Select"
val SelectFromTypeTree: NameType = "SelectFromTypeTree"
val SyntacticApplied: NameType = "SyntacticApplied"
- val SyntacticApply: NameType = "SyntacticApply"
val SyntacticAssign: NameType = "SyntacticAssign"
val SyntacticBlock: NameType = "SyntacticBlock"
val SyntacticClassDef: NameType = "SyntacticClassDef"
@@ -3,8 +3,10 @@ import scala.reflect.runtime.universe._, Flag._
object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") {
property("f(..x) = f") = test {
- val q"f(..$args)" = q"f"
- assert(args ≈ Nil)
+ // see SI-8008
+ assertThrows[MatchError] {
+ val q"f(..$args)" = q"f"
+ }
}
property("f(x)") = forAll { (x: Tree) =>

0 comments on commit 8bde124

Please sign in to comment.