Don't use global state for keeping incremental compilation state

Previously IC state was stored in System properties. As result parallel
compilation might cause incorrect state of IC, what led to corruption
of kotlin_module files. Now IC state is stored via CompilerArguments
and CompilerConfiguration
#KT-46038 Fixed
This commit is contained in:
Andrey Uskov
2021-09-20 21:17:18 +03:00
committed by teamcity
parent 99300bd885
commit 2adc851f1b
21 changed files with 98 additions and 32 deletions
@@ -372,7 +372,7 @@ class MultifileClassCodegenImpl(
private fun getCompiledPackageFragment(
facadeFqName: FqName, state: GenerationState
): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? {
if (!IncrementalCompilation.isEnabledForJvm()) return null
if (!state.isIncrementalCompilation) return null
val packageFqName = facadeFqName.parent()
@@ -72,6 +72,7 @@ class GenerationState private constructor(
val isIrBackend: Boolean,
val ignoreErrors: Boolean,
val diagnosticReporter: DiagnosticReporter,
val isIncrementalCompilation: Boolean
) {
class Builder(
private val project: Project,
@@ -129,13 +130,16 @@ class GenerationState private constructor(
fun diagnosticReporter(v: DiagnosticReporter) =
apply { diagnosticReporter = v }
val isIncrementalCompilation: Boolean = configuration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION)
fun build() =
GenerationState(
project, builderFactory, module, bindingContext, files, configuration,
generateDeclaredClassFilter, codegenFactory, targetId,
moduleName, outDirectory, onIndependentPartCompilationEnd, wantsDiagnostics,
jvmBackendClassResolver, isIrBackend, ignoreErrors,
diagnosticReporter ?: DiagnosticReporterFactory.createReporter()
diagnosticReporter ?: DiagnosticReporterFactory.createReporter(),
isIncrementalCompilation
)
}