Repository: JetBrains/kotlin
File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt (Kotlin)

Code before:
import kotlin.reflect.KProperty0

internal open class KProperty0Impl<out V> : KProperty0<V>, KPropertyImpl<V> {
    constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)

    constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
        container, name, signature, boundReceiver
    )

    private val _getter = ReflectProperties.lazy { Getter(this) }

    override val getter: Getter<V> get() = _getter()

    override fun get(): V = getter.call()

    private val delegateFieldValue = lazy(PUBLICATION) { getDelegate(computeDelegateField(), boundReceiver) }

    override fun getDelegate(): Any? = delegateFieldValue.value

    override fun invoke(): V = get()

    class Getter<out R>(override val property: KProperty0Impl<R>) : KPropertyImpl.Getter<R>(), KProperty0.Getter<R> {
        override fun invoke(): R = property.get()

        override fun equals(other: Any?): Boolean {
            val that = other as? Getter<*> ?: return false
            return property.toString() == that.property.toString()
        }

        override fun hashCode(): Int = property.toString().hashCode()
    }
}

internal class KMutableProperty0Impl<V> : KProperty0Impl<V>, KMutableProperty0<V> {
    constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)

    constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
        container, name, signature, boundReceiver
    )

    private val _setter = ReflectProperties.lazy { Setter(this) }

    override val setter: Setter<V> get() = _setter()

    override fun set(value: V) = setter.call(value)

    class Setter<R>(override val property: KMutableProperty0Impl<R>) : KPropertyImpl.Setter<R>(), KMutableProperty0.Setter<R> {
        override fun invoke(value: R): Unit = property.set(value)

        override fun equals(other: Any?): Boolean {
            val that = other as? Setter<*> ?: return false

Review comment (suggestion):
```property.name``` is not sufficient as a basis for equality, and it is not feasible to use ```property==that.property```  directly because it requires equality of ```rawBoundReceiver```.
So ```property.toString() == that.property.toString()``` seems good to me.

Code after:
import kotlin.reflect.KProperty0

internal open class KProperty0Impl<out V> : KProperty0<V>, KPropertyImpl<V> {
    constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)

    constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
        container, name, signature, boundReceiver
    )

    private val _getter = ReflectProperties.lazy { Getter(this) }

    override val getter: Getter<V> get() = _getter()

    override fun get(): V = getter.call()

    private val delegateFieldValue = lazy(PUBLICATION) { getDelegate(computeDelegateField(), boundReceiver) }

    override fun getDelegate(): Any? = delegateFieldValue.value

    override fun invoke(): V = get()

    class Getter<out R>(override val property: KProperty0Impl<R>) : KPropertyImpl.Getter<R>(), KProperty0.Getter<R> {
        override fun invoke(): R = property.get()
    }
}

internal class KMutableProperty0Impl<V> : KProperty0Impl<V>, KMutableProperty0<V> {
    constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)

    constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
        container, name, signature, boundReceiver
    )

    private val _setter = ReflectProperties.lazy { Setter(this) }

    override val setter: Setter<V> get() = _setter()

    override fun set(value: V) = setter.call(value)

    class Setter<R>(override val property: KMutableProperty0Impl<R>) : KPropertyImpl.Setter<R>(), KMutableProperty0.Setter<R> {
        override fun invoke(value: R): Unit = property.set(value)
    }
}