From f0becd00409e9cd8f0b84a01c2508c192b6c1c35 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Wed, 2 Aug 2017 22:49:20 +0300 Subject: [PATCH] Fix IC with daemon JPS IC with daemon was not working since the commit 514635e965b7c4378ef535c1e13cf68146753528 Before that change `IncrementalCompilation.isEnabled` returned `true` when the corresponding system property was not set. After the change `isEnabled` returns `true` only if the system property is set and equals to `"true"`. The property was never set up for the daemon if `CompilerMode.JPS_COMPILER` was used (the property was set up in a JPS process or in the daemon in case it was used with Gradle). #KT-19414 fixed --- .../src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt | 8 +++++--- .../kotlin/incremental/IncrementalJvmCompilerRunner.kt | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index 1625dcb16b4..643148e970d 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -376,9 +376,11 @@ class CompileServiceImpl( CompilerMode.JPS_COMPILER -> { val jpsServicesFacade = servicesFacade as JpsCompilerServicesFacade - doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler -> - val services = createCompileServices(jpsServicesFacade, eventManger, profiler) - compiler.exec(messageCollector, services, k2PlatformArgs) + withIC(enabled = servicesFacade.hasIncrementalCaches()) { + doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler -> + val services = createCompileServices(jpsServicesFacade, eventManger, profiler) + compiler.exec(messageCollector, services, k2PlatformArgs) + } } } CompilerMode.NON_INCREMENTAL_COMPILER -> { diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt index d6ac3752148..ffd9890af13 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt @@ -71,9 +71,9 @@ private object EmptyICReporter : ICReporter { } } -inline fun withIC(fn: ()->R): R { +inline fun withIC(enabled: Boolean = true, fn: ()->R): R { val isEnabledBackup = IncrementalCompilation.isEnabled() - IncrementalCompilation.setIsEnabled(true) + IncrementalCompilation.setIsEnabled(enabled) try { return fn()