Invalidate package objects transitively in name hashing

Modify `invalidatedPackageObjects` to look for package objects that
transitively inherit from an invalidated class instead of just inheriting
directly. This is the correct behavior that should have been implemented
in the first place. The bug comes from a subtle copy&paste mistake. The old
implementation used `publicInherited` relation and new one looks identical
but uses `inheritance` relation. The difference is that `publicInherited`
was a relation that was expanded transitively along inheritance chain but
`inheritance` is not. We have to perform the transitive walk in
`IncrementalNameHashing.invalidatedPackageObjects` implementation.

Mark `pkg-self` test as passing.

Fixes #2326
This commit is contained in:
Grzegorz Kossakowski 2016-02-02 01:33:43 +01:00
parent f78b7112a2
commit 65f7958898
2 changed files with 3 additions and 1 deletions

View File

@ -18,7 +18,9 @@ private final class IncrementalNameHashing(log: Logger, options: IncOptions) ext
// Package objects are fragile: if they inherit from an invalidated source, get "class file needed by package is missing" error
// This might be too conservative: we probably only need package objects for packages of invalidated sources.
override protected def invalidatedPackageObjects(invalidated: Set[File], relations: Relations): Set[File] =
invalidated flatMap relations.inheritance.internal.reverse filter { _.getName == "package.scala" }
transitiveDeps(invalidated)(relations.inheritance.internal.reverse).filter {
_.getName == "package.scala"
}
override protected def sameAPI[T](src: T, a: Source, b: Source): Option[APIChange[T]] = {
if (SameAPI(a, b))