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 @@ -346,7 +346,10 @@ class TailRec extends MiniPhase {
346346 case prefix : This if prefix.symbol == enclosingClass =>
347347 // Avoid assigning `this = this`
348348 assignParamPairs
349- case prefix if prefix.symbol.is(Module ) && prefix.symbol.moduleClass == enclosingClass =>
349+ case prefix
350+ if prefix.symbol.is(Module )
351+ && prefix.symbol.moduleClass == enclosingClass
352+ && isPurePath(prefix) =>
350353 // Avoid assigning `this = MyObject`
351354 assignParamPairs
352355 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