Skip to content

IndexOutOfBoundsException by getElementDescriptor with @Serializer #840

Open
@Ktlo

Description

@Ktlo

Describe the bug

When using @Serializer, the following exception is thrown when trying to get an element descriptor.

java.lang.IndexOutOfBoundsException: Example descriptor has only 1 elements, index: 0

To Reproduce

data class Example(
    val value: String
)

@Serializer(Example::class)
object ExampleSerializer

fun main() {
    println(ExampleSerializer.descriptor.getElementName(0)) // Everything is fine here
    println(ExampleSerializer.descriptor.getElementDescriptor(0)) // IndexOutOfBoundsException
}

Expected behavior

Method SerialDescriptor::getElementDescriptor should return a SerialDescriptor.

Environment

  • Kotlin version: 1.3.72
  • Library version: 0.20.0
  • Kotlin platforms: JVM
  • Gradle version: 6.4.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions