Support KPackage.members, functions and properties

This commit is contained in:
Alexander Udalov
2015-07-15 23:50:45 +03:00
parent 95be8b11f5
commit 93656c93c1
11 changed files with 184 additions and 72 deletions
@@ -0,0 +1,23 @@
import kotlin.reflect.*
import kotlin.reflect.jvm.*
import kotlin.test.assertEquals
fun foo() {}
fun Int.bar() {}
val baz = 42
val Int.quux: Int get() = this
fun box(): String {
fun check(actual: Collection<KCallable<*>>, expected: Set<String>) {
assertEquals(expected, actual.map { it.name }.toSet())
}
val kp = Class.forName("_DefaultPackage").kotlinPackage ?: return "Fail: package class not found"
check(kp.members, setOf("bar", "baz", "foo", "box", "quux"))
check(kp.functions, setOf("bar", "foo", "box"))
check(kp.properties, setOf("baz"))
check(kp.extensionProperties, setOf("quux"))
return "OK"
}