For example
open class TestClass
fun TestClass.testFunc(): String = "ext"
now in another file I write:
import xx.xx.testFunc as rename
class OverTestClass : TestClass() {
fun testFunc(): String {
return "OverTestClass - " + rename()
}
}
You can see I rename TestClass.testFunc()
as rename()
so I can call TestClass.testFunc()
in OverTestClass
. But this is not cool, what the way I want to is like this:
return "OverTestClass - " + super.testFunc()
Is it possible?
I know this problem is upside down,the reason I want to this is: I am writing a lib used both in java and kotlin, I don't want write java like:
XxxKt.func(obj)
I want to:
obj.func(func)
So I put func
as an instance function. and implement directly by its "super" extension function