aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/TreeInterrogation.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-11-22 11:17:22 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-11-22 11:52:32 +0100
commit4fc54635380eca4beb13678f24ba0a8e4d592bec (patch)
treec365f365b294ac16c74c03f38bf0c9f267df3cb4 /src/test/scala/scala/async/TreeInterrogation.scala
parent23f94c257c3d5e8ad345cdcc7c9dae8b214d7c51 (diff)
downloadscala-async-4fc54635380eca4beb13678f24ba0a8e4d592bec.tar.gz
scala-async-4fc54635380eca4beb13678f24ba0a8e4d592bec.tar.bz2
scala-async-4fc54635380eca4beb13678f24ba0a8e4d592bec.zip
Fix crashers in do/while and while(await(..))
The new tree shapes handled for do/while look like: // type checked async({ val b = false; doWhile$1(){ await(()); if (b) doWhile$1() else () }; () }) We had to change ExprBuilder to create states for the if/else that concludes the doWhile body, and also loosen the assertion that the label jump must be the last thing we see. We also have to look for more than just `containsAwait` when deciding whether an `If` needs to be transformed into states; it might also contain a jump to the enclosing label that is on the other side of an `await`, and hence needs to be a state transition instead.
Diffstat (limited to 'src/test/scala/scala/async/TreeInterrogation.scala')
-rw-r--r--src/test/scala/scala/async/TreeInterrogation.scala37
1 files changed, 6 insertions, 31 deletions
diff --git a/src/test/scala/scala/async/TreeInterrogation.scala b/src/test/scala/scala/async/TreeInterrogation.scala
index c8fe2d6..b42726b 100644
--- a/src/test/scala/scala/async/TreeInterrogation.scala
+++ b/src/test/scala/scala/async/TreeInterrogation.scala
@@ -66,43 +66,18 @@ object TreeInterrogation extends App {
withDebug {
val cm = reflect.runtime.currentMirror
val tb = mkToolbox("-cp ${toolboxClasspath} -Xprint:typer -uniqid")
- import scala.async.internal.AsyncTestLV._
+ import scala.async.internal.AsyncId._
val tree = tb.parse(
"""
- | import scala.async.internal.AsyncTestLV._
- | import scala.async.internal.AsyncTestLV
- |
- | case class MCell[T](var v: T)
- | val f = async { MCell(1) }
- |
- | def m1(x: MCell[Int], y: Int): Int =
- | async { x.v + y }
- | case class Cell[T](v: T)
- |
+ | import scala.async.internal.AsyncId._
| async {
- | // state #1
- | val a: MCell[Int] = await(f) // await$13$1
- | // state #2
- | var y = MCell(0)
- |
- | while (a.v < 10) {
- | // state #4
- | a.v = a.v + 1
- | y = MCell(await(a).v + 1) // await$14$1
- | // state #7
+ | var b = true
+ | while(await(b)) {
+ | b = false
| }
- |
- | // state #3
- | assert(AsyncTestLV.log.exists(entry => entry._1 == "await$14$1"))
- |
- | val b = await(m1(a, y.v)) // await$15$1
- | // state #8
- | assert(AsyncTestLV.log.exists(_ == ("a$1" -> MCell(10))))
- | assert(AsyncTestLV.log.exists(_ == ("y$1" -> MCell(11))))
- | b
+ | await(b)
| }
|
- |
| """.stripMargin)
println(tree)
val tree1 = tb.typeCheck(tree.duplicate)