[KSP2] Fix tests on annotation type values
In KSP2 getting the type name of annotation type values returns KClass instead of Class when the origin is Java source. This makes it more consistent on the KSP side so we're adjusting the test to reflect the change.
Test: XAnnotationValueTest.kt
Change-Id: I6715676baa08ac893702ab5e7d4c1d1d0ba0d34a
diff --git a/room/room-compiler-processing/src/test/java/androidx/room/compiler/processing/XAnnotationValueTest.kt b/room/room-compiler-processing/src/test/java/androidx/room/compiler/processing/XAnnotationValueTest.kt
index da629f7..46e753d 100644
--- a/room/room-compiler-processing/src/test/java/androidx/room/compiler/processing/XAnnotationValueTest.kt
+++ b/room/room-compiler-processing/src/test/java/androidx/room/compiler/processing/XAnnotationValueTest.kt
@@ -18,6 +18,7 @@
import androidx.kruth.assertThat
import androidx.room.compiler.codegen.JArrayTypeName
+import androidx.room.compiler.processing.compat.XConverters.toKS
import androidx.room.compiler.processing.util.Source
import androidx.room.compiler.processing.util.XTestInvocation
import androidx.room.compiler.processing.util.asJClassName
@@ -1284,7 +1285,10 @@
val kClassKTypeName = kotlin.reflect.KClass::class.asKClassName().parameterizedBy(STAR)
fun checkSingleValue(annotationValue: XAnnotationValue, expectedValue: String) {
// TODO(bcorso): Consider making the value types match in this case.
- if (!invocation.isKsp || (sourceKind == SourceKind.JAVA && !isPreCompiled)) {
+ if (!invocation.isKsp ||
+ (invocation.processingEnv.toKS().kspVersion < KotlinVersion(2, 0) &&
+ sourceKind == SourceKind.JAVA &&
+ !isPreCompiled)) {
assertThat(annotationValue.valueType.asTypeName().java)
.isEqualTo(classJTypeName)
} else {
@@ -1299,7 +1303,10 @@
fun checkListValues(annotationValue: XAnnotationValue, vararg expectedValues: String) {
// TODO(bcorso): Consider making the value types match in this case.
- if (!invocation.isKsp || (sourceKind == SourceKind.JAVA && !isPreCompiled)) {
+ if (!invocation.isKsp ||
+ (invocation.processingEnv.toKS().kspVersion < KotlinVersion(2, 0) &&
+ sourceKind == SourceKind.JAVA &&
+ !isPreCompiled)) {
assertThat(annotationValue.valueType.asTypeName().java)
.isEqualTo(JArrayTypeName.of(classJTypeName))
} else {