[Wasm] Replace ClassId and InterfaceId with single TypeId
This commit is contained in:
committed by
Space Team
parent
5a46cb1c40
commit
49beec33b4
@@ -5,7 +5,7 @@
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
import kotlin.wasm.internal.wasmClassId
|
||||
import kotlin.wasm.internal.wasmTypeId
|
||||
import kotlin.wasm.internal.findAssociatedObject
|
||||
|
||||
/**
|
||||
@@ -40,4 +40,4 @@ public annotation class AssociatedObjectKey
|
||||
@ExperimentalAssociatedObjects
|
||||
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
public inline fun <reified T : Annotation> KClass<*>.findAssociatedObject(): Any? =
|
||||
findAssociatedObject(this, wasmClassId<T>())
|
||||
findAssociatedObject(this, wasmTypeId<T>())
|
||||
@@ -8,6 +8,7 @@ import kotlin.reflect.*
|
||||
import kotlin.wasm.internal.TypeInfoData
|
||||
import kotlin.wasm.internal.getSuperTypeId
|
||||
import kotlin.wasm.internal.isInterfaceById
|
||||
import kotlin.wasm.internal.isInterfaceType
|
||||
|
||||
internal object NothingKClassImpl : KClass<Nothing> {
|
||||
override val simpleName: String = "Nothing"
|
||||
@@ -37,12 +38,16 @@ internal class KClassImpl<T : Any>(internal val typeData: TypeInfoData) : KClass
|
||||
return false
|
||||
}
|
||||
|
||||
override fun isInstance(value: Any?): Boolean = value?.let {
|
||||
if (typeData.isInterface) isInterfaceById(it, typeData.typeId) else checkSuperTypeInstance(it)
|
||||
} ?: false
|
||||
override fun isInstance(value: Any?): Boolean {
|
||||
if (value !is Any) return false
|
||||
return when (typeData.isInterfaceType) {
|
||||
true -> isInterfaceById(value, typeData.typeId)
|
||||
false -> checkSuperTypeInstance(value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
(this === other) || (other is KClassImpl<*> && other.typeData.isInterface == typeData.isInterface && other.typeData.typeId == typeData.typeId)
|
||||
(this === other) || (other is KClassImpl<*> && other.typeData.typeId == typeData.typeId)
|
||||
|
||||
override fun hashCode(): Int = typeData.typeId
|
||||
|
||||
|
||||
Reference in New Issue
Block a user