@@ -10,6 +10,7 @@ import annotation.constructorOnly
1010import scala .compiletime .uninitialized
1111
1212import dotty .tools .backend .sjs .JSDefinitions .jsdefn
13+ import dotty .tools .dotc .core .SymDenotations .NoDenotation .owner
1314
1415/** Exposes the dependencies of the `root` tree in three functions or maps:
1516 * `freeVars`, `tracked`, and `logicalOwner`.
@@ -137,6 +138,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
137138 if ! enclosure.exists then throw NoPath ()
138139 if enclosure == sym.enclosure then NoSymbol
139140 else
141+ /** is sym a constructor or a term that is nested in a constructor? */
140142 def nestedInConstructor (sym : Symbol ): Boolean =
141143 sym.isConstructor
142144 || sym.isTerm && nestedInConstructor(sym.enclosure)
@@ -237,6 +239,10 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
237239 captureImplicitThis(tree.tpe)
238240 case tree : Select =>
239241 if isExpr(sym) && isLocal(sym) then markCalled(sym, enclosure)
242+ case tree : New =>
243+ val constr = tree.tpe.typeSymbol.primaryConstructor
244+ if isExpr(constr) then
245+ symSet(called, enclosure) += constr
240246 case tree : This =>
241247 narrowTo(tree.symbol.asClass)
242248 case tree : MemberDef if isExpr(sym) && sym.owner.isTerm =>
@@ -291,7 +297,6 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
291297 val calleeOwner = normalizedCallee.owner
292298 if calleeOwner.isTerm then narrowLogicOwner(caller, logicOwner(normalizedCallee))
293299 else
294- assert(calleeOwner.is(Trait ))
295300 // methods nested inside local trait methods cannot be lifted out
296301 // beyond the trait. Note that we can also call a trait method through
297302 // a qualifier; in that case no restriction to lifted owner arises.
0 commit comments