Skip to content

SI-8275 allow to directly extract block contents of the case def #3591

Merged
merged 2 commits into from Mar 1, 2014

4 participants

@densh
densh commented Feb 28, 2014

Due to the fact that blocks in cases are implicit one might expect to be
able to extract its contents with ..$.

review @xeno-by

@densh densh added this to the 2.11.0-RC2 milestone Feb 28, 2014
@densh densh assigned retronym and xeno-by and unassigned retronym Feb 28, 2014
@retronym
The Scala Programming Language member

Lgtm.

@densh
densh commented Feb 28, 2014

There is an additional problem I've noticed here so please don't merge it yet, I'll update soon with revised fix.

@densh
densh commented Feb 28, 2014

/cc @xeno-by

densh added some commits Feb 24, 2014
@densh densh SI-8275 allow to directly extract block contents of the case def
Due to the fact that blocks in cases are implicit one might expect to be
able to extract its contents with `..$`.
e17c055
@densh densh 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.
fae2912
@densh densh added tested and removed needs-attention labels Feb 28, 2014
@xeno-by
xeno-by commented on fae2912 Mar 1, 2014

Could you elaborate on the effect of this change?

@xeno-by
xeno-by commented Mar 1, 2014

All in all sounds reasonable. I think val q"()" = q"{}" is a right thing to do.

@xeno-by xeno-by merged commit 6b63bb8 into scala:master Mar 1, 2014

1 check passed

Details default pr-scala Took 83 min.
@adriaanm adriaanm modified the milestone: 2.11.0-RC3, 2.11.0-RC2 Mar 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.