Is something like the following possible somehow? ...
# getting-started
m
Is something like the following possible somehow?
Copy code
class BaseType {
    val someProp: Int = 10
}

fun handleProperty(prop: KProperty1<BaseType, Int>) {
    // get BaseType instance here somehow
}

fun main() {
    val x = BaseType()
    handleProperty(x::someProp)
}
e
KProperty1
is an unbound member property, so it doesn't have an instance. if you bind it to an instance, you get a
KProperty0
, but that doesn't expose the instance -
KProperty0
can also be a top-level (non-member) property.
what are you trying to do? if you're writing a property delegate, the
this
ref is passed separately
m
Basically I currently have a setup like this:
Copy code
class X {
    val in1 by input()
    val out1 by output()

    fun connect(output: String, node: X, input: String) { ... }
}

fun main() {
    x1 = X()
    x2 = X()
    x1.connect("out1", x2, "in1")
}

// ideally:

fun main() {
    x1 = X()
    x2 = X()
    x1::out1 connectsTo x2::in1  // connectsTo is an infix fun taking both properties but has access to the property owners
}