min
10/08/2026, 8:48 AMclassId
?.takeIf { id ->
true == session.classFromId(id)
?.takeIf { maybeAnnotation -> maybeAnnotation.classKind.isAnnotationClass }
?.takeIf { annotationClass ->
annotationClass.constructors(session).any { ctor ->
ctor.valueParameterSymbols.all(FirValueParameterSymbol::hasDefaultValue)
}
}
?.getAllowedAnnotationTargets(session)
?.contains(KotlinTarget.FUNCTION)
}
I want to take the classId if the corresponding class is a nullary annotation class that can be applied to functions.
• The ID of annotation class Foo(val str: String = "") should be taken, since @Foo is applicable to functions.
• The ID of @Target(AnnotationTarget._CLASS_) annotation class Bar should be discarded, since @Bar is not for functions.
Does my solution successfully cover all edge cases? Have I missed any?