Skip to content

Commit

Permalink
Fixes undercompilation on local inheritance
Browse files Browse the repository at this point in the history
### background

In sbt 0.13 days, we could ignore the relationship between two classes defined in the same `*.scala` source file, because they will be compiled anyway, and the invalidation was done at the source file level. With class-based namehashing, the invalidation is done at the class level, so we can no longer ignore inheritance relationship coming from the same source. This fact is acknowledged in the existence of `LocalDependencyByInheritance`, but we still have old assumptions scattered around the xsbt-dependency implementation.

### what this changes

This change removes two if expressions that was used to filter out dependency info coming from the same source.

### notes

One might wonder why it's necessary to keep the local inheritance info, if two classes involved are compiled together anyways. The answer is transitive dependencies. Using trait-trait-211 as example, `gg.table.ObjectConcatHelpers` was changed, eventually causing `xx.EvaluatorTestSupport` to invalidate. However, because of the missing same-source inheritance, it did not invalidate `xx.EvaluatorSpecification`. This meant that neither `xx.StringLibSpecs` was invalidated, and resulting to a runtime error.

Fixes sbt#417
  • Loading branch information
eed3si9n committed Oct 7, 2017
1 parent 2e0d611 commit bc52af0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/compiler-bridge/src/main/scala/xsbt/Dependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
case None =>
debuglog(Feedback.noOriginFileForExternalSymbol(dep.to))
}
} else if (onSource.file != sourceFile) {
// Dependency is internal -- but from other file / compilation unit
} else {
// We cannot ignore dependencies coming from the same source file because
// the dependency info needs to propagate. See source-dependencies/trait-trait-211.
val onClassName = classNameAsString(dep.to)
callback.classDependency(onClassName, fromClassName, context)
} else () // Comes from the same file, ignore
}
}
}

Expand Down Expand Up @@ -227,7 +228,6 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
val depClass = enclOrModuleClass(dep)
val dependency = ClassDependency(fromClass, depClass)
if (!cache.contains(dependency) &&
fromClass.associatedFile != depClass.associatedFile &&
!depClass.isRefinementClass) {
process(dependency)
cache.add(dependency)
Expand Down

0 comments on commit bc52af0

Please sign in to comment.