In FIR, how do you get all callables for a given c...
# compiler
c
In FIR, how do you get all callables for a given class, including extension methods and inherited members?
FirClassSymbol<*>#declaredX
only gives class members. This is specifically for diagnostics, so it should be resolved at that point, right?
y
Inherited I think you can get by getting the super symbols and iterating (you might need to use the actual
FirClass
). I don't think there's a general way to get all extension funs. If you want specifically extensions in certain packages, then there's something like a package fragment provider IIRC
c
Thanks!
d
Never use
FirClass.declarations
to get the list of class declarations. For accessing class member there is a scope API, which correctly handles inheritance, generics substitution, java type enhancements, matching overrides and other stuff.
Copy code
// assuming you have `CheckerContext` around
val scope = classSymbol.unsubstitutedScope()
val allFunctions = scope.collectAllFunctions()
val allProperties = scope.collectAllProperties()
There is also an advanced API of scopes for processing overrides, you can check it's usage in compiler checkers like in FirNotImplementedOverrideChecker.