Skip to content

Commit 221320f

Browse files
committed
Avoid unnecessary narrowLiftedOwner in markFree
This prevented many local functions from being lifted out to static scope, and thereby caused memory leaks. The memory leak found in the IDE was caused an anonymous function in NamerContextOps (a base trait of Context) that was kept as a non-private private method of NamerContextOps, taking a `this` referring to a context.
1 parent 2cb53d9 commit 221320f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
204204
if (enclosure.is(PackageClass)) enclosure
205205
else if (enclosure.isConstructor) markFree(sym, enclosure.owner.enclosure)
206206
else markFree(sym, enclosure.enclosure)
207-
narrowLiftedOwner(enclosure, intermediate orElse sym.enclosingClass)
207+
if (intermediate.exists) narrowLiftedOwner(enclosure, intermediate)
208208
if (!intermediate.isRealClass || enclosure.isConstructor) {
209209
// Constructors and methods nested inside traits get the free variables
210210
// of the enclosing trait or class.
@@ -384,7 +384,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
384384
local.copySymDenotation(
385385
owner = newOwner,
386386
name = newName(local),
387-
initFlags = local.flags &~ Module | Private | maybeStatic,
387+
initFlags = local.flags &~ Module &~ Final | Private | maybeStatic,
388388
// drop Module because class is no longer a singleton in the lifted context.
389389
info = liftedInfo(local)).installAfter(thisTransform)
390390
}

0 commit comments

Comments
 (0)