Do not rely on descriptors in KParameterImpl.equals/hashCode
For the same reason as in the previous commit: descriptors are cached via weak references in moduleByClassLoader.kt and can be garbage-collected at any point. So different instances of KParameterImpl representing the same parameter may store different instances of descriptors.
This commit is contained in:
@@ -64,10 +64,10 @@ internal class KParameterImpl(
|
||||
get() = descriptor.let { it is ValueParameterDescriptor && it.varargElementType != null }
|
||||
|
||||
override fun equals(other: Any?) =
|
||||
other is KParameterImpl && callable == other.callable && descriptor == other.descriptor
|
||||
other is KParameterImpl && callable == other.callable && index == other.index
|
||||
|
||||
override fun hashCode() =
|
||||
(callable.hashCode() * 31) + descriptor.hashCode()
|
||||
(callable.hashCode() * 31) + index.hashCode()
|
||||
|
||||
override fun toString() =
|
||||
ReflectionObjectRenderer.renderParameter(this)
|
||||
|
||||
Reference in New Issue
Block a user