Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.fir.kt
T

26 lines
642 B
Kotlin
Vendored

// !LANGUAGE: +SafeCastCheckBoundSmartCasts
// See KT-20752
class Unstable {
val first: String? get() = null
}
class StringList {
fun remove(s: String) = s
}
fun StringList.remove(s: String?) = s ?: ""
fun foo(list: StringList, arg: Unstable) {
list.remove(arg.first)
if (arg.first as? String != null) {
// Should be still resolved to extension, without smart cast or smart cast impossible
list.remove(arg.first)
}
val s = arg.first as? String
if (s != null) {
// Should be still resolved to extension, without smart cast or smart cast impossible
list.remove(arg.first)
}
}