From baa922bf9476401d1001b4285515e489b13f5aa6 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Mon, 12 Feb 2024 23:17:07 -0800 Subject: [PATCH] fix jvm name for annotation values --- .../main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt | 3 +++ test-utils/testData/api/mangledNames.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt index 02168c1dc7..753e75366f 100644 --- a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt +++ b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt @@ -409,6 +409,9 @@ class ResolverAAImpl( // TODO: handle @JvmName annotations, mangled names override fun getJvmName(accessor: KSPropertyAccessor): String? { + if (accessor.receiver.closestClassDeclaration()?.classKind == ClassKind.ANNOTATION_CLASS) { + return accessor.receiver.simpleName.asString() + } val prefix = if (accessor is KSPropertyGetter) { "get" } else { diff --git a/test-utils/testData/api/mangledNames.kt b/test-utils/testData/api/mangledNames.kt index cb00475a4c..e3a651e6ed 100644 --- a/test-utils/testData/api/mangledNames.kt +++ b/test-utils/testData/api/mangledNames.kt @@ -47,6 +47,8 @@ // inlineReturningFun -> inlineReturningFun-HRn7Rpw // internalInlineReceivingFun -> internalInlineReceivingFun-E03SJzc$mainModule // internalInlineReturningFun -> internalInlineReturningFun-HRn7Rpw$mainModule +// mainPackage.Anno -> declarations +// get-a -> a // mainPackage.AbstractKotlinClass -> declarations // get-abstractVar -> getAbstractVar // set-abstractVar -> setAbstractVar @@ -151,6 +153,7 @@ class Foo { internal fun internalInlineReturningFun(): Inline1 = TODO() } +annotation class Anno(val a: String) abstract class AbstractKotlinClass { abstract var abstractVar:String abstract val abstractVal:String