Skip to content

Commit 01d35ff

Browse files
committed
Rework inheritance dependencies
1 parent 6b9aa1f commit 01d35ff

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,16 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
266266
sym.isAnonymousFunction ||
267267
sym.isAnonymousClass
268268

269-
private def addInheritanceDependency(parent: Symbol)(implicit ctx: Context): Unit =
270-
_dependencies += ClassDependency(resolveDependencySource, parent.topLevelClass, DependencyByInheritance)
269+
private def addInheritanceDependency(tree: Template)(implicit ctx: Context): Unit =
270+
if (tree.parents.nonEmpty) {
271+
val depContext =
272+
if (isLocal(tree.symbol.owner)) LocalDependencyByInheritance
273+
else DependencyByInheritance
274+
val from = resolveDependencySource
275+
tree.parents.foreach { parent =>
276+
_dependencies += ClassDependency(from, parent.tpe.classSymbol.topLevelClass, depContext)
277+
}
278+
}
271279

272280
/** Traverse the tree of a source file and record the dependencies which
273281
* can be retrieved using `topLevelDependencies`, `topLevelInheritanceDependencies`,
@@ -303,8 +311,8 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
303311
case ref: RefTree =>
304312
addDependency(ref.symbol)
305313
addTypeDependency(ref.tpe)
306-
case t @ Template(_, parents, _, _) =>
307-
t.parents.foreach(p => addInheritanceDependency(p.tpe.classSymbol))
314+
case t: Template =>
315+
addInheritanceDependency(t)
308316
case _ =>
309317
}
310318
traverseChildren(tree)

0 commit comments

Comments
 (0)