Is there a way to do something like the following:...
# announcements
j
Is there a way to do something like the following:
Copy code
fun <T: Somethingable> String.buildSomething(): T {
	return T.buildSomethingFromString(this)
}
The only way to get buildSomethingFromString is to have a interface Somethingable have a default implementation in a companion object. But then I lose compile time checking for overriding implementation on T. I thought I could be specific on the extension for each concrete impl, but I can’t redefine String.buildSomething(): Impl1 and String.buildSomething(): Impl2 without changing the name.