@@ -27,8 +27,8 @@ import annotation.constructorOnly
2727abstract class Dependencies (@ constructorOnly rootContext : Context ):
2828 import ast .tpd ._
2929
30- def enclosure (using Context ): Symbol
31- def isExpr (sym : Symbol )(using Context ): Boolean
30+ protected def enclosure (using Context ): Symbol
31+ protected def isExpr (sym : Symbol )(using Context ): Boolean
3232
3333 type SymSet = TreeSet [Symbol ]
3434
@@ -45,7 +45,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
4545 * Note: During tree transform (which runs at phase LambdaLift + 1), liftedOwner
4646 * is also used to decide whether a method had a term owner before.
4747 */
48- val liftedOwner = new LinkedHashMap [Symbol , Symbol ]
48+ private val depOwner = new LinkedHashMap [Symbol , Symbol ]
4949
5050 /** A flag to indicate whether new free variables have been found */
5151 private var changedFreeVars : Boolean = _
@@ -63,6 +63,8 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
6363
6464 def tracked : Iterable [Symbol ] = free.keys
6565
66+ def dependentOwner : collection.Map [Symbol , Symbol ] = depOwner
67+
6668 /** A symbol is local if it is owned by a term or a local trait,
6769 * or if it is a constructor of a local symbol.
6870 * Note: we count members of local traits as local since their free variables
@@ -80,12 +82,12 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
8082 */
8183 private def narrowLiftedOwner (sym : Symbol , owner : Symbol )(using Context ): Unit =
8284 if sym.maybeOwner.isTerm
83- && owner.isProperlyContainedIn(liftedOwner (sym))
85+ && owner.isProperlyContainedIn(depOwner (sym))
8486 && owner != sym
8587 then
8688 report.log(i " narrow lifted $sym to $owner" )
8789 changedLiftedOwner = true
88- liftedOwner (sym) = owner
90+ depOwner (sym) = owner
8991
9092 private class NoPath extends Exception
9193
@@ -202,7 +204,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
202204 narrowTo(tree.symbol.asClass)
203205 case tree : DefDef =>
204206 if sym.owner.isTerm then
205- liftedOwner (sym) = sym.enclosingPackageClass
207+ depOwner (sym) = sym.enclosingPackageClass
206208 // this will make methods in supercall constructors of top-level classes owned
207209 // by the enclosing package, which means they will be static.
208210 // On the other hand, all other methods will be indirectly owned by their
@@ -215,7 +217,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
215217 // the free variables of the class.
216218 symSet(called, sym) += sym.owner
217219 case tree : TypeDef =>
218- if sym.owner.isTerm then liftedOwner (sym) = sym.topLevelClass.owner
220+ if sym.owner.isTerm then depOwner (sym) = sym.topLevelClass.owner
219221 case _ =>
220222 end process
221223
@@ -252,7 +254,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
252254 do
253255 val normalizedCallee = callee.skipConstructor
254256 val calleeOwner = normalizedCallee.owner
255- if calleeOwner.isTerm then narrowLiftedOwner(caller, liftedOwner (normalizedCallee))
257+ if calleeOwner.isTerm then narrowLiftedOwner(caller, depOwner (normalizedCallee))
256258 else
257259 assert(calleeOwner.is(Trait ))
258260 // methods nested inside local trait methods cannot be lifted out
0 commit comments