diff --git a/transpiler/java/com/google/j2cl/common/Problems.java b/transpiler/java/com/google/j2cl/common/Problems.java index e8bc594e6c..e63bc853b4 100644 --- a/transpiler/java/com/google/j2cl/common/Problems.java +++ b/transpiler/java/com/google/j2cl/common/Problems.java @@ -245,7 +245,7 @@ public void abortIfCancelled() { } } - protected boolean isCancelled() { + public boolean isCancelled() { return false; } diff --git a/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/KotlinParser.kt b/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/KotlinParser.kt index 84e271d2e4..43d730aac6 100644 --- a/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/KotlinParser.kt +++ b/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/KotlinParser.kt @@ -77,6 +77,7 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil import org.jetbrains.kotlin.modules.TargetId +import org.jetbrains.kotlin.progress.CompilationCanceledException import org.jetbrains.kotlin.progress.CompilationCanceledStatus import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus @@ -102,7 +103,9 @@ class KotlinParser(private val problems: Problems) { ProgressIndicatorAndCompilationCanceledStatus.setCompilationCanceledStatus( object : CompilationCanceledStatus { override fun checkCanceled() { - problems.abortIfCancelled() + // throw CompilationCanceledException instead of our own which is properly handled by + // kotlinc to gracefully exit from the compilation. + if (problems.isCancelled) throw CompilationCanceledException() } } )