I'm really confused: I thought that context receiv...
# javascript
n
I'm really confused: I thought that context receivers are available in JVM code only but I accidentally(* ๐Ÿ™‚) compiled the following function in my Kotlin/JS project:
Copy code
context(SelectorsScope)
infix fun CSSSelector.child(selector: CSSSelector): CSSSelector = child(this, selector)
And it works! Are context receivers allowed on platforms other than JVM in Kotlin 1.9.22? * I was just experimenting how the
SelectorsScope.child()
function could be made more comfortable with context receivers
e
Context receivers should be multiplatform. IIRC I did use them in Native, for example.
๐Ÿ˜ฎ 2
n
j
They are absolutely not multiplatform
๐Ÿ‘๐Ÿป 1
That's so weird
๐Ÿ‘๐Ÿป 1
I tried native a few weeks ago and they did not work, only JVM worked
๐Ÿ‘๐Ÿป 1
n
It seems to work even in common code, although editor support is sometimes misbehaving. For example one of my JVM unit tests (using context receivers from a library's common code) compiles and executes as expected but the editor still displays an error:
e
Not sure what to say guys, it looks like shouldn't be multiplatform, but I definitely remember compiling on mingwX64
๐Ÿ‘๐Ÿป 1
n
I have asked it in the #compiler group (sorry for the "cross-post"): https://kotlinlang.slack.com/archives/C7L3JB43G/p1706689232765499 What I have learnt is context receivers will be removed in favor of context parameters ๐Ÿ˜ฎ See: https://kotlinlang.slack.com/archives/C7L3JB43G/p1706690703933919?thread_ts=1706689232.765499&cid=C7L3JB43G
j
I tried on macosArm and linuxArm and they were not working (was porting code from JVM that was already using them)
๐Ÿ˜ฎ 1
Of course the target shouldn't affect the ability to use them since they're implemented way before any target stuff applies
๐Ÿ˜• 1