JVM_IR: Prevent writing output after an error is reported

#KT-53825 Fixed
This commit is contained in:
Xin Wang
2022-10-18 15:36:46 +08:00
committed by Alexander Udalov
parent 252e97663b
commit 7b3ce35613
12 changed files with 43 additions and 12 deletions
@@ -306,11 +306,14 @@ open class JvmIrCodegenFactory(
override fun invokeCodegen(input: CodegenFactory.CodegenInput) {
val (state, context, module, notifyCodegenStart) = input as JvmIrCodegenInput
if ((state.diagnosticReporter as? BaseDiagnosticsCollector)?.hasErrors == true) return
fun hasErrors() = (state.diagnosticReporter as? BaseDiagnosticsCollector)?.hasErrors == true
if (hasErrors()) return
notifyCodegenStart()
jvmCodegenPhases.invokeToplevel(PhaseConfig(jvmCodegenPhases), context, module)
if (hasErrors()) return
// TODO: split classes into groups connected by inline calls; call this after every group
// and clear `JvmBackendContext.classCodegens`
state.afterIndependentPart()