You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
An external serializer's descriptor seems to lack element descriptors despite having elements. This leads to unexpected errors and currently prevents me from implementing some complex custom serializers, including a shape-agnostic solution for #292.
To Reproduce
Consider the following simple test program:
@Serializer(forClass = Foo::class)
object GeneratedFooSerializer : KSerializer<Foo>
@Serializable
data class Foo(val bar: String)
fun main() {
println(GeneratedFooSerializer.descriptor)
}
This will throw an AIOOB:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.getElementDescriptor(PluginGeneratedSerialDescriptor.kt:135)
at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$toString$1.invoke(PluginGeneratedSerialDescriptor.kt:101)
at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$toString$1.invoke(PluginGeneratedSerialDescriptor.kt:100)
at kotlin.text.StringsKt__AppendableKt.appendElement(Appendable.kt:85)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:3490)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:3507)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:3506)
at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.toString(PluginGeneratedSerialDescriptor.kt:100)
at java.base/java.lang.String.valueOf(String.java:4461)
at java.base/java.io.PrintStream.println(PrintStream.java:1187)
at TestKt.main(Test.kt:33)
at TestKt.main(Test.kt)
Expected behavior
Checking elementsCountconfirms that there is one element. getElementName and getElementAnnotations work fine but getElementDescriptor throws. I expect this to work fine as all required information should be available.
Environment
Kotlin version: 1.9.22
Library version: 1.6.2
Kotlin platforms: any
The text was updated successfully, but these errors were encountered:
Describe the bug
An external serializer's descriptor seems to lack element descriptors despite having elements. This leads to unexpected errors and currently prevents me from implementing some complex custom serializers, including a shape-agnostic solution for #292.
To Reproduce
Consider the following simple test program:
This will throw an AIOOB:
Expected behavior
Checking
elementsCount
confirms that there is one element.getElementName
andgetElementAnnotations
work fine butgetElementDescriptor
throws. I expect this to work fine as all required information should be available.Environment
The text was updated successfully, but these errors were encountered: