mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
Simplify property hierarchy in reflection
Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their mutable analogs, depending on the number of receivers a property takes
This commit is contained in:
@@ -10,8 +10,8 @@ fun box(): String {
|
||||
val s = J::s
|
||||
|
||||
// Check that correct reflection objects are created
|
||||
assert(i.javaClass.getSimpleName() == "KMemberPropertyImpl", "Fail i class")
|
||||
assert(s.javaClass.getSimpleName() == "KMutableMemberPropertyImpl", "Fail s class")
|
||||
assert(i.javaClass.getSimpleName() == "KProperty1Impl", "Fail i class")
|
||||
assert(s.javaClass.getSimpleName() == "KMutableProperty1Impl", "Fail s class")
|
||||
|
||||
// Check that no Method objects are created for such properties
|
||||
assert(i.javaGetter == null, "Fail i getter")
|
||||
@@ -33,8 +33,8 @@ fun box(): String {
|
||||
assert(a.s == "def", "Fail js access")
|
||||
|
||||
// Check that valid Kotlin reflection objects are created by those Field objects
|
||||
val ki = ji.kotlin as KMemberProperty<J, Int>
|
||||
val ks = js.kotlin as KMutableMemberProperty<J, String>
|
||||
val ki = ji.kotlin as KProperty1<J, Int>
|
||||
val ks = js.kotlin as KMutableProperty1<J, String>
|
||||
assert(ki.get(a) == 42, "Fail ki get")
|
||||
assert(ks.get(a) == "def", "Fail ks get")
|
||||
ks.set(a, "ghi")
|
||||
|
||||
Reference in New Issue
Block a user