Can't get interface serializer
See original GitHub issueBug is related to the fact that I am unable to get serializer of interfaces.
To Reproduce
You can see this repo OR
you can use this template and try to put in the main
function next code:
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
fun main() {
AdministratorChatMember.serializer()
}
And you will see that currently it is impossible to get serializer.
Expected behavior
This call must return serializer because of I have set it manually
Environment
- Kotlin version: 1.4.10
- Library version: 1.0.1
- Kotlin platforms: JVM (possibly JS too)
- Gradle version: 6.7
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
XML serialization of interface property - Stack Overflow
I understand that the problem is that an interface cannot be serialized. However, the concrete Model object type is unknown until runtime. Replacing...
Read more >XmlSerialization with Interfaces - MSDN - Microsoft
You can not serialize an interface. The problem is that an interface is an opaque type. There is no way for the serializer...
Read more >Serialise interfaces in C# - CodeProject
Ok I know it's strictly possible. But..... I have a class with say a List<IPerson> where IPerson is an interface. I want to...
Read more >How to specify interface type for serialization? - Google Groups
I am new to Kryo. I am getting error (can't serialize due to missing default constructor) when try to serialize an object of...
Read more >Serialization in Java - DigitalOcean
When we run above test program for serialization in java, we get ... need to extend a class that doesn't implement Serializable interface....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately the comment isn’t helpful in explaining why the behaviour is as it is. I would see that the absence of a with parameter should be allowed (and trigger polymorphic serialization as well). If there is an explicit serializer I don’t see why it is not valid to trust the user that that serializer will “correctly” handle the implementation classes (although this can only really be done for sealed interfaces).
Thanks for the report, it is indeed a bug.
Unfortunately,
serializer< AdministratorChatMember>
doesn’t work either