Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/variables/kt7599.kt
T
2015-05-12 19:43:17 +02:00

23 lines
450 B
Kotlin
Vendored

interface A {
fun ok(): Boolean
}
class B: A {
override fun ok(): Boolean { return true }
}
class C: A {
override fun ok(): Boolean { return false }
}
fun foo(): Boolean {
var v: A
v = B()
// No smart cast needed, but not a problem if ever
if (<!DEBUG_INFO_SMARTCAST!>v<!>.ok()) {
v = C()
}
// No smart cast needed, and no smart cast possible!
// We cannot choose between B and C
return v.ok()
}