Skip to content

Add regression test for annotation array value type#3010

Open
Yong-yuan-X wants to merge 3 commits into
google:mainfrom
Yong-yuan-X:issue-3008-array-annotation-value
Open

Add regression test for annotation array value type#3010
Yong-yuan-X wants to merge 3 commits into
google:mainfrom
Yong-yuan-X:issue-3008-array-annotation-value

Conversation

@Yong-yuan-X

Copy link
Copy Markdown

Adds a failing regression test for Java annotation array arguments.

The test covers a Java source annotation usage where a Java annotation array argument is read through KSValueArgument.value. It verifies that the value should be exposed as Array<*>, matching the KSP API contract.

The test is currently registered with runFailingTest in both AA and PSI configured suites to document the existing incorrect behavior before implementing the fix.

Refs #3008

Verified locally:

./gradlew :kotlin-analysis-api:test \
  --tests com.google.devtools.ksp.test.AAConfiguredUnitTestSuite.testAnnotationArrayValueType \
  --tests com.google.devtools.ksp.test.PsiConfiguredUnitTestSuite.testAnnotationArrayValueType
AAConfiguredUnitTestSuite > testAnnotationArrayValueType() PASSED
PsiConfiguredUnitTestSuite > testAnnotationArrayValueType() PASSED
BUILD SUCCESSFUL

@jaschdoc jaschdoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @Yong-yuan-X! It looks good. Just a few minor comments 👍

Comment thread kotlin-analysis-api/testData/annotationArrayValueType.kt
@Yong-yuan-X

Copy link
Copy Markdown
Author

@jaschdoc Thanks for the review! I addressed both comments:

  • Added Kotlin source coverage to annotationArrayValueType.kt.
  • Moved AnnotationArrayValueTypeProcessor to kotlin-analysis-api/src/test/kotlin/com/google/devtools/ksp/processor/.

Verified locally:

./gradlew :kotlin-analysis-api:test \
  --tests com.google.devtools.ksp.test.AAConfiguredUnitTestSuite.testAnnotationArrayValueType \
  --tests com.google.devtools.ksp.test.PsiConfiguredUnitTestSuite.testAnnotationArrayValueType

Both targeted tests passed.

@jaschdoc jaschdoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick update. Just one more thing and then it's good to go.

Comment thread kotlin-analysis-api/testData/annotationArrayValueType.kt
@Yong-yuan-X

Copy link
Copy Markdown
Author

Thanks for the follow-up! I added the Kotlin annotation case as requested.

The test now uses both JavaAnnotation and KotlinAnnotation on both JavaAnnotated and KotlinAnnotated, and verifies each annotation array argument.

Verified locally:

./gradlew :kotlin-analysis-api:test \
  --tests com.google.devtools.ksp.test.AAConfiguredUnitTestSuite.testAnnotationArrayValueType \
  --tests com.google.devtools.ksp.test.PsiConfiguredUnitTestSuite.testAnnotationArrayValueType

Both targeted tests passed.

@jaschdoc jaschdoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants