Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/comparingSmartCastValueToBoolean.fir.kt
T
Nikolay Lunyak f5d859f209 [FIR] Don't miss smartcast info on equalities with when subjects
Since they are not `FirSmartCastExpression`s,
they are treated as proper original types,
thus leading to reporting errors instead of
warnings.

^KT-60095 Fixed
2023-10-31 10:40:43 +00:00

24 lines
714 B
Kotlin
Vendored

// ISSUE: KT-35134
interface A
fun foo(a: Any) {
if (a is A) {
if (<!EQUALITY_NOT_APPLICABLE_WARNING!>a == (<!EQUALITY_NOT_APPLICABLE_WARNING!>a == 1<!>)<!>) {
println(1)
}
when (a) {
<!CONFUSING_BRANCH_CONDITION_ERROR, EQUALITY_NOT_APPLICABLE_WARNING, INCOMPATIBLE_TYPES_WARNING!>a == 1<!> -> print("1")
}
if (<!EQUALITY_NOT_APPLICABLE!>(a <!USELESS_CAST!>as A<!>) == (<!EQUALITY_NOT_APPLICABLE_WARNING!>a == 1<!>)<!>) {
println(1)
}
when (a <!USELESS_CAST!>as A<!>) {
<!CONFUSING_BRANCH_CONDITION_ERROR, EQUALITY_NOT_APPLICABLE_WARNING, INCOMPATIBLE_TYPES!>a == 1<!> -> print("1")
}
}
}