How can I call a super's extension function?
For example:
open class Parent {
open fun String.print() = println(this)
}
class Child : Parent() {
override fun String.print() {
print("child says ")
super.print() // syntax error on this
}
}
Even though the print() function is defined inside of Parent, it belongs to String, not to Parent. So there's no print function that you can call on Parent, which is what you're trying to do with super.
I don't think there's syntax support for the type of call you're trying to do in Kotlin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With