KProperty and ReadOnlyProperty type parameter names #KT-16529
This commit is contained in:
@@ -21,7 +21,7 @@ import kotlin.LazyThreadSafetyMode.PUBLICATION
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
import kotlin.reflect.KProperty0
|
||||
|
||||
internal open class KProperty0Impl<out R> : KProperty0<R>, KPropertyImpl<R> {
|
||||
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(
|
||||
@@ -30,22 +30,22 @@ internal open class KProperty0Impl<out R> : KProperty0<R>, KPropertyImpl<R> {
|
||||
|
||||
private val _getter = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<R> get() = _getter()
|
||||
override val getter: Getter<V> 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<out R>(override val property: KProperty0Impl<R>) : KPropertyImpl.Getter<R>(), KProperty0.Getter<R> {
|
||||
override fun invoke(): R = property.get()
|
||||
}
|
||||
}
|
||||
|
||||
internal class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R> {
|
||||
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(
|
||||
@@ -54,9 +54,9 @@ internal class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R
|
||||
|
||||
private val _setter = ReflectProperties.lazy { Setter(this) }
|
||||
|
||||
override val setter: Setter<R> get() = _setter()
|
||||
override val setter: Setter<V> get() = _setter()
|
||||
|
||||
override fun set(value: R) = setter.call(value)
|
||||
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)
|
||||
|
||||
@@ -21,7 +21,7 @@ import kotlin.LazyThreadSafetyMode.PUBLICATION
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
internal open class KProperty1Impl<T, out R> : KProperty1<T, R>, KPropertyImpl<R> {
|
||||
internal open class KProperty1Impl<T, out V> : KProperty1<T, V>, KPropertyImpl<V> {
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
|
||||
container, name, signature, boundReceiver
|
||||
)
|
||||
@@ -30,22 +30,22 @@ internal open class KProperty1Impl<T, out R> : KProperty1<T, R>, KPropertyImpl<R
|
||||
|
||||
private val _getter = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<T, R> get() = _getter()
|
||||
override val getter: Getter<T, V> 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<T, out R>(override val property: KProperty1Impl<T, R>) : KPropertyImpl.Getter<R>(), KProperty1.Getter<T, R> {
|
||||
override fun invoke(receiver: T): R = property.get(receiver)
|
||||
class Getter<T, out V>(override val property: KProperty1Impl<T, V>) : KPropertyImpl.Getter<V>(), KProperty1.Getter<T, V> {
|
||||
override fun invoke(receiver: T): V = property.get(receiver)
|
||||
}
|
||||
}
|
||||
|
||||
internal class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1<T, R> {
|
||||
internal class KMutableProperty1Impl<T, V> : KProperty1Impl<T, V>, KMutableProperty1<T, V> {
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : super(
|
||||
container, name, signature, boundReceiver
|
||||
)
|
||||
@@ -54,11 +54,11 @@ internal class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutablePrope
|
||||
|
||||
private val _setter = ReflectProperties.lazy { Setter(this) }
|
||||
|
||||
override val setter: Setter<T, R> get() = _setter()
|
||||
override val setter: Setter<T, V> 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<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)
|
||||
class Setter<T, V>(override val property: KMutableProperty1Impl<T, V>) : KPropertyImpl.Setter<V>(), KMutableProperty1.Setter<T, V> {
|
||||
override fun invoke(receiver: T, value: V): Unit = property.set(receiver, value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.jvm.internal.CallableReference
|
||||
import kotlin.reflect.KMutableProperty2
|
||||
import kotlin.reflect.KProperty2
|
||||
|
||||
internal open class KProperty2Impl<D, E, out R> : KProperty2<D, E, R>, KPropertyImpl<R> {
|
||||
internal open class KProperty2Impl<D, E, out V> : KProperty2<D, E, V>, KPropertyImpl<V> {
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(
|
||||
container, name, signature, CallableReference.NO_RECEIVER
|
||||
)
|
||||
@@ -31,34 +31,34 @@ internal open class KProperty2Impl<D, E, out R> : KProperty2<D, E, R>, KProperty
|
||||
|
||||
private val _getter = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<D, E, R> get() = _getter()
|
||||
override val getter: Getter<D, E, V> 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<D, E, out R>(override val property: KProperty2Impl<D, E, R>) : KPropertyImpl.Getter<R>(), KProperty2.Getter<D, E, R> {
|
||||
override fun invoke(receiver1: D, receiver2: E): R = property.get(receiver1, receiver2)
|
||||
class Getter<D, E, out V>(override val property: KProperty2Impl<D, E, V>) : KPropertyImpl.Getter<V>(), KProperty2.Getter<D, E, V> {
|
||||
override fun invoke(receiver1: D, receiver2: E): V = property.get(receiver1, receiver2)
|
||||
}
|
||||
}
|
||||
|
||||
internal class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KMutableProperty2<D, E, R> {
|
||||
internal class KMutableProperty2Impl<D, E, V> : KProperty2Impl<D, E, V>, KMutableProperty2<D, E, V> {
|
||||
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<D, E, R> get() = _setter()
|
||||
override val setter: Setter<D, E, V> 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<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)
|
||||
class Setter<D, E, V>(override val property: KMutableProperty2Impl<D, E, V>) : KPropertyImpl.Setter<V>(),
|
||||
KMutableProperty2.Setter<D, E, V> {
|
||||
override fun invoke(receiver1: D, receiver2: E, value: V): Unit = property.set(receiver1, receiver2, value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<out R> private constructor(
|
||||
internal abstract class KPropertyImpl<out V> private constructor(
|
||||
override val container: KDeclarationContainerImpl,
|
||||
override val name: String,
|
||||
val signature: String,
|
||||
descriptorInitialValue: PropertyDescriptor?,
|
||||
private val rawBoundReceiver: Any?
|
||||
) : KCallableImpl<R>(), KProperty<R> {
|
||||
) : KCallableImpl<V>(), KProperty<V> {
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String, boundReceiver: Any?) : this(
|
||||
container, name, signature, null, boundReceiver
|
||||
)
|
||||
@@ -96,7 +96,7 @@ internal abstract class KPropertyImpl<out R> private constructor(
|
||||
throw IllegalPropertyDelegateAccessException(e)
|
||||
}
|
||||
|
||||
abstract override val getter: Getter<R>
|
||||
abstract override val getter: Getter<V>
|
||||
|
||||
private val _descriptor = ReflectProperties.lazySoft(descriptorInitialValue) {
|
||||
container.findPropertyDescriptor(name, signature)
|
||||
@@ -144,7 +144,7 @@ internal abstract class KPropertyImpl<out R> private constructor(
|
||||
override val isSuspend: Boolean get() = descriptor.isSuspend
|
||||
}
|
||||
|
||||
abstract class Getter<out R> : Accessor<R, R>(), KProperty.Getter<R> {
|
||||
abstract class Getter<out V> : Accessor<V, V>(), KProperty.Getter<V> {
|
||||
override val name: String get() = "<get-${property.name}>"
|
||||
|
||||
override val descriptor: PropertyGetterDescriptor by ReflectProperties.lazySoft {
|
||||
@@ -157,7 +157,7 @@ internal abstract class KPropertyImpl<out R> private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Setter<R> : Accessor<R, Unit>(), KMutableProperty.Setter<R> {
|
||||
abstract class Setter<V> : Accessor<V, Unit>(), KMutableProperty.Setter<V> {
|
||||
override val name: String get() = "<set-${property.name}>"
|
||||
|
||||
override val descriptor: PropertySetterDescriptor by ReflectProperties.lazySoft {
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ import kotlin.properties.*
|
||||
|
||||
fun f(readonlypr<caret>)
|
||||
|
||||
// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: "<R, T> (kotlin.properties)" }
|
||||
// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: "<T, V> (kotlin.properties)" }
|
||||
// NUMBER: 1
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fun f(read<caret>)
|
||||
|
||||
// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: "<R, T> (kotlin.properties)" }
|
||||
// EXIST: { itemText: "readOnlyProperty: ReadOnlyProperty", tailText: "<T, V> (kotlin.properties)" }
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ fun firstFun() {
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 1
|
||||
// EXIST: { lookupString:"KProperty", itemText:"KProperty", tailText:"<R> (kotlin.reflect)" }
|
||||
// EXIST: { lookupString:"KProperty", itemText:"KProperty", tailText:"<V> (kotlin.reflect)" }
|
||||
|
||||
+2
-2
@@ -5,5 +5,5 @@ import kotlin.properties.Delegates
|
||||
var x: Int <caret>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)
|
||||
|
||||
@@ -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<out R> : KCallable<R>
|
||||
public actual interface KProperty<out V> : KCallable<V>
|
||||
|
||||
/**
|
||||
* Represents a property declared as a `var`.
|
||||
*/
|
||||
public actual interface KMutableProperty<R> : KProperty<R>
|
||||
public actual interface KMutableProperty<V> : KProperty<V>
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,23 +28,23 @@ public actual interface KMutableProperty<R> : KProperty<R>
|
||||
* 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<out R> : KProperty<R>, () -> R {
|
||||
public actual interface KProperty0<out V> : KProperty<V>, () -> 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<R> : KProperty0<R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V> {
|
||||
/**
|
||||
* 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<R> : KProperty0<R>, KMutableProperty<R
|
||||
* Represents a property, operations on which take one receiver as a parameter.
|
||||
*
|
||||
* @param T the type of the receiver which should be used to obtain the value of the property.
|
||||
* @param R the type of the property.
|
||||
* @param V the type of the property value.
|
||||
*/
|
||||
public actual interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
||||
public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
*
|
||||
@@ -62,13 +62,13 @@ public actual interface KProperty1<T, out R> : KProperty<R>, (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<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -77,7 +77,7 @@ public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, 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<T, R> : KProperty1<T, R>, 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<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||
public actual interface KProperty2<D, E, out V> : KProperty<V>, (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<D, E, out R> : KProperty<R>, (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<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -113,5 +113,5 @@ public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, 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)
|
||||
}
|
||||
|
||||
@@ -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<out R> : KCallable<R> {
|
||||
public actual interface KProperty<out V> : KCallable<V> {
|
||||
/**
|
||||
* `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<out R> : KCallable<R> {
|
||||
public val isConst: Boolean
|
||||
|
||||
/** The getter of this property, used to obtain the value of the property. */
|
||||
public val getter: Getter<R>
|
||||
public val getter: Getter<V>
|
||||
|
||||
/**
|
||||
* 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<out R> {
|
||||
public interface Accessor<out V> {
|
||||
/** The property which this accessor is originated from. */
|
||||
public val property: KProperty<R>
|
||||
public val property: KProperty<V>
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of the property is a `get` method declared alongside the property.
|
||||
*/
|
||||
public interface Getter<out R> : Accessor<R>, KFunction<R>
|
||||
public interface Getter<out V> : Accessor<V>, KFunction<V>
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a property declared as a `var`.
|
||||
*/
|
||||
public actual interface KMutableProperty<R> : KProperty<R> {
|
||||
public actual interface KMutableProperty<V> : KProperty<V> {
|
||||
/** The setter of this mutable property, used to change the value of the property. */
|
||||
public val setter: Setter<R>
|
||||
public val setter: Setter<V>
|
||||
|
||||
/**
|
||||
* Setter of the property is a `set` method declared alongside the property.
|
||||
*/
|
||||
public interface Setter<R> : KProperty.Accessor<R>, KFunction<Unit>
|
||||
public interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit>
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ public actual interface KMutableProperty<R> : KProperty<R> {
|
||||
* 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<out R> : KProperty<R>, () -> R {
|
||||
public actual interface KProperty0<out V> : KProperty<V>, () -> 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<out R> : KProperty<R>, () -> R {
|
||||
@SinceKotlin("1.1")
|
||||
public fun getDelegate(): Any?
|
||||
|
||||
override val getter: Getter<R>
|
||||
override val getter: Getter<V>
|
||||
|
||||
/**
|
||||
* 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<out R> : KProperty.Getter<R>, () -> R
|
||||
public interface Getter<out V> : KProperty.Getter<V>, () -> V
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a `var`-property without any kind of receiver.
|
||||
*/
|
||||
public actual interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V> {
|
||||
/**
|
||||
* 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<R>
|
||||
override val setter: Setter<V>
|
||||
|
||||
/**
|
||||
* 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<R> : KMutableProperty.Setter<R>, (R) -> Unit
|
||||
public interface Setter<V> : KMutableProperty.Setter<V>, (V) -> Unit
|
||||
}
|
||||
|
||||
|
||||
@@ -122,9 +122,9 @@ public actual interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R
|
||||
* Represents a property, operations on which take one receiver as a parameter.
|
||||
*
|
||||
* @param T the type of the receiver which should be used to obtain the value of the property.
|
||||
* @param R the type of the property.
|
||||
* @param V the type of the property value.
|
||||
*/
|
||||
public actual interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
||||
public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
*
|
||||
@@ -132,7 +132,7 @@ public actual interface KProperty1<T, out R> : KProperty<R>, (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<T, out R> : KProperty<R>, (T) -> R {
|
||||
@SinceKotlin("1.1")
|
||||
public fun getDelegate(receiver: T): Any?
|
||||
|
||||
override val getter: Getter<T, R>
|
||||
override val getter: Getter<T, V>
|
||||
|
||||
/**
|
||||
* 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<T, out R> : KProperty.Getter<R>, (T) -> R
|
||||
public interface Getter<T, out V> : KProperty.Getter<V>, (T) -> V
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a `var`-property, operations on which take one receiver as a parameter.
|
||||
*/
|
||||
public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -173,16 +173,16 @@ public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, 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<T, R>
|
||||
override val setter: Setter<T, V>
|
||||
|
||||
/**
|
||||
* 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<T, R> : KMutableProperty.Setter<R>, (T, R) -> Unit
|
||||
public interface Setter<T, V> : KMutableProperty.Setter<V>, (T, V) -> Unit
|
||||
}
|
||||
|
||||
|
||||
@@ -194,9 +194,9 @@ public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, 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<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||
public actual interface KProperty2<D, E, out V> : KProperty<V>, (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<D, E, out R> : KProperty<R>, (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<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||
@SinceKotlin("1.1")
|
||||
public fun getDelegate(receiver1: D, receiver2: E): Any?
|
||||
|
||||
override val getter: Getter<D, E, R>
|
||||
override val getter: Getter<D, E, V>
|
||||
|
||||
/**
|
||||
* 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<D, E, out R> : KProperty.Getter<R>, (D, E) -> R
|
||||
public interface Getter<D, E, out V> : KProperty.Getter<V>, (D, E) -> V
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a `var`-property, operations on which take two receivers as parameters.
|
||||
*/
|
||||
public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
|
||||
public actual interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -244,9 +244,9 @@ public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, 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<D, E, R>
|
||||
override val setter: Setter<D, E, V>
|
||||
|
||||
/**
|
||||
* Setter of the property is a `set` method declared alongside the property.
|
||||
@@ -254,5 +254,5 @@ public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, 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<D, E, R> : KMutableProperty.Setter<R>, (D, E, R) -> Unit
|
||||
public interface Setter<D, E, V> : KMutableProperty.Setter<V>, (D, E, V) -> Unit
|
||||
}
|
||||
|
||||
@@ -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<in R, out T> {
|
||||
public interface ReadOnlyProperty<in T, out V> {
|
||||
/**
|
||||
* 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<in R, out T> {
|
||||
* 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<in R, T> {
|
||||
public interface ReadWriteProperty<in T, V> {
|
||||
/**
|
||||
* 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<in R, T> {
|
||||
* @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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<T>(initialValue: T) : ReadWriteProperty<Any?, T> {
|
||||
public abstract class ObservableProperty<V>(initialValue: V) : ReadWriteProperty<Any?, V> {
|
||||
private var value = initialValue
|
||||
|
||||
/**
|
||||
@@ -20,19 +20,19 @@ public abstract class ObservableProperty<T>(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
|
||||
|
||||
@@ -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<out R> : KCallable<R> {
|
||||
public expect interface KProperty<out V> : KCallable<V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a property declared as a `var`.
|
||||
*/
|
||||
public expect interface KMutableProperty<R> : KProperty<R> {
|
||||
public expect interface KMutableProperty<V> : KProperty<V> {
|
||||
}
|
||||
|
||||
|
||||
@@ -30,23 +30,23 @@ public expect interface KMutableProperty<R> : KProperty<R> {
|
||||
* 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<out R> : KProperty<R>, () -> R {
|
||||
public expect interface KProperty0<out V> : KProperty<V>, () -> 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<R> : KProperty0<R>, KMutableProperty<R> {
|
||||
public expect interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V> {
|
||||
/**
|
||||
* 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<R> : KProperty0<R>, KMutableProperty<R
|
||||
* Represents a property, operations on which take one receiver as a parameter.
|
||||
*
|
||||
* @param T the type of the receiver which should be used to obtain the value of the property.
|
||||
* @param R the type of the property.
|
||||
* @param V the type of the property value.
|
||||
*/
|
||||
public expect interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
||||
public expect interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
*
|
||||
@@ -64,13 +64,13 @@ public expect interface KProperty1<T, out R> : KProperty<R>, (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<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
||||
public expect interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -79,7 +79,7 @@ public expect interface KMutableProperty1<T, R> : KProperty1<T, R>, 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<T, R> : KProperty1<T, R>, 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<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||
public expect interface KProperty2<D, E, out V> : KProperty<V>, (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<D, E, out R> : KProperty<R>, (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<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
|
||||
public expect interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
*
|
||||
@@ -115,5 +115,5 @@ public expect interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user