Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 1 | // This file was automatically generated from polymorphism.md by Knit tool. Do not edit. |
| 2 | package example.examplePoly05 |
| 3 | |
| 4 | import kotlinx.serialization.* |
| 5 | import kotlinx.serialization.json.* |
| 6 | |
| 7 | @Serializable |
| 8 | sealed class Project { |
| 9 | abstract val name: String |
| 10 | } |
| 11 | |
Roman Elizarov | 2f4d91c | 2021-05-17 18:53:04 +0300 | [diff] [blame] | 12 | @Serializable |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 13 | class OwnedProject(override val name: String, val owner: String) : Project() |
| 14 | |
| 15 | fun main() { |
Roman Elizarov | 2f4d91c | 2021-05-17 18:53:04 +0300 | [diff] [blame] | 16 | val data = OwnedProject("kotlinx.coroutines", "kotlin") // data: OwnedProject here |
| 17 | println(Json.encodeToString(data)) // Serializing data of compile-time type OwnedProject |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 18 | } |