Lazy extension properties


#1

Can an extension property be lazy?

This works:

val Kos.foo: Int get() {
    return keep.size
}

this gives me an error: “unresolved reference: keep”:

val Kos.keepCount: Int by lazy {
    keep.size
}

#2

No. A lazy property requires storing state (the evaluated value), and there is no way to add state to an existing object from an extension property.