Support annotations on property accessors in JS/common metadata
#KT-14529 Fixed
This commit is contained in:
+2
@@ -27,6 +27,8 @@ open class SerializerExtensionProtocol(
|
||||
val classAnnotation: GeneratedExtension<ProtoBuf.Class, List<ProtoBuf.Annotation>>,
|
||||
val functionAnnotation: GeneratedExtension<ProtoBuf.Function, List<ProtoBuf.Annotation>>,
|
||||
val propertyAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>,
|
||||
val propertyGetterAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>,
|
||||
val propertySetterAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>,
|
||||
val enumEntryAnnotation: GeneratedExtension<ProtoBuf.EnumEntry, List<ProtoBuf.Annotation>>,
|
||||
val compileTimeValue: GeneratedExtension<ProtoBuf.Property, ProtoBuf.Annotation.Argument.Value>,
|
||||
val parameterAnnotation: GeneratedExtension<ProtoBuf.ValueParameter, List<ProtoBuf.Annotation>>,
|
||||
|
||||
+6
-1
@@ -47,7 +47,12 @@ class AnnotationAndConstantLoaderImpl(
|
||||
val annotations = when (proto) {
|
||||
is ProtoBuf.Constructor -> proto.getExtension(protocol.constructorAnnotation)
|
||||
is ProtoBuf.Function -> proto.getExtension(protocol.functionAnnotation)
|
||||
is ProtoBuf.Property -> proto.getExtension(protocol.propertyAnnotation)
|
||||
is ProtoBuf.Property -> when (kind) {
|
||||
AnnotatedCallableKind.PROPERTY -> proto.getExtension(protocol.propertyAnnotation)
|
||||
AnnotatedCallableKind.PROPERTY_GETTER -> proto.getExtension(protocol.propertyGetterAnnotation)
|
||||
AnnotatedCallableKind.PROPERTY_SETTER -> proto.getExtension(protocol.propertySetterAnnotation)
|
||||
else -> error("Unsupported callable kind with property proto")
|
||||
}
|
||||
else -> error("Unknown message: $proto")
|
||||
}.orEmpty()
|
||||
return annotations.map { annotationProto ->
|
||||
|
||||
+12
-4
@@ -11,11 +11,19 @@ import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||
|
||||
object BuiltInSerializerProtocol : SerializerExtensionProtocol(
|
||||
ExtensionRegistryLite.newInstance().apply { BuiltInsProtoBuf.registerAllExtensions(this) },
|
||||
ExtensionRegistryLite.newInstance().apply(BuiltInsProtoBuf::registerAllExtensions),
|
||||
BuiltInsProtoBuf.packageFqName,
|
||||
BuiltInsProtoBuf.constructorAnnotation, BuiltInsProtoBuf.classAnnotation, BuiltInsProtoBuf.functionAnnotation,
|
||||
BuiltInsProtoBuf.propertyAnnotation, BuiltInsProtoBuf.enumEntryAnnotation, BuiltInsProtoBuf.compileTimeValue,
|
||||
BuiltInsProtoBuf.parameterAnnotation, BuiltInsProtoBuf.typeAnnotation, BuiltInsProtoBuf.typeParameterAnnotation
|
||||
BuiltInsProtoBuf.constructorAnnotation,
|
||||
BuiltInsProtoBuf.classAnnotation,
|
||||
BuiltInsProtoBuf.functionAnnotation,
|
||||
BuiltInsProtoBuf.propertyAnnotation,
|
||||
BuiltInsProtoBuf.propertyGetterAnnotation,
|
||||
BuiltInsProtoBuf.propertySetterAnnotation,
|
||||
BuiltInsProtoBuf.enumEntryAnnotation,
|
||||
BuiltInsProtoBuf.compileTimeValue,
|
||||
BuiltInsProtoBuf.parameterAnnotation,
|
||||
BuiltInsProtoBuf.typeAnnotation,
|
||||
BuiltInsProtoBuf.typeParameterAnnotation
|
||||
) {
|
||||
const val BUILTINS_FILE_EXTENSION = "kotlin_builtins"
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ extend Function {
|
||||
|
||||
extend Property {
|
||||
repeated Annotation property_annotation = 150;
|
||||
repeated Annotation property_getter_annotation = 152;
|
||||
repeated Annotation property_setter_annotation = 153;
|
||||
optional Annotation.Argument.Value compile_time_value = 151;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class BuiltInsBinaryVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE = BuiltInsBinaryVersion(1, 0, 6)
|
||||
val INSTANCE = BuiltInsBinaryVersion(1, 0, 7)
|
||||
|
||||
@JvmField
|
||||
val INVALID_VERSION = BuiltInsBinaryVersion()
|
||||
|
||||
@@ -12,6 +12,8 @@ public final class BuiltInsProtoBuf {
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.constructorAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.functionAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.propertyAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.propertyGetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.propertySetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.compileTimeValue);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.enumEntryAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.metadata.builtins.BuiltInsProtoBuf.parameterAnnotation);
|
||||
@@ -98,6 +100,38 @@ public final class BuiltInsProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int PROPERTY_GETTER_ANNOTATION_FIELD_NUMBER = 152;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.ProtoBuf.Annotation>> propertyGetterAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
152,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int PROPERTY_SETTER_ANNOTATION_FIELD_NUMBER = 153;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.ProtoBuf.Annotation>> propertySetterAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
153,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int COMPILE_TIME_VALUE_FIELD_NUMBER = 151;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
|
||||
Reference in New Issue
Block a user