aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-11-23 12:08:59 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-11-23 12:08:59 +0100
commit5a2acf110233669e1cf1124ac54b28a526d37858 (patch)
tree739a82485d838a586809ddedbb2daede096706ed /src/test
parent8ff80d52047360f3236fcbc8e7849d388c4aa744 (diff)
downloadscala-async-5a2acf110233669e1cf1124ac54b28a526d37858.tar.gz
scala-async-5a2acf110233669e1cf1124ac54b28a526d37858.tar.bz2
scala-async-5a2acf110233669e1cf1124ac54b28a526d37858.zip
Ensure unique names for definitions in the async block.
- transform the provided tree using reflect.internal.Symbols#Symbol.name_= and treeCopy.{Ident, Select}. - not sure if this is possible within the public Symbol API. - move checking for unsupported nested module/class to AsyncAnalysis. - make block merging selective (only do so if there are nested await calls.)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/scala/async/TreeInterrogation.scala2
-rw-r--r--src/test/scala/scala/async/run/anf/AnfTransformSpec.scala63
2 files changed, 33 insertions, 32 deletions
diff --git a/src/test/scala/scala/async/TreeInterrogation.scala b/src/test/scala/scala/async/TreeInterrogation.scala
index 02f4b43..9e68005 100644
--- a/src/test/scala/scala/async/TreeInterrogation.scala
+++ b/src/test/scala/scala/async/TreeInterrogation.scala
@@ -32,6 +32,6 @@ class TreeInterrogation {
val varDefs = tree1.collect {
case ValDef(mods, name, _, _) if mods.hasFlag(Flag.MUTABLE) => name
}
- varDefs.map(_.decoded).toSet mustBe(Set("state$async", "onCompleteHandler$async", "await$1$1", "await$2$1"))
+ varDefs.map(_.decoded).toSet mustBe(Set("state$async", "onCompleteHandler$async", "await$1", "await$2"))
}
}
diff --git a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
index 1d6e09a..872e44d 100644
--- a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
+++ b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
@@ -112,37 +112,38 @@ class AnfTransformSpec {
State.result mustBe (14)
}
- // TODO JZ
-// @Test
-// def `inlining block produces duplicate definition`() {
-// import scala.async.AsyncId
-//
-// AsyncId.async {
-// val f = 12
-// val x = AsyncId.await(f)
-//
-// {
-// val x = 42
-// println(x)
-// }
-//
-// x
-// }
-// }
-// @Test
-// def `inlining block in tail position produces duplicate definition`() {
-// import scala.async.AsyncId
-//
-// AsyncId.async {
-// val f = 12
-// val x = AsyncId.await(f)
-//
-// {
-// val x = 42 // TODO should we rename the symbols when we collapse them into the same scope?
-// x
-// }
-// } mustBe (42)
-// }
+ @Test
+ def `inlining block does not produce duplicate definition`() {
+ import scala.async.AsyncId
+
+ AsyncId.async {
+ val f = 12
+ val x = AsyncId.await(f)
+
+ {
+ type X = Int
+ val x: X = 42
+ println(x)
+ }
+ type X = Int
+ x: X
+ }
+ }
+
+ @Test
+ def `inlining block in tail position does not produce duplicate definition`() {
+ import scala.async.AsyncId
+
+ AsyncId.async {
+ val f = 12
+ val x = AsyncId.await(f)
+
+ {
+ val x = 42
+ x
+ }
+ } mustBe (42)
+ }
@Test
def `match as expression 1`() {