Add val KClass.staticProperties: Collection<KProperty0<*>>

To get static fields from Java classes
This commit is contained in:
Alexander Udalov
2015-08-28 13:41:40 +03:00
parent 593937d302
commit a1097f7081
5 changed files with 79 additions and 1 deletions
@@ -114,6 +114,16 @@ public val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>>
.filterIsInstance<KFunction<*>>()
.toList()
/**
* Returns static properties declared in this class.
* Only properties representing static fields of Java classes are considered static.
*/
public val KClass<*>.staticProperties: Collection<KProperty0<*>>
get() = (this as KClassImpl)
.getMembers(staticScope, declaredOnly = false, nonExtensions = true, extensions = false)
.filterIsInstance<KProperty0<*>>()
.toList()
/**
* Returns non-extension properties declared in this class and all of its superclasses.
*/
@@ -149,7 +149,8 @@ object RuntimeTypeMapper {
}
}
fun mapPropertySignature(property: PropertyDescriptor): JvmPropertySignature {
fun mapPropertySignature(possiblyOverriddenProperty: PropertyDescriptor): JvmPropertySignature {
val property = DescriptorUtils.unwrapFakeOverride(possiblyOverriddenProperty)
if (property is DeserializedPropertyDescriptor) {
val proto = property.proto
if (!proto.hasExtension(JvmProtoBuf.propertySignature)) {