[FIR] Forbid complex boolean expressions

Disabling the language feature is supported,
otherwise there are too many tests that
would need to be updated to account for
K2's inability to do it.

The `ifConstVal.kt` test is deleted,
because now it must also be ignored in K2,
and since it is ignored for both the
frontends, and the ignored backends
include all the target backends, this test
is basically unused.

Note that now both the frontends report
`CONST_VAL_WITH_NON_CONST_INITIALIZER`.
for `condition`.

^KT-55196 Fixed
This commit is contained in:
Nikolay Lunyak
2023-08-16 11:00:26 +03:00
committed by Space Team
parent 79fe48ab5b
commit 73b4a81663
26 changed files with 69 additions and 200 deletions
@@ -1,24 +0,0 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
// TARGET_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6, NATIVE
fun <T> T.id() = this
const val flag = <!EVALUATED("true")!>true<!>
const val value = <!EVALUATED("10")!>10<!>
const val condition = <!EVALUATED("True")!>if (flag) "True" else "Error"<!>
const val withWhen = <!EVALUATED("True")!>when (flag) { true -> "True"; else -> "Error" }<!>
const val withWhen2 = <!EVALUATED("True")!>when { flag == true -> "True"; else -> "Error" }<!>
const val withWhen3 = <!EVALUATED("1")!>when(value) { 10 -> "1"; 100 -> "2"; else -> "3" }<!>
const val multibranchIf = <!EVALUATED("3")!>if (value == 100) 1 else if (value == 1000) 2 else 3<!>
// STOP_EVALUATION_CHECKS
fun box(): String {
if (condition.id() != "True") return "Fail 1"
if (withWhen.id() != "True") return "Fail 2"
if (withWhen2.id() != "True") return "Fail 3"
if (withWhen3.id() != "1") return "Fail 4"
if (multibranchIf.id() != 3) return "Fail 5"
return "OK"
}