Add extension for Method.invoke()

This commit is contained in:
Yan Zhulanow
2015-09-25 20:11:24 +03:00
parent b73f91d16b
commit 3a519ccc0a
@@ -1,5 +1,6 @@
package kotlin
import java.lang.reflect.Method
import kotlin.jvm.internal.unsafe.*
import kotlin.jvm.internal.Intrinsic
import kotlin.reflect.KClass
@@ -58,3 +59,11 @@ public inline fun <R> synchronized(lock: Any, block: () -> R): R {
*/
public fun <T : Annotation> T.annotationType() : Class<out T> =
(this as java.lang.annotation.Annotation).annotationType() as Class<out T>
/**
* Invokes the underlying method represented by this [Method] object, on the specified [instance] with the specified parameters.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun Method.invoke(instance: Any, vararg args: Any?): Any? {
return invoke(instance, *args)
}