diff --git a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/java/KSAnnotationJavaImpl.kt b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/java/KSAnnotationJavaImpl.kt index 83e3b79b44..1730461fe5 100644 --- a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/java/KSAnnotationJavaImpl.kt +++ b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/java/KSAnnotationJavaImpl.kt @@ -4,6 +4,7 @@ import com.google.devtools.ksp.common.KSObjectCache import com.google.devtools.ksp.common.impl.KSNameImpl import com.google.devtools.ksp.getClassDeclarationByName import com.google.devtools.ksp.impl.ResolverAAImpl +import com.google.devtools.ksp.impl.symbol.kotlin.KSClassDeclarationEnumEntryImpl import com.google.devtools.ksp.impl.symbol.kotlin.KSErrorType import com.google.devtools.ksp.impl.symbol.kotlin.KSValueArgumentImpl import com.google.devtools.ksp.impl.symbol.kotlin.analyze @@ -202,10 +203,7 @@ fun calcValue(value: PsiAnnotationMemberValue?): Any? { }?.declarations?.find { it is KSClassDeclaration && it.classKind == ClassKind.ENUM_ENTRY && it.simpleName.asString() == result.name - }?.let { (it as KSClassDeclaration).asStarProjectedType() } - ?.let { - return it - } + } as? KSClassDeclarationEnumEntryImpl } else { null } diff --git a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/KSClassDeclarationEnumEntryImpl.kt b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/KSClassDeclarationEnumEntryImpl.kt index 4fb19707c0..26237027c5 100644 --- a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/KSClassDeclarationEnumEntryImpl.kt +++ b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/KSClassDeclarationEnumEntryImpl.kt @@ -102,10 +102,10 @@ class KSClassDeclarationEnumEntryImpl private constructor(private val ktEnumEntr ktEnumEntrySymbol.psi.toLocation() } - override val parent: KSNode? by lazy { + override val parent: KSNode by lazy { analyze { - (ktEnumEntrySymbol.getContainingSymbol() as? KtNamedClassOrObjectSymbol) - ?.let { KSClassDeclarationImpl.getCached(it) } + (ktEnumEntrySymbol.getContainingSymbol() as KtNamedClassOrObjectSymbol) + .let { KSClassDeclarationImpl.getCached(it) } } } diff --git a/kotlin-analysis-api/testData/annotationValue/java.kt b/kotlin-analysis-api/testData/annotationValue/java.kt index 5c88bacb37..4a1735e5b7 100644 --- a/kotlin-analysis-api/testData/annotationValue/java.kt +++ b/kotlin-analysis-api/testData/annotationValue/java.kt @@ -32,8 +32,8 @@ // Array // @Foo // @Suppress -// RGB -// JavaEnum +// G +// ONE // 31 // [warning1, warning 2] // END diff --git a/test-utils/src/test/kotlin/com/google/devtools/ksp/test/KSPAATest.kt b/test-utils/src/test/kotlin/com/google/devtools/ksp/test/KSPAATest.kt index 0e566bbd91..ddbf8f31f5 100644 --- a/test-utils/src/test/kotlin/com/google/devtools/ksp/test/KSPAATest.kt +++ b/test-utils/src/test/kotlin/com/google/devtools/ksp/test/KSPAATest.kt @@ -90,7 +90,6 @@ class KSPAATest : AbstractKSPAATest() { runTest("../kotlin-analysis-api/testData/annotationValue/java.kt") } - @Disabled @TestMetadata("annotationValue_kt.kt") @Test fun testAnnotationValue_kt() {