aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scala/async/internal/Lifter.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-10-23 16:25:02 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-01-19 14:27:31 +1000
commit549a656fa22af5f7f0c5e89dd6e0a19ed4b604f5 (patch)
tree7a7c778a24143923a674acb9db30ecdc5e3f8f5e /src/main/scala/scala/async/internal/Lifter.scala
parent634c454dbd546e2f3db6321b4047b3cebd2f899a (diff)
downloadscala-async-549a656fa22af5f7f0c5e89dd6e0a19ed4b604f5.tar.gz
scala-async-549a656fa22af5f7f0c5e89dd6e0a19ed4b604f5.tar.bz2
scala-async-549a656fa22af5f7f0c5e89dd6e0a19ed4b604f5.zip
Various fixes to late expansion
- Detect cross-state symbol references where the RefTree is nested in a LabelDef. Failure to do so led to ill-scoped local variable references which sometimes manifest as VerifyErrors. - Emit a default case in the Match intended to be a tableswitch. We have to do this ourselves if we expand after pattern matcher - Cleanup generated code to avoid redundant blocks - Avoid unnecessary `matchRes` temporary variable for unit-typed pattern matches - Fix the trace level logging in the ANF transform to restore indented output. - Emit `{ state = nextState; ... }` rather than `try { ... } finally { state = nextState }` in state handlers. This simplifies generated code and has the same meaning, as the code in the state machine isn't reentrant and can't observe the "early" transition of the state.
Diffstat (limited to 'src/main/scala/scala/async/internal/Lifter.scala')
-rw-r--r--src/main/scala/scala/async/internal/Lifter.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/scala/scala/async/internal/Lifter.scala b/src/main/scala/scala/async/internal/Lifter.scala
index 2998baf..9481f69 100644
--- a/src/main/scala/scala/async/internal/Lifter.scala
+++ b/src/main/scala/scala/async/internal/Lifter.scala
@@ -76,8 +76,9 @@ trait Lifter {
// are already accounted for.
val stateIdToDirectlyReferenced: Map[Int, List[Symbol]] = {
val refs: List[(Int, Symbol)] = asyncStates.flatMap(
- asyncState => asyncState.stats.filterNot(_.isDef).flatMap(_.collect {
- case rt: RefTree if symToDefiningState.contains(rt.symbol) => (asyncState.state, rt.symbol)
+ asyncState => asyncState.stats.filterNot(t => t.isDef && !isLabel(t.symbol)).flatMap(_.collect {
+ case rt: RefTree
+ if symToDefiningState.contains(rt.symbol) => (asyncState.state, rt.symbol)
})
)
toMultiMap(refs)