HI, while playing around with context receivers `c...
# language-evolution
d
HI, while playing around with context receivers
context(someInstance, someInterface)
I just realized, that if you want to use context receiver declaration on
override fun xyz(...)
on
interface
methods, then you have to have the context declaration on BOTH, the interface fun definition AND the implementing class fun (correct??). That is ok by itself ... but the compile time error message for this is 2-pages long and really really cryptic with no hint what might be the problem whatsoever ... don't know if this is the correct channel, but I would love to see a bit more "readable and usefull" compiler error for that case.
e
Yes. You have to use it on both. Compiler currently crashes if there is a mismatch, e.g. https://youtrack.jetbrains.com/issue/KT-51474
d
@elizarov yes, that's ok ... but are there any plans (e.g. included in the "outcomes" of your linked ticket) to present the user a more meaningful error message? It took me half a day to decrypt the stacktrace and to find the root cause in the missing context() on the interface function.
BTW, right now I have some new finding, and am not sure if I should file a bug for this, maybe you can have a look at it upfront: working version:
Failing version:
diff:
context() is Failing when the function is implemented via a delegated interface.