Hello! What is the syntax to call super for overriden function that has additional receiver?
Copy code
open class Test {
open fun SomeClass.test(){}
}
class Test2 : Test() {
override fun SomeClass.test() {
super.test() // is compilation error
}
}
d
dmitriy.novozhilov
07/29/2022, 11:00 AM
Unfortunately, there is no such syntax
There is an ugly workaround:
Copy code
abstract class Base {
abstract fun String.foo()
open fun applyFoo(s: String) {
s.foo()
}
}
open class Derived : Base() {
override fun String.foo() {
// do something
}
}
class Impl : Derived() {
override fun applyFoo(s: String) {
super.applyFoo(s) // calls `foo` from Derived
// do something else
}
}
fun use(base: Base, s: String) {
base.applyFoo(s)
}
dmitriy.novozhilov
07/29/2022, 11:00 AM
We are aware of this problem and looking some solution, which will cover extension and context receivers