diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/reflection/reflectionApi.kt b/compiler/testData/diagnostics/testsWithJsStdLib/reflection/reflectionApi.kt index 802a9d1128a..5174cc73fe2 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/reflection/reflectionApi.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/reflection/reflectionApi.kt @@ -27,22 +27,22 @@ fun testSomeValidCases(p0: KProperty0, pm0: KMutableProperty0, f: K fun kclass(k: KClass<*>, kt: KClass) { k.simpleName k.qualifiedName - k.members - k.constructors - k.nestedClasses - k.objectInstance - k.typeParameters - k.supertypes - k.visibility - k.isFinal - k.isOpen - k.isAbstract - k.isSealed - k.isData - k.isInner - k.isCompanion + k.members + k.constructors + k.nestedClasses + k.objectInstance + k.typeParameters + k.supertypes + k.visibility + k.isFinal + k.isOpen + k.isAbstract + k.isSealed + k.isData + k.isInner + k.isCompanion - k.annotations + k.annotations k == kt k.hashCode() diff --git a/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt b/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt deleted file mode 100644 index 4fa1a1e29eb..00000000000 --- a/libraries/stdlib/js/src/kotlin/reflect/KAnnotatedElement.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 index d76d25db6e9..e65165a2389 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KCallable.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KCallable.kt @@ -10,7 +10,7 @@ package kotlin.reflect * * @param R return type of the callable. */ -public actual interface KCallable : KAnnotatedElement { +public actual interface KCallable { /** * 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. @@ -20,66 +20,4 @@ public actual interface KCallable : KAnnotatedElement { * 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 index 2a10b13a53e..791325dc753 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KClass.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KClass.kt @@ -23,110 +23,17 @@ public actual interface KClass : KClassifier { /** * The fully qualified dot-separated name of the class, * or `null` if the class is local or it is an anonymous object literal. + * + * This property is currently not supported in Kotlin/JS. */ 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: diff --git a/libraries/stdlib/js/src/kotlin/reflect/KClassImpl.kt b/libraries/stdlib/js/src/kotlin/reflect/KClassImpl.kt index 97d35ddfa72..027adba3999 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KClassImpl.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KClassImpl.kt @@ -10,40 +10,9 @@ import kotlin.reflect.* internal abstract class KClassImpl( internal open val jClass: JsClass ) : KClass { - override val annotations: List - get() = TODO() - override val constructors: Collection> - get() = TODO() - override val isAbstract: Boolean - get() = TODO() - override val isCompanion: Boolean - get() = TODO() - override val isData: Boolean - get() = TODO() - override val isFinal: Boolean - get() = TODO() - override val isInner: Boolean - get() = TODO() - override val isOpen: Boolean - get() = TODO() - override val isSealed: Boolean - get() = TODO() - override val members: Collection> - get() = TODO() - override val nestedClasses: Collection> - get() = TODO() - override val objectInstance: T? - get() = TODO() + override val qualifiedName: String? get() = TODO() - override val supertypes: List - get() = TODO() - override val typeParameters: List - get() = TODO() - override val sealedSubclasses: List> - get() = TODO() - override val visibility: KVisibility? - get() = TODO() override fun equals(other: Any?): Boolean { return other is KClassImpl<*> && jClass == other.jClass diff --git a/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt b/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt deleted file mode 100644 index 447cfb33d49..00000000000 --- a/libraries/stdlib/js/src/kotlin/reflect/KDeclarationContainer.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 index 41c9c2d25bb..959ff78c9dc 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KFunction.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KFunction.kt @@ -8,42 +8,4 @@ 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 -} +public actual interface KFunction : KCallable, Function \ No newline at end of file diff --git a/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt b/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt deleted file mode 100644 index 2e29830da9b..00000000000 --- a/libraries/stdlib/js/src/kotlin/reflect/KParameter.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 index 85935f74735..9d5a1193c14 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KProperty.kt @@ -15,56 +15,12 @@ package kotlin.reflect * * @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 -} +public actual interface KProperty : KCallable /** * 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 -} +public actual interface KMutableProperty : KProperty /** @@ -77,23 +33,6 @@ 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 } /** @@ -106,15 +45,6 @@ public actual interface KMutableProperty0 : KProperty0, KMutableProperty - - /** - * 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 } @@ -133,32 +63,6 @@ public actual interface KProperty1 : KProperty, (T) -> R { * 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 } /** @@ -174,15 +78,6 @@ public actual interface KMutableProperty1 : KProperty1, KMutableProp * @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 } @@ -205,32 +100,6 @@ public actual interface KProperty2 : KProperty, (D, E) -> R { * @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 } /** @@ -245,14 +114,4 @@ public actual interface KMutableProperty2 : KProperty2, KMutab * @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 index 742c89e5cf2..d9f655745fc 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KType.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KType.kt @@ -9,7 +9,7 @@ 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 { +public actual interface KType { /** * The declaration of the classifier used in this type. * For example, in the type `List` the classifier would be the [KClass] instance for [List]. diff --git a/libraries/stdlib/js/src/kotlin/reflect/KTypeImpl.kt b/libraries/stdlib/js/src/kotlin/reflect/KTypeImpl.kt index 4a9b7d07be4..281c309cefa 100644 --- a/libraries/stdlib/js/src/kotlin/reflect/KTypeImpl.kt +++ b/libraries/stdlib/js/src/kotlin/reflect/KTypeImpl.kt @@ -12,9 +12,6 @@ internal class KTypeImpl( override val arguments: List, override val isMarkedNullable: Boolean ) : KType { - override val annotations: List - get() = emptyList() - override fun equals(other: Any?): Boolean = other is KTypeImpl && classifier == other.classifier && arguments == other.arguments && isMarkedNullable == other.isMarkedNullable @@ -49,7 +46,6 @@ internal object DynamicKType : KType { override val classifier: KClassifier? = null override val arguments: List = emptyList() override val isMarkedNullable: Boolean = false - override val annotations: List = emptyList() override fun toString(): String = "dynamic" } diff --git a/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt b/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt deleted file mode 100644 index 6ddd7e1769b..00000000000 --- a/libraries/stdlib/js/src/kotlin/reflect/KVisibility.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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, -}