summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-05-29 22:58:03 +0000
committerPaul Phillips <paulp@improving.org>2009-05-29 22:58:03 +0000
commit661f1ba10e5062fd987c4cafe43ad1f0dc3f5491 (patch)
tree072736f2f6ee0aaadec200b3775f02378d8d433b /src/compiler
parentc36e3cc0a6599092f752ec7304d164cc06b9739c (diff)
downloadscala-661f1ba10e5062fd987c4cafe43ad1f0dc3f5491.tar.gz
scala-661f1ba10e5062fd987c4cafe43ad1f0dc3f5491.tar.bz2
scala-661f1ba10e5062fd987c4cafe43ad1f0dc3f5491.zip
Endless exploration of exception handling synta...
Endless exploration of exception handling syntax continues.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala6
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala20
2 files changed, 11 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 4869ff04f1..6173753c6d 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -16,7 +16,7 @@ import scala.collection.immutable.ListSet
import scala.collection.mutable
import scala.collection.mutable.{ ListBuffer, HashSet, ArrayBuffer }
import scala.util.{ ScalaClassLoader, URLClassLoader }
-import scala.util.control.Exception.{ Catcher, catching, unwrapping }
+import scala.util.control.Exception.{ Catcher, catching, ultimately, unwrapping }
import io.{ PlainFile, VirtualDirectory }
import reporters.{ ConsoleReporter, Reporter }
@@ -94,11 +94,9 @@ class Interpreter(val settings: Settings, out: PrintWriter)
/** Temporarily be quiet */
def beQuietDuring[T](operation: => T): T = {
val wasPrinting = printResults
- try {
+ ultimately(printResults = wasPrinting) {
printResults = false
operation
- } finally {
- printResults = wasPrinting
}
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
index 392685c4c0..3d1bfd547a 100644
--- a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
@@ -5,6 +5,7 @@
// $Id$
package scala.tools.nsc.interpreter
+import scala.util.control.Exception._
/** Reads lines from an input stream */
trait InteractiveReader {
@@ -14,14 +15,12 @@ trait InteractiveReader {
protected def readOneLine(prompt: String): String
val interactive: Boolean
- def readLine(prompt: String): String =
- try {
- readOneLine(prompt)
- }
- catch {
+ def readLine(prompt: String): String = {
+ def handler: Catcher[String] = {
case e: IOException if restartSystemCall(e) => readLine(prompt)
- case e => throw e
}
+ catching(handler) { readOneLine(prompt) }
+ }
// hack necessary for OSX jvm suspension because read calls are not restarted after SIGTSTP
private def restartSystemCall(e: Exception): Boolean =
@@ -31,6 +30,7 @@ trait InteractiveReader {
object InteractiveReader {
val msgEINTR = "Interrupted system call"
+ private val exes = List(classOf[Exception], classOf[NoClassDefFoundError])
def createDefault(): InteractiveReader = createDefault(null)
@@ -38,10 +38,8 @@ object InteractiveReader {
* library is available, but otherwise uses a <code>SimpleReader</code>.
*/
def createDefault(interpreter: Interpreter): InteractiveReader =
- try {
- new JLineReader(interpreter)
- } catch {
- case _: Exception | _: NoClassDefFoundError => new SimpleReader
- }
+ catching(exes: _*)
+ . opt (new JLineReader(interpreter))
+ . getOrElse (new SimpleReader)
}