diff --git a/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt b/core/reflection.jvm/src/kotlin/reflect/KClasses.kt similarity index 95% rename from core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt rename to core/reflection.jvm/src/kotlin/reflect/KClasses.kt index eb4acb75085..6c566b12163 100644 --- a/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt +++ b/core/reflection.jvm/src/kotlin/reflect/KClasses.kt @@ -14,6 +14,7 @@ * limitations under the License. */ +@file:JvmName("KClasses") package kotlin.reflect import org.jetbrains.kotlin.descriptors.ConstructorDescriptor @@ -57,6 +58,13 @@ public val KClass<*>.defaultType: KType get() = KTypeImpl((this as KClassImpl<*>).descriptor.defaultType) { jClass } +/** + * Returns all functions declared in this class, including all non-static methods declared in the class + * and the superclasses, as well as static methods declared in the class. + */ +public val KClass<*>.functions: Collection> + get() = members.filterIsInstance>() + /** * Returns static functions declared in this class. */ diff --git a/core/reflection.jvm/src/kotlin/reflect/KDeclarationContainerExtensions.kt b/core/reflection.jvm/src/kotlin/reflect/KDeclarationContainerExtensions.kt deleted file mode 100644 index d0418500836..00000000000 --- a/core/reflection.jvm/src/kotlin/reflect/KDeclarationContainerExtensions.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 - -/** - * Returns all functions declared in this container. - * If this container is a Java class, it includes all non-static methods declared in the class - * and the superclasses, as well as static methods declared in the class. - */ -public val KDeclarationContainer.functions: Collection> - get() = members.filterIsInstance>() - -public val KDeclarationContainer.properties: Collection> - get() = members.filterIsInstance>() diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/callables.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt similarity index 99% rename from core/reflection.jvm/src/kotlin/reflect/jvm/callables.kt rename to core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt index 1e0db1db8a6..839d013fb67 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/callables.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt @@ -14,6 +14,7 @@ * limitations under the License. */ +@file:JvmName("KCallablesJvm") package kotlin.reflect.jvm import java.lang.reflect.AccessibleObject diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt similarity index 96% rename from core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt rename to core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt index f059b078f0f..be8725e98b2 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt @@ -14,6 +14,7 @@ * limitations under the License. */ +@file:JvmName("KClassesJvm") package kotlin.reflect.jvm import kotlin.reflect.KClass diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt similarity index 97% rename from core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt rename to core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt index 8d49af45411..2063c74cedd 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt @@ -14,9 +14,9 @@ * limitations under the License. */ +@file:JvmName("ReflectJvmMapping") package kotlin.reflect.jvm -import org.jetbrains.kotlin.load.java.JvmAbi import java.lang.reflect.* import java.util.* import kotlin.jvm.internal.KotlinFileFacade @@ -118,7 +118,7 @@ public val Method.kotlinFunction: KFunction<*>? if (Modifier.isStatic(modifiers)) { val kotlinPackage = getKPackage() if (kotlinPackage != null) { - return kotlinPackage.functions.firstOrNull { it.javaMethod == this } + return kotlinPackage.members.filterIsInstance>().firstOrNull { it.javaMethod == this } } // For static bridge method generated for a jvmStatic function in the companion object, also try to find the latter