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:
@@ -9,7 +9,6 @@ fun n02() = Foo::func
|
||||
fun n03() = Foo::class
|
||||
fun n04(p: KProperty0<Int>) = p.get()
|
||||
fun n05(p: KMutableProperty0<String>) = p.set("")
|
||||
fun n06(p: KProperty0<Int>) = p.get()
|
||||
fun n07(p: KFunction<String>) = p.name
|
||||
fun n08(p: KProperty1<String, Int>) = p.get("")
|
||||
fun n09(p: KProperty2<String, String, Int>) = p.get("", "")
|
||||
@@ -20,3 +19,28 @@ fun y01() = Foo::prop.<!NO_REFLECTION_IN_CLASS_PATH!>getter<!>
|
||||
fun y02() = Foo::class.<!NO_REFLECTION_IN_CLASS_PATH!>members<!>
|
||||
fun y03() = Foo::class.<!NO_REFLECTION_IN_CLASS_PATH!>simpleName<!>
|
||||
fun y04() = Foo::class.<!UNRESOLVED_REFERENCE!>properties<!>
|
||||
|
||||
fun <T : Any> kclass(k: KClass<*>, kt: KClass<T>) {
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>simpleName<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>qualifiedName<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>members<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>constructors<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>nestedClasses<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>objectInstance<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>typeParameters<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>supertypes<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>visibility<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isFinal<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isOpen<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isAbstract<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isSealed<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isData<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isInner<!>
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isCompanion<!>
|
||||
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>annotations<!>
|
||||
|
||||
k == kt
|
||||
k.hashCode()
|
||||
k.toString()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : kotlin.Any> kclass(/*0*/ k: kotlin.reflect.KClass<*>, /*1*/ kt: kotlin.reflect.KClass<T>): kotlin.Unit
|
||||
public fun n01(): kotlin.reflect.KProperty1<Foo, kotlin.Any>
|
||||
public fun n02(): kotlin.reflect.KFunction1<Foo, kotlin.Unit>
|
||||
public fun n03(): kotlin.reflect.KClass<Foo>
|
||||
public fun n04(/*0*/ p: kotlin.reflect.KProperty0<kotlin.Int>): kotlin.Int
|
||||
public fun n05(/*0*/ p: kotlin.reflect.KMutableProperty0<kotlin.String>): kotlin.Unit
|
||||
public fun n06(/*0*/ p: kotlin.reflect.KProperty0<kotlin.Int>): kotlin.Int
|
||||
public fun n07(/*0*/ p: kotlin.reflect.KFunction<kotlin.String>): kotlin.String
|
||||
public fun n08(/*0*/ p: kotlin.reflect.KProperty1<kotlin.String, kotlin.Int>): kotlin.Int
|
||||
public fun n09(/*0*/ p: kotlin.reflect.KProperty2<kotlin.String, kotlin.String, kotlin.Int>): kotlin.Int
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : kotlin.Any> kclass(/*0*/ k: kotlin.reflect.KClass<*>, /*1*/ kt: kotlin.reflect.KClass<T>): kotlin.Unit
|
||||
public fun testSomeValidCases(/*0*/ p0: kotlin.reflect.KProperty0<kotlin.Int>, /*1*/ pm0: kotlin.reflect.KMutableProperty0<kotlin.String>, /*2*/ f: kotlin.reflect.KFunction<kotlin.String>, /*3*/ p1: kotlin.reflect.KProperty1<kotlin.String, kotlin.Int>, /*4*/ p2: kotlin.reflect.KProperty2<kotlin.String, kotlin.String, kotlin.Int>): kotlin.Unit
|
||||
|
||||
public final class Foo {
|
||||
public constructor Foo(/*0*/ prop: kotlin.Any)
|
||||
public final val prop: kotlin.Any
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun func(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user