Files
Leonid Startsev aac9a06474 Also support intrinsification for SerializersModule.serializer<T>()
method that fallbacks to module.getContextual().
2022-09-16 14:34:28 +00:00

32 lines
700 B
Kotlin
Vendored

// CURIOUS_ABOUT: test, getSer
// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
@Serializable
class Simple(val firstName: String, val lastName: String)
class NoSer
class NoSerGeneric<T>
val module = SerializersModule {}
inline fun <reified T: Any> getSer(module: SerializersModule): KSerializer<T> {
return module.serializer()
}
fun test() {
module.serializer<Simple>()
module.serializer<NoSer>()
module.serializer<List<Simple>>()
module.serializer<List<NoSer>>()
getSer<Simple>(module)
getSer<NoSer>(module)
getSer<NoSerGeneric<Simple>>(module)
getSer<NoSerGeneric<NoSer>>(module)
}