From 5adda00be0251ee8b2d5aeb7c6aaebd5ac59c8f4 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 24 Jun 2020 04:11:32 +0800 Subject: [PATCH] Support ArrayList, LinkedHashMap, HashMap, LinkedHashSet, HashSet for value() --- .../internal/Setting.value composite impl.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/Setting.value composite impl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/Setting.value composite impl.kt index b2a679108..3f6927227 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/Setting.value composite impl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/Setting.value composite impl.kt @@ -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>) // 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<*>)