Do not serialize JVM kotlin.reflect to builtins
Serialize common types from kotlin-reflect as builtins instead.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 an annotated element and allows to obtain its annotations.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/annotations.html)
|
||||
* for more information.
|
||||
*/
|
||||
public interface KAnnotatedElement {
|
||||
/**
|
||||
* Annotations which are present on this element.
|
||||
*/
|
||||
public val annotations: List<Annotation>
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 actual interface KCallable<out R> : KAnnotatedElement {
|
||||
/**
|
||||
* 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 actual val name: String
|
||||
|
||||
/**
|
||||
* Parameters required to make a call to this callable.
|
||||
* If this callable requires a `this` instance or an extension receiver parameter,
|
||||
* they come first in the list in that order.
|
||||
*/
|
||||
public val parameters: List<KParameter>
|
||||
|
||||
/**
|
||||
* The type of values returned by this callable.
|
||||
*/
|
||||
public val returnType: KType
|
||||
|
||||
/**
|
||||
* The list of type parameters of this callable.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val typeParameters: List<KTypeParameter>
|
||||
|
||||
/**
|
||||
* Calls this callable with the specified list of arguments and returns the result.
|
||||
* Throws an exception if the number of specified arguments is not equal to the size of [parameters],
|
||||
* or if their types do not match the types of the parameters.
|
||||
*/
|
||||
public fun call(vararg args: Any?): R
|
||||
|
||||
/**
|
||||
* Calls this callable with the specified mapping of parameters to arguments and returns the result.
|
||||
* If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
|
||||
* or its type does not match the type of the provided value, an exception is thrown.
|
||||
*/
|
||||
public fun callBy(args: Map<KParameter, Any?>): R
|
||||
|
||||
/**
|
||||
* Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val visibility: KVisibility?
|
||||
|
||||
/**
|
||||
* `true` if this callable is `final`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isFinal: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this callable is `open`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isOpen: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this callable is `abstract`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isAbstract: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this is a suspending function.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public val isSuspend: Boolean
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 class and provides introspection capabilities.
|
||||
* Instances of this class are obtainable by the `::class` syntax.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html#class-references)
|
||||
* for more information.
|
||||
*
|
||||
* @param T the type of the class.
|
||||
*/
|
||||
public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier {
|
||||
/**
|
||||
* The simple name of the class as it was declared in the source code,
|
||||
* or `null` if the class has no name (if, for example, it is an anonymous object literal).
|
||||
*/
|
||||
public actual val simpleName: String?
|
||||
|
||||
/**
|
||||
* The fully qualified dot-separated name of the class,
|
||||
* or `null` if the class is local or it is an anonymous object literal.
|
||||
*/
|
||||
public val qualifiedName: String?
|
||||
|
||||
/**
|
||||
* All functions and properties accessible in this class, including those declared in this class
|
||||
* and all of its superclasses. Does not include constructors.
|
||||
*/
|
||||
override val members: Collection<KCallable<*>>
|
||||
|
||||
/**
|
||||
* All constructors declared in this class.
|
||||
*/
|
||||
public val constructors: Collection<KFunction<T>>
|
||||
|
||||
/**
|
||||
* All classes declared inside this class. This includes both inner and static nested classes.
|
||||
*/
|
||||
public val nestedClasses: Collection<KClass<*>>
|
||||
|
||||
/**
|
||||
* The instance of the object declaration, or `null` if this class is not an object declaration.
|
||||
*/
|
||||
public val objectInstance: T?
|
||||
|
||||
/**
|
||||
* Returns `true` if [value] is an instance of this class on a given platform.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun isInstance(value: Any?): Boolean
|
||||
|
||||
/**
|
||||
* The list of type parameters of this class. This list does *not* include type parameters of outer classes.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val typeParameters: List<KTypeParameter>
|
||||
|
||||
/**
|
||||
* The list of immediate supertypes of this class, in the order they are listed in the source code.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val supertypes: List<KType>
|
||||
|
||||
/**
|
||||
* The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public val sealedSubclasses: List<KClass<out T>>
|
||||
|
||||
/**
|
||||
* Visibility of this class, or `null` if its visibility cannot be represented in Kotlin.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val visibility: KVisibility?
|
||||
|
||||
/**
|
||||
* `true` if this class is `final`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isFinal: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is `open`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isOpen: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is `abstract`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isAbstract: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is `sealed`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/sealed-classes.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isSealed: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is a data class.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/data-classes.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isData: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is an inner class.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isInner: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this class is a companion object.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isCompanion: Boolean
|
||||
|
||||
/**
|
||||
* Returns `true` if this [KClass] instance represents the same Kotlin class as the class represented by [other].
|
||||
* On JVM this means that all of the following conditions are satisfied:
|
||||
*
|
||||
* 1. [other] has the same (fully qualified) Kotlin class name as this instance.
|
||||
* 2. [other]'s backing [Class] object is loaded with the same class loader as the [Class] object of this instance.
|
||||
* 3. If the classes represent [Array], then [Class] objects of their element types are equal.
|
||||
*
|
||||
* For example, on JVM, [KClass] instances for a primitive type (`int`) and the corresponding wrapper type (`java.lang.Integer`)
|
||||
* are considered equal, because they have the same fully qualified name "kotlin.Int".
|
||||
*/
|
||||
override fun equals(other: Any?): Boolean
|
||||
|
||||
override fun hashCode(): Int
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* A classifier is either a class or a type parameter.
|
||||
*
|
||||
* @see [KClass]
|
||||
* @see [KTypeParameter]
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public interface KClassifier
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* Represents an entity which may contain declarations of any other entities,
|
||||
* such as a class or a package.
|
||||
*/
|
||||
public interface KDeclarationContainer {
|
||||
/**
|
||||
* All functions and properties accessible in this container.
|
||||
*/
|
||||
public val members: Collection<KCallable<*>>
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 function with introspection capabilities.
|
||||
*/
|
||||
public interface KFunction<out R> : KCallable<R>, Function<R> {
|
||||
/**
|
||||
* `true` if this function is `inline`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/inline-functions.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isInline: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this function is `external`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/java-interop.html#using-jni-with-kotlin)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isExternal: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this function is `operator`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/operator-overloading.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isOperator: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this function is `infix`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/functions.html#infix-notation)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isInfix: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this is a suspending function.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public override val isSuspend: Boolean
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* Represents a parameter passed to a function or a property getter/setter,
|
||||
* including `this` and extension receiver parameters.
|
||||
*/
|
||||
public interface KParameter : KAnnotatedElement {
|
||||
/**
|
||||
* 0-based index of this parameter in the parameter list of its containing callable.
|
||||
*/
|
||||
public val index: Int
|
||||
|
||||
/**
|
||||
* Name of this parameter as it was declared in the source code,
|
||||
* or `null` if the parameter has no name or its name is not available at runtime.
|
||||
* Examples of nameless parameters include `this` instance for member functions,
|
||||
* extension receiver for extension functions or properties, parameters of Java methods
|
||||
* compiled without the debug information, and others.
|
||||
*/
|
||||
public val name: String?
|
||||
|
||||
/**
|
||||
* Type of this parameter. For a `vararg` parameter, this is the type of the corresponding array,
|
||||
* not the individual element.
|
||||
*/
|
||||
public val type: KType
|
||||
|
||||
/**
|
||||
* Kind of this parameter.
|
||||
*/
|
||||
public val kind: Kind
|
||||
|
||||
/**
|
||||
* Kind represents a particular position of the parameter declaration in the source code,
|
||||
* such as an instance, an extension receiver parameter or a value parameter.
|
||||
*/
|
||||
public enum class Kind {
|
||||
/** Instance required to make a call to the member, or an outer class instance for an inner class constructor. */
|
||||
INSTANCE,
|
||||
|
||||
/** Extension receiver of an extension function or property. */
|
||||
EXTENSION_RECEIVER,
|
||||
|
||||
/** Ordinary named value parameter. */
|
||||
VALUE,
|
||||
}
|
||||
|
||||
/**
|
||||
* `true` if this parameter is optional and can be omitted when making a call via [KCallable.callBy], or `false` otherwise.
|
||||
*
|
||||
* A parameter is optional in any of the two cases:
|
||||
* 1. The default value is provided at the declaration of this parameter.
|
||||
* 2. The parameter is declared in a member function and one of the corresponding parameters in the super functions is optional.
|
||||
*/
|
||||
public val isOptional: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this parameter is `vararg`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/functions.html#variable-number-of-arguments-varargs)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isVararg: Boolean
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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](https://kotlinlang.org/docs/reference/reflection.html)
|
||||
* for more information.
|
||||
*
|
||||
* @param R the type of the property.
|
||||
*/
|
||||
public actual interface KProperty<out R> : KCallable<R> {
|
||||
/**
|
||||
* `true` if this property is `lateinit`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isLateinit: Boolean
|
||||
|
||||
/**
|
||||
* `true` if this property is `const`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#compile-time-constants)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val isConst: Boolean
|
||||
|
||||
/** The getter of this property, used to obtain the value of the property. */
|
||||
public val getter: Getter<R>
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public interface Accessor<out R> {
|
||||
/** The property which this accessor is originated from. */
|
||||
public val property: KProperty<R>
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of the property is a `get` method declared alongside the property.
|
||||
*/
|
||||
public interface Getter<out R> : Accessor<R>, KFunction<R>
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a property declared as a `var`.
|
||||
*/
|
||||
public actual interface KMutableProperty<R> : KProperty<R> {
|
||||
/** The setter of this mutable property, used to change the value of the property. */
|
||||
public val setter: Setter<R>
|
||||
|
||||
/**
|
||||
* Setter of the property is a `set` method declared alongside the property.
|
||||
*/
|
||||
public interface Setter<R> : KProperty.Accessor<R>, KFunction<Unit>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 actual interface KProperty0<out R> : KProperty<R>, () -> R {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
*/
|
||||
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.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun getDelegate(): Any?
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a `var`-property without any kind of receiver.
|
||||
*/
|
||||
public actual 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 actual fun set(value: 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
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 actual 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 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.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
|
||||
* for more information.
|
||||
*
|
||||
* Note that for a top level **extension** property, the delegate is the same for all extension receivers,
|
||||
* so the actual [receiver] instance passed in is not going to make any difference, it must only be a value of [T].
|
||||
*
|
||||
* @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 [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
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a `var`-property, operations on which take one receiver as a parameter.
|
||||
*/
|
||||
public actual 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 actual fun set(receiver: T, value: 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
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 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,
|
||||
* 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 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.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
|
||||
* for more information.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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> {
|
||||
/**
|
||||
* 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 actual fun set(receiver1: D, receiver2: E, value: R)
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 type. Type is usually either a class with optional type arguments,
|
||||
* or a type parameter of some declaration, plus nullability.
|
||||
*/
|
||||
public interface KType : KAnnotatedElement {
|
||||
/**
|
||||
* The declaration of the classifier used in this type.
|
||||
* For example, in the type `List<String>` the classifier would be the [KClass] instance for [List].
|
||||
*
|
||||
* Returns `null` if this type is not denotable in Kotlin, for example if it is an intersection type.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val classifier: KClassifier?
|
||||
|
||||
/**
|
||||
* Type arguments passed for the parameters of the classifier in this type.
|
||||
* For example, in the type `Array<out Number>` the only type argument is `out Number`.
|
||||
*
|
||||
* In case this type is based on an inner class, the returned list contains the type arguments provided for the innermost class first,
|
||||
* then its outer class, and so on.
|
||||
* For example, in the type `Outer<A, B>.Inner<C, D>` the returned list is `[C, D, A, B]`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public val arguments: List<KTypeProjection>
|
||||
|
||||
/**
|
||||
* `true` if this type was marked nullable in the source code.
|
||||
*
|
||||
* For Kotlin types, it means that `null` value is allowed to be represented by this type.
|
||||
* In practice it means that the type was declared with a question mark at the end.
|
||||
* For non-Kotlin types, it means the type or the symbol which was declared with this type
|
||||
* is annotated with a runtime-retained nullability annotation such as [javax.annotation.Nullable].
|
||||
*
|
||||
* Note that even if [isMarkedNullable] is false, values of the type can still be `null`.
|
||||
* This may happen if it is a type of the type parameter with a nullable upper bound:
|
||||
*
|
||||
* ```
|
||||
* fun <T> foo(t: T) {
|
||||
* // isMarkedNullable == false for t's type, but t can be null here when T = "Any?"
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
public val isMarkedNullable: Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a type projection. Type projection is usually the argument to another type in a type usage.
|
||||
* For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`.
|
||||
*
|
||||
* Type projection is either the star projection, or an entity consisting of a specific type plus optional variance.
|
||||
*
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#type-projections)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public data class KTypeProjection constructor(
|
||||
/**
|
||||
* The use-site variance specified in the projection, or `null` if this is a star projection.
|
||||
*/
|
||||
public val variance: KVariance?,
|
||||
/**
|
||||
* The type specified in the projection, or `null` if this is a star projection.
|
||||
*/
|
||||
public val type: KType?
|
||||
) {
|
||||
public companion object {
|
||||
/**
|
||||
* Star projection, denoted by the `*` character.
|
||||
* For example, in the type `KClass<*>`, `*` is the star projection.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#star-projections)
|
||||
* for more information.
|
||||
*/
|
||||
public val STAR: KTypeProjection = KTypeProjection(null, null)
|
||||
|
||||
/**
|
||||
* Creates an invariant projection of a given type. Invariant projection is just the type itself,
|
||||
* without any use-site variance modifiers applied to it.
|
||||
* For example, in the type `Set<String>`, `String` is an invariant projection of the type represented by the class `String`.
|
||||
*/
|
||||
public fun invariant(type: KType): KTypeProjection =
|
||||
KTypeProjection(KVariance.INVARIANT, type)
|
||||
|
||||
/**
|
||||
* Creates a contravariant projection of a given type, denoted by the `in` modifier applied to a type.
|
||||
* For example, in the type `MutableList<in Number>`, `in Number` is a contravariant projection of the type of class `Number`.
|
||||
*/
|
||||
public fun contravariant(type: KType): KTypeProjection =
|
||||
KTypeProjection(KVariance.IN, type)
|
||||
|
||||
/**
|
||||
* Creates a covariant projection of a given type, denoted by the `out` modifier applied to a type.
|
||||
* For example, in the type `Array<out Number>`, `out Number` is a covariant projection of the type of class `Number`.
|
||||
*/
|
||||
public fun covariant(type: KType): KTypeProjection =
|
||||
KTypeProjection(KVariance.OUT, type)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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 declaration of a type parameter of a class or a callable.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#generics)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public interface KTypeParameter : KClassifier {
|
||||
/**
|
||||
* The name of this type parameter as it was declared in the source code.
|
||||
*/
|
||||
public val name: String
|
||||
|
||||
/**
|
||||
* Upper bounds, or generic constraints imposed on this type parameter.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#upper-bounds)
|
||||
* for more information.
|
||||
*/
|
||||
public val upperBounds: List<KType>
|
||||
|
||||
/**
|
||||
* Declaration-site variance of this type parameter.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#declaration-site-variance)
|
||||
* for more information.
|
||||
*/
|
||||
public val variance: KVariance
|
||||
|
||||
/**
|
||||
* `true` if this type parameter is `reified`.
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters)
|
||||
* for more information.
|
||||
*/
|
||||
public val isReified: Boolean
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* Represents variance applied to a type parameter on the declaration site (*declaration-site variance*),
|
||||
* or to a type in a projection (*use-site variance*).
|
||||
*
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#variance)
|
||||
* for more information.
|
||||
*
|
||||
* @see [KTypeParameter.variance]
|
||||
* @see [KTypeProjection]
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
enum class KVariance {
|
||||
/**
|
||||
* The affected type parameter or type is *invariant*, which means it has no variance applied to it.
|
||||
*/
|
||||
INVARIANT,
|
||||
|
||||
/**
|
||||
* The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code.
|
||||
*/
|
||||
IN,
|
||||
|
||||
/**
|
||||
* The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code.
|
||||
*/
|
||||
OUT,
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code.
|
||||
* Visibility can be changed with one of the following modifiers: `public`, `protected`, `internal`, `private`.
|
||||
*
|
||||
* Note that some Java visibilities such as package-private and protected (which also gives access to items from the same package)
|
||||
* cannot be represented in Kotlin, so there's no [KVisibility] value corresponding to them.
|
||||
*
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/visibility-modifiers.html)
|
||||
* for more information.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
enum class KVisibility {
|
||||
/**
|
||||
* Visibility of declarations marked with the `public` modifier, or with no modifier at all.
|
||||
*/
|
||||
PUBLIC,
|
||||
|
||||
/**
|
||||
* Visibility of declarations marked with the `protected` modifier.
|
||||
*/
|
||||
PROTECTED,
|
||||
|
||||
/**
|
||||
* Visibility of declarations marked with the `internal` modifier.
|
||||
*/
|
||||
INTERNAL,
|
||||
|
||||
/**
|
||||
* Visibility of declarations marked with the `private` modifier.
|
||||
*/
|
||||
PRIVATE,
|
||||
}
|
||||
Reference in New Issue
Block a user