Support ArrayList, LinkedHashMap, HashMap, LinkedHashSet, HashSet for value()

This commit is contained in:
Him188 2020-06-24 04:11:32 +08:00
parent d120bfe576
commit 5adda00be0

View File

@ -44,7 +44,9 @@ internal fun Setting.valueFromKTypeImpl(type: KType): SerializerAwareValue<*> {
when (classifier) {
MutableMap::class,
Map::class
Map::class,
LinkedHashMap::class,
HashMap::class
-> {
val keyClass = type.arguments[0].type?.classifier
require(keyClass is KClass<*>)
@ -63,10 +65,9 @@ internal fun Setting.valueFromKTypeImpl(type: KType): SerializerAwareValue<*> {
).serializableValueWith(serializerMirai(type) as KSerializer<Map<Any?, Any?>>) // erased
}
}
Collection::class,
MutableCollection::class,
MutableList::class,
List::class
List::class,
ArrayList::class
-> {
val elementClass = type.arguments[0].type?.classifier
require(elementClass is KClass<*>)
@ -81,7 +82,9 @@ internal fun Setting.valueFromKTypeImpl(type: KType): SerializerAwareValue<*> {
}
}
MutableSet::class,
Set::class
Set::class,
LinkedHashSet::class,
HashSet::class
-> {
val elementClass = type.arguments[0].type?.classifier
require(elementClass is KClass<*>)