Is there a way to get the `resolvedType` of an ann...
# compiler
a
Is there a way to get the
resolvedType
of an annotation argument? I'm using this in
FirDeclarationGenerationExtension
to create a function with a specific returnType:
Copy code
val annotation = resolvedAnnotationsWithArguments.getAnnotationByClassId(annotationClassId, session) ?: return null
val returnTypeArgument = annotation.findArgumentByName(returnTypeArg, false) as? FirGetClassCall
val returnType = returnTypeArgument?.resolvedType
The annotation is like:
@Generate(returnType = MyClass::class)
. If the value is present, then the return type will be the specified, or the type of the class otherwise. But
Caused by: org.jetbrains.kotlin.utils.exceptions.KotlinIllegalArgumentExceptionWithAttachments: Expected expression 'FirGetClassCallImpl' to be resolved
is thrown.
d
FirDeclarationGenerationExtension
could be called before the arguments of annotation are resolved, so the answer is no for the general case
👍 1
a
And is there a way to modify the return type after the function is generated? Like
FirStatusTransformerExtension
?
d
No