mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 04:50:26 +08:00
Fix internals
This commit is contained in:
parent
ff9702a992
commit
97be9afeb9
buildSrc/src/main/kotlin
mirai-core/src
commonMain/kotlin
jvmMain/kotlin/utils
@ -36,7 +36,7 @@ object Versions {
|
||||
const val coroutinesIo = "0.1.16"
|
||||
const val dokka = "0.10.1"
|
||||
|
||||
const val blockingBridge = "1.5.0"
|
||||
const val blockingBridge = "1.4.1"
|
||||
|
||||
const val androidGradlePlugin = "3.5.3"
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
*/
|
||||
package net.mamoe.mirai.internal.network.protocol
|
||||
|
||||
import net.mamoe.mirai.internal.utils.LinkedList
|
||||
import kotlin.jvm.Synchronized
|
||||
import java.util.*
|
||||
|
||||
internal class SyncingCacheList<E>(private val size: Int = 50) {
|
||||
private val packetIdList = LinkedList<E>()
|
||||
|
@ -14,10 +14,12 @@ package net.mamoe.mirai.internal.utils
|
||||
import kotlinx.serialization.Transient
|
||||
import net.mamoe.mirai.utils.DefaultLogger
|
||||
import net.mamoe.mirai.utils.debug
|
||||
import java.lang.reflect.Modifier
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
|
||||
private val indent: String = " ".repeat(4)
|
||||
@ -135,14 +137,6 @@ internal fun Any?._miraiContentToString(prefix: String = ""): String = when (thi
|
||||
|
||||
internal expect fun KProperty1<*, *>.getValueAgainstPermission(receiver: Any): Any?
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
private val KProperty1<*, *>.isConst: Boolean
|
||||
get() = false // on JVM, it will be resolved to member function
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
private val KClass<*>.isData: Boolean
|
||||
get() = false // on JVM, it will be resolved to member function
|
||||
|
||||
private fun Any.canBeIgnored(): Boolean {
|
||||
return when (this) {
|
||||
is String -> this.isEmpty()
|
||||
@ -192,11 +186,6 @@ private fun Any.contentToStringReflectively(
|
||||
}.lines().filterNot { it.isBlank() }.joinToString("\n") + "\n$prefix}"
|
||||
}
|
||||
|
||||
// on JVM, it will be resolved to member function
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
private val <T : Any> KClass<T>.supertypes: List<KType>
|
||||
get() = listOf()
|
||||
|
||||
private fun KClass<out Any>.thisClassAndSuperclassSequence(): Sequence<KClass<out Any>> {
|
||||
return sequenceOf(this) +
|
||||
this.supertypes.asSequence()
|
||||
@ -205,11 +194,6 @@ private fun KClass<out Any>.thisClassAndSuperclassSequence(): Sequence<KClass<ou
|
||||
}.flatMap { it.thisClassAndSuperclassSequence() }
|
||||
}
|
||||
|
||||
// on JVM, it will be resolved to member function
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
private val <T : Any> KClass<T>.members: List<KProperty<*>>
|
||||
get() = listOf()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun Any.allMembersFromSuperClassesMatching(classFilter: (KClass<out Any>) -> Boolean): Sequence<KProperty1<Any, *>> {
|
||||
return this::class.thisClassAndSuperclassSequence()
|
||||
@ -222,8 +206,6 @@ private fun Any.allMembersFromSuperClassesMatching(classFilter: (KClass<out Any>
|
||||
.mapNotNull { it as KProperty1<Any, *> }
|
||||
}
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
internal expect inline fun <reified T : Annotation> KProperty<*>.hasAnnotation(): Boolean
|
||||
internal fun KProperty<*>.isTransient(): Boolean =
|
||||
javaField?.modifiers?.and(Modifier.TRANSIENT) != 0
|
||||
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
internal expect fun KProperty<*>.isTransient(): Boolean
|
@ -9,24 +9,9 @@
|
||||
|
||||
package net.mamoe.mirai.internal.utils
|
||||
|
||||
import java.lang.reflect.Modifier
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
internal actual fun KProperty1<*, *>.getValueAgainstPermission(receiver: Any): Any? {
|
||||
return this.javaField?.apply { isAccessible = true }?.get(receiver)
|
||||
}
|
||||
|
||||
// on JVM, it will be resolved to member function
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
internal actual inline fun <reified T : Annotation> KProperty<*>.hasAnnotation(): Boolean =
|
||||
findAnnotation<T>() != null
|
||||
|
||||
|
||||
// on JVM, it will be resolved to member function
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
internal actual fun KProperty<*>.isTransient(): Boolean =
|
||||
javaField?.modifiers?.and(Modifier.TRANSIENT) != 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user