https://kotlinlang.org logo
Title
a

Alexandru Nedelcu

05/07/2023, 7:17 AM
How stable is the "multiple context receivers" experimental feature in Kotlin? Do you foresee any risk in enabling
-Xcontext-receivers
? 🙂
s

simon.vergauwen

05/07/2023, 7:42 AM
It’s experimental because it’s JVM only atm. The syntax is also not guaranteed yet, some minor details are still being discuss such as labels, sometimes it doesn’t compile, but changing some code around always fixed it for me. I don’t expect the syntax to change tbh. Hopefully we’ll get (poly) n-arity
with
in the Std instead of having to define it ourselves.
a

Alexandru Nedelcu

05/07/2023, 7:44 AM
Yikes, I crashed the compiler due to type inference, I guess not 🙂
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: .../UserPatchRequest.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:51)
Just played with context receivers, I'm excited 🤩 but bumped into some sort of type inference bug.
s

simon.vergauwen

05/07/2023, 9:08 AM
Yes, that’s what I meant with sometimes it doesn’t compile but changing the code fixes it 😅 inference sometimes breaks, and heavy `inline`/`suspend` also doesn’t always play nice. If not had any cases where I couldn’t fix it by explicitly adding types arguments, or explicitly using
suspend
instead of
inline
. I’m super excited for context receivers, and am hoping we’ll get alpha or beta in 2.1 🤞 next year
c

CLOVIS

05/07/2023, 8:54 PM
I don’t expect the syntax to change tbh. Hopefully we’ll get (poly) n-arity
with
in the Std instead of having to define it ourselves.
I don't think we'll get multi-arity
with
at all. The
with val
syntax in the KEEP looks much better to me, but they plan on designing it as a second step. I don't see them introducing multi-arity
with
with it as a future possibility.
t

thanh

05/08/2023, 8:45 AM
I been using it for almost a year in prod. It works really well ( except type inference errorwhich just need to clean/compile again to work).
g

Giulio Caccin

05/08/2023, 10:22 AM
We finally got it in prod too right after the conference, the entire team is loving it.