diff --git a/libraries/stdlib/js-v1/build.gradle b/libraries/stdlib/js-v1/build.gradle index 707f83e5720..e245d62991d 100644 --- a/libraries/stdlib/js-v1/build.gradle +++ b/libraries/stdlib/js-v1/build.gradle @@ -120,7 +120,6 @@ task prepareBuiltinsSources(type: Copy) { include "Ranges.kt" include "internal/InternalAnnotations.kt" include "internal/progressionUtil.kt" - include "reflect/**/*.kt" include "Unit.kt" } into builtinsSrcDir diff --git a/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt b/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt new file mode 100644 index 00000000000..4fa1a1e29eb --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt @@ -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 +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KCallable.kt b/libraries/stdlib/js/src/kotlin/reflect/KCallable.kt new file mode 100644 index 00000000000..d76d25db6e9 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KCallable.kt @@ -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 : 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 "", + * - property accessors: the getter for a property named "foo" will have the name "", + * the setter, similarly, will have the name "". + */ + 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 + + /** + * 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 + + /** + * 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): 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 +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KClass.kt b/libraries/stdlib/js/src/kotlin/reflect/KClass.kt new file mode 100644 index 00000000000..2a10b13a53e --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KClass.kt @@ -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 : 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 actual 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> + + /** + * All constructors declared in this class. + */ + public val constructors: Collection> + + /** + * All classes declared inside this class. This includes both inner and static nested classes. + */ + public val nestedClasses: Collection> + + /** + * 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 actual 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 + + /** + * 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 + + /** + * 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> + + /** + * 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 +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt b/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt new file mode 100644 index 00000000000..447cfb33d49 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt @@ -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> +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KFunction.kt b/libraries/stdlib/js/src/kotlin/reflect/KFunction.kt new file mode 100644 index 00000000000..41c9c2d25bb --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KFunction.kt @@ -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 actual interface KFunction : KCallable, Function { + /** + * `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 +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt b/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt new file mode 100644 index 00000000000..2e29830da9b --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt @@ -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 { + /** + * 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 +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt b/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt new file mode 100644 index 00000000000..85935f74735 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt @@ -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 : KCallable { + /** + * `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 + + /** + * 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 { + /** The property which this accessor is originated from. */ + public val property: KProperty + } + + /** + * Getter of the property is a `get` method declared alongside the property. + */ + public interface Getter : Accessor, KFunction +} + +/** + * Represents a property declared as a `var`. + */ +public actual interface KMutableProperty : KProperty { + /** The setter of this mutable property, used to change the value of the property. */ + public val setter: Setter + + /** + * Setter of the property is a `set` method declared alongside the property. + */ + public interface Setter : KProperty.Accessor, KFunction +} + + +/** + * 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 : KProperty, () -> 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 + + /** + * 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 : KProperty.Getter, () -> R +} + +/** + * Represents a `var`-property without any kind of receiver. + */ +public actual interface KMutableProperty0 : KProperty0, KMutableProperty { + /** + * 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 + + /** + * 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 : KMutableProperty.Setter, (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 : KProperty, (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 + + /** + * 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 : KProperty.Getter, (T) -> R +} + +/** + * Represents a `var`-property, operations on which take one receiver as a parameter. + */ +public actual interface KMutableProperty1 : KProperty1, KMutableProperty { + /** + * 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 + + /** + * 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 : KMutableProperty.Setter, (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 : KProperty, (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 + + /** + * 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 : KProperty.Getter, (D, E) -> R +} + +/** + * Represents a `var`-property, operations on which take two receivers as parameters. + */ +public actual interface KMutableProperty2 : KProperty2, KMutableProperty { + /** + * 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 + + /** + * 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 : KMutableProperty.Setter, (D, E, R) -> Unit +} diff --git a/libraries/stdlib/js/src/kotlin/reflect/KType.kt b/libraries/stdlib/js/src/kotlin/reflect/KType.kt new file mode 100644 index 00000000000..742c89e5cf2 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KType.kt @@ -0,0 +1,52 @@ +/* + * 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 actual interface KType : KAnnotatedElement { + /** + * The declaration of the classifier used in this type. + * For example, in the type `List` 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 actual val classifier: KClassifier? + + /** + * Type arguments passed for the parameters of the classifier in this type. + * For example, in the type `Array` 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.Inner` the returned list is `[C, D, A, B]`. + */ + @SinceKotlin("1.1") + public actual val arguments: List + + /** + * `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 foo(t: T) { + * // isMarkedNullable == false for t's type, but t can be null here when T = "Any?" + * } + * ``` + */ + public actual val isMarkedNullable: Boolean +} + diff --git a/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt b/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt new file mode 100644 index 00000000000..6ddd7e1769b --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt @@ -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, +}