Skip to content

Commit d733e96

Browse files
committed
sbt.ExtractDependencies: avoid false dependencies
Type#member might return a denotation that doesn't "really exists" (as defined by TypeAssigner#reallyExists), in some circumstance this denotation can refer to a symbol in a class that is in the classpath but that is not used by this file, so using addDependency on the result of Type#member might add a false dependency. We avoid this by using Type#select instead which will internally do the right thing. This issue was discovered while compiling the bootstrapped projects which would sometimes force a full recompilation for no reason.
1 parent 5310c94 commit d733e96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private class ExtractDependenciesCollector(implicit val ctx: Context) extends tp
175175
override def traverse(tree: Tree)(implicit ctx: Context): Unit = {
176176
tree match {
177177
case Import(expr, selectors) =>
178-
def lookupImported(name: Name) = expr.tpe.member(name).symbol
178+
def lookupImported(name: Name) = expr.tpe.select(name).typeSymbol
179179
def addImported(name: Name) = {
180180
// importing a name means importing both a term and a type (if they exist)
181181
addDependency(lookupImported(name.toTermName))

0 commit comments

Comments
 (0)