Consider the following code fragment:
object C {
@JvmStatic
fun main(vararg args: String) {
val s: String? = null
check(s != null) {
"The string is null"
}
require(s != null) {
"The string is null"
}
assert(s != null) {
"The string is null"
}
s.length
}
}
While both check() and require() have
contract {
returns() implies value
}
in their body, the above code still doesn't compile, forcing me to use either ?.:
s?.length
or !!:
s!!.length
Why no smart cast is performed in the above code?