[FIR] Add the new test set to render diagnostics from IR const evaluator
This commit is contained in:
@@ -167,6 +167,8 @@ internal fun IrBuiltIns.emptyArrayConstructor(arrayType: IrType): IrConstructorC
|
||||
}
|
||||
|
||||
internal fun IrConst<*>.toConstantValue(): ConstantValue<*> {
|
||||
if (value == null) return NullValue
|
||||
|
||||
val constType = this.type.makeNotNull().removeAnnotations()
|
||||
return when (this.type.getPrimitiveType()) {
|
||||
PrimitiveType.BOOLEAN -> BooleanValue(this.value as Boolean)
|
||||
|
||||
+5
-4
@@ -14,7 +14,10 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||
import org.jetbrains.kotlin.ir.interpreter.IrInterpreter
|
||||
import org.jetbrains.kotlin.ir.interpreter.IrInterpreterConfiguration
|
||||
import org.jetbrains.kotlin.ir.interpreter.checker.*
|
||||
import org.jetbrains.kotlin.ir.interpreter.checker.EvaluationMode
|
||||
import org.jetbrains.kotlin.ir.interpreter.checker.IrInterpreterChecker
|
||||
import org.jetbrains.kotlin.ir.interpreter.checker.IrInterpreterCheckerData
|
||||
import org.jetbrains.kotlin.ir.interpreter.checker.IrInterpreterCommonChecker
|
||||
import org.jetbrains.kotlin.ir.interpreter.preprocessor.IrInterpreterConstGetterPreprocessor
|
||||
import org.jetbrains.kotlin.ir.interpreter.preprocessor.IrInterpreterKCallableNamePreprocessor
|
||||
import org.jetbrains.kotlin.ir.interpreter.preprocessor.IrInterpreterPreprocessorData
|
||||
@@ -58,13 +61,11 @@ fun IrFile.runConstOptimizations(
|
||||
mode: EvaluationMode,
|
||||
evaluatedConstTracker: EvaluatedConstTracker? = null,
|
||||
inlineConstTracker: InlineConstTracker? = null,
|
||||
onWarning: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
|
||||
onError: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
|
||||
suppressExceptions: Boolean = false,
|
||||
) {
|
||||
val checker = IrInterpreterCommonChecker()
|
||||
val irConstExpressionTransformer = IrConstAllTransformer(
|
||||
interpreter, this, mode, checker, evaluatedConstTracker, inlineConstTracker, onWarning, onError, suppressExceptions
|
||||
interpreter, this, mode, checker, evaluatedConstTracker, inlineConstTracker, { _, _, _ -> }, { _, _, _ -> }, suppressExceptions
|
||||
)
|
||||
this.transform(irConstExpressionTransformer, IrConstTransformer.Data())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user