summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-10 07:03:13 +0000
committerPaul Phillips <paulp@improving.org>2011-08-10 07:03:13 +0000
commit386dddde5361e5c2b9876dbb8855a0f1a81ca95b (patch)
tree4485238a41f7743b2f432131086d8f73ee5d8758 /src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
parentff7416d88b67b26c5f066ef08801517c09bd2859 (diff)
downloadscala-386dddde5361e5c2b9876dbb8855a0f1a81ca95b.tar.gz
scala-386dddde5361e5c2b9876dbb8855a0f1a81ca95b.tar.bz2
scala-386dddde5361e5c2b9876dbb8855a0f1a81ca95b.zip
Turned up the defense against compiler exceptio...
Turned up the defense against compiler exceptions in the repl. And gave in and disabled an assertion I should have disabled two years ago. Closes SI-4874, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
index 8b387823ff..9c5299b633 100644
--- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -359,18 +359,30 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
if (!looksLikePath(buf)) None
else tryCompletion(mkUndelimited, FileCompletion completionsFor _.buffer)
- /** This is the kickoff point for all manner of theoretically possible compiler
- * unhappiness - fault may be here or elsewhere, but we don't want to crash the
- * repl regardless. Hopefully catching Exception is enough, but because the
- * compiler still throws some Errors it may not be.
+ def tryAll = (
+ lastResultCompletion
+ orElse regularCompletion
+ orElse fileCompletion
+ getOrElse Candidates(cursor, Nil)
+ )
+
+ /**
+ * This is the kickoff point for all manner of theoretically
+ * possible compiler unhappiness. The fault may be here or
+ * elsewhere, but we don't want to crash the repl regardless.
+ * The compiler makes it impossible to avoid catching Throwable
+ * with its unfortunate tendency to throw java.lang.Errors and
+ * AssertionErrors as the hats drop. We take two swings at it
+ * because there are some spots which like to throw an assertion
+ * once, then work after that. Yeah, what can I say.
*/
- try {
- (lastResultCompletion orElse regularCompletion orElse fileCompletion) getOrElse Candidates(cursor, Nil)
- }
- catch {
- case ex: Exception =>
- repldbg("Error: complete(%s, %s) provoked %s".format(buf, cursor, ex))
- Candidates(cursor, List(" ", "<completion error: " + ex.getMessage + ">"))
+ try tryAll
+ catch { case ex: Throwable =>
+ repldbg("Error: complete(%s, %s) provoked".format(buf, cursor) + ex)
+ Candidates(cursor,
+ if (isReplDebug) List("<error:" + ex + ">")
+ else Nil
+ )
}
}
}