summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-12-02 18:50:40 +0100
committerDen Shabalin <den.shabalin@gmail.com>2013-12-10 14:09:27 +0100
commit8bde124040f3e053d6312702f2cd722ac92fc132 (patch)
tree7a885b01a74b959ceb3b53272b37034591d9ad3a
parentb345b42cac64aa97e3bbcc6f14ef8f08214ab56f (diff)
downloadscala-8bde124040f3e053d6312702f2cd722ac92fc132.tar.gz
scala-8bde124040f3e053d6312702f2cd722ac92fc132.tar.bz2
scala-8bde124040f3e053d6312702f2cd722ac92fc132.zip
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".
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala3
-rw-r--r--src/reflect/scala/reflect/api/BuildUtils.scala7
-rw-r--r--src/reflect/scala/reflect/internal/BuildUtils.scala9
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala1
-rw-r--r--test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala6
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) =>