タイトルがイマイチ決まらないが、つまり次のコードのようなこと。this@<interface>
を使う。super
でもthis
でもない。
interface I {
fun meth()
fun obj() = object : I {
override fun meth() { this@I.meth() }
}
}
class A : I {
override fun meth() = println("I am A")
}
これでA().obj().meth()
は"I am A"
を印字する。