Skip to content

Commit 2aca3be

Browse files
committed
Support more simple recursions
1 parent ddf73dd commit 2aca3be

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class TailRec extends MiniPhase {
179179
def isInfiniteRecCall(tree: Tree): Boolean = {
180180
def statOk(stat: Tree): Boolean = stat match {
181181
case stat: ValDef if stat.name.is(TailTempName) || !stat.symbol.is(Mutable) => statOk(stat.rhs)
182-
case Assign(lhs: Ident, rhs: Ident) if lhs.symbol.name.is(TailLocalName) => statOk(rhs)
182+
case Assign(lhs: Ident, rhs) if lhs.symbol.name.is(TailLocalName) => statOk(rhs)
183183
case stat: Ident if stat.symbol.name.is(TailLocalName) => true
184184
case _ => tpd.isPureExpr(stat)
185185
}

tests/neg-custom-args/fatal-warnings/i7821b.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ object Test {
66
{ def f(x: Int, y: Int): Int = f(x, x) } // error
77
{ def f(x: Int, y: Int): Int = f(1, 1) } // error
88
{ def f(x: Int, y: Int): Int = { val a = 3; f(a, 1) } } // error
9+
{ def f(x: Int): Int = f(1) } // error
910

1011
}

0 commit comments

Comments
 (0)