Generate reflection info to classes for function references
The information includes the owner (class, package, script, or null for local functions) and the JVM signature -- this information will be used by reflection to locate the symbol
This commit is contained in:
@@ -16,9 +16,10 @@
|
||||
|
||||
package kotlin.jvm.internal;
|
||||
|
||||
import kotlin.jvm.KotlinReflectionNotSupportedError;
|
||||
import kotlin.reflect.*;
|
||||
|
||||
public abstract class FunctionReference
|
||||
public class FunctionReference
|
||||
extends FunctionImpl
|
||||
implements KTopLevelFunction,
|
||||
KMemberFunction,
|
||||
@@ -39,4 +40,30 @@ public abstract class FunctionReference
|
||||
public int getArity() {
|
||||
return arity;
|
||||
}
|
||||
|
||||
// The following methods provide the information identifying this function, which is used by the reflection implementation.
|
||||
// They are supposed to be overridden in each subclass (each anonymous class generated for a function reference).
|
||||
|
||||
public KDeclarationContainer getOwner() {
|
||||
throw error();
|
||||
}
|
||||
|
||||
// Kotlin name of the function, the one which was declared in the source code (@platformName can't change it)
|
||||
public String getName() {
|
||||
throw error();
|
||||
}
|
||||
|
||||
// JVM signature of the function, e.g. "println(Ljava/lang/Object;)V"
|
||||
public String getSignature() {
|
||||
throw error();
|
||||
}
|
||||
|
||||
// The following methods are the stub implementations of reflection functions.
|
||||
// They are called when you're using reflection on a function reference without the reflection implementation in the classpath.
|
||||
|
||||
// (nothing here yet)
|
||||
|
||||
private static Error error() {
|
||||
throw new KotlinReflectionNotSupportedError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user