Skip to content

Commit

Permalink
use safe cast for annotation type to declaration resolution
Browse files Browse the repository at this point in the history
(cherry picked from commit def3bc0)
  • Loading branch information
neetopia authored and KSP Auto Pick committed May 21, 2024
1 parent ac5c3cc commit e2da237
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class KSAnnotationJavaImpl private constructor(private val psi: PsiAnnotation, o

override val arguments: List<KSValueArgument> by lazy {
val annotationConstructor = analyze {
(type.classifierSymbol() as KtClassOrObjectSymbol).getMemberScope().getConstructors().singleOrNull()
(type.classifierSymbol() as? KtClassOrObjectSymbol)?.getMemberScope()?.getConstructors()?.singleOrNull()
}
val presentArgs = psi.parameterList.attributes.mapIndexed { index, it ->
val name = it.name ?: annotationConstructor?.valueParameters?.getOrNull(index)?.name?.asString()
Expand All @@ -91,7 +91,7 @@ class KSAnnotationJavaImpl private constructor(private val psi: PsiAnnotation, o

override val defaultArguments: List<KSValueArgument> by lazy {
analyze {
(type.classifierSymbol() as KtClassOrObjectSymbol).getMemberScope().getConstructors().singleOrNull()
(type.classifierSymbol() as? KtClassOrObjectSymbol)?.getMemberScope()?.getConstructors()?.singleOrNull()
?.let { symbol ->
if (symbol.origin == KtSymbolOrigin.JAVA && symbol.psi != null) {
(symbol.psi as PsiClass).allMethods.filterIsInstance<PsiAnnotationMethod>()
Expand Down

0 comments on commit e2da237

Please sign in to comment.