Remove dirty output files when expanding IC scope early

Previously IC could go to the next iteration without removing
outputs for the files compiled during the last iteration.
For example, it could happen, when a multifile part is changed
(we add sources for other parts and recompile everything together).

In case of MPP it could lead to compile error, because
the compiler would see the same actual declarations from dirty sources
and dirty outputs from previous iteration (which should have been removed).
That behaviour did not raise an error before dc8240c24e
because actual declarations from binaries (e.g. compile classpath) were ignored.

    #KT-35957 Fixed
This commit is contained in:
Alexey Tsvetkov
2020-04-17 12:54:19 +03:00
parent 2442abadc3
commit 4ccec5218f
2 changed files with 2 additions and 6 deletions
@@ -246,6 +246,7 @@ abstract class IncrementalCompilerRunner<
val additionalDirtyFiles = additionalDirtyFiles(caches, generatedFiles, services).filter { it !in dirtySourcesSet }
if (additionalDirtyFiles.isNotEmpty()) {
dirtySources.addAll(additionalDirtyFiles)
generatedFiles.forEach { it.outputFile.delete() }
continue
}
}
@@ -6,9 +6,4 @@ Compiling files:
src/utilsActual.kt
src/utilsNoActual.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
Class 'X' has several compatible actual declarations in modules <multifilePartChanged>, <multifilePartChanged>
Function 'foo' has several compatible actual declarations in modules <multifilePartChanged>, <multifilePartChanged>
Function 'useX' has several compatible actual declarations in modules <multifilePartChanged>, <multifilePartChanged>
Exit code: OK