aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-10-09 15:34:59 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-10-09 15:34:59 +1000
commit01b36eae1da662763d969a9c312832a4e7ea1f84 (patch)
treed3bc4adb923e1b47765d0b929942559f078a869c /src/test
parent7263aaad02a75978a0a48f90bf171c66cda4328c (diff)
downloadscala-async-01b36eae1da662763d969a9c312832a4e7ea1f84.tar.gz
scala-async-01b36eae1da662763d969a9c312832a4e7ea1f84.tar.bz2
scala-async-01b36eae1da662763d969a9c312832a4e7ea1f84.zip
Avoid spurious "illegal await" error in IDE with nesting
The presentation compiler runs with `-Ymacro-expand:discard`, which retains the macro expandee in the typechecked trees, rather than substituting in the expansion. This mode was motivated as a means to keep IDE functionality working (e.g. completion, navigation, refactoring) inside macro applications. However, if one has nested async macro applications, as reported in the IDE ticket: https://www.assembla.com/spaces/scala-ide/tickets/1002561 ... the expansion of the outer async application was reporting await calls enclosed by the inner async application. This change tweaks the traversers used for this analysis to stop whenever it sees an async.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/scala/async/run/WarningsSpec.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/WarningsSpec.scala b/src/test/scala/scala/async/run/WarningsSpec.scala
index 00c6466..c80bf9e 100644
--- a/src/test/scala/scala/async/run/WarningsSpec.scala
+++ b/src/test/scala/scala/async/run/WarningsSpec.scala
@@ -74,4 +74,24 @@ class WarningsSpec {
run.compileSources(sourceFile :: Nil)
assert(!global.reporter.hasErrors, global.reporter.asInstanceOf[StoreReporter].infos)
}
+
+ @Test
+ def ignoreNestedAwaitsInIDE_t1002561() {
+ // https://www.assembla.com/spaces/scala-ide/tickets/1002561
+ val global = mkGlobal("-cp ${toolboxClasspath} -Yrangepos -Ystop-after:typer ")
+ val source = """
+ | class Test {
+ | def test = {
+ | import scala.async.Async._, scala.concurrent._, ExecutionContext.Implicits.global
+ | async {
+ | 1 + await({def foo = (async(await(async(2)))); foo})
+ | }
+ | }
+ |}
+ """.stripMargin
+ val run = new global.Run
+ val sourceFile = global.newSourceFile(source)
+ run.compileSources(sourceFile :: Nil)
+ assert(!global.reporter.hasErrors, global.reporter.asInstanceOf[StoreReporter].infos)
+ }
}