The `KClass#hashCode` method uses the class simple...
# javascript
e
The
KClass#hashCode
method uses the class simple name
Copy code
// TODO: use FQN
override fun hashCode(): Int = simpleName?.hashCode() ?: 0
I suppose it's better to avoid using it as of now, as we might have collisions
a
What could we use in this case?
e
Seems like the TODO suggests the fully qualified name, but personally I have no idea if it's enough or not
a
Yes, but as far as I remember, we don't save this information for runtime (because fqn are long, and they make the bundle heavier)
e
Yeah, the qualified name property is marked with a
TODO()
For the couple of places I need this, I have manually typed the FQN. No big deal
Probably some kind of compile-time warning could be emitted when using
hashCode
tho, just so the consumer is aware of the potential collision issue
j
But that's always a possibility with hashCode anyway
e
But in this case the possibility is quite high, that's why I mentioned a warning
j
It is, but hashCode is typically used in a polymorphic context where you've completely lost the original type. Or the hashCode usage is abstracted away such as in a map or set.