mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
PluginData: do not add supertype ConcurrentMap
for shadowed maps even though original map implements it
This commit is contained in:
parent
048a0bbdd6
commit
55281ed228
@ -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<K, V, KR, VR>(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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<K, V, KR, VR>(
|
||||
originMapComputer: () -> MutableMap<K, V>,
|
||||
kTransform: (K) -> KR,
|
||||
kTransformBack: (KR) -> K,
|
||||
vTransform: (V) -> VR,
|
||||
vTransformBack: (VR) -> V
|
||||
) : ShadowMap<K, V, KR, VR>(
|
||||
originMapComputer, kTransform, kTransformBack, vTransform, vTransformBack
|
||||
), ConcurrentMap<KR, VR>
|
||||
|
||||
internal fun <K, V, KR, VR> MutableMap<K, V>.shadowMap(
|
||||
kTransform: (K) -> KR,
|
||||
kTransformBack: (KR) -> K,
|
||||
vTransform: (V) -> VR,
|
||||
vTransformBack: (VR) -> V
|
||||
): MutableMap<KR, VR> = if (this is ConcurrentMap<K, V>) {
|
||||
ConcurrentShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack)
|
||||
} else {
|
||||
ShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack)
|
||||
}
|
||||
): MutableMap<KR, VR> = ShadowMap({ this }, kTransform, kTransformBack, vTransform, vTransformBack)
|
||||
|
||||
|
||||
internal inline fun <E, R> MutableCollection<E>.shadowMap(
|
||||
@ -454,14 +433,7 @@ internal fun <K, V> MutableMap<K, V>.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<K, V>, MutableMap<K, V>, ObservableMap() {}
|
||||
} else ObservableMap()
|
||||
return ObservableMap()
|
||||
}
|
||||
|
||||
internal inline fun <T> MutableList<T>.observable(crossinline onChanged: () -> Unit): MutableList<T> {
|
||||
|
Loading…
Reference in New Issue
Block a user