Files
kotlin-fork/compiler/testData/codegen/box/safeCall/kt52580.kt
T
Dmitriy Novozhilov b73783b693 Add test for KT-52580
2022-06-21 14:10:37 +00:00

33 lines
566 B
Kotlin
Vendored

// ISSUE: KT-52580
interface Base {
val a: String
}
interface Derived : Base {
override val a: String
val b: Int
}
class BaseImpl(override val a: String) : Base
fun test(base: Base): String {
return consume(
base.run { a },
(base as? Derived)?.b?.toString(),
base.a
)
}
fun consume(s1: String, s2: String?, s3: String): String {
return "$s1|$s2|$s3"
}
fun box(): String {
val result = test(BaseImpl("Base"))
return when (result) {
"Base|null|Base" -> "OK"
else -> "Fail: $result"
}
}