Introduce KProperty{1,2}.getExtensionDelegate

These two functions are supposed to fix an inconvenience in the design of
KProperty{1,2}.getDelegate for extension properties, where you have to pass an
instance of the extension receiver which is going to be completely ignored

 #KT-8384 Fixed
This commit is contained in:
Alexander Udalov
2017-01-18 18:15:24 +03:00
parent 78f2515e95
commit ebd577e52a
9 changed files with 154 additions and 0 deletions
@@ -145,6 +145,8 @@ public interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
* @param receiver the receiver which is used to obtain the value of the property delegate.
* 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]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver: T): Any?
@@ -204,6 +206,8 @@ 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]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver1: D, receiver2: E): Any?