I am attempting to use FIR generate a nested class...
# compiler
r
I am attempting to use FIR generate a nested class for each constructor an annotated class has. I'm attempting to use a FIR scope to get the constructor declarations in
getNestedClassifiersNames
, and running into problems because
FirClassDeclaredMemberScopeImpl
attempts to list the nested classifiers on creation, resulting a stack overflow. This is used by
FirClassSymbol.constructors
and
FirSession.declaredMemberScope
. Presumably this is to allow inclusion of static/companion object members, which I don't care about here. I've found several options to work around it: 1. Look at the declarations in
classSymbol.fir.declarations
or
classSymbol.declarationSymbols
directly - this has all sorts of warning annotations and seems like a bad idea 2. Use
session.declaredMemberScopeWithLazyNestedScope(classSymbol.fir, emptyList())
- this uses the FIR scopes, but requires manually accessing
.fir
. Doesn't seem to result in the generated name showing up unless it's also in the
existingNames
argument, which defeats the point. What's the best option here? Is there an option I'm missing?
d
Accessing
.fir
is fine if you do it carefully: don't invoke lazy resolve and don't try to get the information which potentially could be unresolved at this point