I'm noticing that in K1, context receivers are pla...
# k2-adopters
m
I'm noticing that in K1, context receivers are placed before the function definition. Are there any plans to change this in K2? It leads to code that seems a bit confusing like
Copy code
context(Something)
@Annotation
fun myFunction() { ... }
especially with how intellij colors
context
the same as other keywords
plus one 1
s
You mean that it's placed before annotations?
k
The canonical way to write this would be
Copy code
@Annotation
context(Something)
fun myFunction() { ... }
Not sure if being able to place the annotation in the middle is a bug or a feature. Did you write the function yourself or did the IDE generate it, e.g. for an override?
m
This is the current behavior in K1:
whereas this is perfectly fine
k
Could you please report an issue, this seems to be a bug.
m
Seems already reported as KT-51258
k
Correct, thank you.
j
I still would like to know if annotating
context
is a valid use case too
You can annotate parameters individually, but you cannot annotate the group of them. So allowing annotating
context
could break the coherence there
k
I don't think it's intended to be able to annotate the whole group. Most likely, the annotation will just be applied to the function/property.
👍 1