hfhbd
05/15/2025, 1:53 PMFirDeclarationGenerationExtension
, I call declarationSymbols
inside generateFunctions
. Now this call is marked with DirectDeclarationsAccess
. What is the alternative, beside optin (like the parcelize plugin does that I use as reference)?dmitriy.novozhilov
05/15/2025, 1:57 PMcontext.declaredScope
.
In other cases it's better to use `classSymbol.declaredMemberScope()`/`classSymbol.unsubstitutedScope()` (unless it won't cause loop with a plugin)hfhbd
05/15/2025, 2:05 PMcontext.declaredScope
?dmitriy.novozhilov
05/15/2025, 2:06 PMhfhbd
05/15/2025, 2:22 PMMemberGenerationContext
?dmitriy.novozhilov
05/15/2025, 2:23 PMnull
in case of classes generated by plugins.
These classes don't contain "real" declared scope, only generated onehfhbd
05/15/2025, 2:27 PMdmitriy.novozhilov
05/15/2025, 2:29 PMhfhbd
05/15/2025, 2:32 PMval hasContentTypeFunction = context.declaredScope?.hasContentTypeFunction() == true || lookupSuperTypes(
owner,
lookupInterfaces = true,
deep = true,
session,
).any {
it.fullyExpandedType(session).toRegularClassSymbol(session)?.hasContentTypeFunction() ?: false
}
dmitriy.novozhilov
05/15/2025, 2:33 PMFirUseSiteMemberScope
(`classSymbol.unsubsitutedScope()`/`type.useSiteScope()`), which consists of declared scope (both "real" and plugin-generated) and supertype scopes. This scope correctly matches overrides between members of the class and supertypes, but for that it's needed to know all declarations from the declared scope. So if you try to use it while generating functions for the class you will get a recursion:
• to build function you need use-site scope
• to operate use-site scope need to access declared scope
• declared scope should ask plugins to generate functions
That's the root of all of this inconveniencedmitriy.novozhilov
05/15/2025, 2:33 PMLike you did here:Yep, it should do the trick
hfhbd
05/15/2025, 2:38 PMFirRegularClassSymbol.declarationSymbols
in the superTypeLookup after calling toRegularClassSymbol
. Should I still call declarationSymbols
because they are resolved anyway?hfhbd
05/15/2025, 2:40 PMdmitriy.novozhilov
05/15/2025, 2:41 PMdmitriy.novozhilov
05/15/2025, 2:45 PMdeclarationSymbols
instead of declaredScope()
is the fact that the scope contains declarations from the plugins and the declarationSymbols
doesn't, so it's easy to miss some declarations.
But in your case you are explicitly want to check only declarations without pluginhfhbd
05/15/2025, 2:48 PM@DirectDeclarationsAccess
from declarations generators (or a marker interface) only 🤔dmitriy.novozhilov
05/15/2025, 2:49 PM