Skip to content

Commit cd90612

Browse files
committed
Fix printing catch clause
1 parent 95ec081 commit cd90612

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,12 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
383383
this += "try "
384384
printTree(body)
385385
if (cases.nonEmpty) {
386-
this += " catch "
387-
printCases(cases, lineBreak())
386+
this += " catch {"
387+
indented {
388+
this += lineBreak()
389+
printCases(cases, lineBreak())
390+
}
391+
this += lineBreak() += "}"
388392
}
389393
finallyOpt match {
390394
case Some(t) =>

tests/run/t6370.decompiled

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** Decompiled from out/runTestFromTasty/run/t6370/Test.class */
2+
object Test {
3+
def main(args: scala.Array[scala.Predef.String]): scala.Unit = {
4+
val m: collection.immutable.ListMap[java.lang.String, scala.Int] = scala.collection.immutable.ListMap.apply[java.lang.String, scala.Int](scala.Predef.ArrowAssoc[java.lang.String]("x").->[scala.Int](1))
5+
try {
6+
{
7+
m.apply("y")
8+
()
9+
}
10+
} catch {
11+
case e: scala.NoSuchElementException =>
12+
dotty.DottyPredef.assert(e.getMessage().==("key not found: y"))
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)