Zac Sweers
01/18/2025, 4:17 AMKClass
arguments it results in the parent annotation call's argumentList being unresolved (even though the class call argument within is resolved). It seems that buildAnnotationCallCopy()
isn't enough for this caseZac Sweers
01/18/2025, 4:45 AMinternal fun FirAnnotation.copy(newParent: FirBasedSymbol<*>): FirAnnotation {
if (this !is FirAnnotationCall) return this
return buildAnnotationCallCopy(this) {
this.containingDeclarationSymbol = newParent
this.argumentList = buildResolvedArgumentList(
this@copy.argumentList,
(this@copy.argumentList as FirResolvedArgumentList).mapping
)
}
}
It somehow becomes... unresolved? when it reaches FirGeneratedElementsValidator.visitArgumentList()
Zac Sweers
01/18/2025, 5:07 AMFirGetClassCall
. I'm not exactly sure why though as the class argument here is resolved. I guess maybe we need to manually replace these during copying?Zac Sweers
01/18/2025, 8:36 PMZac Sweers
01/18/2025, 8:43 PMZac Sweers
01/18/2025, 8:44 PMFirResolvedArgumentList
instance that just doesn't forward acceptChildren
calls to interrupt this check, the resulting code works finedmitriy.novozhilov
01/20/2025, 8:30 AMFirGeneratedElementsValidator
during the first implementation of the plugin API five years ago without any proper design and the whole picture of possible usecases, so ideally it should be just dropped at all until we design it properly
In theory it's ok to not copy the annotations, but just reuse the same instances. So they will be resolved on the base declaration, they will be automatically resolved on the generated one too. But FirGeneratedElementsValidator
prevents it. So you can try the following workaround: create your own inheritor of FirAnnotationCall
, which will delegate all properties to the base annotation and has an empty acceptChildren
implementation. I think it should work
And also you need to not delegate the sourceElement
, otherwise it could cause generation of incorrect offsets in fir2irZac Sweers
01/20/2025, 3:40 PMcontainingDeclarationSymbol
to the new location?Zac Sweers
01/20/2025, 3:41 PMFirGeneratedElementsValidator
?dmitriy.novozhilov
01/20/2025, 4:58 PMIn this copy should I also replace the containingDeclarationSymbol to the new location?It worth to
also do you want me to file an issue for FirGeneratedElementsValidator?No, we will revise it soon anyway