Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/varnotnull/boundInitializerWrong.fir.kt
T
Tianyu Geng 7e2f15f532 FIR DFA: fix logic clear aliasing
The logic should clear back aliases as well. To ensure all back aliases
don't lose any information, statements on the original variable are
copied over to its aliases.
2021-08-06 22:57:15 +03:00

46 lines
718 B
Kotlin
Vendored

// KT-15792 and related
fun foo() {
var x: String? = ""
val y = x
x = null
if (y != null) {
x<!UNSAFE_CALL!>.<!>hashCode()
}
}
fun foo2() {
var x: String? = ""
val y = x
if (y != null) {
x.hashCode()
}
}
fun bar(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
ss = null
if (hashCode != null) {
ss<!UNSAFE_CALL!>.<!>hashCode()
}
}
fun bar2(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
if (hashCode != null) {
ss.hashCode()
}
}
class Some(var s: String?)
fun baz(arg: Some?) {
val ss = arg?.s
if (ss != null) {
arg.hashCode()
arg.s<!UNSAFE_CALL!>.<!>hashCode()
}
}