JVM IR: generate synthetic $annotations methods for properties

This commit is contained in:
Alexander Udalov
2019-02-13 01:25:37 +01:00
parent c92c50aa98
commit d267f1e875
19 changed files with 110 additions and 57 deletions
@@ -350,7 +350,7 @@ public class PropertyCodegen {
Annotations annotations = descriptor.getAnnotations();
if (annotations.isEmpty()) return;
Method signature = getSyntheticMethodSignature(descriptor);
Method signature = typeMapper.mapSyntheticMethodForPropertyAnnotations(descriptor);
if (kind != OwnerKind.DEFAULT_IMPLS && CodegenContextUtil.isImplementationOwner(context, descriptor)) {
v.getSerializationBindings().put(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor, signature);
}
@@ -363,14 +363,6 @@ public class PropertyCodegen {
}
}
@NotNull
private Method getSyntheticMethodSignature(@NotNull PropertyDescriptor descriptor) {
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
String desc = receiver == null ? "()V" : "(" + typeMapper.mapType(receiver.getType()) + ")V";
return new Method(name, desc);
}
private void generateBackingField(
@NotNull KtNamedDeclaration element,
@NotNull PropertyDescriptor propertyDescriptor,
@@ -1834,6 +1834,14 @@ public class KotlinTypeMapper {
}
}
@NotNull
public Method mapSyntheticMethodForPropertyAnnotations(@NotNull PropertyDescriptor descriptor) {
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
String desc = receiver == null ? "()V" : "(" + mapType(receiver.getType()) + ")V";
return new Method(name, desc);
}
@NotNull
public JvmMethodSignature mapScriptSignature(
@NotNull ScriptDescriptor script,