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:
Alexander Udalov
2015-06-26 16:40:39 +03:00
parent c3b97e0668
commit 30794060a9
58 changed files with 374 additions and 653 deletions

View File

@@ -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")