Report error when try to use unsupported reflection API in Kotlin JS; allow to use kotlin.Any members on reflection classes for both platforms.

This commit is contained in:
Zalim Bashorov
2016-10-07 15:53:10 +03:00
parent 11b2c5fe59
commit c21e1eb857
10 changed files with 217 additions and 33 deletions
@@ -0,0 +1,50 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.*
class Foo(val prop: Any) {
fun func() {}
}
fun testSomeValidCases(p0: KProperty0<Int>, pm0: KMutableProperty0<String>, f: KFunction<String>, p1: KProperty1<String, Int>, p2: KProperty2<String, String, Int>) {
Foo::prop
Foo::func
Foo::class
p0.get()
p0.name
pm0.set("")
f.name
p1.get("")
p2.get("", "")
(Foo::func).invoke(Foo(""))
(Foo::func)(Foo(""))
p0 == pm0
p1.equals(p2)
p0.hashCode()
f.toString()
}
fun <T : Any> kclass(k: KClass<*>, kt: KClass<T>) {
k.simpleName
k.<!UNSUPPORTED!>qualifiedName<!>
k.<!UNSUPPORTED!>members<!>
k.<!UNSUPPORTED!>constructors<!>
k.<!UNSUPPORTED!>nestedClasses<!>
k.<!UNSUPPORTED!>objectInstance<!>
k.<!UNSUPPORTED!>typeParameters<!>
k.<!UNSUPPORTED!>supertypes<!>
k.<!UNSUPPORTED!>visibility<!>
k.<!UNSUPPORTED!>isFinal<!>
k.<!UNSUPPORTED!>isOpen<!>
k.<!UNSUPPORTED!>isAbstract<!>
k.<!UNSUPPORTED!>isSealed<!>
k.<!UNSUPPORTED!>isData<!>
k.<!UNSUPPORTED!>isInner<!>
k.<!UNSUPPORTED!>isCompanion<!>
k.<!UNSUPPORTED!>annotations<!>
k == kt
k.hashCode()
k.toString()
}