I realize that 2.2.0-Beta2 doesn't seem to officia...
# eap
j
I realize that 2.2.0-Beta2 doesn't seem to officially mention context parameters (so I understand it may not be working). But when trying to use the newly added
context(...)
functions in the standard library the Intellij does not seem to recognize items being brought into context. However, if I write my own version of
context(...)
in the same module it works just fine. Also worth noting that this compiles just fine despite the IDE errors. Is this expected behavior at this point in the release cycle? I'm just eager to start refactoring some of my personal projects to use context parameters!
youtrack 1
message has been deleted
y
I didn't even realize the function was added! I think use your own definition of it for now. It's probably a disconnect between IDE and compiler
j
Fair enough! I got really excited when I saw it and wanted to go wild replacing all of my own functions.
Also
implicit()
seems to be called
contextOf()
h
I just use
with
as a workaround.
i
I created an issue - KTIJ-34074 False positive NO_CONTEXT_ARGUMENT caused by context parameter.
thank you color 3
g
Wait, what does context() in the body of a function do that with() doesn't?
y
It can accept multiple arguments, and it also only brings in the contextual scope of its argument, not the member scope (and so extension functions on the type don't show up, for instance)
👍 2
👍🏾 1
j
For me it's strictly just ergonomic. I am making heavy use of context parameters and find nesting a ton of with statements less than ideal. I also have been writing my own dsl builders to bring a bunch of stuff into context but then they don't work across modules. I'm using a beta version of Kotlin that doesn't even state official support for all of context params so these sorts of things are expected. Figured it was worth mentioning though!
👍 1
Adding for anyone following this or anyone that finds it via search. This appears to be resolved on 2025.02 EAP 😄
👍 1
g
@James Yox Now I understood what you meant 🤔 Is there an Android Studio version with 2025.02 EAP ? I'm on the nightly so I guess not, I'll have to wait then