I have been looking at the `FirDeclarationGenerati...
# compiler
r
I have been looking at the
FirDeclarationGenerationExtension
documentation to try and understand what source code details are available to plugins inside `generateFunctions`/`generateProperties`. According to the docs these functions can be called on the STATUS stage. So now I am wondering how much of the declarationSymbols signatures is available to plugins at that stage: • can we safely access
resolvedStatus
? • how about
resolvedReturnType
? The docs (here and here) say it isn’t safe since implicit return types aren’t resolved yet. • would it be possible to access explicit return types safely?
The serialization plugin seems to be accessing these specific details: • statusreturnTypeRef However those are accessed on the
fir
object. Which is mentioned in the docs as being illegal in most cases.
I am asking because I am trying to figure out if it’s possible to “duplicate” existing declarations with a slightly modified signature.
d
can we safely access
resolvedStatus
Not really If extension was called on
STATUS
phase, then it might be not over and not all statuses are resolved yet So
visibility
,
operator
and
infix
parts of the status for
override
functions might be not inferred yey
how about
resolvedReturnType
Docs are correct here. You can access
symbol.fir.returnTypeRef
and manually process case if it is already resolved and if it implicit In IDE it also may be a
FirUserTypeRef
, and in this case it's safe to call
resolvedReturnType
(but only in this case)
r
So visibility, operator and infix parts of the status for override functions might be not inferred yey
I am particularly interested in the
suspend
modifier. Would there be a similar way with
fir
to access that (ignoring other parts of the status that still need to be inferred)?
Docs are correct here. You can access symbol.fir.returnTypeRef and manually process case if it is already resolved and if it implicit
Cool I’ll give that a try.
d
suspend
is not inheritable, so it cannot be changed during status resolution and it's ok to access it with raw status There is even special
rawStatus
accessor so you don't need to access
.fir
thank you color 1