From fe50bb4b939f92dc720b3cb8e6711bd719652dd2 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Mon, 17 Feb 2020 15:40:57 +0300 Subject: [PATCH] KProperty and ReadOnlyProperty type parameter names #KT-16529 --- .../reflect/jvm/internal/KProperty0Impl.kt | 14 ++-- .../reflect/jvm/internal/KProperty1Impl.kt | 22 +++--- .../reflect/jvm/internal/KProperty2Impl.kt | 24 +++--- .../reflect/jvm/internal/KPropertyImpl.kt | 10 +-- .../parameterNameAndType/NoDuplication.kt | 2 +- .../parameterNameAndType/NotImported.kt | 2 +- .../testData/basic/java/KProperty.kt | 2 +- .../inStandardLibrary/notNull.kt | 4 +- .../stdlib/js/src/kotlin/reflect/KProperty.kt | 34 ++++---- .../jvm/src/kotlin/reflect/KProperty.kt | 78 +++++++++---------- .../src/kotlin/properties/Interfaces.kt | 18 ++--- .../kotlin/properties/ObservableProperty.kt | 10 +-- .../stdlib/src/kotlin/reflect/KProperty.kt | 34 ++++---- 13 files changed, 127 insertions(+), 127 deletions(-) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt index 9ed1fe3219f..517a667035b 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt @@ -21,7 +21,7 @@ import kotlin.LazyThreadSafetyMode.PUBLICATION import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty0 -internal open class KProperty0Impl : KProperty0, KPropertyImpl { +internal open class KProperty0Impl : KProperty0, KPropertyImpl { constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super( @@ -30,22 +30,22 @@ internal open class KProperty0Impl : KProperty0, KPropertyImpl { private val _getter = ReflectProperties.lazy { Getter(this) } - override val getter: Getter get() = _getter() + override val getter: Getter get() = _getter() - override fun get(): R = getter.call() + override fun get(): V = getter.call() private val delegateFieldValue = lazy(PUBLICATION) { getDelegate(computeDelegateField(), boundReceiver) } override fun getDelegate(): Any? = delegateFieldValue.value - override fun invoke(): R = get() + override fun invoke(): V = get() class Getter(override val property: KProperty0Impl) : KPropertyImpl.Getter(), KProperty0.Getter { override fun invoke(): R = property.get() } } -internal class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0 { +internal class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0 { constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super( @@ -54,9 +54,9 @@ internal class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0 get() = _setter() + override val setter: Setter get() = _setter() - override fun set(value: R) = setter.call(value) + override fun set(value: V) = setter.call(value) class Setter(override val property: KMutableProperty0Impl) : KPropertyImpl.Setter(), KMutableProperty0.Setter { override fun invoke(value: R): Unit = property.set(value) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt index 7163b965575..921417fa8cd 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt @@ -21,7 +21,7 @@ import kotlin.LazyThreadSafetyMode.PUBLICATION import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty1 -internal open class KProperty1Impl : KProperty1, KPropertyImpl { +internal open class KProperty1Impl : KProperty1, KPropertyImpl { constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super( container, name, signature, boundReceiver ) @@ -30,22 +30,22 @@ internal open class KProperty1Impl : KProperty1, KPropertyImpl get() = _getter() + override val getter: Getter get() = _getter() - override fun get(receiver: T): R = getter.call(receiver) + override fun get(receiver: T): V = getter.call(receiver) private val delegateField = lazy(PUBLICATION) { computeDelegateField() } override fun getDelegate(receiver: T): Any? = getDelegate(delegateField.value, receiver) - override fun invoke(receiver: T): R = get(receiver) + override fun invoke(receiver: T): V = get(receiver) - class Getter(override val property: KProperty1Impl) : KPropertyImpl.Getter(), KProperty1.Getter { - override fun invoke(receiver: T): R = property.get(receiver) + class Getter(override val property: KProperty1Impl) : KPropertyImpl.Getter(), KProperty1.Getter { + override fun invoke(receiver: T): V = property.get(receiver) } } -internal class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1 { +internal class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1 { constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super( container, name, signature, boundReceiver ) @@ -54,11 +54,11 @@ internal class KMutableProperty1Impl : KProperty1Impl, KMutablePrope private val _setter = ReflectProperties.lazy { Setter(this) } - override val setter: Setter get() = _setter() + override val setter: Setter get() = _setter() - override fun set(receiver: T, value: R) = setter.call(receiver, value) + override fun set(receiver: T, value: V) = setter.call(receiver, value) - class Setter(override val property: KMutableProperty1Impl) : KPropertyImpl.Setter(), KMutableProperty1.Setter { - override fun invoke(receiver: T, value: R): Unit = property.set(receiver, value) + class Setter(override val property: KMutableProperty1Impl) : KPropertyImpl.Setter(), KMutableProperty1.Setter { + override fun invoke(receiver: T, value: V): Unit = property.set(receiver, value) } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt index 04b6e711b94..75e4adaa9c8 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt @@ -22,7 +22,7 @@ import kotlin.jvm.internal.CallableReference import kotlin.reflect.KMutableProperty2 import kotlin.reflect.KProperty2 -internal open class KProperty2Impl : KProperty2, KPropertyImpl { +internal open class KProperty2Impl : KProperty2, KPropertyImpl { constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super( container, name, signature, CallableReference.NO_RECEIVER ) @@ -31,34 +31,34 @@ internal open class KProperty2Impl : KProperty2, KProperty private val _getter = ReflectProperties.lazy { Getter(this) } - override val getter: Getter get() = _getter() + override val getter: Getter get() = _getter() - override fun get(receiver1: D, receiver2: E): R = getter.call(receiver1, receiver2) + override fun get(receiver1: D, receiver2: E): V = getter.call(receiver1, receiver2) private val delegateField = lazy(PUBLICATION) { computeDelegateField() } override fun getDelegate(receiver1: D, receiver2: E): Any? = getDelegate(delegateField.value, receiver1) - override fun invoke(receiver1: D, receiver2: E): R = get(receiver1, receiver2) + override fun invoke(receiver1: D, receiver2: E): V = get(receiver1, receiver2) - class Getter(override val property: KProperty2Impl) : KPropertyImpl.Getter(), KProperty2.Getter { - override fun invoke(receiver1: D, receiver2: E): R = property.get(receiver1, receiver2) + class Getter(override val property: KProperty2Impl) : KPropertyImpl.Getter(), KProperty2.Getter { + override fun invoke(receiver1: D, receiver2: E): V = property.get(receiver1, receiver2) } } -internal class KMutableProperty2Impl : KProperty2Impl, KMutableProperty2 { +internal class KMutableProperty2Impl : KProperty2Impl, KMutableProperty2 { constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) private val _setter = ReflectProperties.lazy { Setter(this) } - override val setter: Setter get() = _setter() + override val setter: Setter get() = _setter() - override fun set(receiver1: D, receiver2: E, value: R) = setter.call(receiver1, receiver2, value) + override fun set(receiver1: D, receiver2: E, value: V) = setter.call(receiver1, receiver2, value) - class Setter(override val property: KMutableProperty2Impl) : KPropertyImpl.Setter(), - KMutableProperty2.Setter { - override fun invoke(receiver1: D, receiver2: E, value: R): Unit = property.set(receiver1, receiver2, value) + class Setter(override val property: KMutableProperty2Impl) : KPropertyImpl.Setter(), + KMutableProperty2.Setter { + override fun invoke(receiver1: D, receiver2: E, value: V): Unit = property.set(receiver1, receiver2, value) } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt index b33c9aad529..e012609a6cb 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt @@ -24,13 +24,13 @@ import kotlin.reflect.full.IllegalPropertyDelegateAccessException import kotlin.reflect.jvm.internal.JvmPropertySignature.* import kotlin.reflect.jvm.internal.calls.* -internal abstract class KPropertyImpl private constructor( +internal abstract class KPropertyImpl private constructor( override val container: KDeclarationContainerImpl, override val name: String, val signature: String, descriptorInitialValue: PropertyDescriptor?, private val rawBoundReceiver: Any? -) : KCallableImpl(), KProperty { +) : KCallableImpl(), KProperty { constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : this( container, name, signature, null, boundReceiver ) @@ -96,7 +96,7 @@ internal abstract class KPropertyImpl private constructor( throw IllegalPropertyDelegateAccessException(e) } - abstract override val getter: Getter + abstract override val getter: Getter private val _descriptor = ReflectProperties.lazySoft(descriptorInitialValue) { container.findPropertyDescriptor(name, signature) @@ -144,7 +144,7 @@ internal abstract class KPropertyImpl private constructor( override val isSuspend: Boolean get() = descriptor.isSuspend } - abstract class Getter : Accessor(), KProperty.Getter { + abstract class Getter : Accessor(), KProperty.Getter { override val name: String get() = "" override val descriptor: PropertyGetterDescriptor by ReflectProperties.lazySoft { @@ -157,7 +157,7 @@ internal abstract class KPropertyImpl private constructor( } } - abstract class Setter : Accessor(), KMutableProperty.Setter { + abstract class Setter : Accessor(), KMutableProperty.Setter { override val name: String get() = "" override val descriptor: PropertySetterDescriptor by ReflectProperties.lazySoft { diff --git a/idea/idea-completion/testData/basic/common/parameterNameAndType/NoDuplication.kt b/idea/idea-completion/testData/basic/common/parameterNameAndType/NoDuplication.kt index 8da3c4fcfa8..ea638ef1caf 100644 --- a/idea/idea-completion/testData/basic/common/parameterNameAndType/NoDuplication.kt +++ b/idea/idea-completion/testData/basic/common/parameterNameAndType/NoDuplication.kt @@ -2,5 +2,5 @@ import kotlin.properties.* fun f(readonlypr) -// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: " (kotlin.properties)" } +// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: " (kotlin.properties)" } // NUMBER: 1 diff --git a/idea/idea-completion/testData/basic/common/parameterNameAndType/NotImported.kt b/idea/idea-completion/testData/basic/common/parameterNameAndType/NotImported.kt index a1fd51c577c..25aec4c9320 100644 --- a/idea/idea-completion/testData/basic/common/parameterNameAndType/NotImported.kt +++ b/idea/idea-completion/testData/basic/common/parameterNameAndType/NotImported.kt @@ -1,3 +1,3 @@ fun f(read) -// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: " (kotlin.properties)" } +// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: " (kotlin.properties)" } diff --git a/idea/idea-completion/testData/basic/java/KProperty.kt b/idea/idea-completion/testData/basic/java/KProperty.kt index 13222f01188..4a6efa47d0f 100644 --- a/idea/idea-completion/testData/basic/java/KProperty.kt +++ b/idea/idea-completion/testData/basic/java/KProperty.kt @@ -6,4 +6,4 @@ fun firstFun() { } // INVOCATION_COUNT: 1 -// EXIST: { lookupString:"KProperty", itemText:"KProperty", tailText:" (kotlin.reflect)" } +// EXIST: { lookupString:"KProperty", itemText:"KProperty", tailText:" (kotlin.reflect)" } diff --git a/idea/testData/resolve/references/delegatedPropertyAccessors/inStandardLibrary/notNull.kt b/idea/testData/resolve/references/delegatedPropertyAccessors/inStandardLibrary/notNull.kt index ab39524681d..80f818c4250 100644 --- a/idea/testData/resolve/references/delegatedPropertyAccessors/inStandardLibrary/notNull.kt +++ b/idea/testData/resolve/references/delegatedPropertyAccessors/inStandardLibrary/notNull.kt @@ -5,5 +5,5 @@ import kotlin.properties.Delegates var x: Int by Delegates.notNull() // MULTIRESOLVE -// REF: (in kotlin.properties.ReadWriteProperty).getValue(R, kotlin.reflect.KProperty<*>) -// REF: (in kotlin.properties.ReadWriteProperty).setValue(R, kotlin.reflect.KProperty<*>, T) +// REF: (in kotlin.properties.ReadWriteProperty).getValue(T, kotlin.reflect.KProperty<*>) +// REF: (in kotlin.properties.ReadWriteProperty).setValue(T, kotlin.reflect.KProperty<*>, V) diff --git a/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt b/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt index 9d5a1193c14..3a40904f9ca 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt @@ -13,14 +13,14 @@ package kotlin.reflect * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html) * for more information. * - * @param R the type of the property. + * @param V the type of the property value. */ -public actual interface KProperty : KCallable +public actual interface KProperty : KCallable /** * Represents a property declared as a `var`. */ -public actual interface KMutableProperty : KProperty +public actual interface KMutableProperty : KProperty /** @@ -28,23 +28,23 @@ public actual interface KMutableProperty : KProperty * Such property is either originally declared in a receiverless context such as a package, * or has the receiver bound to it. */ -public actual interface KProperty0 : KProperty, () -> R { +public actual interface KProperty0 : KProperty, () -> V { /** * Returns the current value of the property. */ - public actual fun get(): R + public actual fun get(): V } /** * Represents a `var`-property without any kind of receiver. */ -public actual interface KMutableProperty0 : KProperty0, KMutableProperty { +public actual interface KMutableProperty0 : KProperty0, KMutableProperty { /** * Modifies the value of the property. * * @param value the new value to be assigned to this property. */ - public actual fun set(value: R) + public actual fun set(value: V) } @@ -52,9 +52,9 @@ public actual interface KMutableProperty0 : KProperty0, KMutableProperty : KProperty, (T) -> R { +public actual interface KProperty1 : KProperty, (T) -> V { /** * Returns the current value of the property. * @@ -62,13 +62,13 @@ public actual interface KProperty1 : KProperty, (T) -> R { * For example, it should be a class instance if this is a member property of that class, * or an extension receiver if this is a top level extension property. */ - public actual fun get(receiver: T): R + public actual fun get(receiver: T): V } /** * Represents a `var`-property, operations on which take one receiver as a parameter. */ -public actual interface KMutableProperty1 : KProperty1, KMutableProperty { +public actual interface KMutableProperty1 : KProperty1, KMutableProperty { /** * Modifies the value of the property. * @@ -77,7 +77,7 @@ public actual interface KMutableProperty1 : KProperty1, KMutableProp * or an extension receiver if this is a top level extension property. * @param value the new value to be assigned to this property. */ - public actual fun set(receiver: T, value: R) + public actual fun set(receiver: T, value: V) } @@ -89,9 +89,9 @@ public actual interface KMutableProperty1 : KProperty1, KMutableProp * the type of the declaring class of the property, or any subclass of that class. * @param E the type of the second receiver. In case of the extension property in a class this is * the type of the extension receiver. - * @param R the type of the property. + * @param V the type of the property value. */ -public actual interface KProperty2 : KProperty, (D, E) -> R { +public actual interface KProperty2 : KProperty, (D, E) -> V { /** * Returns the current value of the property. In case of the extension property in a class, * the instance of the class should be passed first and the instance of the extension receiver second. @@ -99,13 +99,13 @@ public actual interface KProperty2 : KProperty, (D, E) -> R { * @param receiver1 the instance of the first receiver. * @param receiver2 the instance of the second receiver. */ - public actual fun get(receiver1: D, receiver2: E): R + public actual fun get(receiver1: D, receiver2: E): V } /** * Represents a `var`-property, operations on which take two receivers as parameters. */ -public actual interface KMutableProperty2 : KProperty2, KMutableProperty { +public actual interface KMutableProperty2 : KProperty2, KMutableProperty { /** * Modifies the value of the property. * @@ -113,5 +113,5 @@ public actual interface KMutableProperty2 : KProperty2, KMutab * @param receiver2 the instance of the second receiver. * @param value the new value to be assigned to this property. */ - public actual fun set(receiver1: D, receiver2: E, value: R) + public actual fun set(receiver1: D, receiver2: E, value: V) } diff --git a/libraries/stdlib/jvm/src/kotlin/reflect/KProperty.kt b/libraries/stdlib/jvm/src/kotlin/reflect/KProperty.kt index 85935f74735..1f65afcef55 100644 --- a/libraries/stdlib/jvm/src/kotlin/reflect/KProperty.kt +++ b/libraries/stdlib/jvm/src/kotlin/reflect/KProperty.kt @@ -13,9 +13,9 @@ package kotlin.reflect * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html) * for more information. * - * @param R the type of the property. + * @param V the type of the property value. */ -public actual interface KProperty : KCallable { +public actual interface KProperty : KCallable { /** * `true` if this property is `lateinit`. * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties) @@ -33,37 +33,37 @@ public actual interface KProperty : KCallable { public val isConst: Boolean /** The getter of this property, used to obtain the value of the property. */ - public val getter: Getter + public val getter: Getter /** * Represents a property accessor, which is a `get` or `set` method declared alongside the property. * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#getters-and-setters) * for more information. * - * @param R the type of the property, which it is an accessor of. + * @param V the type of the property, which it is an accessor of. */ - public interface Accessor { + public interface Accessor { /** The property which this accessor is originated from. */ - public val property: KProperty + public val property: KProperty } /** * Getter of the property is a `get` method declared alongside the property. */ - public interface Getter : Accessor, KFunction + public interface Getter : Accessor, KFunction } /** * Represents a property declared as a `var`. */ -public actual interface KMutableProperty : KProperty { +public actual interface KMutableProperty : KProperty { /** The setter of this mutable property, used to change the value of the property. */ - public val setter: Setter + public val setter: Setter /** * Setter of the property is a `set` method declared alongside the property. */ - public interface Setter : KProperty.Accessor, KFunction + public interface Setter : KProperty.Accessor, KFunction } @@ -72,11 +72,11 @@ public actual interface KMutableProperty : KProperty { * Such property is either originally declared in a receiverless context such as a package, * or has the receiver bound to it. */ -public actual interface KProperty0 : KProperty, () -> R { +public actual interface KProperty0 : KProperty, () -> V { /** * Returns the current value of the property. */ - public actual fun get(): R + public actual fun get(): V /** * Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. @@ -86,35 +86,35 @@ public actual interface KProperty0 : KProperty, () -> R { @SinceKotlin("1.1") public fun getDelegate(): Any? - override val getter: Getter + override val getter: Getter /** * Getter of the property is a `get` method declared alongside the property. * - * Can be used as a function that takes 0 arguments and returns the value of the property type [R]. + * Can be used as a function that takes 0 arguments and returns the value of the property type [V]. */ - public interface Getter : KProperty.Getter, () -> R + public interface Getter : KProperty.Getter, () -> V } /** * Represents a `var`-property without any kind of receiver. */ -public actual interface KMutableProperty0 : KProperty0, KMutableProperty { +public actual interface KMutableProperty0 : KProperty0, KMutableProperty { /** * Modifies the value of the property. * * @param value the new value to be assigned to this property. */ - public actual fun set(value: R) + public actual fun set(value: V) - override val setter: Setter + override val setter: Setter /** * Setter of the property is a `set` method declared alongside the property. * * Can be used as a function that takes new property value as an argument and returns [Unit]. */ - public interface Setter : KMutableProperty.Setter, (R) -> Unit + public interface Setter : KMutableProperty.Setter, (V) -> Unit } @@ -122,9 +122,9 @@ public actual interface KMutableProperty0 : KProperty0, KMutableProperty : KProperty, (T) -> R { +public actual interface KProperty1 : KProperty, (T) -> V { /** * Returns the current value of the property. * @@ -132,7 +132,7 @@ public actual interface KProperty1 : KProperty, (T) -> R { * For example, it should be a class instance if this is a member property of that class, * or an extension receiver if this is a top level extension property. */ - public actual fun get(receiver: T): R + public actual fun get(receiver: T): V /** * Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. @@ -151,20 +151,20 @@ public actual interface KProperty1 : KProperty, (T) -> R { @SinceKotlin("1.1") public fun getDelegate(receiver: T): Any? - override val getter: Getter + override val getter: Getter /** * Getter of the property is a `get` method declared alongside the property. * - * Can be used as a function that takes an argument of type [T] (the receiver) and returns the value of the property type [R]. + * Can be used as a function that takes an argument of type [T] (the receiver) and returns the value of the property type [V]. */ - public interface Getter : KProperty.Getter, (T) -> R + public interface Getter : KProperty.Getter, (T) -> V } /** * Represents a `var`-property, operations on which take one receiver as a parameter. */ -public actual interface KMutableProperty1 : KProperty1, KMutableProperty { +public actual interface KMutableProperty1 : KProperty1, KMutableProperty { /** * Modifies the value of the property. * @@ -173,16 +173,16 @@ public actual interface KMutableProperty1 : KProperty1, KMutableProp * or an extension receiver if this is a top level extension property. * @param value the new value to be assigned to this property. */ - public actual fun set(receiver: T, value: R) + public actual fun set(receiver: T, value: V) - override val setter: Setter + override val setter: Setter /** * Setter of the property is a `set` method declared alongside the property. * * Can be used as a function that takes the receiver and the new property value as arguments and returns [Unit]. */ - public interface Setter : KMutableProperty.Setter, (T, R) -> Unit + public interface Setter : KMutableProperty.Setter, (T, V) -> Unit } @@ -194,9 +194,9 @@ public actual interface KMutableProperty1 : KProperty1, KMutableProp * the type of the declaring class of the property, or any subclass of that class. * @param E the type of the second receiver. In case of the extension property in a class this is * the type of the extension receiver. - * @param R the type of the property. + * @param V the type of the property value. */ -public actual interface KProperty2 : KProperty, (D, E) -> R { +public actual interface KProperty2 : KProperty, (D, E) -> V { /** * Returns the current value of the property. In case of the extension property in a class, * the instance of the class should be passed first and the instance of the extension receiver second. @@ -204,7 +204,7 @@ public actual interface KProperty2 : KProperty, (D, E) -> R { * @param receiver1 the instance of the first receiver. * @param receiver2 the instance of the second receiver. */ - public actual fun get(receiver1: D, receiver2: E): R + public actual fun get(receiver1: D, receiver2: E): V /** * Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. @@ -222,21 +222,21 @@ public actual interface KProperty2 : KProperty, (D, E) -> R { @SinceKotlin("1.1") public fun getDelegate(receiver1: D, receiver2: E): Any? - override val getter: Getter + override val getter: Getter /** * Getter of the property is a `get` method declared alongside the property. * * Can be used as a function that takes an argument of type [D] (the first receiver), an argument of type [E] (the second receiver) - * and returns the value of the property type [R]. + * and returns the value of the property type [V]. */ - public interface Getter : KProperty.Getter, (D, E) -> R + public interface Getter : KProperty.Getter, (D, E) -> V } /** * Represents a `var`-property, operations on which take two receivers as parameters. */ -public actual interface KMutableProperty2 : KProperty2, KMutableProperty { +public actual interface KMutableProperty2 : KProperty2, KMutableProperty { /** * Modifies the value of the property. * @@ -244,9 +244,9 @@ public actual interface KMutableProperty2 : KProperty2, KMutab * @param receiver2 the instance of the second receiver. * @param value the new value to be assigned to this property. */ - public actual fun set(receiver1: D, receiver2: E, value: R) + public actual fun set(receiver1: D, receiver2: E, value: V) - override val setter: Setter + override val setter: Setter /** * Setter of the property is a `set` method declared alongside the property. @@ -254,5 +254,5 @@ public actual interface KMutableProperty2 : KProperty2, KMutab * Can be used as a function that takes an argument of type [D] (the first receiver), an argument of type [E] (the second receiver), * and the new property value and returns [Unit]. */ - public interface Setter : KMutableProperty.Setter, (D, E, R) -> Unit + public interface Setter : KMutableProperty.Setter, (D, E, V) -> Unit } diff --git a/libraries/stdlib/src/kotlin/properties/Interfaces.kt b/libraries/stdlib/src/kotlin/properties/Interfaces.kt index 55b6579e123..7e78dc4a46f 100644 --- a/libraries/stdlib/src/kotlin/properties/Interfaces.kt +++ b/libraries/stdlib/src/kotlin/properties/Interfaces.kt @@ -13,17 +13,17 @@ import kotlin.reflect.KProperty * This is provided only for convenience; you don't have to extend this interface * as long as your property delegate has methods with the same signatures. * - * @param R the type of object which owns the delegated property. - * @param T the type of the property value. + * @param T the type of object which owns the delegated property. + * @param V the type of the property value. */ -public interface ReadOnlyProperty { +public interface ReadOnlyProperty { /** * Returns the value of the property for the given object. * @param thisRef the object for which the value is requested. * @param property the metadata for the property. * @return the property value. */ - public operator fun getValue(thisRef: R, property: KProperty<*>): T + public operator fun getValue(thisRef: T, property: KProperty<*>): V } /** @@ -32,17 +32,17 @@ public interface ReadOnlyProperty { * This is provided only for convenience; you don't have to extend this interface * as long as your property delegate has methods with the same signatures. * - * @param R the type of object which owns the delegated property. - * @param T the type of the property value. + * @param T the type of object which owns the delegated property. + * @param V the type of the property value. */ -public interface ReadWriteProperty { +public interface ReadWriteProperty { /** * Returns the value of the property for the given object. * @param thisRef the object for which the value is requested. * @param property the metadata for the property. * @return the property value. */ - public operator fun getValue(thisRef: R, property: KProperty<*>): T + public operator fun getValue(thisRef: T, property: KProperty<*>): V /** * Sets the value of the property for the given object. @@ -50,7 +50,7 @@ public interface ReadWriteProperty { * @param property the metadata for the property. * @param value the value to set. */ - public operator fun setValue(thisRef: R, property: KProperty<*>, value: T) + public operator fun setValue(thisRef: T, property: KProperty<*>, value: V) } /** diff --git a/libraries/stdlib/src/kotlin/properties/ObservableProperty.kt b/libraries/stdlib/src/kotlin/properties/ObservableProperty.kt index 683a4042e98..ffa78099577 100644 --- a/libraries/stdlib/src/kotlin/properties/ObservableProperty.kt +++ b/libraries/stdlib/src/kotlin/properties/ObservableProperty.kt @@ -11,7 +11,7 @@ import kotlin.reflect.KProperty * Implements the core logic of a property delegate for a read/write property that calls callback functions when changed. * @param initialValue the initial value of the property. */ -public abstract class ObservableProperty(initialValue: T) : ReadWriteProperty { +public abstract class ObservableProperty(initialValue: V) : ReadWriteProperty { private var value = initialValue /** @@ -20,19 +20,19 @@ public abstract class ObservableProperty(initialValue: T) : ReadWriteProperty * If the callback returns `true` the value of the property is being set to the new value, * and if the callback returns `false` the new value is discarded and the property remains its old value. */ - protected open fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean = true + protected open fun beforeChange(property: KProperty<*>, oldValue: V, newValue: V): Boolean = true /** * The callback which is called after the change of the property is made. The value of the property * has already been changed when this callback is invoked. */ - protected open fun afterChange(property: KProperty<*>, oldValue: T, newValue: T): Unit {} + protected open fun afterChange(property: KProperty<*>, oldValue: V, newValue: V): Unit {} - public override fun getValue(thisRef: Any?, property: KProperty<*>): T { + public override fun getValue(thisRef: Any?, property: KProperty<*>): V { return value } - public override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { + public override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) { val oldValue = this.value if (!beforeChange(property, oldValue, value)) { return diff --git a/libraries/stdlib/src/kotlin/reflect/KProperty.kt b/libraries/stdlib/src/kotlin/reflect/KProperty.kt index 04d4c91a4d1..4c932c3518f 100644 --- a/libraries/stdlib/src/kotlin/reflect/KProperty.kt +++ b/libraries/stdlib/src/kotlin/reflect/KProperty.kt @@ -13,15 +13,15 @@ package kotlin.reflect * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html) * for more information. * - * @param R the type of the property. + * @param V the type of the property value. */ -public expect interface KProperty : KCallable { +public expect interface KProperty : KCallable { } /** * Represents a property declared as a `var`. */ -public expect interface KMutableProperty : KProperty { +public expect interface KMutableProperty : KProperty { } @@ -30,23 +30,23 @@ public expect interface KMutableProperty : KProperty { * Such property is either originally declared in a receiverless context such as a package, * or has the receiver bound to it. */ -public expect interface KProperty0 : KProperty, () -> R { +public expect interface KProperty0 : KProperty, () -> V { /** * Returns the current value of the property. */ - public fun get(): R + public fun get(): V } /** * Represents a `var`-property without any kind of receiver. */ -public expect interface KMutableProperty0 : KProperty0, KMutableProperty { +public expect interface KMutableProperty0 : KProperty0, KMutableProperty { /** * Modifies the value of the property. * * @param value the new value to be assigned to this property. */ - public fun set(value: R) + public fun set(value: V) } @@ -54,9 +54,9 @@ public expect interface KMutableProperty0 : KProperty0, KMutableProperty : KProperty, (T) -> R { +public expect interface KProperty1 : KProperty, (T) -> V { /** * Returns the current value of the property. * @@ -64,13 +64,13 @@ public expect interface KProperty1 : KProperty, (T) -> R { * For example, it should be a class instance if this is a member property of that class, * or an extension receiver if this is a top level extension property. */ - public fun get(receiver: T): R + public fun get(receiver: T): V } /** * Represents a `var`-property, operations on which take one receiver as a parameter. */ -public expect interface KMutableProperty1 : KProperty1, KMutableProperty { +public expect interface KMutableProperty1 : KProperty1, KMutableProperty { /** * Modifies the value of the property. * @@ -79,7 +79,7 @@ public expect interface KMutableProperty1 : KProperty1, KMutableProp * or an extension receiver if this is a top level extension property. * @param value the new value to be assigned to this property. */ - public fun set(receiver: T, value: R) + public fun set(receiver: T, value: V) } @@ -91,9 +91,9 @@ public expect interface KMutableProperty1 : KProperty1, KMutableProp * the type of the declaring class of the property, or any subclass of that class. * @param E the type of the second receiver. In case of the extension property in a class this is * the type of the extension receiver. - * @param R the type of the property. + * @param V the type of the property value. */ -public expect interface KProperty2 : KProperty, (D, E) -> R { +public expect interface KProperty2 : KProperty, (D, E) -> V { /** * Returns the current value of the property. In case of the extension property in a class, * the instance of the class should be passed first and the instance of the extension receiver second. @@ -101,13 +101,13 @@ public expect interface KProperty2 : KProperty, (D, E) -> R { * @param receiver1 the instance of the first receiver. * @param receiver2 the instance of the second receiver. */ - public fun get(receiver1: D, receiver2: E): R + public fun get(receiver1: D, receiver2: E): V } /** * Represents a `var`-property, operations on which take two receivers as parameters. */ -public expect interface KMutableProperty2 : KProperty2, KMutableProperty { +public expect interface KMutableProperty2 : KProperty2, KMutableProperty { /** * Modifies the value of the property. * @@ -115,5 +115,5 @@ public expect interface KMutableProperty2 : KProperty2, KMutab * @param receiver2 the instance of the second receiver. * @param value the new value to be assigned to this property. */ - public fun set(receiver1: D, receiver2: E, value: R) + public fun set(receiver1: D, receiver2: E, value: V) }