diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala index 492b0e63f..4bdef942d 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala @@ -464,16 +464,10 @@ private[inc] abstract class IncrementalCommon( val dependsOnClass = findClassDependencies(_, relations) val firstClassInvalidation: Set[String] = { val invalidated = - if (invalidateTransitively) { - // Invalidate by brute force (normally happens when we've done more than 3 incremental runs) - IncrementalCommon.transitiveDeps(initial, log)(dependsOnClass) - } else { - changes.apiChanges.flatMap(invalidateClassesInternally(relations, _, isScalaClass)).toSet - } - val included = includeTransitiveInitialInvalidations(initial, invalidated, dependsOnClass) - log.debug("Final step, transitive dependencies:\n\t" + included) - included + changes.apiChanges.flatMap(invalidateClassesInternally(relations, _, isScalaClass)).toSet + includeTransitiveInitialInvalidations(initial, invalidated, dependsOnClass) } + log.debug("Final step, transitive dependencies:\n\t" + firstClassInvalidation) // Invalidate classes linked with a class file that is produced by more than one source file val secondClassInvalidation = IncrementalCommon.invalidateNamesProducingSameClassFile(relations) @@ -506,7 +500,13 @@ private[inc] abstract class IncrementalCommon( Set.empty } else { if (invalidateTransitively) { - newInvalidations ++ recompiledClasses + val firstClassTransitiveInvalidation = includeTransitiveInitialInvalidations( + initial, + IncrementalCommon.transitiveDeps(initial, log)(dependsOnClass), + dependsOnClass + ) + log.debug("Invalidate by brute force:\n\t" + firstClassTransitiveInvalidation) + firstClassTransitiveInvalidation ++ secondClassInvalidation ++ thirdClassInvalidation ++ recompiledClasses } else { firstClassInvalidation ++ secondClassInvalidation ++ thirdClassInvalidation } diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/A.scala b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/A.scala new file mode 100644 index 000000000..d26475934 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/A.scala @@ -0,0 +1,3 @@ +object A { + val a: Int = 0 +} \ No newline at end of file diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/B.scala b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/B.scala new file mode 100644 index 000000000..e2eb7968d --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/B.scala @@ -0,0 +1,3 @@ +object B { + val b = A.a +} \ No newline at end of file diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/C.scala b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/C.scala new file mode 100644 index 000000000..75b2d7c07 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/C.scala @@ -0,0 +1,4 @@ +object C { + val c1 = B.b + val c2: Int = 0; +} \ No newline at end of file diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/D.scala b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/D.scala new file mode 100644 index 000000000..497b75205 --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/D.scala @@ -0,0 +1,3 @@ +object D { + val d: Int = C.c2 +} \ No newline at end of file diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/changes/A.scala b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/changes/A.scala new file mode 100644 index 000000000..822a53e8f --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/changes/A.scala @@ -0,0 +1,3 @@ +object A { + val a: String = "" +} \ No newline at end of file diff --git a/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/test b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/test new file mode 100644 index 000000000..10867af1a --- /dev/null +++ b/zinc/src/sbt-test/source-dependencies/transitive-early-stopping/test @@ -0,0 +1,5 @@ +> compile + +$ copy-file changes/A.scala A.scala +> compile +> checkIterations 4 \ No newline at end of file