Jacob Rhoda
07/06/2023, 5:08 PMAdam S
07/06/2023, 6:12 PMinterface Foo { /*...*/ }
class FooImpl : Foo { /*...*/ }
fun Foo(): Foo { return FooImpl() }
This approach is used by KxS, where JsonPrimitive
is a public sealed class with lots of JsonPrimitive()
factory functions, while the implementation JsonLiteral
is an internal class type https://github.com/Kotlin/kotlinx.serialization/blob/9056f309cab0e3f361547c48fdc8f0904443f8ab/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt#L52-L56Jacob Rhoda
07/06/2023, 6:37 PMDaniel Weidensdörfer
07/06/2023, 6:44 PMJacob Rhoda
07/06/2023, 6:48 PM