提交 5f18cb87 编写于 作者: A Alexander Udalov

Rename files in reflection.jvm

Move KDeclarationContainer.functions to KClasses and make it accept only
KClass, since KPackage is deprecated anyway
上级 a09c8105
......@@ -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<KFunction<*>>
get() = members.filterIsInstance<KFunction<*>>()
/**
* Returns static functions declared in this class.
*/
......
/*
* 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<KFunction<*>>
get() = members.filterIsInstance<KFunction<*>>()
public val KDeclarationContainer.properties: Collection<KProperty<*>>
get() = members.filterIsInstance<KProperty<*>>()
......@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("KCallablesJvm")
package kotlin.reflect.jvm
import java.lang.reflect.AccessibleObject
......
......@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("KClassesJvm")
package kotlin.reflect.jvm
import kotlin.reflect.KClass
......
......@@ -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<KFunction<*>>().firstOrNull { it.javaMethod == this }
}
// For static bridge method generated for a jvmStatic function in the companion object, also try to find the latter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册