Add 'val KClass.declaredProperties', make getProperties a property

This commit is contained in:
Alexander Udalov
2015-03-16 16:14:32 +03:00
parent 4a61f2751c
commit d3abd54b06
14 changed files with 107 additions and 48 deletions
@@ -0,0 +1,23 @@
import kotlin.reflect.*
import kotlin.test.*
open class Super {
val a: Int = 1
val String.b: String get() = this
}
class Sub : Super() {
val c: Double = 1.0
val Char.d: Char get() = this
}
fun box(): String {
val sub = Sub::class
assertEquals(listOf("a", "c"), sub.properties.map { it.name }.sort())
assertEquals(listOf("b", "d"), sub.extensionProperties.map { it.name }.sort())
assertEquals(listOf("c"), sub.declaredProperties.map { it.name })
assertEquals(listOf("d"), sub.declaredExtensionProperties.map { it.name })
return "OK"
}