zjuhasz
02/03/2019, 5:27 AMopen class D { }
class D1 : D() { }
open class C {
open fun D.foo() {
println("D.foo in C")
}
open fun D1.foo() {
println("D1.foo in C")
}
fun caller(d: D) {
d.foo() // call the extension function
}
}
class C1 : C() {
override fun D.foo() {
// Is there some way to get something like super.foo() on this receiver?
println("D.foo in C1")
}
override fun D1.foo() {
println("D1.foo in C1")
}
}
fun main() {
C().caller(D()) // prints "D.foo in C"
C1().caller(D()) // prints "D.foo in C1" - dispatch receiver is resolved virtually
C().caller(D1()) // prints "D.foo in C" - extension receiver is resolved statically
}