Fix deserialization of enum annotation arguments at runtime
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test;
|
||||
|
||||
// This test checks that we don't accidentally call toString() on an enum value
|
||||
// to determine which enum entry appears in the annotation, and call name() instead
|
||||
|
||||
public class EnumArgumentWithCustomToString {
|
||||
public enum E {
|
||||
CAKE {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LIE";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public @interface EnumAnno {
|
||||
E value();
|
||||
}
|
||||
|
||||
public @interface EnumArrayAnno {
|
||||
E[] value();
|
||||
}
|
||||
|
||||
@EnumAnno(E.CAKE)
|
||||
@EnumArrayAnno({E.CAKE, E.CAKE})
|
||||
void annotated() {}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package test
|
||||
|
||||
public open class EnumArgumentWithCustomToString {
|
||||
public constructor EnumArgumentWithCustomToString()
|
||||
test.EnumArgumentWithCustomToString.EnumAnno(value = E.CAKE: test.EnumArgumentWithCustomToString.E) test.EnumArgumentWithCustomToString.EnumArrayAnno(value = {E.CAKE, E.CAKE}: kotlin.Array<out test.EnumArgumentWithCustomToString.E>) public/*package*/ open fun annotated(): kotlin.Unit
|
||||
|
||||
public open enum class E : kotlin.Enum<test.EnumArgumentWithCustomToString.E!> {
|
||||
public enum entry CAKE : test.EnumArgumentWithCustomToString.E {
|
||||
private constructor CAKE()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.EnumArgumentWithCustomToString.E!): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
}
|
||||
|
||||
private constructor E()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.EnumArgumentWithCustomToString.E!): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.EnumArgumentWithCustomToString.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<test.EnumArgumentWithCustomToString.E>
|
||||
}
|
||||
|
||||
public final annotation class EnumAnno : kotlin.Annotation {
|
||||
public constructor EnumAnno(/*0*/ value: test.EnumArgumentWithCustomToString.E)
|
||||
public abstract fun value(): test.EnumArgumentWithCustomToString.E
|
||||
}
|
||||
|
||||
public final annotation class EnumArrayAnno : kotlin.Annotation {
|
||||
public constructor EnumArrayAnno(/*0*/ vararg value: test.EnumArgumentWithCustomToString.E /*kotlin.Array<out test.EnumArgumentWithCustomToString.E>*/)
|
||||
public abstract fun value(): kotlin.Array<test.EnumArgumentWithCustomToString.E>
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
// This test checks that we don't accidentally call toString() on an enum value
|
||||
// to determine which enum entry appears in the annotation, and call name() instead
|
||||
|
||||
enum class E {
|
||||
CAKE {
|
||||
override fun toString() = "LIE"
|
||||
}
|
||||
}
|
||||
|
||||
annotation class EnumAnno(val value: E)
|
||||
annotation class EnumArrayAnno(vararg val value: E)
|
||||
|
||||
public class EnumArgumentWithCustomToString {
|
||||
EnumAnno(E.CAKE)
|
||||
EnumArrayAnno(E.CAKE, E.CAKE)
|
||||
fun annotated() {}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package test
|
||||
|
||||
internal final enum class E : kotlin.Enum<test.E> {
|
||||
public enum entry CAKE : test.E {
|
||||
/*primary*/ private constructor CAKE()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
}
|
||||
|
||||
/*primary*/ private constructor E()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<test.E>
|
||||
}
|
||||
|
||||
internal final annotation class EnumAnno : kotlin.Annotation {
|
||||
/*primary*/ public constructor EnumAnno(/*0*/ value: test.E)
|
||||
internal final val value: test.E
|
||||
internal final fun <get-value>(): test.E
|
||||
}
|
||||
|
||||
public final class EnumArgumentWithCustomToString {
|
||||
/*primary*/ public constructor EnumArgumentWithCustomToString()
|
||||
test.EnumAnno(value = E.CAKE: test.E) test.EnumArrayAnno(value = {E.CAKE, E.CAKE}: kotlin.Array<out test.E>) internal final fun annotated(): kotlin.Unit
|
||||
}
|
||||
|
||||
internal final annotation class EnumArrayAnno : kotlin.Annotation {
|
||||
/*primary*/ public constructor EnumArrayAnno(/*0*/ vararg value: test.E /*kotlin.Array<out test.E>*/)
|
||||
internal final val value: kotlin.Array<out test.E>
|
||||
internal final fun <get-value>(): kotlin.Array<out test.E>
|
||||
}
|
||||
Reference in New Issue
Block a user