Skip to content

Commit ddb9c01

Browse files
committed
Make Dependency collection work for lazy vals
1 parent 82a2898 commit ddb9c01

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,18 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
194194
if isExpr(sym) && isLocal(sym) then markCalled(sym, enclosure)
195195
case tree: This =>
196196
narrowTo(tree.symbol.asClass)
197-
case tree: DefDef =>
198-
if sym.owner.isTerm then
199-
logicOwner(sym) = sym.enclosingPackageClass
200-
// this will make methods in supercall constructors of top-level classes owned
201-
// by the enclosing package, which means they will be static.
202-
// On the other hand, all other methods will be indirectly owned by their
203-
// top-level class. This avoids possible deadlocks when a static method
204-
// has to access its enclosing object from the outside.
205-
else if sym.isConstructor then
206-
if sym.isPrimaryConstructor && isLocal(sym.owner) && !sym.owner.is(Trait) then
207-
// add a call edge from the constructor of a local non-trait class to
208-
// the class itself. This is done so that the constructor inherits
209-
// the free variables of the class.
210-
symSet(called, sym) += sym.owner
197+
case tree: MemberDef if isExpr(sym) && sym.owner.isTerm =>
198+
logicOwner(sym) = sym.enclosingPackageClass
199+
// this will make methods in supercall constructors of top-level classes owned
200+
// by the enclosing package, which means they will be static.
201+
// On the other hand, all other methods will be indirectly owned by their
202+
// top-level class. This avoids possible deadlocks when a static method
203+
// has to access its enclosing object from the outside.
204+
case tree: DefDef if sym.isPrimaryConstructor && isLocal(sym.owner) && !sym.owner.is(Trait) =>
205+
// add a call edge from the constructor of a local non-trait class to
206+
// the class itself. This is done so that the constructor inherits
207+
// the free variables of the class.
208+
symSet(called, sym) += sym.owner
211209
case tree: TypeDef =>
212210
if sym.owner.isTerm then logicOwner(sym) = sym.topLevelClass.owner
213211
case _ =>

0 commit comments

Comments
 (0)