Skip to content

Commit 59505ce

Browse files
authored
Merge pull request #1397 from Friendseeker/transitive-invalidation-fast-pass-2
[1.x] Refine early return condition in `invalidateAfterInternalCompilation`
2 parents 4d4c4ac + 9204ba9 commit 59505ce

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalCommon.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,16 +464,10 @@ private[inc] abstract class IncrementalCommon(
464464
val dependsOnClass = findClassDependencies(_, relations)
465465
val firstClassInvalidation: Set[String] = {
466466
val invalidated =
467-
if (invalidateTransitively) {
468-
// Invalidate by brute force (normally happens when we've done more than 3 incremental runs)
469-
IncrementalCommon.transitiveDeps(initial, log)(dependsOnClass)
470-
} else {
471-
changes.apiChanges.flatMap(invalidateClassesInternally(relations, _, isScalaClass)).toSet
472-
}
473-
val included = includeTransitiveInitialInvalidations(initial, invalidated, dependsOnClass)
474-
log.debug("Final step, transitive dependencies:\n\t" + included)
475-
included
467+
changes.apiChanges.flatMap(invalidateClassesInternally(relations, _, isScalaClass)).toSet
468+
includeTransitiveInitialInvalidations(initial, invalidated, dependsOnClass)
476469
}
470+
log.debug("Final step, transitive dependencies:\n\t" + firstClassInvalidation)
477471

478472
// Invalidate classes linked with a class file that is produced by more than one source file
479473
val secondClassInvalidation = IncrementalCommon.invalidateNamesProducingSameClassFile(relations)
@@ -506,7 +500,13 @@ private[inc] abstract class IncrementalCommon(
506500
Set.empty
507501
} else {
508502
if (invalidateTransitively) {
509-
newInvalidations ++ recompiledClasses
503+
val firstClassTransitiveInvalidation = includeTransitiveInitialInvalidations(
504+
initial,
505+
IncrementalCommon.transitiveDeps(initial, log)(dependsOnClass),
506+
dependsOnClass
507+
)
508+
log.debug("Invalidate by brute force:\n\t" + firstClassTransitiveInvalidation)
509+
firstClassTransitiveInvalidation ++ secondClassInvalidation ++ thirdClassInvalidation ++ recompiledClasses
510510
} else {
511511
firstClassInvalidation ++ secondClassInvalidation ++ thirdClassInvalidation
512512
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object A {
2+
val a: Int = 0
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object B {
2+
val b = A.a
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object C {
2+
val c1 = B.b
3+
val c2: Int = 0;
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object D {
2+
val d: Int = C.c2
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object A {
2+
val a: String = ""
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
> compile
2+
3+
$ copy-file changes/A.scala A.scala
4+
> compile
5+
> checkIterations 4

0 commit comments

Comments
 (0)