[FIR, Tests] Add box tests to verify that disappeared DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE leads to executable code

#KT-59903


Merge-request: KT-MR-13423
Merged-by: Evgeniy Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>
This commit is contained in:
Evgeniy.Zhelenskiy
2023-12-08 13:18:59 +00:00
committed by Space Team
parent aff5b91da3
commit 9cef8a2133
25 changed files with 774 additions and 0 deletions
@@ -0,0 +1,55 @@
// ISSUE: KT-58754
// IGNORE_BACKEND_K1: ANY
// WITH_STDLIB
fun foo(): Int = 1
fun bar(): Int = 2
class Test(b: Boolean) {
val test_1 by lazy {
val a = if (b) {
::foo
} else {
::bar
}
a
}
val test_2 by lazy {
val a = if (b) ::foo else ::bar
a
}
val test_3 by lazy {
val a = when {
b -> { ::foo }
else -> { ::bar }
}
a
}
val test_4 by lazy {
val a = when {
b -> ::foo
else -> ::bar
}
a
}
}
fun box(): String {
with(Test(b = false)) {
require(test_1() == bar())
require(test_2() == bar())
require(test_3() == bar())
require(test_4() == bar())
}
with(Test(b = true)) {
require(test_1() == foo())
require(test_2() == foo())
require(test_3() == foo())
require(test_4() == foo())
}
return "OK"
}