@@ -137,6 +137,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
137137 if ! enclosure.exists then throw NoPath ()
138138 if enclosure == sym.enclosure then NoSymbol
139139 else
140+ /** is sym a constructor or a term that is nested in a constructor? */
140141 def nestedInConstructor (sym : Symbol ): Boolean =
141142 sym.isConstructor
142143 || sym.isTerm && nestedInConstructor(sym.enclosure)
@@ -147,7 +148,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
147148 else markFree(sym, enclosure.enclosure)
148149 if intermediate.exists then
149150 narrowLogicOwner(enclosure, intermediate)
150- if ! intermediate.isRealClass || nestedInConstructor(enclosure) then
151+ if ! intermediate.isRealClass || nestedInConstructor(enclosure)then
151152 // Constructors and methods nested inside traits get the free variables
152153 // of the enclosing trait or class.
153154 // Conversely, local traits do not get free variables.
@@ -237,6 +238,9 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
237238 captureImplicitThis(tree.tpe)
238239 case tree : Select =>
239240 if isExpr(sym) && isLocal(sym) then markCalled(sym, enclosure)
241+ case tree : New =>
242+ val constr = tree.tpe.typeSymbol.primaryConstructor
243+ if enclosure.exists && isExpr(constr) then symSet(called, enclosure) += constr
240244 case tree : This =>
241245 narrowTo(tree.symbol.asClass)
242246 case tree : MemberDef if isExpr(sym) && sym.owner.isTerm =>
@@ -291,7 +295,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
291295 val calleeOwner = normalizedCallee.owner
292296 if calleeOwner.isTerm then narrowLogicOwner(caller, logicOwner(normalizedCallee))
293297 else
294- assert(calleeOwner.is(Trait ))
298+ // assert(calleeOwner.is(Trait))
295299 // methods nested inside local trait methods cannot be lifted out
296300 // beyond the trait. Note that we can also call a trait method through
297301 // a qualifier; in that case no restriction to lifted owner arises.
0 commit comments