Skip to content

Commit 8bde124

Browse files
committed
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".
1 parent b345b42 commit 8bde124

File tree

5 files changed

+4
-22
lines changed

5 files changed

+4
-22
lines changed

src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ trait Reifiers { self: Quasiquotes =>
161161
reifyBuildCall(nme.SyntacticForYield, enums, body)
162162
case SyntacticAssign(lhs, rhs) =>
163163
reifyBuildCall(nme.SyntacticAssign, lhs, rhs)
164-
case SyntacticApplied(fun, List(args))
165-
if args.forall { case Placeholder(_, _, DotDotDot) => false case _ => true } =>
166-
reifyBuildCall(nme.SyntacticApply, fun, args)
167164
case SyntacticApplied(fun, argss) if argss.nonEmpty =>
168165
reifyBuildCall(nme.SyntacticApplied, fun, argss)
169166
case SyntacticTypeApplied(fun, targs) if targs.nonEmpty =>

src/reflect/scala/reflect/api/BuildUtils.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,6 @@ private[reflect] trait BuildUtils { self: Universe =>
122122
def unapply(tree: Tree): Some[(Tree, List[List[Tree]])]
123123
}
124124

125-
val SyntacticApply: SyntacticApplyExtractor
126-
127-
trait SyntacticApplyExtractor {
128-
def apply(tree: Tree, args: List[Tree]): Tree
129-
def unapply(tree: Tree): Some[(Tree, List[Tree])]
130-
}
131-
132125
val SyntacticClassDef: SyntacticClassDefExtractor
133126

134127
trait SyntacticClassDefExtractor {

src/reflect/scala/reflect/internal/BuildUtils.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@ trait BuildUtils { self: SymbolTable =>
165165
}
166166
}
167167

168-
object SyntacticApply extends SyntacticApplyExtractor {
169-
def apply(tree: Tree, args: List[Tree]): Tree = SyntacticApplied(tree, List(args))
170-
171-
def unapply(tree: Tree): Some[(Tree, List[Tree])] = tree match {
172-
case Apply(fun, args) => Some((fun, args))
173-
case other => Some((other, Nil))
174-
}
175-
}
176-
177168
// recover constructor contents generated by gen.mkTemplate
178169
protected object UnCtor {
179170
def unapply(tree: Tree): Option[(Modifiers, List[List[ValDef]], List[Tree])] = tree match {

src/reflect/scala/reflect/internal/StdNames.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ trait StdNames {
588588
val Select: NameType = "Select"
589589
val SelectFromTypeTree: NameType = "SelectFromTypeTree"
590590
val SyntacticApplied: NameType = "SyntacticApplied"
591-
val SyntacticApply: NameType = "SyntacticApply"
592591
val SyntacticAssign: NameType = "SyntacticAssign"
593592
val SyntacticBlock: NameType = "SyntacticBlock"
594593
val SyntacticClassDef: NameType = "SyntacticClassDef"

test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import scala.reflect.runtime.universe._, Flag._
33

44
object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") {
55
property("f(..x) = f") = test {
6-
val q"f(..$args)" = q"f"
7-
assert(args Nil)
6+
// see SI-8008
7+
assertThrows[MatchError] {
8+
val q"f(..$args)" = q"f"
9+
}
810
}
911

1012
property("f(x)") = forAll { (x: Tree) =>

0 commit comments

Comments
 (0)