4ad6cfcf53
We can't rely on argument type nullability here, because it still can hold an uninitialized value on JVM. KT-50577 KT-35272 KT-27427
30 lines
283 B
Kotlin
Vendored
30 lines
283 B
Kotlin
Vendored
// KT-27427
|
|
|
|
interface A {
|
|
fun foo()
|
|
}
|
|
|
|
class B : A {
|
|
override fun foo() {
|
|
}
|
|
}
|
|
|
|
fun test1() {
|
|
val b = B()
|
|
(b as A).foo()
|
|
}
|
|
|
|
fun test2() {
|
|
val b = getB()
|
|
(b as A).foo()
|
|
}
|
|
|
|
fun test3() {
|
|
val b = getB()
|
|
b.foo()
|
|
}
|
|
|
|
fun getB(): B = B()
|
|
|
|
// 1 IFNONNULL
|