Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/varnotnull/boundInitializerWrong.fir.kt
T
Dmitriy Novozhilov 6735cc8937 [FIR] Implement new bound smartcast algorithm
#KT-36055 Fixed
2020-02-12 10:17:45 +03:00

47 lines
745 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// KT-15792 and related
fun foo() {
var x: String? = ""
val y = x
x = null
if (y != null) {
x.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.<!INAPPLICABLE_CANDIDATE!>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.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
}
}