[FIR] Unconditionally enable BooleanElvisBoundSmartCasts feature in K2

^KT-54694 Fixed
^KT-26357
This commit is contained in:
Dmitriy Novozhilov
2022-11-29 11:01:35 +02:00
committed by Space Team
parent ac7fddaad5
commit 46928eaa0b
3 changed files with 52 additions and 8 deletions
@@ -0,0 +1,50 @@
// !LANGUAGE: -BooleanElvisBoundSmartCasts
interface Order {
val expired: Boolean?
fun notExpired(): Boolean
fun doSomething()
}
fun foo(o: Any) {
val order = o as? Order
if (order?.expired ?: false) {
order.doSomething()
}
else {
}
if (order?.notExpired() ?: false) {
order.doSomething()
}
}
fun bar(o: Any) {
val order = o as? Order
if (order?.expired ?: true) {
}
else {
order<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.doSomething()
}
if (order?.notExpired() ?: true) {
}
else {
order<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.doSomething()
}
}
fun baz(o: Boolean?) {
if (o ?: false) {
o.hashCode()
}
if (o ?: true) {
}
else {
o.hashCode()
}
}