Refactor KClassValue to store ClassLiteralValue internally
Only invariant array projections and non-null element types will be supported soon (see KT-26568), so it makes no sense to store the complete type in KClassValue. What we need is only the ClassId of the class, and the number of times it's wrapped into kotlin/Array, which is exactly what ClassLiteralValue represents. This change helps in decoupling annotation values from descriptors/types. The only constant value that depends on descriptors is now AnnotationValue. #KT-26582 Fixed
This commit is contained in:
+4
-2
@@ -27,6 +27,7 @@ annotation class Anno(
|
||||
val za: BooleanArray,
|
||||
val str: String,
|
||||
val k: KClass<*>,
|
||||
val k2: KClass<*>,
|
||||
val e: AnnotationTarget,
|
||||
val a: Nested,
|
||||
val stra: Array<String>,
|
||||
@@ -54,10 +55,11 @@ fun f(): @Anno(
|
||||
[false, true],
|
||||
"lol",
|
||||
Number::class,
|
||||
IntArray::class,
|
||||
AnnotationTarget.EXPRESSION,
|
||||
Nested("1"),
|
||||
["lmao"],
|
||||
// [Double::class, Unit::class],
|
||||
// [Double::class, Unit::class, LongArray::class],
|
||||
[AnnotationTarget.TYPEALIAS, AnnotationTarget.FIELD],
|
||||
[Nested("2"), Nested("3")]
|
||||
) Unit {}
|
||||
@@ -66,7 +68,7 @@ fun box(): String {
|
||||
assertEquals(
|
||||
"[@Anno(b=1, c=x, d=3.14, f=-2.72, i=42424242, j=239239239239239, s=42, z=true, " +
|
||||
"ba=[-1], ca=[y], da=[-3.14159], fa=[2.7218], ia=[424242], ja=[239239239239], sa=[-43], za=[false, true], " +
|
||||
"str=lol, k=class java.lang.Number, e=EXPRESSION, a=@Nested(value=1), " +
|
||||
"str=lol, k=class java.lang.Number, k2=class [I, e=EXPRESSION, a=@Nested(value=1), " +
|
||||
"stra=[lmao], ea=[TYPEALIAS, FIELD], aa=[@Nested(value=2), @Nested(value=3)])]",
|
||||
::f.returnType.annotations.toString()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user