aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Decorators.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-05 02:44:40 +0200
committerMartin Odersky <odersky@gmail.com>2014-09-05 02:57:59 +0200
commitc0b69bb4b51605cbd0230e672cd4d026011c0e8d (patch)
treed0205842b01cef0fd14a45bad3a17e7725b73350 /src/dotty/tools/dotc/core/Decorators.scala
parent795796dbfb0d5617163bcc2d1db856b912b7043a (diff)
downloaddotty-c0b69bb4b51605cbd0230e672cd4d026011c0e8d.tar.gz
dotty-c0b69bb4b51605cbd0230e672cd4d026011c0e8d.tar.bz2
dotty-c0b69bb4b51605cbd0230e672cd4d026011c0e8d.zip
Harden construction of i"..." strings
Catch exceptions and embed into string instead of passing exception on. Reason: i"" strings are for diagnostic output but may cause exceptions such as CyclicReferences, stale symbols and so on. We never want to crash the program with such an exception.
Diffstat (limited to 'src/dotty/tools/dotc/core/Decorators.scala')
-rw-r--r--src/dotty/tools/dotc/core/Decorators.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala
index 3575029e8..99af4d0cb 100644
--- a/src/dotty/tools/dotc/core/Decorators.scala
+++ b/src/dotty/tools/dotc/core/Decorators.scala
@@ -157,10 +157,15 @@ object Decorators {
(treatSingleArg(arg), suffix)
}
- def treatSingleArg(arg: Any) : Any = arg match {
- case arg: Showable => arg.show
- case _ => arg
- }
+ def treatSingleArg(arg: Any) : Any =
+ try
+ arg match {
+ case arg: Showable => arg.show
+ case _ => arg
+ }
+ catch {
+ case ex: Exception => s"(missing due to $ex)"
+ }
val prefix :: suffixes = sc.parts.toList
val (args1, suffixes1) = (args, suffixes).zipped.map(treatArg(_, _)).unzip