Skip to content

Commit 1413c20

Browse files
Merge commit '13310fdad' into main
2 parents 9222662 + 13310fd commit 1413c20

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

backend/src/main/scala/sbt/internal/inc/bloop/internal/BloopNameHashing.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package sbt.internal.inc.bloop.internal
22

3+
import scala.collection.parallel.immutable.ParVector
4+
35
import _root_.bloop.UniqueCompileInputs
46
import _root_.bloop.tracing.BraveTracer
57
import monix.eval.Task
@@ -178,9 +180,16 @@ private final class BloopNameHashing(
178180
}
179181
}
180182
}
183+
val removedProducts =
184+
lookup.removedProducts(previousAnalysis).getOrElse {
185+
new ParVector(previous.allProducts.toVector)
186+
.filter(p => {
187+
!equivS.equiv(previous.product(p), stamps.product(p))
188+
})
189+
.toVector
190+
.toSet
191+
}
181192

182-
// Unnecessary to compute removed products because we can ensure read-only classes dir is untouched
183-
val removedProducts = Set.empty[VirtualFileRef]
184193
val changedBinaries: Set[VirtualFileRef] = tracer.traceVerbose("changed binaries") { _ =>
185194
lookup.changedBinaries(previousAnalysis).getOrElse {
186195
val detectChange = IncrementalCommon.isLibraryModified(

frontend/src/test/scala/bloop/BaseCompileSpec.scala

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ abstract class BaseCompileSpec extends bloop.testing.BaseSuite {
463463
| public void entrypoint(String[] args) {
464464
| A$ a = A$.MODULE$;
465465
| System.out.println(a.HelloWorld());
466-
| }
466+
| }
467467
|}""".stripMargin
468468
val `C.scala` =
469469
"""/C.scala
@@ -1829,4 +1829,50 @@ abstract class BaseCompileSpec extends bloop.testing.BaseSuite {
18291829
assertExitStatus(compiledState, ExitStatus.Ok)
18301830
}
18311831
}
1832+
1833+
test("detects removed products") {
1834+
TestUtil.withinWorkspace { workspace =>
1835+
object Sources {
1836+
val `A.scala` =
1837+
"""/a/A.scala
1838+
|package a
1839+
|class A
1840+
""".stripMargin
1841+
1842+
val `B.scala` =
1843+
"""/a/B.scala
1844+
|package a
1845+
|class B extends A
1846+
""".stripMargin
1847+
1848+
val `B2.scala` =
1849+
"""/a/B.scala
1850+
|package a
1851+
|class B extends A {
1852+
| def foo: Int = ???
1853+
|}
1854+
""".stripMargin
1855+
}
1856+
val logger = new RecordingLogger(ansiCodesSupported = false)
1857+
val `A` = TestProject(workspace, "a", List(Sources.`A.scala`, Sources.`B.scala`))
1858+
1859+
val projects = List(`A`)
1860+
val state = loadState(workspace, projects, logger)
1861+
1862+
val firstState = state.compile(`A`)
1863+
assertExitStatus(firstState, ExitStatus.Ok)
1864+
1865+
writeFile(`A`.srcFor("a/B.scala"), Sources.`B2.scala`)
1866+
def deleteAProduct(classesDir: AbsolutePath): Unit = {
1867+
val productA = classesDir.resolve("a").resolve("A.class")
1868+
Files.delete(productA.underlying)
1869+
}
1870+
1871+
deleteAProduct(firstState.getLastClassesDir(`A`).get)
1872+
1873+
val secondState = firstState.compile(`A`)
1874+
assertExitStatus(secondState, ExitStatus.Ok)
1875+
1876+
}
1877+
}
18321878
}

0 commit comments

Comments
 (0)