Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/TailRec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ class TailRec extends MiniPhase {
tree

case tree: ValDef =>
if (isMandatory) noTailTransform(tree.rhs)
tree
// This could contain a return statement in a code block, so we do have to go into it.
cpy.ValDef(tree)(rhs = noTailTransform(tree.rhs))

case tree: DefDef =>
if (isMandatory)
Expand Down
1 change: 1 addition & 0 deletions tests/run/i20145.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10000001
15 changes: 15 additions & 0 deletions tests/run/i20145.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import scala.annotation.tailrec
@tailrec
def foo(i: Int): Int = {
if (i > 10000000) {
i
} else {
val bar: String = {
return foo(i + 1)
"foo"
}
-1
}
}
@main def Test =
println(foo(0))