diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt index 0b1c651e7..66627edb8 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt @@ -129,7 +129,10 @@ fun Any?._miraiContentToString(prefix: String = ""): String = when (this) { 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 @MiraiDebugAPI @@ -163,14 +166,23 @@ private fun Any.contentToStringReflectively( } + "\n$prefix}" } -private val KClass.supertypes: List get() = listOf() // on JVM, it will be resolved to member function +// on JVM, it will be resolved to member function +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +private val KClass.supertypes: List + get() = listOf() private fun KClass.thisClassAndSuperclassSequence(): Sequence> { return sequenceOf(this) + this.supertypes.asSequence() - .mapNotNull { type -> type.classifier?.takeIf { it is KClass<*> }?.takeIf { it != Any::class } as? KClass }.flatMap { it.thisClassAndSuperclassSequence() } + .mapNotNull { type -> + type.classifier?.takeIf { it is KClass<*> }?.takeIf { it != Any::class } as? KClass + }.flatMap { it.thisClassAndSuperclassSequence() } } -private val KClass.members: List> get() = listOf() // on JVM, it will be resolved to member function + +// on JVM, it will be resolved to member function +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +private val KClass.members: List> + get() = listOf() @Suppress("UNCHECKED_CAST") private fun Any.allMembersFromSuperClassesMatching(classFilter: (KClass) -> Boolean): Sequence> {