Has an extension function
fun <T> T.doSomething() where T: A, T: B
If there only one generic bound A
, I can use syntax (A::doSomething)(instanceOfA)
to reference to the function, but how to do this with multiple bounds?
Example:
interface A
, interface B
, and a extension function bounded with both interfaces fun <T> T.doSomething() where T: A, T: B
.
Now I manage to "override" doSomething
if a class extends additional interface C
, like class X: A, B, C
:
- Declare another extension function
fun <T> T.doSomething() where T: A, T: B, T: C
- Declare
doSomething()
inside classX
If I use doSomething()
in both "override" function directly will cause endless recursion. How can I reference to original fun <T> T.doSomething() where T: A, T: B
(like super.doSomething()
)?