[IR] Split const folding into necessary one and for optimizations only

In this commit we have a lot of change in test data. This was caused
by the way where we evaluate constants. We split constant evaluation
into two distinct parts: only necessary evaluations for `fir2ir`
(like const val and annotations) and optimizations for lowering.
Now we don't do all constant evaluation on `fir2ir`, but IR
dump is executed after this phase, so test data changed.

#KT-58923
This commit is contained in:
Ivan Kylchik
2023-05-28 18:43:30 +02:00
committed by Space Team
parent 8067df3c94
commit dd264cff50
96 changed files with 648 additions and 327 deletions
@@ -2,6 +2,4 @@
/exceptionFromInterpreter_ir.kt:7:26: warning: Constant expression will throw an exception at runtime: / by zero
/exceptionFromInterpreter_ir.kt:8:39: error: Cannot evaluate constant expression: marginPrefix must be non-blank string.
/exceptionFromInterpreter_ir.kt:12:4: error: Cannot evaluate constant expression: / by zero
/exceptionFromInterpreter_ir.kt:8:39: error: Cannot evaluate constant expression: marginPrefix must be non-blank string.
@@ -3,5 +3,3 @@
/exceptionFromInterpreter_ir.kt:(205,210): warning: Division by zero
/exceptionFromInterpreter_ir.kt:(243,264): error: Const 'val' initializer should be a constant value
/exceptionFromInterpreter_ir.kt:(313,318): warning: Division by zero
@@ -7,7 +7,8 @@ const val divideByZero = <!EXCEPTION_IN_CONST_VAL_INITIALIZER!>1 / 0<!>
val disivionByZeroWarn = <!EXCEPTION_IN_CONST_EXPRESSION!>1 / 0<!>
const val trimMarginException = "123".<!EXCEPTION_IN_CONST_VAL_INITIALIZER!>trimMargin(" ")<!>
annotation class A(val i: Int, val b: Int)
@A(<!EXCEPTION_IN_CONST_VAL_INITIALIZER!>1 / 0<!>, 2)
fun foo() {}
// TODO must report all these exceptions directly from fir2ir
//annotation class A(val i: Int, val b: Int)
//
//@A(1 / 0, 2)
//fun foo() {}