Skip to content

Commit

Permalink
Test case for type annotation on libs
Browse files Browse the repository at this point in the history
for #1833
  • Loading branch information
ting-yuan committed Jul 30, 2024
1 parent 42b296c commit 192e312
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kotlin-analysis-api/testData/annotationValue/annotationValue_kt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
// JavaEnum.ONE
// 31
// Throws
// Cls: argToA: b
// Cls: argToB: 42
// END
// MODULE: module1
// FILE: placeholder.kt
Expand All @@ -48,6 +50,14 @@
String value2();
Class<?> value3();
}

// FILE: Cls.kt
annotation class ClsB(val i: Int)
annotation class ClsA(val b: ClsB)

@ClsA(b = ClsB(i = 42))
class Cls

// MODULE: main(module1)
// FILE: a.kt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ class AnnotationArgumentProcessor : AbstractTestProcessor() {
println(a.arguments)
}
}

resolver.getClassDeclarationByName("Cls")?.let { cls ->
cls.annotations.single().arguments.forEach { argToA ->
results.add("Cls: argToA: ${argToA.name!!.asString()}")
argToA.value.let { argBVal ->
if (argBVal is KSAnnotation) {
argBVal.arguments.forEach { argToB ->
results.add("Cls: argToB: " + argToB.value)
}
} else {
results.add("Cls: argBVal unknown: $argBVal")
}
}
}
}
return emptyList()
}

Expand Down

0 comments on commit 192e312

Please sign in to comment.