aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/neg/NakedAwait.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:53:28 +0100
commitf38a2f78243b4cc481d7150e78adef2b2f8afc8d (patch)
tree2548b81364d77bb97583c99b2c06b520c44c8ad0 /src/test/scala/scala/async/neg/NakedAwait.scala
parentbdb1686c00a7fc9304c91eb5418a83529ab935fc (diff)
downloadscala-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/test/scala/scala/async/neg/NakedAwait.scala')
-rw-r--r--src/test/scala/scala/async/neg/NakedAwait.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/scala/scala/async/neg/NakedAwait.scala b/src/test/scala/scala/async/neg/NakedAwait.scala
index 9778c72..f9264c7 100644
--- a/src/test/scala/scala/async/neg/NakedAwait.scala
+++ b/src/test/scala/scala/async/neg/NakedAwait.scala
@@ -163,10 +163,10 @@ class NakedAwait {
@Test
def lazyValIllegal() {
- expectError("lazy vals are illegal") {
+ expectError("await must not be used under a lazy val initalizer") {
"""
| import _root_.scala.async.internal.AsyncId._
- | def foo(): Any = async { val x = { lazy val y = 0; y } }
+ | def foo(): Any = async { val x = { lazy val y = await(0); y } }
| ()
|
|""".stripMargin