Skip to content

Commit e44e4aa

Browse files
committed
TailRec now handles Try with Ident-handler
1 parent 1be3b2f commit e44e4aa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/dotty/tools/dotc/transform/TailRec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
237237
case Block(List((d: DefDef)), cl@Closure(Nil, _, EmptyTree)) =>
238238
val newDef = cpy.DefDef(d)(rhs = transform(d.rhs))
239239
Block(List(newDef), cl)
240+
case t: Ident => t // handler is an external function
240241
case _ => assert(false, s"failed to deconstruct try handler ${t.show}"); ???
241242
}
242243
}

tests/pos/tryTyping.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object tryTyping{
2+
def foo: Int = {
3+
try{???; 1}
4+
catch {
5+
case e: Exception => 2
6+
}
7+
}
8+
9+
def foo2: Int = {
10+
val a: (Throwable => Int) = _ match {case _ => 2}
11+
try{???; 1}
12+
catch a
13+
}
14+
}

0 commit comments

Comments
 (0)