File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -277,8 +277,8 @@ class TailRec extends MiniPhase {
277277 }
278278
279279 val isRecursiveCall = calledMethod eq method
280- // FIXME ` (method.name eq sym)` is always false (Name vs Symbol). What is this trying to do?
281- def isRecursiveSuperCall = ( method.name eq calledMethod) &&
280+ def isRecursiveSuperCall = (method.name eq calledMethod.name) &&
281+ method.matches( calledMethod) &&
282282 enclosingClass.appliedRef.widen <:< prefix.tpe.widenDealias
283283
284284 if (isRecursiveCall) {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ sealed abstract class Super[+A] {
88class Bop1 [+ A ](val element : A ) extends Super [A ] {
99
1010 @ tailrec final def f [B >: A ](mem : List [B ]): List [B ] = // error: TailRec optimisation not applicable
11- (null : Super [A ]).f(mem)
11+ (null : Super [A ]).f(mem) // error: recursive call targeting a supertype
1212
1313 @ tailrec final def f1 [B >: A ](mem : List [B ]): List [B ] = this .g(mem) // error: TailRec optimisation not applicable
1414}
Original file line number Diff line number Diff line change 1+ import annotation .tailrec
2+
3+ class UnrolledBuffer {
4+ def remove (idx : Int ): Unit = ()
5+ @ tailrec final def remove (idx : Int , count : Int ): Unit =
6+ if (count > 0 ) {
7+ remove(idx) // ok: not a recursive call
8+ remove(idx, count - 1 )
9+ }
10+ }
You can’t perform that action at this time.
0 commit comments