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
For a local class MyData (declared within a block) you can't get a serializer instance by calling MyData::class.serializer(). But the expression MyData.serializer() works fine.
For a top level or nested classes both forms are working ok.
This error makes all inline functions with reified type parameters unusable for such classes (for instance JSON.stringify()).
Root of this issue is quite interesting. Serialization plugin adds a companion object for each serializable class to access serializer functions and for internal machinery. But in Kotlin language, companion objects in local classes are prohibited. While JVM compiler works well with such synthetic declarations, JS compiler perform some optimisations and doesn't define Companion property on local KClass, while direct companion access (MyData.serializer()) still works.
I'll investigate further to see if it's possible to disable this optimisation for synthetic declarations.
We've decided not to implement this during the transition between old JS compiler backend to new JS IR backend.
Now all inline reified functions are using typeOf API instead of KClass, so the problem should be gone for most of the usages.
For a local class MyData (declared within a block) you can't get a serializer instance by calling MyData::class.serializer(). But the expression MyData.serializer() works fine.
For a top level or nested classes both forms are working ok.
This error makes all inline functions with reified type parameters unusable for such classes (for instance JSON.stringify()).
Platform: Kotlin/JS 1.2.40
Kotlin serialization: 0.4.2
The text was updated successfully, but these errors were encountered: