Is there a current way to access a context receive...
# language-evolution
a
Is there a current way to access a context receiver on a functional type or is that missing from the language right now?
Copy code
class C {
    val a = 1
}

context(C)
fun foo() {
    a // Works
    this@C // Works
    this@C.a // Works
}

val lambda: context(C) () -> Unit = {
    a // Works
    this@C // Does not work
    this@C.a // Does not work
}
y
Copy code
context(A) fun <A> given(): A = this@A

given<C>() // Works
a
Oof, nice workaround but feels somewhat broken that you need this?
y
It's actually what the new contexts KEEP is suggesting. It's good because it allows you to differentiate between different type args e.g.
List<String>
vs
List<Int>
❤️ 1
a
Yeah I've seen that. Anyway, this helps me get unblocked, thanks!