Write JVM signatures to new protobuf messages

This commit is contained in:
Alexander Udalov
2015-09-30 18:58:29 +03:00
parent 06a7ca5571
commit 8c0a86617a
14 changed files with 530 additions and 146 deletions
@@ -294,9 +294,9 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
// Returns the JVM class which contains this callable. This class may be different from the one represented by descriptors
// in case of top level functions (their bodies are in package parts), methods with implementations in interfaces, etc.
private fun implClassForCallable(nameResolver: NameResolver, proto: ProtoBuf.Callable): Class<*>? {
if (!proto.hasExtension(JvmProtoBuf.implClassName)) return null
if (!proto.hasExtension(JvmProtoBuf.oldImplClassName)) return null
val implClassName = nameResolver.getName(proto.getExtension(JvmProtoBuf.implClassName))
val implClassName = nameResolver.getName(proto.getExtension(JvmProtoBuf.oldImplClassName))
// TODO: store fq name of impl class name in jvm_descriptors.proto
val classId = ClassId(jClass.classId.getPackageFqName(), implClassName)
return jClass.safeClassLoader.loadClass(classId.asSingleFqName().asString())
@@ -124,8 +124,8 @@ internal object RuntimeTypeMapper {
when (function) {
is DeserializedCallableMemberDescriptor -> {
val proto = function.proto
if (proto.hasExtension(JvmProtoBuf.methodSignature)) {
val signature = proto.getExtension(JvmProtoBuf.methodSignature)
if (proto.hasExtension(JvmProtoBuf.oldMethodSignature)) {
val signature = proto.getExtension(JvmProtoBuf.oldMethodSignature)
return JvmFunctionSignature.KotlinFunction(proto, signature, function.nameResolver)
}
// If it's a deserialized function but has no JVM signature, it must be from built-ins
@@ -153,10 +153,10 @@ internal object RuntimeTypeMapper {
val property = DescriptorUtils.unwrapFakeOverride(possiblyOverriddenProperty)
if (property is DeserializedPropertyDescriptor) {
val proto = property.proto
if (!proto.hasExtension(JvmProtoBuf.propertySignature)) {
if (!proto.hasExtension(JvmProtoBuf.oldPropertySignature)) {
throw KotlinReflectionInternalError("No metadata found for $property")
}
return JvmPropertySignature.KotlinProperty(proto, proto.getExtension(JvmProtoBuf.propertySignature), property.nameResolver)
return JvmPropertySignature.KotlinProperty(proto, proto.getExtension(JvmProtoBuf.oldPropertySignature), property.nameResolver)
}
else if (property is JavaPropertyDescriptor) {
val field = ((property.source as? JavaSourceElement)?.javaElement as? ReflectJavaField)?.member ?: