Introduce KClass.members, make properties/extensionProperties extensions

To avoid significant growth of KClass and KPackage interfaces
This commit is contained in:
Alexander Udalov
2015-07-08 03:13:40 +03:00
parent 2492977274
commit 50dbda1e1a
19 changed files with 80 additions and 54 deletions
@@ -4,6 +4,8 @@ fun box(): String {
val f = J::x
assertEquals("x", f.name)
assertEquals(f, J::class.members.single { it.name == "x" })
f.set("OK")
assertEquals("OK", J.x)
assertEquals("OK", f.getter())
@@ -1,4 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.*
class A {
var String.id: String
@@ -1,4 +1,4 @@
import kotlin.reflect.KMutableProperty2
import kotlin.reflect.*
import kotlin.test.assertEquals
class C(var state: String) {
@@ -1,10 +1,10 @@
import kotlin.reflect.KProperty1
import kotlin.reflect.*
class A<T> {
val result = "OK"
}
fun box(): String {
val k : KProperty1<A<*>, *> = A::class.properties.single()
val k: KProperty1<A<*>, *> = A::class.properties.single()
return k.get(A<String>()) as String
}
@@ -1,5 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KMutableProperty2
import kotlin.reflect.*
var storage = "before"
@@ -1,5 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.*
class A(val readonly: String) {
var mutable: String = "before"
@@ -1,6 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KProperty1
import kotlin.reflect.KProperty2
import kotlin.reflect.*
class A {
val foo: String = "member"
@@ -1,5 +1,4 @@
import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.KProperty1
import kotlin.reflect.*
import kotlin.reflect.jvm.accessible
class Result {
@@ -1,5 +1,4 @@
import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.*
import kotlin.reflect.jvm.accessible
class A {
@@ -1,3 +1,5 @@
import kotlin.reflect.*
open class A(private val p: Int)
class B : A(42)
@@ -1,6 +1,5 @@
import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.*
import kotlin.reflect.jvm.accessible
import kotlin.reflect.KMutableProperty1
class A(param: String) {
protected var v: String = param
@@ -1,3 +1,4 @@
import kotlin.reflect.*
import kotlin.reflect.jvm.kotlin
class A(param: String) {
@@ -1,6 +1,6 @@
package test
import kotlin.reflect.KClass
import kotlin.reflect.*
import kotlin.test.*
class K(val p: String)
@@ -17,5 +17,6 @@ fun n10() = (Foo::func).invoke(Foo(""))
fun n11() = (Foo::func)(Foo(""))
fun y01() = Foo::prop.<!NO_REFLECTION_IN_CLASS_PATH!>getter<!>
fun y02() = Foo::class.<!NO_REFLECTION_IN_CLASS_PATH!>properties<!>
fun y02() = Foo::class.<!NO_REFLECTION_IN_CLASS_PATH!>members<!>
fun y03() = Foo::class.<!NO_REFLECTION_IN_CLASS_PATH!>simpleName<!>
fun y04() = Foo::class.<!UNRESOLVED_REFERENCE!>properties<!>
@@ -12,8 +12,9 @@ internal fun n09(/*0*/ p: kotlin.reflect.KProperty2<kotlin.String, kotlin.String
internal fun n10(): kotlin.Unit
internal fun n11(): kotlin.Unit
internal fun y01(): kotlin.reflect.KProperty1.Getter<Foo, kotlin.Any>
internal fun y02(): kotlin.Collection<kotlin.reflect.KProperty1<Foo, *>>
internal fun y02(): kotlin.Collection<kotlin.reflect.KCallable<*>>
internal fun y03(): kotlin.String?
internal fun y04(): [ERROR : Error function type]
internal final class Foo {
public constructor Foo(/*0*/ prop: kotlin.Any)