File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -344,7 +344,10 @@ class TailRec extends MiniPhase {
344344 case prefix : This if prefix.symbol == enclosingClass =>
345345 // Avoid assigning `this = this`
346346 assignParamPairs
347- case prefix if prefix.symbol.is(Module ) && prefix.symbol.moduleClass == enclosingClass =>
347+ case prefix
348+ if prefix.symbol.is(Module )
349+ && prefix.symbol.moduleClass == enclosingClass
350+ && isPurePath(prefix) =>
348351 // Avoid assigning `this = MyObject`
349352 assignParamPairs
350353 case _ =>
Original file line number Diff line number Diff line change 1+
2+ import annotation .*
3+
4+ class Path (action : () => Unit , parent : Option [Path ]):
5+ object O :
6+ @ tailrec
7+ def apply (): Unit =
8+ action()
9+
10+ parent match
11+ case Some (p) =>
12+ p.O .apply()
13+ case None =>
14+
15+ @ main def Test : Unit =
16+ var counter = 0
17+ val fun = () => {
18+ counter += 1
19+ if counter > 2 then throw AssertionError (" bad loop" )
20+ }
21+ val path = Path (fun, Some (Path (fun, None )))
22+ path.O ()
You can’t perform that action at this time.
0 commit comments