Move ignoreConstOptimizationErrors compiler key from jvm to common

#KT-56023
This commit is contained in:
Ivan Kylchik
2023-02-06 14:46:28 +01:00
committed by Space Team
parent b58de2f8da
commit 5d5582d201
11 changed files with 22 additions and 21 deletions
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.IrErrorExpression
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.ir.interpreter.checker.IrConstTransformer
class ConstEvaluationLowering(
val context: CommonBackendContext,
private val suppressErrors: Boolean = false,
private val suppressErrors: Boolean = context.configuration.getBoolean(CommonConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS),
private val onWarning: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
private val onError: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
) : FileLoweringPass {
@@ -320,12 +320,11 @@ val constEvaluationPhase = makeIrModulePhase<JvmBackendContext>(
{
ConstEvaluationLowering(
it,
it.configuration.getBoolean(JVMConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS),
{ irFile, element, warning ->
onWarning = { irFile, element, warning ->
it.ktDiagnosticReporter.at(element, irFile)
.report(JvmBackendErrors.EXCEPTION_IN_CONST_EXPRESSION, warning.description)
},
{ irFile, element, error ->
onError = { irFile, element, error ->
it.ktDiagnosticReporter.at(element, irFile)
.report(JvmBackendErrors.EXCEPTION_IN_CONST_VAL_INITIALIZER, error.description)
}