summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2012-09-04 10:50:21 +0200
committerIulian Dragos <jaguarul@gmail.com>2012-09-04 10:50:21 +0200
commit4f932df552fd2a9e1af31bc3b5fbbfeeaa15feed (patch)
tree2459e2680ec8a879a07a7ea967ed6a02ee91b6e1 /src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
parent5415272018114bb2e15036c5d6f9ae9c5af625d2 (diff)
downloadscala-4f932df552fd2a9e1af31bc3b5fbbfeeaa15feed.tar.gz
scala-4f932df552fd2a9e1af31bc3b5fbbfeeaa15feed.tar.bz2
scala-4f932df552fd2a9e1af31bc3b5fbbfeeaa15feed.zip
Allow nested calls to `askForResponse` in the presentation compiler.
Fix #6312. review by @odersky,@lrytz.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interactive/CompilerControl.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index 6acd6d2382..3de2359ce3 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -257,12 +257,18 @@ trait CompilerControl { self: Global =>
*/
def askForResponse[A](op: () => A): Response[A] = {
val r = new Response[A]
- val ir = scheduler askDoQuickly op
- ir onComplete {
- case Left(result) => r set result
- case Right(exc) => r raise exc
+ if (self.onCompilerThread) {
+ try { r set op() }
+ catch { case exc: Throwable => r raise exc }
+ r
+ } else {
+ val ir = scheduler askDoQuickly op
+ ir onComplete {
+ case Left(result) => r set result
+ case Right(exc) => r raise exc
+ }
+ r
}
- r
}
def onCompilerThread = Thread.currentThread == compileRunner