question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get interface serializer

See original GitHub issue

Bug 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pdvriezecommented, Feb 3, 2022

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).

1reaction
qwwdfsadcommented, Nov 16, 2020

Thanks for the report, it is indeed a bug.

Unfortunately, serializer< AdministratorChatMember> doesn’t work either

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found