Supporting callable references to variables

Is there a YouTrack issue for supporting callable references to variables?

e.g., when compiling the code below with kotlinc 1.3.61, I get the following error for the line with the comment:

unsupported [References to variables aren’t supported yet]

(Should kotlinc error messages for features that “aren’t supported yet” provide a link to the relevant YouTrack issue, so people who want them can vote for them, and track their implementation progress?)

Example code:

class C(f: C.(s: String) -> Unit) {

    init {
        ::f // compilation error on this line
    }
}

It’s pretty easy to search for issues if they mention the error message: https://youtrack.jetbrains.com/issues/KT?q=“References%20to%20variables%20aren’t%20supported%20yet”

The request is tracked here: https://youtrack.jetbrains.com/issue/KT-28346

1 Like

Why do you want a callable reference to the variable, anyway? Can’t you just use the variable itself, anywhere you would otherwise pass a callable reference to a method? E.g.,

inline fun <T, U> T.apply1(
        value: U, f: T.(u: U) -> Unit
) {
    this.f(value)
    return this
}

class C(f: C.(s: String) -> Unit) {
    init {
        this.apply1("foo", f)
    }
}