Introduce common KCallable and K(Mutable)Property(ø,0,1,2) interfaces
#KT-25935
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
* that can be found in the license/LICENSE.txt file.
|
* that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("ACTUAL_WITHOUT_EXPECT") // for building kotlin-runtime
|
||||||
package kotlin.reflect
|
package kotlin.reflect
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +11,7 @@ package kotlin.reflect
|
|||||||
*
|
*
|
||||||
* @param R return type of the callable.
|
* @param R return type of the callable.
|
||||||
*/
|
*/
|
||||||
public interface KCallable<out R> : KAnnotatedElement {
|
public actual interface KCallable<out R> : KAnnotatedElement {
|
||||||
/**
|
/**
|
||||||
* The name of this callable as it was declared in the source code.
|
* The name of this callable as it was declared in the source code.
|
||||||
* If the callable has no name, a special invented name is created.
|
* If the callable has no name, a special invented name is created.
|
||||||
@@ -19,7 +20,7 @@ public interface KCallable<out R> : KAnnotatedElement {
|
|||||||
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
|
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
|
||||||
* the setter, similarly, will have the name "<set-foo>".
|
* the setter, similarly, will have the name "<set-foo>".
|
||||||
*/
|
*/
|
||||||
public val name: String
|
public actual val name: String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters required to make a call to this callable.
|
* Parameters required to make a call to this callable.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE")
|
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE", /* for building kotlin-runtime */ "ACTUAL_WITHOUT_EXPECT")
|
||||||
package kotlin.reflect
|
package kotlin.reflect
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +26,7 @@ package kotlin.reflect
|
|||||||
*
|
*
|
||||||
* @param R the type of the property.
|
* @param R the type of the property.
|
||||||
*/
|
*/
|
||||||
public interface KProperty<out R> : KCallable<R> {
|
public actual interface KProperty<out R> : KCallable<R> {
|
||||||
/**
|
/**
|
||||||
* `true` if this property is `lateinit`.
|
* `true` if this property is `lateinit`.
|
||||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
|
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
|
||||||
@@ -67,7 +67,7 @@ public interface KProperty<out R> : KCallable<R> {
|
|||||||
/**
|
/**
|
||||||
* Represents a property declared as a `var`.
|
* Represents a property declared as a `var`.
|
||||||
*/
|
*/
|
||||||
public interface KMutableProperty<R> : KProperty<R> {
|
public actual interface KMutableProperty<R> : KProperty<R> {
|
||||||
/** The setter of this mutable property, used to change the value of the property. */
|
/** The setter of this mutable property, used to change the value of the property. */
|
||||||
public val setter: Setter<R>
|
public val setter: Setter<R>
|
||||||
|
|
||||||
@@ -83,11 +83,11 @@ public interface KMutableProperty<R> : KProperty<R> {
|
|||||||
* Such property is either originally declared in a receiverless context such as a package,
|
* Such property is either originally declared in a receiverless context such as a package,
|
||||||
* or has the receiver bound to it.
|
* or has the receiver bound to it.
|
||||||
*/
|
*/
|
||||||
public interface KProperty0<out R> : KProperty<R>, () -> R {
|
public actual interface KProperty0<out R> : KProperty<R>, () -> R {
|
||||||
/**
|
/**
|
||||||
* Returns the current value of the property.
|
* Returns the current value of the property.
|
||||||
*/
|
*/
|
||||||
public fun get(): R
|
public actual fun get(): R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
||||||
@@ -110,13 +110,13 @@ public interface KProperty0<out R> : KProperty<R>, () -> R {
|
|||||||
/**
|
/**
|
||||||
* Represents a `var`-property without any kind of receiver.
|
* Represents a `var`-property without any kind of receiver.
|
||||||
*/
|
*/
|
||||||
public interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
|
public actual interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
|
||||||
/**
|
/**
|
||||||
* Modifies the value of the property.
|
* Modifies the value of the property.
|
||||||
*
|
*
|
||||||
* @param value the new value to be assigned to this property.
|
* @param value the new value to be assigned to this property.
|
||||||
*/
|
*/
|
||||||
public fun set(value: R)
|
public actual fun set(value: R)
|
||||||
|
|
||||||
override val setter: Setter<R>
|
override val setter: Setter<R>
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
|
|||||||
* @param T the type of the receiver which should be used to obtain the value of the property.
|
* @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 R the type of the property.
|
||||||
*/
|
*/
|
||||||
public interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
public actual interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
||||||
/**
|
/**
|
||||||
* Returns the current value of the property.
|
* Returns the current value of the property.
|
||||||
*
|
*
|
||||||
@@ -143,7 +143,7 @@ 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,
|
* 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.
|
* or an extension receiver if this is a top level extension property.
|
||||||
*/
|
*/
|
||||||
public fun get(receiver: T): R
|
public actual fun get(receiver: T): R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
||||||
@@ -175,7 +175,7 @@ public interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
|||||||
/**
|
/**
|
||||||
* Represents a `var`-property, operations on which take one receiver as a parameter.
|
* Represents a `var`-property, operations on which take one receiver as a parameter.
|
||||||
*/
|
*/
|
||||||
public interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
||||||
/**
|
/**
|
||||||
* Modifies the value of the property.
|
* Modifies the value of the property.
|
||||||
*
|
*
|
||||||
@@ -184,7 +184,7 @@ public interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R>
|
|||||||
* or an extension receiver if this is a top level extension property.
|
* or an extension receiver if this is a top level extension property.
|
||||||
* @param value the new value to be assigned to this property.
|
* @param value the new value to be assigned to this property.
|
||||||
*/
|
*/
|
||||||
public fun set(receiver: T, value: R)
|
public actual fun set(receiver: T, value: R)
|
||||||
|
|
||||||
override val setter: Setter<T, R>
|
override val setter: Setter<T, R>
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ public interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R>
|
|||||||
* the type of the extension receiver.
|
* the type of the extension receiver.
|
||||||
* @param R the type of the property.
|
* @param R the type of the property.
|
||||||
*/
|
*/
|
||||||
public interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
|
public actual interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||||
/**
|
/**
|
||||||
* Returns the current value of the property. In case of the extension property in a class,
|
* 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.
|
* the instance of the class should be passed first and the instance of the extension receiver second.
|
||||||
@@ -215,7 +215,7 @@ public interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
|
|||||||
* @param receiver1 the instance of the first receiver.
|
* @param receiver1 the instance of the first receiver.
|
||||||
* @param receiver2 the instance of the second receiver.
|
* @param receiver2 the instance of the second receiver.
|
||||||
*/
|
*/
|
||||||
public fun get(receiver1: D, receiver2: E): R
|
public actual fun get(receiver1: D, receiver2: E): R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
|
||||||
@@ -247,7 +247,7 @@ public interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
|
|||||||
/**
|
/**
|
||||||
* Represents a `var`-property, operations on which take two receivers as parameters.
|
* Represents a `var`-property, operations on which take two receivers as parameters.
|
||||||
*/
|
*/
|
||||||
public interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
|
public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
|
||||||
/**
|
/**
|
||||||
* Modifies the value of the property.
|
* Modifies the value of the property.
|
||||||
*
|
*
|
||||||
@@ -255,7 +255,7 @@ public interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutablePrope
|
|||||||
* @param receiver2 the instance of the second receiver.
|
* @param receiver2 the instance of the second receiver.
|
||||||
* @param value the new value to be assigned to this property.
|
* @param value the new value to be assigned to this property.
|
||||||
*/
|
*/
|
||||||
public fun set(receiver1: D, receiver2: E, value: R)
|
public actual fun set(receiver1: D, receiver2: E, value: R)
|
||||||
|
|
||||||
override val setter: Setter<D, E, R>
|
override val setter: Setter<D, E, R>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.reflect
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a callable entity, such as a function or a property.
|
||||||
|
*
|
||||||
|
* @param R return type of the callable.
|
||||||
|
*/
|
||||||
|
public expect interface KCallable<out R> {
|
||||||
|
/**
|
||||||
|
* The name of this callable as it was declared in the source code.
|
||||||
|
* If the callable has no name, a special invented name is created.
|
||||||
|
* Nameless callables include:
|
||||||
|
* - constructors have the name "<init>",
|
||||||
|
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
|
||||||
|
* the setter, similarly, will have the name "<set-foo>".
|
||||||
|
*/
|
||||||
|
public val name: String
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE")
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @param R the type of the property.
|
||||||
|
*/
|
||||||
|
public expect interface KProperty<out R> : KCallable<R> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a property declared as a `var`.
|
||||||
|
*/
|
||||||
|
public expect interface KMutableProperty<R> : KProperty<R> {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a property without any kind of receiver.
|
||||||
|
* 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 {
|
||||||
|
/**
|
||||||
|
* Returns the current value of the property.
|
||||||
|
*/
|
||||||
|
public fun get(): R
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a `var`-property without any kind of receiver.
|
||||||
|
*/
|
||||||
|
public expect interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
|
||||||
|
/**
|
||||||
|
* Modifies the value of the property.
|
||||||
|
*
|
||||||
|
* @param value the new value to be assigned to this property.
|
||||||
|
*/
|
||||||
|
public fun set(value: 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.
|
||||||
|
*/
|
||||||
|
public expect interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
|
||||||
|
/**
|
||||||
|
* Returns the current value of the property.
|
||||||
|
*
|
||||||
|
* @param receiver the receiver which is used to obtain the value of the property.
|
||||||
|
* 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
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a `var`-property, operations on which take one receiver as a parameter.
|
||||||
|
*/
|
||||||
|
public expect interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
|
||||||
|
/**
|
||||||
|
* Modifies the value of the property.
|
||||||
|
*
|
||||||
|
* @param receiver the receiver which is used to modify the value of the property.
|
||||||
|
* 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.
|
||||||
|
* @param value the new value to be assigned to this property.
|
||||||
|
*/
|
||||||
|
public fun set(receiver: T, value: R)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a property, operations on which take two receivers as parameters,
|
||||||
|
* such as an extension property declared in a class.
|
||||||
|
*
|
||||||
|
* @param D the type of the first receiver. In case of the extension property in a class this is
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public expect interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @param receiver1 the instance of the first receiver.
|
||||||
|
* @param receiver2 the instance of the second receiver.
|
||||||
|
*/
|
||||||
|
public fun get(receiver1: D, receiver2: E): R
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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> {
|
||||||
|
/**
|
||||||
|
* Modifies the value of the property.
|
||||||
|
*
|
||||||
|
* @param receiver1 the instance of the first receiver.
|
||||||
|
* @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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user