import kotlin.reflect.KProperty class LazyDelegate(val value: T) { operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value } fun lazy(block: () -> T): LazyDelegate = LazyDelegate(block()) fun getAny(): Any? = null class Test { val x by lazy { val y = getAny() as? String ?: "" y } }