Tmpod
01/12/2023, 4:14 PMsuspend context(Foo, Bar) () -> Unit
, however its .invoke
method is requiring two arguments, one for each receiver. The thing is: I explicitly have the receiver for one of them, but the other one is also a context receiver of the callee, so it isn't available as this
. Is there any way I can call this function?
this@Foo
and this@Bar
are not options, according to IntelliJ.
Thank you!ephemient
01/12/2023, 4:28 PMTmpod
01/12/2023, 5:28 PMphldavies
01/12/2023, 6:05 PMcontext(T)
fun <T> context() = this@T
which allows you to
context(Greeter, Greeting)
fun example() {
val greeting = context<Greeting>()
greet(greeting)
}