From c0b69bb4b51605cbd0230e672cd4d026011c0e8d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 5 Sep 2014 02:44:40 +0200 Subject: 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. --- src/dotty/tools/dotc/core/Decorators.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') 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 -- cgit v1.2.3