Skip to content

Commit a3d332b

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

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-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/pos/simpleTry.decompiled

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** Decompiled from out/posTestFromTasty/pos/simpleTry/Foo.class */
2+
class Foo() {
3+
try 3 catch {
4+
case e: scala.Throwable =>
5+
4
6+
} finally scala.Predef.println(6)
7+
}

tests/pos/simpleTry.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
class Foo {
3+
try 3
4+
catch {
5+
case e: Throwable => 4
6+
} finally println(6)
7+
}

0 commit comments

Comments
 (0)