{"action":"created","issue":{"url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/317","repository_url":"https://api.github.com/repos/Kotlin/kotlinx.serialization","labels_url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/317/labels{/name}","comments_url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/317/comments","events_url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/317/events","html_url":"https://github.com/Kotlin/kotlinx.serialization/issues/317","id":394282668,"node_id":"MDU6SXNzdWUzOTQyODI2Njg=","number":317,"title":"Example has @Serializable when using external Serializer, can cause issues","user":{"login":"rnett","id":32281897,"node_id":"MDQ6VXNlcjMyMjgxODk3","avatar_url":"https://avatars1.githubusercontent.com/u/32281897?v=4","gravatar_id":"","url":"https://api.github.com/users/rnett","html_url":"https://github.com/rnett","followers_url":"https://api.github.com/users/rnett/followers","following_url":"https://api.github.com/users/rnett/following{/other_user}","gists_url":"https://api.github.com/users/rnett/gists{/gist_id}","starred_url":"https://api.github.com/users/rnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnett/subscriptions","organizations_url":"https://api.github.com/users/rnett/orgs","repos_url":"https://api.github.com/users/rnett/repos","events_url":"https://api.github.com/users/rnett/events{/privacy}","received_events_url":"https://api.github.com/users/rnett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-27T03:16:31Z","updated_at":"2018-12-29T15:54:07Z","closed_at":null,"author_association":"NONE","body":"I was following the example [here](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md) for Representing classes as a single value (specifically for an Exposed DAO class), and was getting errors.\r\n\r\nThe example itself works fine, but with what I was trying to do, the class (and its superclasses) are not Serializable.\r\n\r\nExample:\r\n```kotlin\r\nabstract class Test<T>(val id: T)\r\nabstract class TestInt(id: Int) : Test<Int>(id)\r\n\r\nclass MyTest(val i: Int) : TestInt(i){\r\n    @Serializer(MyTest::class)\r\n    companion object {\r\n        override val descriptor: SerialDescriptor\r\n            get() = StringDescriptor.withName(\"MyTest\")\r\n\r\n        override fun serialize(output: Encoder, obj: MyTest) {\r\n            output.encodeString(HexConverter.printHexBinary(obj.id.toString().toByteArray()))\r\n        }\r\n\r\n        override fun deserialize(input: Decoder): MyTest {\r\n            return MyTest(String(HexConverter.parseHexBinary(input.decodeString())).toInt())\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nAs it is, this works.\r\n\r\nHowever, when I mark MyTest `@Serializable`, as is done in the example, it breaks (on compile) because \"Non-serializable parent of serializable class MyTest must have no arg constructor\".\r\n\r\nIt seems this is more a problem with the documentation (not needing the `@Serializable` annotation in that example) that anything major."},"comment":{"url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/comments/450501863","html_url":"https://github.com/Kotlin/kotlinx.serialization/issues/317#issuecomment-450501863","issue_url":"https://api.github.com/repos/Kotlin/kotlinx.serialization/issues/317","id":450501863,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDUwMTg2Mw==","user":{"login":"sandwwraith","id":11777575,"node_id":"MDQ6VXNlcjExNzc3NTc1","avatar_url":"https://avatars1.githubusercontent.com/u/11777575?v=4","gravatar_id":"","url":"https://api.github.com/users/sandwwraith","html_url":"https://github.com/sandwwraith","followers_url":"https://api.github.com/users/sandwwraith/followers","following_url":"https://api.github.com/users/sandwwraith/following{/other_user}","gists_url":"https://api.github.com/users/sandwwraith/gists{/gist_id}","starred_url":"https://api.github.com/users/sandwwraith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandwwraith/subscriptions","organizations_url":"https://api.github.com/users/sandwwraith/orgs","repos_url":"https://api.github.com/users/sandwwraith/repos","events_url":"https://api.github.com/users/sandwwraith/events{/privacy}","received_events_url":"https://api.github.com/users/sandwwraith/received_events","type":"User","site_admin":false},"created_at":"2018-12-29T15:54:07Z","updated_at":"2018-12-29T15:54:07Z","author_association":"COLLABORATOR","body":"No, the annotation is needed so the class serializer can be auto-discovered. As a workaround, you can specify `@Serializable(with=MyTest.Companion::class)` on MyTest.\r\n\r\nCheck for no-arg constructor in parent should be disabled if custom serializer is provided."}}
{"actor":{"display_login":"sandwwraith"}}