Skip to content

Commit

Permalink
Merge pull request #1397 from Friendseeker/transitive-invalidation-fa…
Browse files Browse the repository at this point in the history
…st-pass-2

[1.x] Refine early return condition in `invalidateAfterInternalCompilation`
  • Loading branch information
eed3si9n authored Sep 28, 2024
2 parents 4d4c4ac + 9204ba9 commit 59505ce
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object A {
val a: Int = 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object B {
val b = A.a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object C {
val c1 = B.b
val c2: Int = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object D {
val d: Int = C.c2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object A {
val a: String = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> compile

$ copy-file changes/A.scala A.scala
> compile
> checkIterations 4

0 comments on commit 59505ce

Please sign in to comment.