From 55281ed228c5b0d2c094615ba990841cfa114dbc Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 9 May 2021 00:15:35 +0800 Subject: [PATCH] PluginData: do not add supertype `ConcurrentMap` for shadowed maps even though original map implements it --- .../src/internal/data/collectionUtil.kt | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/backend/mirai-console/src/internal/data/collectionUtil.kt b/backend/mirai-console/src/internal/data/collectionUtil.kt index 43135f913..be0f9c81c 100644 --- a/backend/mirai-console/src/internal/data/collectionUtil.kt +++ b/backend/mirai-console/src/internal/data/collectionUtil.kt @@ -11,7 +11,6 @@ package net.mamoe.mirai.console.internal.data -import java.util.concurrent.ConcurrentMap import java.util.function.BiConsumer import java.util.function.BiFunction import java.util.function.Function @@ -153,32 +152,12 @@ internal open class ShadowMap( } } - -@Suppress( - "MANY_IMPL_MEMBER_NOT_IMPLEMENTED", "MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED", - "UNCHECKED_CAST", "USELESS_CAST", "ACCIDENTAL_OVERRIDE", "TYPE_MISMATCH", - "EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE", "CONFLICTING_INHERITED_JVM_DECLARATIONS" -) -internal open class ConcurrentShadowMap( - originMapComputer: () -> MutableMap, - kTransform: (K) -> KR, - kTransformBack: (KR) -> K, - vTransform: (V) -> VR, - vTransformBack: (VR) -> V -) : ShadowMap( - originMapComputer, kTransform, kTransformBack, vTransform, vTransformBack -), ConcurrentMap - internal fun MutableMap.shadowMap( kTransform: (K) -> KR, kTransformBack: (KR) -> K, vTransform: (V) -> VR, vTransformBack: (VR) -> V -): MutableMap = if (this is ConcurrentMap) { - ConcurrentShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack) -} else { - ShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack) -} +): MutableMap = ShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack) internal inline fun MutableCollection.shadowMap( @@ -454,14 +433,7 @@ internal fun MutableMap.observable(onChanged: () -> Unit): MutableM this@observable.merge(key, value, remappingFunction).also { onChanged() } } - @Suppress( - "MANY_IMPL_MEMBER_NOT_IMPLEMENTED", "MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED", - "UNCHECKED_CAST", "USELESS_CAST", "ACCIDENTAL_OVERRIDE", "TYPE_MISMATCH", - "EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE", "CONFLICTING_INHERITED_JVM_DECLARATIONS" - ) - return if (this is ConcurrentMap<*, *>) { - object : ConcurrentMap, MutableMap, ObservableMap() {} - } else ObservableMap() + return ObservableMap() } internal inline fun MutableList.observable(crossinline onChanged: () -> Unit): MutableList {