From 8bde124040f3e053d6312702f2cd722ac92fc132 Mon Sep 17 00:00:00 2001 From: Den Shabalin Date: Mon, 2 Dec 2013 18:50:40 +0100 Subject: SI-8008 Make q”f(..$xs)” only match trees with Apply node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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". --- src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala | 3 --- src/reflect/scala/reflect/api/BuildUtils.scala | 7 ------- src/reflect/scala/reflect/internal/BuildUtils.scala | 9 --------- src/reflect/scala/reflect/internal/StdNames.scala | 1 - test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala | 6 ++++-- 5 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala index b28c85cfc2..6922ec1bb4 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala @@ -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 => diff --git a/src/reflect/scala/reflect/api/BuildUtils.scala b/src/reflect/scala/reflect/api/BuildUtils.scala index cf05aefe72..9af6422e0c 100644 --- a/src/reflect/scala/reflect/api/BuildUtils.scala +++ b/src/reflect/scala/reflect/api/BuildUtils.scala @@ -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 { diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index 8fc1869dd2..d7d0b27dd2 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -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 { diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index c26e815df1..9b5cdcb402 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -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" diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index bd81afa125..8d1ada342a 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -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) => -- cgit v1.2.3