I am getting an empty list when I call `function.c...
# compiler
j
I am getting an empty list when I call
function.contextReceivers
where
function
is
KtNamedFunction
with Kotlin 1.7.10. Is there any way to get the list of context receivers?
Tried 1.7.20 beta and same issue
d
It should not be empty in case the function has context receivers specified. Otherwise other part of the feature wouldn’t just work.
j
The use case can be weird, it was a test for a formatter, maybe the problem is I need to enable context receivers in tests or something so (the tests are just strings assertions).
d
maybe the problem is I need to enable context receivers in tests
For that, actually you don’t need to enable anything in the test I would assume, there are just no context receivers on the
function
, probably it’s the wrong instance or something like that
j
not sure what I am doing wrong
d
Probably it’s worth trying to debug what children the PSI node of
function
actually have Like does it have a
CONTEXT_RECEIVER_LIST
j
I have tried adding other things like
<T>
and they are there
looks like they are not detected, if I add a
<T>
, it is appearing there too as third element
d
Really strange. Then I would debug if we really parse it at
org.jetbrains.kotlin.parsing.KotlinParsing#parseContextReceiverList
j
the debugger doesn't enter in that function
d
But how does it behave at
parseTopLevelDeclaration
? At the
Copy code
if (at(CONTEXT_KEYWORD)) {
    parseContextReceiverList();
}
j
the debugger doesn't even appear outside
if
🤔
I put a breakpoint in all of those lines
looks like the debugger doesn't work there
or it is not entering
d
It’s really hard to tell, but it seems that you’ve got some semi-correct env where the parsing classes come from the outdated version of compiler or something like this 😞
j
Not sure, I can push to a branch and share a repo for you
d
Sorry, I’m not sure I will be able to dig into this issue deeper, soon. Only can suggest to somehow make sure that
org.jetbrains.kotlin.parsing.KotlinParsing
used at runtime is really up-to-date (i.e., it actually has
parseContextReceiverList
method) or somehow figure out how to debug it properly.
j
the debugger is entering in the KotlinParsing class, but not in the
parseFile
method
yeah, there is something weird now