Skip to content

Commit 9722a20

Browse files
ting-yuanKSP Auto Pick
authored andcommitted
Fallback to AA for unexpected Java psi type
when getting annotations. Avoid the dangerous cast. (cherry picked from commit fda519a)
1 parent e21be8b commit 9722a20

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/AbstractKSDeclarationImpl.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ abstract class AbstractKSDeclarationImpl(val ktDeclarationSymbol: KaDeclarationS
125125
internal open val originalAnnotations: Sequence<KSAnnotation> by lazyMemoizedSequence {
126126
if (ktDeclarationSymbol.psi is KtAnnotated) {
127127
(ktDeclarationSymbol.psi as KtAnnotated).annotations(ktDeclarationSymbol, this)
128-
} else if (ktDeclarationSymbol.origin == KaSymbolOrigin.JAVA_SOURCE && ktDeclarationSymbol.psi != null) {
128+
} else if (
129+
ktDeclarationSymbol.origin == KaSymbolOrigin.JAVA_SOURCE &&
130+
ktDeclarationSymbol.psi is PsiJvmModifiersOwner
131+
) {
129132
(ktDeclarationSymbol.psi as PsiJvmModifiersOwner)
130133
.annotations.map { KSAnnotationJavaImpl.getCached(it, this) }.asSequence()
131134
} else {

0 commit comments

Comments
 (0)