Simplify KProperty implementations: get rid of KMutablePropertyImpl

This commit is contained in:
Alexander Udalov
2016-09-06 16:37:29 +03:00
parent c7050ed445
commit 304b5deacb
4 changed files with 7 additions and 14 deletions
@@ -38,7 +38,7 @@ internal open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KPropert
}
}
internal open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R>, KMutablePropertyImpl<R> {
internal class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R> {
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
@@ -49,7 +49,7 @@ internal open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProper
override fun set(value: R) = setter.call(value)
class Setter<R>(override val property: KMutableProperty0Impl<R>) : KMutablePropertyImpl.Setter<R>(), KMutableProperty0.Setter<R> {
class Setter<R>(override val property: KMutableProperty0Impl<R>) : KPropertyImpl.Setter<R>(), KMutableProperty0.Setter<R> {
override fun invoke(value: R): Unit = property.set(value)
}
}
@@ -38,7 +38,7 @@ internal open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProp
}
}
internal open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1<T, R>, KMutablePropertyImpl<R> {
internal class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1<T, R> {
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
@@ -49,7 +49,7 @@ internal open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutable
override fun set(receiver: T, value: R) = setter.call(receiver, value)
class Setter<T, R>(override val property: KMutableProperty1Impl<T, R>) : KMutablePropertyImpl.Setter<R>(), KMutableProperty1.Setter<T, R> {
class Setter<T, R>(override val property: KMutableProperty1Impl<T, R>) : KPropertyImpl.Setter<R>(), KMutableProperty1.Setter<T, R> {
override fun invoke(receiver: T, value: R): Unit = property.set(receiver, value)
}
}
@@ -38,7 +38,7 @@ internal open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KP
}
}
internal open class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KMutableProperty2<D, E, R>, KMutablePropertyImpl<R> {
internal class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KMutableProperty2<D, E, R> {
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
@@ -49,7 +49,7 @@ internal open class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KM
override fun set(receiver1: D, receiver2: E, value: R) = setter.call(receiver1, receiver2, value)
class Setter<D, E, R>(override val property: KMutableProperty2Impl<D, E, R>) : KMutablePropertyImpl.Setter<R>(), KMutableProperty2.Setter<D, E, R> {
class Setter<D, E, R>(override val property: KMutableProperty2Impl<D, E, R>) : KPropertyImpl.Setter<R>(), KMutableProperty2.Setter<D, E, R> {
override fun invoke(receiver1: D, receiver2: E, value: R): Unit = property.set(receiver1, receiver2, value)
}
}
@@ -94,15 +94,8 @@ internal interface KPropertyImpl<out R> : KProperty<R>, KCallableImpl<R> {
override val defaultCaller: FunctionCaller<*>? get() = null
}
}
internal interface KMutablePropertyImpl<R> : KMutableProperty<R>, KPropertyImpl<R> {
override val setter: Setter<R>
abstract class Setter<R> : KPropertyImpl.Accessor<R>(), KMutableProperty.Setter<R>, KCallableImpl<Unit> {
abstract override val property: KMutablePropertyImpl<R>
abstract class Setter<R> : Accessor<R>(), KMutableProperty.Setter<R>, KCallableImpl<Unit> {
override val name: String get() = "<set-${property.name}>"
override val container: KDeclarationContainerImpl get() = property.container