diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala index 9381ec1fb9..2cfd8ff396 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala @@ -44,9 +44,16 @@ private[inc] class IncrementalNameHashingCommon( apis: APIs ): Set[String] = { val findSubclasses = relations.inheritance.internal.reverse _ + val invalidatedClassesAndCodefinedClasses = for { + cls <- invalidatedClasses.iterator + file <- relations.definesClass(cls).iterator + cls1 <- relations.classNames(file) + } yield cls1 + debug("Invalidate package objects by inheritance only...") val invalidatedPackageObjects = - transitiveDeps(invalidatedClasses, log)(findSubclasses).filter(_.endsWith(".package")) + transitiveDeps(invalidatedClassesAndCodefinedClasses.toSet, log)(findSubclasses) + .filter(_.endsWith(".package")) debug(s"Package object invalidations: ${invalidatedPackageObjects.mkString(", ")}") invalidatedPackageObjects } diff --git a/zinc/src/sbt-test/source-dependencies/package-object-name-inner/A.scala b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/A.scala new file mode 100644 index 0000000000..deb2b552a6 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/A.scala @@ -0,0 +1,7 @@ +package b + +class A { + class Inner { + O.o + } +} diff --git a/zinc/src/sbt-test/source-dependencies/package-object-name-inner/O.scala b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/O.scala new file mode 100644 index 0000000000..89d388076e --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/O.scala @@ -0,0 +1,5 @@ +package b + +object O { + def o = "" +} diff --git a/zinc/src/sbt-test/source-dependencies/package-object-name-inner/b.scala b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/b.scala new file mode 100644 index 0000000000..0a6e215a52 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/b.scala @@ -0,0 +1 @@ +package object b extends A diff --git a/zinc/src/sbt-test/source-dependencies/package-object-name-inner/changes/O1.scala b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/changes/O1.scala new file mode 100644 index 0000000000..afbcaef289 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/changes/O1.scala @@ -0,0 +1,5 @@ +package b + +object O { + def o = 42 +} diff --git a/zinc/src/sbt-test/source-dependencies/package-object-name-inner/test b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/test new file mode 100644 index 0000000000..9379c031e7 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/package-object-name-inner/test @@ -0,0 +1,4 @@ +> compile +$ copy-file changes/O1.scala O.scala +> compile +> checkIterations 3