8f0885ca03
To better emphasize the fact that all returned properties require an instance of the class they are declared in. Another issue was that 'Some::class.extensionProperties' was sometimes incorrectly perceived as "get all extension properties available on the class Some"
25 lines
734 B
Kotlin
Vendored
25 lines
734 B
Kotlin
Vendored
import kotlin.reflect.jvm.kotlin
|
|
import kotlin.reflect.*
|
|
|
|
class A {
|
|
val foo: String = "member"
|
|
val Unit.foo: String get() = "extension"
|
|
}
|
|
|
|
fun box(): String {
|
|
run {
|
|
val foo: KProperty1<A, *> = javaClass<A>().kotlin.memberProperties.single()
|
|
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
|
|
assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" }
|
|
}
|
|
|
|
run {
|
|
val foo: KProperty2<A, *, *> = javaClass<A>().kotlin.memberExtensionProperties.single()
|
|
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
|
|
foo as KProperty2<A, Unit, *>
|
|
assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" }
|
|
}
|
|
|
|
return "OK"
|
|
}
|