Permalink
Browse files

SI-8016 Ensure that q”..$xs” is equivalent to q”{..$xs}”

  • Loading branch information...
1 parent 8bde124 commit 207b945353bd49f4357ebb9921280591b309db3f @densh densh committed Dec 2, 2013
@@ -161,7 +161,12 @@ trait Parsers { self: Quasiquotes =>
}
object TermParser extends Parser {
- def entryPoint = { parser => gen.mkTreeOrBlock(parser.templateOrTopStatSeq()) }
+ def entryPoint = { parser =>
+ parser.templateOrTopStatSeq() match {
+ case head :: Nil => Block(Nil, head)
+ case lst => gen.mkTreeOrBlock(lst)
+ }
+ }
}
object TypeParser extends Parser {
@@ -167,6 +167,10 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticTypeApplied, fun, targs)
case SyntacticFunction(args, body) =>
reifyBuildCall(nme.SyntacticFunction, args, body)
+ case Block(Nil, Placeholder(tree, _, DotDot)) =>
+ mirrorBuildCall(nme.SyntacticBlock, tree)
+ case Block(Nil, other) =>
+ reifyTree(other)
case Block(stats, last) =>
reifyBuildCall(nme.SyntacticBlock, stats :+ last)
// parser emits trees with scala package symbol to ensure
@@ -203,4 +203,10 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
assert(q"f(..${l1 ++ l2}, $baz)" ≈ q"f(foo, bar, baz)")
assert(q"f(${if (true) q"a" else q"b"})" ≈ q"f(a)")
}
+
+ property("SI-8016") = test {
+ val xs = q"1" :: q"2" :: Nil
+ assertEqAst(q"..$xs", "{1; 2}")
+ assertEqAst(q"{..$xs}", "{1; 2}")
+ }
}

0 comments on commit 207b945

Please sign in to comment.