Move reporting of interpreter's backend errors tests to fir module

This commit is contained in:
Ivan Kylchik
2021-12-14 23:31:46 +03:00
parent 44cf64a00c
commit 0f0b48f87b
8 changed files with 101 additions and 20 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.interpreter.IrInterpreter
import org.jetbrains.kotlin.ir.interpreter.isPrimitiveArray
@@ -29,7 +30,11 @@ class IrConstTransformer(
private fun IrExpression.reportIfError(original: IrExpression): IrExpression {
if (this is IrErrorExpression) {
onError(original, this)
return original
return when (mode) {
// need to pass any const value to be able to get some bytecode and then report error
EvaluationMode.ONLY_INTRINSIC_CONST -> IrConstImpl.int(startOffset, endOffset, type, 0)
else -> original
}
}
return this
}