Daniel Pitts
12/14/2024, 2:44 AMDaniel Pitts
12/14/2024, 2:45 AMopen class FooAccess {
fun createFoo() = Foo()
}
class Foo {
companion object
}
class Bar : FooAccess() {
val foo by Foo
}
// In the context of FooAccess
operator fun Foo.Companion.getValue(thisRef: Any?, property: KProperty<*>): Foo = createFoo()
Daniel Pitts
12/14/2024, 2:46 AMDaniel Pitts
12/14/2024, 2:49 AMFoo
is a low-level property, FooAccess
is a bridge between low and high level, Bar
is a high-level class, and getValue
has logic that needs to be aware of high-level classes, so doesn't belong in the bridge package.Youssef Shoaib [MOD]
12/14/2024, 2:54 AMthisRef
to be a FooAccess
, but that would limit its use to only be inside that classDaniel Pitts
12/14/2024, 2:56 AM