diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-10-09 15:34:59 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-10-09 15:34:59 +1000 |
commit | 01b36eae1da662763d969a9c312832a4e7ea1f84 (patch) | |
tree | d3bc4adb923e1b47765d0b929942559f078a869c /src/main/scala/scala/async/internal/ExprBuilder.scala | |
parent | 7263aaad02a75978a0a48f90bf171c66cda4328c (diff) | |
download | scala-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/main/scala/scala/async/internal/ExprBuilder.scala')
-rw-r--r-- | src/main/scala/scala/async/internal/ExprBuilder.scala | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/main/scala/scala/async/internal/ExprBuilder.scala b/src/main/scala/scala/async/internal/ExprBuilder.scala index 16b9207..ce2345d 100644 --- a/src/main/scala/scala/async/internal/ExprBuilder.scala +++ b/src/main/scala/scala/async/internal/ExprBuilder.scala @@ -237,10 +237,8 @@ trait ExprBuilder { var stateBuilder = new AsyncStateBuilder(startState, symLookup) var currState = startState - def checkForUnsupportedAwait(tree: Tree) = if (tree exists { - case Apply(fun, _) if isAwait(fun) => true - case _ => false - }) c.abort(tree.pos, "await must not be used in this position") + def checkForUnsupportedAwait(tree: Tree) = if (containsAwait(tree)) + c.abort(tree.pos, "await must not be used in this position") def nestedBlockBuilder(nestedTree: Tree, startState: Int, endState: Int) = { val (nestedStats, nestedExpr) = statsAndExpr(nestedTree) |