Skip to content

Commit

Permalink
[KSP2] Remove ordering check in
Browse files Browse the repository at this point in the history
XRoundEnvTest.getAnnotatedParamElements()

KSP2 doesn't guarantee the ordering of results from `Resolver.getSymbolsWithAnnotation()`[1] and our wrapper `XRoundEnv.getElementsAnnotatedWith()` is returning a `Set` anyway so we remove the ordering check in our test in this CL.

[1] google/ksp#1719

Test: XRoundEnvTest
Change-Id: Ib7865860214b76207c250b1d0ab257ef1cd4c2dd
  • Loading branch information
kuanyingchou committed Mar 8, 2024
1 parent 5ebbf3c commit 4423c93
Showing 1 changed file with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,25 +417,16 @@ class XRoundEnvTest {
val typeElement = testInvocation.processingEnv.requireTypeElement("Baz")
val annotatedElements =
testInvocation.roundEnv.getElementsAnnotatedWith(TopLevelAnnotation::class)
val annotatedParams = annotatedElements.filterIsInstance<XExecutableParameterElement>()
assertThat(annotatedParams.map { it.name }).containsExactly(
"ctorProperty",
"ctorParam",
"p0",
"methodParam",
).inOrder()
assertThat(annotatedParams.map { it.jvmName }).containsExactly(
"ctorProperty",
"ctorParam",
"p0",
"methodParam",
).inOrder()
assertThat(annotatedParams.map { it.enclosingElement }).containsExactly(
typeElement.findPrimaryConstructor(),
typeElement.findPrimaryConstructor(),
typeElement.getDeclaredMethodByJvmName("setProperty"),
typeElement.getDeclaredMethodByJvmName("method"),
).inOrder()
val results = annotatedElements.filterIsInstance<XExecutableParameterElement>().map {
listOf(it.name, it.jvmName, it.enclosingElement)
}
assertThat(results).containsExactly(
listOf("ctorProperty", "ctorProperty", typeElement.findPrimaryConstructor()),
listOf("ctorParam", "ctorParam", typeElement.findPrimaryConstructor()),
listOf("p0", "p0", typeElement.getDeclaredMethodByJvmName("setProperty")),
listOf("methodParam", "methodParam",
typeElement.getDeclaredMethodByJvmName("method")),
)
}
}

Expand Down

0 comments on commit 4423c93

Please sign in to comment.