You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce Labeled blocks, and use them in PatternMatcher.
A Labeled block is an expression tree of the form
label[T]: {
expr
}
where `expr` must conform to the type `T`. In addition, within
`expr` (but nowhere else), return from the label is allowed:
return[label] e
where `e` must conform to the type `T` as well.
If execution of `expr` completes normally (rather than throwing an
exception or returning, etc.), then the result of evaluating the
`Labeled` block is the result of `expr`. If a `return[label] e` is
reached, the execution of `expr` is interrupted, and the result of
evaluating the `Labeled` block is the result of evaluating the
argument `e`.
Implementation-wise, a `Labeled` block is represented as a `Tree`
with the shape:
Labeled(Bind(labelName), expr)
where the `Bind` nodes holds the definition of the label symbol.
That symbol is a term symbol with the flag `Label` (but not
`Method`, unlike symbols for label-defs) and whose `info` is the
result type `T` of the labeled block.
We use those new `Labeled` blocks in `PatternMatcher`, instead of
label-defs. This is the first step towards completely removing
label-defs from the compiler.
This commit structurally fixes a few issues:
* It fixes#1313 through the `mergeTests` optimization.
* It fixes#4563 because Labeled blocks are erasure-friendly.
* It does a big step towards fixing the upstream test t10387: the
compiler can get to the back-end on that test, but it produces
too much bytecode for a single JVM method. We do add a sister
test t10387b which works because optimizations can kick in.
0 commit comments