summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-02-28 14:04:31 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-02-28 21:27:27 +0100
commitfae2912a60b33f6866a87d30a4e698e433939dc7 (patch)
tree76ec65450632f773fa3790d83bcb01fdb67c0b5b /src/compiler
parente17c055df049c6f8b42d31629e70df5bb44e2bfb (diff)
downloadscala-fae2912a60b33f6866a87d30a4e698e433939dc7.tar.gz
scala-fae2912a60b33f6866a87d30a4e698e433939dc7.tar.bz2
scala-fae2912a60b33f6866a87d30a4e698e433939dc7.zip
Fix block construction/deconstruction asymmetry
Deconstruction of blocks in case clauses uncovered asymmetry between construction and deconstruction of blocks: tree match { case cq"$pat => ..$cases" => cq"$pat => ..$cases" } Such an identity-like transformation used to produce an incorrect tree due to the fact that zero-element block was mistakingly associated with empty tree. Such association was used as a solution to block flatenning: val ab = q"a; b" q"..$ab; c" // ==> q"a; b; c" val a = q"a" q"..$a; c" // ==> q"a; c" val empty = q"" q"..$empty; c" // ==> q"c" This commit changes meaning of zero-element block to a be a synthetic unit instead. This is consistent with parsing of `{}`, cases, ifs and non-abstract empty-bodied methods. A local tweak to block flattenning is used to flatten empty tree as empty list instead.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index 4937bfc35d..481897d0ec 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -202,6 +202,8 @@ trait Reifiers { self: Quasiquotes =>
// not to cause infinite recursion.
case block @ SyntacticBlock(stats) if block.isInstanceOf[Block] =>
reifyBuildCall(nme.SyntacticBlock, stats)
+ case SyntheticUnit() =>
+ reifyBuildCall(nme.SyntacticBlock, Nil)
case Try(block, catches, finalizer) =>
reifyBuildCall(nme.SyntacticTry, block, catches, finalizer)
case Match(selector, cases) =>