Skip to content

Commit

Permalink
SI-8385 make sure $quasiquote$tuple gets reified properly
Browse files Browse the repository at this point in the history
Previously due to greediness of SyntacticApplied there was a chance that
quasiquote tuple placeholder got reified as its representation rather
than its meaning.
  • Loading branch information
densh committed Mar 9, 2014
1 parent 973f225 commit f94959d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
Expand Up @@ -181,6 +181,10 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticForYield, enums, body)
case SyntacticAssign(lhs, rhs) =>
reifyBuildCall(nme.SyntacticAssign, lhs, rhs)
// rest will always be non-empty due to the fact that every single-parens
// application will be reified by reifyTreePlaceholder before it gets here.
case SyntacticApplied(id @ Ident(nme.QUASIQUOTE_TUPLE), first :: rest) =>
mirrorBuildCall(nme.SyntacticApplied, reifyTreePlaceholder(Apply(id, first)), reify(rest))
case SyntacticApplied(fun, argss) if argss.nonEmpty =>
reifyBuildCall(nme.SyntacticApplied, fun, argss)
case SyntacticTypeApplied(fun, targs) if targs.nonEmpty =>
Expand Down
8 changes: 8 additions & 0 deletions test/files/scalacheck/quasiquotes/TermConstructionProps.scala
Expand Up @@ -295,4 +295,12 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
val q"$a = $b = $c = $d = $e = $f = $g = $h = $k = $l" = q"a = b = c = d = e = f = g = h = k = l"
assert(a ≈ q"a" && b ≈ q"b" && c ≈ q"c" && d ≈ q"d" && e ≈ q"e" && g ≈ q"g" && h ≈ q"h" && k ≈ q"k" && l ≈ q"l")
}

property("SI-8385 a") = test {
assertEqAst(q"(foo.x = 1)(2)", "(foo.x = 1)(2)")
}

property("SI-8385 b") = test {
assertEqAst(q"(() => ())()", "(() => ())()")
}
}

0 comments on commit f94959d

Please sign in to comment.