aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scala/async/internal/AsyncAnalysis.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-03-27 14:39:39 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-03-27 14:52:00 +0100
commitee66e081ad0dec0e0c20fbb7e40fd20122bba238 (patch)
tree354938b6e0e3ab18bf89f7d8090456fb767f3509 /src/main/scala/scala/async/internal/AsyncAnalysis.scala
parent6808ce4a4023becd984ebe06805d1eeb844694e1 (diff)
downloadscala-async-ee66e081ad0dec0e0c20fbb7e40fd20122bba238.tar.gz
scala-async-ee66e081ad0dec0e0c20fbb7e40fd20122bba238.tar.bz2
scala-async-ee66e081ad0dec0e0c20fbb7e40fd20122bba238.zip
[backport] 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. (cherry picked from commit cc4587b1985519f7049d0feb0783d8e22c10f792) Conflicts: src/main/scala/scala/async/internal/AsyncAnalysis.scala src/main/scala/scala/async/internal/AsyncTransform.scala
Diffstat (limited to 'src/main/scala/scala/async/internal/AsyncAnalysis.scala')
-rw-r--r--src/main/scala/scala/async/internal/AsyncAnalysis.scala5
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 76c2dba..274603f 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(_) =>
abort(tree.pos, "return is illegal within a async block")
- case ValDef(mods, _, _, _) if mods.hasFlag(Flag.LAZY) =>
- // TODO lift this restriction
- 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")