y
03/23/2023, 4:14 PMclass Foo(val s: String)
interface MyInterface {
fun Foo.bar(): String
}
object MyImpl : MyInterface {
override fun Foo.bar(): String = this.s
}
then given val myImpl = MyImpl
and an instance of Foo
, how/when can I call `MyImpl`'s implementation of bar()
?Paul Griffith
03/23/2023, 4:20 PMwith(MyImpl) {
someFooInstance.bar()
}
y
03/23/2023, 4:25 PMwhen
block brings all the extension functions of MyImpl
into scope?y
03/23/2023, 4:28 PMPaul Griffith
03/23/2023, 4:29 PMMyInterface/MyImpl
is the ‘dispatch receiver’ and Foo.bar
is the ‘extension receiver’