在 Kotlin 中我有如下代码:
open class A {
protected open fun B.doSomething() {}
}
class B {}
class C : A() {
override fun B.doSomething() {
print("first, do some C-specific logic")
print("now try to call super implementation. How?")
super.doSomething() // does not compile
super<A>.doSomething() // does not compile
super<B>.doSomething() // does not compile
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道,在这种情况下如何调用 doSomething() 的超类实现?或者根本不可能在 kotlin 中调用扩展函数的超级实现?