Reflection: add KClass.typeParameters, KCallable.typeParameters

Inheritance from KCallable is removed in kt9078.kt because it was irrelevant to
the test and because it gets in the way of modification of KCallable
This commit is contained in:
Alexander Udalov
2016-07-12 16:50:12 +03:00
parent f69cc01f8e
commit 127e7ab5b7
11 changed files with 89 additions and 21 deletions
@@ -83,6 +83,12 @@ public abstract class CallableReference implements KCallable {
return getReflected().getAnnotations();
}
@NotNull
@Override
public List<KTypeParameter> getTypeParameters() {
return getReflected().getTypeParameters();
}
@Override
public Object call(@NotNull Object... args) {
return getReflected().call(args);
@@ -19,6 +19,7 @@ package kotlin.jvm.internal
import kotlin.reflect.KCallable
import kotlin.reflect.KClass
import kotlin.reflect.KFunction
import kotlin.reflect.KTypeParameter
class ClassReference(override val jClass: Class<*>) : KClass<Any>, ClassBasedDeclarationContainer {
override val simpleName: String?
@@ -42,6 +43,9 @@ class ClassReference(override val jClass: Class<*>) : KClass<Any>, ClassBasedDec
override val objectInstance: Any?
get() = error()
override val typeParameters: List<KTypeParameter>
get() = error()
private fun error(): Nothing = throw KotlinReflectionNotSupportedError()
override fun equals(other: Any?) =
@@ -17,10 +17,7 @@
package kotlin.jvm.internal;
import kotlin.jvm.KotlinReflectionNotSupportedError;
import kotlin.reflect.KDeclarationContainer;
import kotlin.reflect.KFunction;
import kotlin.reflect.KParameter;
import kotlin.reflect.KType;
import kotlin.reflect.*;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.Annotation;
@@ -71,6 +68,12 @@ public class FunctionReference extends FunctionImpl implements KFunction {
return getReflected().getAnnotations();
}
@NotNull
@Override
public List<KTypeParameter> getTypeParameters() {
return getReflected().getTypeParameters();
}
@Override
public Object call(@NotNull Object... args) {
return getReflected().call(args);