Move callable reference diagnostic tests to non-stdlib
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KMemberProperty
|
||||
|
||||
interface Base {
|
||||
val x: Any
|
||||
}
|
||||
|
||||
class A : Base {
|
||||
override val x: String = ""
|
||||
}
|
||||
|
||||
open class B : Base {
|
||||
override val x: Number = 1.0
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
override val x: Int = 42
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val base = Base::x
|
||||
checkSubtype<KMemberProperty<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<String>(a.get(A()))
|
||||
checkSubtype<Number>(<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!>)
|
||||
|
||||
val b = B::x
|
||||
checkSubtype<KMemberProperty<B, Number>>(b)
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>b.get(C())<!>)
|
||||
}
|
||||
Reference in New Issue
Block a user