From e707bb01552106f68b63928327eacccaa3e92096 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Sat, 13 Nov 2021 18:58:04 +0100 Subject: [PATCH 1/2] Don't lift try-catch statements that are already in local functions closes #13941 --- .../src/dotty/tools/dotc/transform/LiftTry.scala | 3 +++ tests/pos/i13941.scala | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/pos/i13941.scala diff --git a/compiler/src/dotty/tools/dotc/transform/LiftTry.scala b/compiler/src/dotty/tools/dotc/transform/LiftTry.scala index e5e234b8fe8e..074ba7bc0516 100644 --- a/compiler/src/dotty/tools/dotc/transform/LiftTry.scala +++ b/compiler/src/dotty/tools/dotc/transform/LiftTry.scala @@ -44,6 +44,9 @@ class LiftTry extends MiniPhase with IdentityDenotTransformer { thisPhase => override def prepareForApply(tree: Apply)(using Context): Context = liftingCtx(true) + override def prepareForDefDef(tree: DefDef)(using Context): Context = + liftingCtx(false) + override def prepareForValDef(tree: ValDef)(using Context): Context = if !tree.symbol.exists || tree.symbol.isSelfSym diff --git a/tests/pos/i13941.scala b/tests/pos/i13941.scala new file mode 100644 index 000000000000..299470e455e3 --- /dev/null +++ b/tests/pos/i13941.scala @@ -0,0 +1,15 @@ +import scala.annotation.tailrec + +object A { + def b = Option("a").map { x => + @tailrec + def loop(): Int = { + try + 2 + catch + case _: Throwable => + loop() + } + x + } +} From abd499885664a5c63aee984943dbba4188a1f468 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Tue, 21 Dec 2021 12:42:42 +0100 Subject: [PATCH 2/2] Fix scalatest community-build --- community-build/community-projects/scalatest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 96650cfbf700..75f5a3be6632 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 96650cfbf7003c198e2759bdca4a9a37dac03cad +Subproject commit 75f5a3be66322f69ea624bbf5f166fbd28c5ff9e