Improve KPropertyN documentation

Provide missing documentation for Getter and Setter of KProperty1/2.
Fix the link to the 'getExtensionDelegate' extension.
This commit is contained in:
Ilya Gorbunov
2018-02-20 18:27:35 +03:00
parent 07b811460a
commit 6955cabbba
+35 -2
View File
@@ -20,6 +20,7 @@ package kotlin.reflect
/**
* Represents a property, such as a named `val` or `var` declaration.
* Instances of this class are obtainable by the `::` operator.
*
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/reflection.html)
* for more information.
*
@@ -98,6 +99,11 @@ public interface KProperty0<out R> : KProperty<R>, () -> R {
override val getter: Getter<R>
/**
* 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].
*/
public interface Getter<out R> : KProperty.Getter<R>, () -> R
}
@@ -114,6 +120,11 @@ public interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
override val setter: Setter<R>
/**
* 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
}
@@ -146,13 +157,18 @@ public 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.
*
* @see [KProperty1.getExtensionDelegate]
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty1.getExtensionDelegate]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver: T): Any?
override val getter: Getter<T, R>
/**
* 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].
*/
public interface Getter<T, out R> : KProperty.Getter<R>, (T) -> R
}
@@ -172,6 +188,11 @@ public interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R>
override val setter: Setter<T, R>
/**
* 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
}
@@ -207,13 +228,19 @@ public 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.
*
* @see [KProperty2.getExtensionDelegate]
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty2.getExtensionDelegate]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver1: D, receiver2: E): Any?
override val getter: Getter<D, E, R>
/**
* 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].
*/
public interface Getter<D, E, out R> : KProperty.Getter<R>, (D, E) -> R
}
@@ -232,5 +259,11 @@ public interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutablePrope
override val setter: Setter<D, E, R>
/**
* Setter of the property is a `set` 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 the new property value and returns [Unit].
*/
public interface Setter<D, E, R> : KMutableProperty.Setter<R>, (D, E, R) -> Unit
}