8ac59592ed
When one side of an Elvis operator can only be `null`, and the entire Elvis operator expression cannot be `null`, this implies that the opposite side of the Elvis operator cannot be `null`. Add such implications to the Elvis exit node of the DFA. This helps smart-casting of variables used within long Elvis operator chains. #KT-49249 Fixed
33 lines
652 B
Kotlin
Vendored
33 lines
652 B
Kotlin
Vendored
// ISSUE: KT-49249
|
|
// WITH_STDLIB
|
|
|
|
fun test_1() {
|
|
val a: Throwable? = null;
|
|
val b: Unit? = null
|
|
val c = a ?: b?.let { return it } ?: return
|
|
c<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
|
throw a
|
|
}
|
|
|
|
fun test_2() {
|
|
val a: Throwable? = null;
|
|
val b: Unit? = null
|
|
val c = a ?: b?.let { return it } ?: return
|
|
throw a
|
|
}
|
|
|
|
fun test_3() {
|
|
val a: Throwable? = null;
|
|
val b: Unit? = null
|
|
val c = b?.let { return it } ?: a ?: return
|
|
c<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
|
throw a
|
|
}
|
|
|
|
fun test_4() {
|
|
val a: Throwable? = null;
|
|
val b: Unit? = null
|
|
val c = b?.let { return it } ?: a ?: return
|
|
throw a
|
|
}
|