@@ -27,8 +27,8 @@ import annotation.constructorOnly
27
27
abstract class Dependencies (@ constructorOnly rootContext : Context ):
28
28
import ast .tpd ._
29
29
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
32
32
33
33
type SymSet = TreeSet [Symbol ]
34
34
@@ -45,7 +45,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
45
45
* Note: During tree transform (which runs at phase LambdaLift + 1), liftedOwner
46
46
* is also used to decide whether a method had a term owner before.
47
47
*/
48
- val liftedOwner = new LinkedHashMap [Symbol , Symbol ]
48
+ private val depOwner = new LinkedHashMap [Symbol , Symbol ]
49
49
50
50
/** A flag to indicate whether new free variables have been found */
51
51
private var changedFreeVars : Boolean = _
@@ -63,6 +63,8 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
63
63
64
64
def tracked : Iterable [Symbol ] = free.keys
65
65
66
+ def dependentOwner : collection.Map [Symbol , Symbol ] = depOwner
67
+
66
68
/** A symbol is local if it is owned by a term or a local trait,
67
69
* or if it is a constructor of a local symbol.
68
70
* Note: we count members of local traits as local since their free variables
@@ -80,12 +82,12 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
80
82
*/
81
83
private def narrowLiftedOwner (sym : Symbol , owner : Symbol )(using Context ): Unit =
82
84
if sym.maybeOwner.isTerm
83
- && owner.isProperlyContainedIn(liftedOwner (sym))
85
+ && owner.isProperlyContainedIn(depOwner (sym))
84
86
&& owner != sym
85
87
then
86
88
report.log(i " narrow lifted $sym to $owner" )
87
89
changedLiftedOwner = true
88
- liftedOwner (sym) = owner
90
+ depOwner (sym) = owner
89
91
90
92
private class NoPath extends Exception
91
93
@@ -202,7 +204,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
202
204
narrowTo(tree.symbol.asClass)
203
205
case tree : DefDef =>
204
206
if sym.owner.isTerm then
205
- liftedOwner (sym) = sym.enclosingPackageClass
207
+ depOwner (sym) = sym.enclosingPackageClass
206
208
// this will make methods in supercall constructors of top-level classes owned
207
209
// by the enclosing package, which means they will be static.
208
210
// On the other hand, all other methods will be indirectly owned by their
@@ -215,7 +217,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
215
217
// the free variables of the class.
216
218
symSet(called, sym) += sym.owner
217
219
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
219
221
case _ =>
220
222
end process
221
223
@@ -252,7 +254,7 @@ abstract class Dependencies(@constructorOnly rootContext: Context):
252
254
do
253
255
val normalizedCallee = callee.skipConstructor
254
256
val calleeOwner = normalizedCallee.owner
255
- if calleeOwner.isTerm then narrowLiftedOwner(caller, liftedOwner (normalizedCallee))
257
+ if calleeOwner.isTerm then narrowLiftedOwner(caller, depOwner (normalizedCallee))
256
258
else
257
259
assert(calleeOwner.is(Trait ))
258
260
// methods nested inside local trait methods cannot be lifted out
0 commit comments