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:
Vendored
+4
-4
@@ -1,6 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KMemberProperty
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
interface Base {
|
||||
val x: Any
|
||||
@@ -20,17 +20,17 @@ class C : B() {
|
||||
|
||||
fun test() {
|
||||
val base = Base::x
|
||||
checkSubtype<KMemberProperty<Base, Any>>(base)
|
||||
checkSubtype<KProperty1<Base, Any>>(base)
|
||||
checkSubtype<Any>(base.get(A()))
|
||||
checkSubtype<Number>(<!TYPE_MISMATCH!>base.get(B())<!>)
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>base.get(C())<!>)
|
||||
|
||||
val a = A::x
|
||||
checkSubtype<KMemberProperty<A, String>>(a)
|
||||
checkSubtype<KProperty1<A, String>>(a)
|
||||
checkSubtype<String>(a.get(A()))
|
||||
checkSubtype<Number>(<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!>)
|
||||
|
||||
val b = B::x
|
||||
checkSubtype<KMemberProperty<B, Number>>(b)
|
||||
checkSubtype<KProperty1<B, Number>>(b)
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>b.get(C())<!>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user