Hello! I've (wrongly) asked this on <#C0KLZSCHF|ea...
# getting-started
t
Hello! I've (wrongly) asked this on #eap already, and moving here as requested. Here's the previous thread: https://kotlinlang.slack.com/archives/C0KLZSCHF/p1673469970819299 I'm playing around with the new context receivers prototype (really exciting!) and I've hit a little snag with function references. I'm trying to run a function of the following type:
suspend 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!
t
Oh neat, so it works 🙂 Thank you!
p
I’ve found this useful before:
Copy code
context(T)
fun <T> context() = this@T
which allows you to
Copy code
context(Greeter, Greeting)
fun example() {
    val greeting = context<Greeting>()
    greet(greeting)
}