Files
Denis.Zharkov 9fa0f51a61 K2: Fix false-negative RETURN_TYPE_MISMATCH
^KT-53987 Fixed
^KT-55932 Fixed
2023-02-15 08:13:42 +00:00

24 lines
571 B
Kotlin
Vendored

import kotlin.reflect.KProperty
class Delegate {
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String? {
return null
}
}
class Example {
private val p: String? by Delegate()
public val r: String? = "xyz"
public fun foo(): String {
// Smart cast is not possible if property is delegated
return <!RETURN_TYPE_MISMATCH!>if (p != null) p else ""<!>
}
public fun bar(): String {
// But is possible for non-delegated value property even if it's public
return if (r != null) r else ""
}
}