[FIR] Support boolean elvis bound smartcasts

#KT-44511 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-02-08 11:26:36 +03:00
committed by TeamCityServer
parent 2b088f1147
commit 9724d81a49
8 changed files with 98 additions and 6 deletions
@@ -0,0 +1,22 @@
// !LANGUAGE: +BooleanElvisBoundSmartCasts
// ISSUE: KT-44511, also relates to KT-8492 and KT-26357
class A(val b: Boolean) {
fun foo() {}
}
fun test_1(a: A?) {
if (a?.b ?: false) {
a.foo() // OK
} else {
a<!UNSAFE_CALL!>.<!>foo() // Error
}
}
fun test_2(a: A?) {
if (a?.b ?: true) {
a<!UNSAFE_CALL!>.<!>foo() // Error
} else {
a.foo() // OK
}
}