Skip to content

Commit c0b69bb

Browse files
committed
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.
1 parent 795796d commit c0b69bb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,15 @@ object Decorators {
157157
(treatSingleArg(arg), suffix)
158158
}
159159

160-
def treatSingleArg(arg: Any) : Any = arg match {
161-
case arg: Showable => arg.show
162-
case _ => arg
163-
}
160+
def treatSingleArg(arg: Any) : Any =
161+
try
162+
arg match {
163+
case arg: Showable => arg.show
164+
case _ => arg
165+
}
166+
catch {
167+
case ex: Exception => s"(missing due to $ex)"
168+
}
164169

165170
val prefix :: suffixes = sc.parts.toList
166171
val (args1, suffixes1) = (args, suffixes).zipped.map(treatArg(_, _)).unzip

0 commit comments

Comments
 (0)