Kotlin JS compiler crash: Arrays of class literals not supported

My gradle build (task compileKotlinJs) dies with this. I have no idea what’s causing it. It gives no source code location. Any ideas?

e: java.lang.IllegalStateException: Arrays of class literals are not supported yet
    at org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer.resolveArrayElementType(AnnotationDeserializer.kt:144)
    at org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer.resolveValue(AnnotationDeserializer.kt:97)
    at org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer.resolveArgument(AnnotationDeserializer.kt:64)
    at org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer.deserializeAnnotation(AnnotationDeserializer.kt:51)
    at org.jetbrains.kotlin.serialization.js.KotlinJavascriptPackageFragment$FileHolder$annotations$2.invoke(KotlinJavascriptPackageFragment.kt:70)
    at org.jetbrains.kotlin.serialization.js.KotlinJavascriptPackageFragment$FileHolder$annotations$2.invoke(KotlinJavascriptPackageFragment.kt:68)
    at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:346)
    at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:402)
    at org.jetbrains.kotlin.storage.StorageKt.getValue(storage.kt:42)

Do you use custom serializers? I have this error sometimes. It is somehow connected with @file:UseSerializers(...). Strangely, in my case it goes away after second compilation, but for one file I had to remove file level annotation and use @Serializable(with=...) on class properties.

Thank you for the suggestion, that appears to have been it. I had a serializer for Date and another for my own UUID data class in a @file:UseSerializers annotation. My data classes are uglier to read now with all the @Serializable(with=...) annotations on their properties, but the error went away.

This is a compiler bug, please see discussion and leave a vote here: https://youtrack.jetbrains.com/issue/KT-28927

1 Like