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

Merged
merged 2 commits into from Mar 1, 2014

Conversation

Projects
None yet
4 participants
@densh
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@retronym

retronym Feb 28, 2014

Member

Lgtm.

Member

retronym commented Feb 28, 2014

Lgtm.

@densh

This comment has been minimized.

Show comment
Hide comment
@densh

densh Feb 28, 2014

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@densh

densh Feb 28, 2014

Contributor

/cc @xeno-by

Contributor

densh commented Feb 28, 2014

/cc @xeno-by

densh added some commits Feb 24, 2014

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 `..$`.
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.

@densh densh added tested and removed needs-attention labels Feb 28, 2014

@xeno-by

This comment has been minimized.

Show comment
Hide comment
@xeno-by

xeno-by Mar 1, 2014

Could you elaborate on the effect of this change?

xeno-by commented on fae2912 Mar 1, 2014

Could you elaborate on the effect of this change?

@xeno-by

This comment has been minimized.

Show comment
Hide comment
@xeno-by

xeno-by Mar 1, 2014

Member

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

Member

xeno-by commented Mar 1, 2014

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

xeno-by added a commit that referenced this pull request Mar 1, 2014

Merge pull request #3591 from densh/si/8275
SI-8275 allow to directly extract block contents of the case def

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

1 check passed

default pr-scala Took 83 min.
Details

@adriaanm adriaanm modified the milestones: 2.11.0-RC3, 2.11.0-RC2 Mar 18, 2014

@scabug scabug referenced this pull request in scala/bug Apr 7, 2017

Closed

Can't extract CaseDef body as a Block stats #8275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment