diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-26 18:26:11 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-27 08:36:30 +0100 |
commit | 9ad8783d39848d2c5dc5a2a73ac8d54c2859dd0e (patch) | |
tree | 3863b06fa4c9b4617f305160793f6d3935370d9c /src/test | |
parent | fe9a0023e685a2924cba10ec738e8babe9e7bd7b (diff) | |
download | scala-async-9ad8783d39848d2c5dc5a2a73ac8d54c2859dd0e.tar.gz scala-async-9ad8783d39848d2c5dc5a2a73ac8d54c2859dd0e.tar.bz2 scala-async-9ad8783d39848d2c5dc5a2a73ac8d54c2859dd0e.zip |
Disallow await in non-primary param sections.
We can allow it, but we need to treat nested
Apply trees holistically, in order to lift out
all the arguments and maintain the correct
evaluation order.
Fixes #33.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/scala/async/run/anf/AnfTransformSpec.scala | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala index 595fa6c..f274068 100644 --- a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala +++ b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala @@ -163,7 +163,7 @@ class AnfTransformSpec { val result = AsyncId.async { val x = "" match { case "" if false => AsyncId.await(1) + 1 - case _ => 2 + AsyncId.await(1) + case _ => 2 + AsyncId.await(1) } val y = x "" match { @@ -222,9 +222,37 @@ class AnfTransformSpec { def foo(a: Int, b: Int) = (a, b) val result = async { var i = 0 - def next() = {i += 1; i} + def next() = { + i += 1; i + } foo(next(), await(next())) } result mustBe ((1, 2)) } + + @Test + def awaitNotAllowedInNonPrimaryParamSection1() { + expectError("implementation restriction: await may only be used in the first parameter list.") { + """ + | import _root_.scala.async.AsyncId.{async, await} + | def foo(primary: Any)(i: Int) = i + | async { + | foo(???)(await(0)) + | } + """.stripMargin + } + } + + @Test + def awaitNotAllowedInNonPrimaryParamSection2() { + expectError("implementation restriction: await may only be used in the first parameter list.") { + """ + | import _root_.scala.async.AsyncId.{async, await} + | def foo[T](primary: Any)(i: Int) = i + | async { + | foo[Int](???)(await(0)) + | } + """.stripMargin + } + } } |