diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-27 14:39:39 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-27 14:53:28 +0100 |
commit | f38a2f78243b4cc481d7150e78adef2b2f8afc8d (patch) | |
tree | 2548b81364d77bb97583c99b2c06b520c44c8ad0 /src/main/scala/scala/async/internal/AsyncAnalysis.scala | |
parent | bdb1686c00a7fc9304c91eb5418a83529ab935fc (diff) | |
download | scala-async-f38a2f78243b4cc481d7150e78adef2b2f8afc8d.tar.gz scala-async-f38a2f78243b4cc481d7150e78adef2b2f8afc8d.tar.bz2 scala-async-f38a2f78243b4cc481d7150e78adef2b2f8afc8d.zip |
Allow lazy vals without await in the initializer
We were incorrectly typechecking the `ClassDef` of the state machine
in the macro in a way that discarded the resulting trees, and only
kept around the symbol.
The led to the the macro engine retypechecking
that node, which somehow led to duplicated lazy val initiaializer
`DefDef`-s in the template, which manifest as a `VerifyError`.
This commit:
- rescues the typechecked `ClassDef` node from the eager
typechecking by the macro
- loosens the restriction on lazy vals in async blocks. They are
still prohibited if they contain an await on the RHS
- Adds a test that shows evalution is indeed lazy.
Fixes #52
Diffstat (limited to 'src/main/scala/scala/async/internal/AsyncAnalysis.scala')
-rw-r--r-- | src/main/scala/scala/async/internal/AsyncAnalysis.scala | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/main/scala/scala/async/internal/AsyncAnalysis.scala b/src/main/scala/scala/async/internal/AsyncAnalysis.scala index ffbc04d..7be6b43 100644 --- a/src/main/scala/scala/async/internal/AsyncAnalysis.scala +++ b/src/main/scala/scala/async/internal/AsyncAnalysis.scala @@ -60,9 +60,8 @@ trait AsyncAnalysis { super.traverse(tree) case Return(_) => c.abort(tree.pos, "return is illegal within a async block") - case ValDef(mods, _, _, _) if mods.hasFlag(Flag.LAZY) => - // TODO lift this restriction - c.abort(tree.pos, "lazy vals are illegal within an async block") + case DefDef(mods, _, _, _, _, _) if mods.hasFlag(Flag.LAZY) && containsAwait => + reportUnsupportedAwait(tree, "lazy val initalizer") case CaseDef(_, guard, _) if guard exists isAwait => // TODO lift this restriction reportUnsupportedAwait(tree, "pattern guard") |