caeus
caeus

Reputation: 3706

Add static extension to generic type

I'd like to be able to do this

fun <A> doSomething(block: A.Companion.() -> Unit): Unit {
    // bla bla bla
    A.block()
}

Is it possible? If not? Is it in the roadmap?

Upvotes: 0

Views: 248

Answers (1)

Peter Samokhin
Peter Samokhin

Reputation: 874

No, your example is impossible and not in roadmap.

Not all classes have companion objects and there are no ability to check if the specific class has.

Upvotes: 1

Related Questions