summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interpreter/IMain.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-05-29 20:19:55 +0000
committerPaul Phillips <paulp@improving.org>2011-05-29 20:19:55 +0000
commit1125a9cfab5c5bacfd10bf1a559b97437339dbaf (patch)
tree5d5155cf1465d1796901773a156d4d9e94efb3b2 /src/compiler/scala/tools/nsc/interpreter/IMain.scala
parent75ec2ba72f17a57060ca5831ccc9e38167e957ae (diff)
downloadscala-1125a9cfab5c5bacfd10bf1a559b97437339dbaf.tar.gz
scala-1125a9cfab5c5bacfd10bf1a559b97437339dbaf.tar.bz2
scala-1125a9cfab5c5bacfd10bf1a559b97437339dbaf.zip
Fixed a crasher in the scanner when unicode esc...
Fixed a crasher in the scanner when unicode escape sequences offered up EOF before completion. Also made the repl a little more robust against crashers in scalac. Treat it like a hostile witness! Closes #4584, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/IMain.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index 0ef82351b1..517e6ee6d0 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -362,16 +362,14 @@ class IMain(val settings: Settings, protected val out: PrintWriter) extends Impo
// warning about serially defining companions. It'd be easy
// enough to just redefine them together but that may not always
// be what people want so I'm waiting until I can do it better.
- if (!settings.nowarnings.value) {
- for {
- name <- req.definedNames filterNot (x => req.definedNames contains x.companionName)
- oldReq <- definedNameMap get name.companionName
- newSym <- req.definedSymbols get name
- oldSym <- oldReq.definedSymbols get name.companionName
- } {
- printMessage("warning: previously defined %s is not a companion to %s.".format(oldSym, newSym))
- printMessage("Companions must be defined together; you may wish to use :paste mode for this.")
- }
+ for {
+ name <- req.definedNames filterNot (x => req.definedNames contains x.companionName)
+ oldReq <- definedNameMap get name.companionName
+ newSym <- req.definedSymbols get name
+ oldSym <- oldReq.definedSymbols get name.companionName
+ } {
+ replwarn("warning: previously defined %s is not a companion to %s.".format(oldSym, newSym))
+ replwarn("Companions must be defined together; you may wish to use :paste mode for this.")
}
// Updating the defined name map
@@ -404,12 +402,20 @@ class IMain(val settings: Settings, protected val out: PrintWriter) extends Impo
}
}
+ private[nsc] def replwarn(msg: => String): Unit =
+ if (!settings.nowarnings.value)
+ printMessage(msg)
+
def isParseable(line: String): Boolean = {
beSilentDuring {
- parse(line) match {
+ try parse(line) match {
case Some(xs) => xs.nonEmpty // parses as-is
case None => true // incomplete
}
+ catch { case x: Exception => // crashed the compiler
+ replwarn("Exception in isParseable(\"" + line + "\"): " + x)
+ false
+ }
}
}