[klib] Fix serialization of missing annotations
^KT-42490 ^KT-44625
This commit is contained in:
committed by
Space Team
parent
90d702ed27
commit
17e9a6a781
@@ -180,6 +180,7 @@
|
||||
/compiler/testData/serialization/builtinsSerializer/ "Kotlin Compiler Core"
|
||||
/compiler/testData/serialization/js/ "Kotlin JS"
|
||||
/compiler/testData/serialization/nonStableParameterNames/ "Kotlin Compiler Core" "Kotlin JVM" "Kotlin JS" "Kotlin Native" "Kotlin Wasm"
|
||||
/compiler/testData/serialization/klib/ "Kotlin Compiler Core" "Kotlin JVM" "Kotlin JS" "Kotlin Native" "Kotlin Wasm"
|
||||
/compiler/testData/type/ "Kotlin Compiler Core"
|
||||
/compiler/testData/typeQualifierNickname/ "Kotlin Compiler Core"
|
||||
/compiler/testData/versionRequirement/ "Kotlin JVM"
|
||||
|
||||
@@ -543,6 +543,15 @@ open class ProtoCompareGenerated(
|
||||
}
|
||||
}
|
||||
|
||||
if (old.getExtensionCount(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation) != new.getExtensionCount(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation)) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
for(i in 0..old.getExtensionCount(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation) - 1) {
|
||||
if (!checkEquals(old.getExtension(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation, i), new.getExtension(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation, i))) return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -718,6 +727,33 @@ open class ProtoCompareGenerated(
|
||||
}
|
||||
}
|
||||
|
||||
if (old.getExtensionCount(KlibMetadataProtoBuf.propertyBackingFieldAnnotation) != new.getExtensionCount(KlibMetadataProtoBuf.propertyBackingFieldAnnotation)) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
for(i in 0..old.getExtensionCount(KlibMetadataProtoBuf.propertyBackingFieldAnnotation) - 1) {
|
||||
if (!checkEquals(old.getExtension(KlibMetadataProtoBuf.propertyBackingFieldAnnotation, i), new.getExtension(KlibMetadataProtoBuf.propertyBackingFieldAnnotation, i))) return false
|
||||
}
|
||||
}
|
||||
|
||||
if (old.getExtensionCount(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation) != new.getExtensionCount(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation)) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
for(i in 0..old.getExtensionCount(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation) - 1) {
|
||||
if (!checkEquals(old.getExtension(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation, i), new.getExtension(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation, i))) return false
|
||||
}
|
||||
}
|
||||
|
||||
if (old.getExtensionCount(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation) != new.getExtensionCount(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation)) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
for(i in 0..old.getExtensionCount(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation) - 1) {
|
||||
if (!checkEquals(old.getExtension(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation, i), new.getExtension(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation, i))) return false
|
||||
}
|
||||
}
|
||||
|
||||
if (old.hasExtension(KlibMetadataProtoBuf.compileTimeValue) != new.hasExtension(KlibMetadataProtoBuf.compileTimeValue)) return false
|
||||
if (old.hasExtension(KlibMetadataProtoBuf.compileTimeValue)) {
|
||||
if (!checkEquals(old.getExtension(KlibMetadataProtoBuf.compileTimeValue), new.getExtension(KlibMetadataProtoBuf.compileTimeValue))) return false
|
||||
@@ -2053,6 +2089,10 @@ fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int)
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.functionAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
for(i in 0..getExtensionCount(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation) - 1) {
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.functionExtensionReceiverAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
return hashCode
|
||||
}
|
||||
|
||||
@@ -2177,6 +2217,18 @@ fun ProtoBuf.Property.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int)
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.propertySetterAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
for(i in 0..getExtensionCount(KlibMetadataProtoBuf.propertyBackingFieldAnnotation) - 1) {
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.propertyBackingFieldAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
for(i in 0..getExtensionCount(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation) - 1) {
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
for(i in 0..getExtensionCount(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation) - 1) {
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation, i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
if (hasExtension(KlibMetadataProtoBuf.compileTimeValue)) {
|
||||
hashCode = 31 * hashCode + getExtension(KlibMetadataProtoBuf.compileTimeValue).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
+145
-80
@@ -16,12 +16,16 @@ public final class DebugKlibMetadataProtoBuf {
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.constructorKdoc);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.constructorUniqId);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.functionAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.functionExtensionReceiverAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.functionFile);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.functionKdoc);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.functionUniqId);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyGetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertySetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyBackingFieldAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyDelegatedFieldAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyExtensionReceiverAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.compileTimeValue);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyFile);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.DebugKlibMetadataProtoBuf.propertyKdoc);
|
||||
@@ -3233,6 +3237,17 @@ public final class DebugKlibMetadataProtoBuf {
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int FUNCTION_EXTENSION_RECEIVER_ANNOTATION_FIELD_NUMBER = 171;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Function { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Function,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation>> functionExtensionReceiverAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessage
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int FUNCTION_FILE_FIELD_NUMBER = 172;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Function { ... }</code>
|
||||
@@ -3299,6 +3314,39 @@ public final class DebugKlibMetadataProtoBuf {
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int PROPERTY_BACKING_FIELD_ANNOTATION_FIELD_NUMBER = 181;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Property,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation>> propertyBackingFieldAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessage
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int PROPERTY_DELEGATED_FIELD_ANNOTATION_FIELD_NUMBER = 182;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Property,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation>> propertyDelegatedFieldAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessage
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int PROPERTY_EXTENSION_RECEIVER_ANNOTATION_FIELD_NUMBER = 183;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Property,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation>> propertyExtensionReceiverAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessage
|
||||
.newFileScopedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.class,
|
||||
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance());
|
||||
public static final int COMPILE_TIME_VALUE_FIELD_NUMBER = 173;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
@@ -3543,64 +3591,77 @@ public final class DebugKlibMetadataProtoBuf {
|
||||
"ns.kotlin.library.metadata.DescriptorUni" +
|
||||
"qId:p\n\023function_annotation\022\'.org.jetbrai" +
|
||||
"ns.kotlin.metadata.Function\030\252\001 \003(\0132).org" +
|
||||
".jetbrains.kotlin.metadata.Annotation:E\n" +
|
||||
"\rfunction_file\022\'.org.jetbrains.kotlin.me" +
|
||||
"tadata.Function\030\254\001 \001(\005B\004\200\265\030\001:E\n\rfunction" +
|
||||
"_kdoc\022\'.org.jetbrains.kotlin.metadata.Fu",
|
||||
"nction\030\256\001 \001(\tB\004\200\265\030\001:{\n\020function_uniq_id\022" +
|
||||
"\'.org.jetbrains.kotlin.metadata.Function" +
|
||||
"\030\255\001 \001(\01327.org.jetbrains.kotlin.library.m" +
|
||||
"etadata.DescriptorUniqId:p\n\023property_ann" +
|
||||
"otation\022\'.org.jetbrains.kotlin.metadata." +
|
||||
"Property\030\252\001 \003(\0132).org.jetbrains.kotlin.m" +
|
||||
"etadata.Annotation:w\n\032property_getter_an" +
|
||||
"notation\022\'.org.jetbrains.kotlin.metadata" +
|
||||
".Property\030\261\001 \003(\0132).org.jetbrains.kotlin." +
|
||||
"metadata.Annotation:w\n\032property_setter_a",
|
||||
"nnotation\022\'.org.jetbrains.kotlin.metadat" +
|
||||
"a.Property\030\262\001 \003(\0132).org.jetbrains.kotlin" +
|
||||
".metadata.Annotation:~\n\022compile_time_val" +
|
||||
"ue\022\'.org.jetbrains.kotlin.metadata.Prope" +
|
||||
"rty\030\255\001 \001(\01328.org.jetbrains.kotlin.metada" +
|
||||
"ta.Annotation.Argument.Value:E\n\rproperty" +
|
||||
"_file\022\'.org.jetbrains.kotlin.metadata.Pr" +
|
||||
"operty\030\260\001 \001(\005B\004\200\265\030\001:E\n\rproperty_kdoc\022\'.o" +
|
||||
"rg.jetbrains.kotlin.metadata.Property\030\264\001" +
|
||||
" \001(\tB\004\200\265\030\001:{\n\020property_uniq_id\022\'.org.jet",
|
||||
"brains.kotlin.metadata.Property\030\263\001 \001(\01327" +
|
||||
".org.jetbrains.kotlin.library.metadata.D" +
|
||||
"escriptorUniqId:s\n\025enum_entry_annotation" +
|
||||
"\022(.org.jetbrains.kotlin.metadata.EnumEnt" +
|
||||
"ry\030\252\001 \003(\0132).org.jetbrains.kotlin.metadat" +
|
||||
"a.Annotation:E\n\022enum_entry_ordinal\022(.org" +
|
||||
".jetbrains.kotlin.metadata.EnumEntry\030\253\001 " +
|
||||
"\001(\005:~\n\022enum_entry_uniq_id\022(.org.jetbrain" +
|
||||
"s.kotlin.metadata.EnumEntry\030\254\001 \001(\01327.org" +
|
||||
".jetbrains.kotlin.library.metadata.Descr",
|
||||
"iptorUniqId:w\n\024parameter_annotation\022-.or" +
|
||||
"g.jetbrains.kotlin.metadata.ValueParamet" +
|
||||
"er\030\252\001 \003(\0132).org.jetbrains.kotlin.metadat" +
|
||||
"a.Annotation:h\n\017type_annotation\022#.org.je" +
|
||||
"tbrains.kotlin.metadata.Type\030\252\001 \003(\0132).or" +
|
||||
"g.jetbrains.kotlin.metadata.Annotation:{" +
|
||||
"\n\031type_parameter_annotation\022,.org.jetbra" +
|
||||
"ins.kotlin.metadata.TypeParameter\030\252\001 \003(\013" +
|
||||
"2).org.jetbrains.kotlin.metadata.Annotat" +
|
||||
"ion:\202\001\n\022type_param_uniq_id\022,.org.jetbrai",
|
||||
"ns.kotlin.metadata.TypeParameter\030\253\001 \001(\0132" +
|
||||
"7.org.jetbrains.kotlin.library.metadata." +
|
||||
"DescriptorUniqId:U\n\026package_fragment_fil" +
|
||||
"es\022..org.jetbrains.kotlin.metadata.Packa" +
|
||||
"geFragment\030\252\001 \003(\005B\004\200\265\030\001:A\n\010is_empty\022..or" +
|
||||
"g.jetbrains.kotlin.metadata.PackageFragm" +
|
||||
"ent\030\254\001 \001(\010:@\n\007fq_name\022..org.jetbrains.ko" +
|
||||
"tlin.metadata.PackageFragment\030\255\001 \001(\t:G\n\n" +
|
||||
"class_name\022..org.jetbrains.kotlin.metada" +
|
||||
"ta.PackageFragment\030\256\001 \003(\005B\002\020\001:~\n\022type_al",
|
||||
"ias_uniq_id\022(.org.jetbrains.kotlin.metad" +
|
||||
"ata.TypeAlias\030\203\001 \001(\01327.org.jetbrains.kot" +
|
||||
"lin.library.metadata.DescriptorUniqIdB\033B" +
|
||||
"\031DebugKlibMetadataProtoBuf"
|
||||
".jetbrains.kotlin.metadata.Annotation:\203\001" +
|
||||
"\n&function_extension_receiver_annotation" +
|
||||
"\022\'.org.jetbrains.kotlin.metadata.Functio" +
|
||||
"n\030\253\001 \003(\0132).org.jetbrains.kotlin.metadata",
|
||||
".Annotation:E\n\rfunction_file\022\'.org.jetbr" +
|
||||
"ains.kotlin.metadata.Function\030\254\001 \001(\005B\004\200\265" +
|
||||
"\030\001:E\n\rfunction_kdoc\022\'.org.jetbrains.kotl" +
|
||||
"in.metadata.Function\030\256\001 \001(\tB\004\200\265\030\001:{\n\020fun" +
|
||||
"ction_uniq_id\022\'.org.jetbrains.kotlin.met" +
|
||||
"adata.Function\030\255\001 \001(\01327.org.jetbrains.ko" +
|
||||
"tlin.library.metadata.DescriptorUniqId:p" +
|
||||
"\n\023property_annotation\022\'.org.jetbrains.ko" +
|
||||
"tlin.metadata.Property\030\252\001 \003(\0132).org.jetb" +
|
||||
"rains.kotlin.metadata.Annotation:w\n\032prop",
|
||||
"erty_getter_annotation\022\'.org.jetbrains.k" +
|
||||
"otlin.metadata.Property\030\261\001 \003(\0132).org.jet" +
|
||||
"brains.kotlin.metadata.Annotation:w\n\032pro" +
|
||||
"perty_setter_annotation\022\'.org.jetbrains." +
|
||||
"kotlin.metadata.Property\030\262\001 \003(\0132).org.je" +
|
||||
"tbrains.kotlin.metadata.Annotation:~\n!pr" +
|
||||
"operty_backing_field_annotation\022\'.org.je" +
|
||||
"tbrains.kotlin.metadata.Property\030\265\001 \003(\0132" +
|
||||
").org.jetbrains.kotlin.metadata.Annotati" +
|
||||
"on:\200\001\n#property_delegated_field_annotati",
|
||||
"on\022\'.org.jetbrains.kotlin.metadata.Prope" +
|
||||
"rty\030\266\001 \003(\0132).org.jetbrains.kotlin.metada" +
|
||||
"ta.Annotation:\203\001\n&property_extension_rec" +
|
||||
"eiver_annotation\022\'.org.jetbrains.kotlin." +
|
||||
"metadata.Property\030\267\001 \003(\0132).org.jetbrains" +
|
||||
".kotlin.metadata.Annotation:~\n\022compile_t" +
|
||||
"ime_value\022\'.org.jetbrains.kotlin.metadat" +
|
||||
"a.Property\030\255\001 \001(\01328.org.jetbrains.kotlin" +
|
||||
".metadata.Annotation.Argument.Value:E\n\rp" +
|
||||
"roperty_file\022\'.org.jetbrains.kotlin.meta",
|
||||
"data.Property\030\260\001 \001(\005B\004\200\265\030\001:E\n\rproperty_k" +
|
||||
"doc\022\'.org.jetbrains.kotlin.metadata.Prop" +
|
||||
"erty\030\264\001 \001(\tB\004\200\265\030\001:{\n\020property_uniq_id\022\'." +
|
||||
"org.jetbrains.kotlin.metadata.Property\030\263" +
|
||||
"\001 \001(\01327.org.jetbrains.kotlin.library.met" +
|
||||
"adata.DescriptorUniqId:s\n\025enum_entry_ann" +
|
||||
"otation\022(.org.jetbrains.kotlin.metadata." +
|
||||
"EnumEntry\030\252\001 \003(\0132).org.jetbrains.kotlin." +
|
||||
"metadata.Annotation:E\n\022enum_entry_ordina" +
|
||||
"l\022(.org.jetbrains.kotlin.metadata.EnumEn",
|
||||
"try\030\253\001 \001(\005:~\n\022enum_entry_uniq_id\022(.org.j" +
|
||||
"etbrains.kotlin.metadata.EnumEntry\030\254\001 \001(" +
|
||||
"\01327.org.jetbrains.kotlin.library.metadat" +
|
||||
"a.DescriptorUniqId:w\n\024parameter_annotati" +
|
||||
"on\022-.org.jetbrains.kotlin.metadata.Value" +
|
||||
"Parameter\030\252\001 \003(\0132).org.jetbrains.kotlin." +
|
||||
"metadata.Annotation:h\n\017type_annotation\022#" +
|
||||
".org.jetbrains.kotlin.metadata.Type\030\252\001 \003" +
|
||||
"(\0132).org.jetbrains.kotlin.metadata.Annot" +
|
||||
"ation:{\n\031type_parameter_annotation\022,.org",
|
||||
".jetbrains.kotlin.metadata.TypeParameter" +
|
||||
"\030\252\001 \003(\0132).org.jetbrains.kotlin.metadata." +
|
||||
"Annotation:\202\001\n\022type_param_uniq_id\022,.org." +
|
||||
"jetbrains.kotlin.metadata.TypeParameter\030" +
|
||||
"\253\001 \001(\01327.org.jetbrains.kotlin.library.me" +
|
||||
"tadata.DescriptorUniqId:U\n\026package_fragm" +
|
||||
"ent_files\022..org.jetbrains.kotlin.metadat" +
|
||||
"a.PackageFragment\030\252\001 \003(\005B\004\200\265\030\001:A\n\010is_emp" +
|
||||
"ty\022..org.jetbrains.kotlin.metadata.Packa" +
|
||||
"geFragment\030\254\001 \001(\010:@\n\007fq_name\022..org.jetbr",
|
||||
"ains.kotlin.metadata.PackageFragment\030\255\001 " +
|
||||
"\001(\t:G\n\nclass_name\022..org.jetbrains.kotlin" +
|
||||
".metadata.PackageFragment\030\256\001 \003(\005B\002\020\001:~\n\022" +
|
||||
"type_alias_uniq_id\022(.org.jetbrains.kotli" +
|
||||
"n.metadata.TypeAlias\030\203\001 \001(\01327.org.jetbra" +
|
||||
"ins.kotlin.library.metadata.DescriptorUn" +
|
||||
"iqIdB\033B\031DebugKlibMetadataProtoBuf"
|
||||
};
|
||||
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
@@ -3643,28 +3704,32 @@ public final class DebugKlibMetadataProtoBuf {
|
||||
constructorKdoc.internalInit(descriptor.getExtensions().get(6));
|
||||
constructorUniqId.internalInit(descriptor.getExtensions().get(7));
|
||||
functionAnnotation.internalInit(descriptor.getExtensions().get(8));
|
||||
functionFile.internalInit(descriptor.getExtensions().get(9));
|
||||
functionKdoc.internalInit(descriptor.getExtensions().get(10));
|
||||
functionUniqId.internalInit(descriptor.getExtensions().get(11));
|
||||
propertyAnnotation.internalInit(descriptor.getExtensions().get(12));
|
||||
propertyGetterAnnotation.internalInit(descriptor.getExtensions().get(13));
|
||||
propertySetterAnnotation.internalInit(descriptor.getExtensions().get(14));
|
||||
compileTimeValue.internalInit(descriptor.getExtensions().get(15));
|
||||
propertyFile.internalInit(descriptor.getExtensions().get(16));
|
||||
propertyKdoc.internalInit(descriptor.getExtensions().get(17));
|
||||
propertyUniqId.internalInit(descriptor.getExtensions().get(18));
|
||||
enumEntryAnnotation.internalInit(descriptor.getExtensions().get(19));
|
||||
enumEntryOrdinal.internalInit(descriptor.getExtensions().get(20));
|
||||
enumEntryUniqId.internalInit(descriptor.getExtensions().get(21));
|
||||
parameterAnnotation.internalInit(descriptor.getExtensions().get(22));
|
||||
typeAnnotation.internalInit(descriptor.getExtensions().get(23));
|
||||
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(24));
|
||||
typeParamUniqId.internalInit(descriptor.getExtensions().get(25));
|
||||
packageFragmentFiles.internalInit(descriptor.getExtensions().get(26));
|
||||
isEmpty.internalInit(descriptor.getExtensions().get(27));
|
||||
fqName.internalInit(descriptor.getExtensions().get(28));
|
||||
className.internalInit(descriptor.getExtensions().get(29));
|
||||
typeAliasUniqId.internalInit(descriptor.getExtensions().get(30));
|
||||
functionExtensionReceiverAnnotation.internalInit(descriptor.getExtensions().get(9));
|
||||
functionFile.internalInit(descriptor.getExtensions().get(10));
|
||||
functionKdoc.internalInit(descriptor.getExtensions().get(11));
|
||||
functionUniqId.internalInit(descriptor.getExtensions().get(12));
|
||||
propertyAnnotation.internalInit(descriptor.getExtensions().get(13));
|
||||
propertyGetterAnnotation.internalInit(descriptor.getExtensions().get(14));
|
||||
propertySetterAnnotation.internalInit(descriptor.getExtensions().get(15));
|
||||
propertyBackingFieldAnnotation.internalInit(descriptor.getExtensions().get(16));
|
||||
propertyDelegatedFieldAnnotation.internalInit(descriptor.getExtensions().get(17));
|
||||
propertyExtensionReceiverAnnotation.internalInit(descriptor.getExtensions().get(18));
|
||||
compileTimeValue.internalInit(descriptor.getExtensions().get(19));
|
||||
propertyFile.internalInit(descriptor.getExtensions().get(20));
|
||||
propertyKdoc.internalInit(descriptor.getExtensions().get(21));
|
||||
propertyUniqId.internalInit(descriptor.getExtensions().get(22));
|
||||
enumEntryAnnotation.internalInit(descriptor.getExtensions().get(23));
|
||||
enumEntryOrdinal.internalInit(descriptor.getExtensions().get(24));
|
||||
enumEntryUniqId.internalInit(descriptor.getExtensions().get(25));
|
||||
parameterAnnotation.internalInit(descriptor.getExtensions().get(26));
|
||||
typeAnnotation.internalInit(descriptor.getExtensions().get(27));
|
||||
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(28));
|
||||
typeParamUniqId.internalInit(descriptor.getExtensions().get(29));
|
||||
packageFragmentFiles.internalInit(descriptor.getExtensions().get(30));
|
||||
isEmpty.internalInit(descriptor.getExtensions().get(31));
|
||||
fqName.internalInit(descriptor.getExtensions().get(32));
|
||||
className.internalInit(descriptor.getExtensions().get(33));
|
||||
typeAliasUniqId.internalInit(descriptor.getExtensions().get(34));
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistry registry =
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistry.newInstance();
|
||||
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.skipMessageInComparison);
|
||||
|
||||
+20
@@ -62,6 +62,11 @@ abstract class KotlinSerializerExtensionBase(private val protocol: SerializerExt
|
||||
for (annotation in descriptor.nonSourceAnnotations) {
|
||||
proto.addExtensionOrNull(protocol.functionAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
protocol.functionExtensionReceiverAnnotation?.let { extension ->
|
||||
for (annotation in descriptor.extensionReceiverParameter?.nonSourceAnnotations.orEmpty()) {
|
||||
proto.addExtensionOrNull(extension, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeProperty(
|
||||
@@ -79,6 +84,21 @@ abstract class KotlinSerializerExtensionBase(private val protocol: SerializerExt
|
||||
for (annotation in descriptor.setter?.nonSourceAnnotations.orEmpty()) {
|
||||
proto.addExtensionOrNull(protocol.propertySetterAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
protocol.propertyExtensionReceiverAnnotation?.let { extension ->
|
||||
for (annotation in descriptor.extensionReceiverParameter?.nonSourceAnnotations.orEmpty()) {
|
||||
proto.addExtensionOrNull(extension, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
protocol.propertyBackingFieldAnnotation?.let { extension ->
|
||||
for (annotation in descriptor.backingField?.nonSourceAnnotations.orEmpty()) {
|
||||
proto.addExtensionOrNull(extension, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
protocol.propertyDelegatedFieldAnnotation?.let { extension ->
|
||||
for (annotation in descriptor.delegateField?.nonSourceAnnotations.orEmpty()) {
|
||||
proto.addExtensionOrNull(extension, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
val constantInitializer = descriptor.compileTimeInitializer ?: return
|
||||
if (constantInitializer !is NullValue) {
|
||||
proto.setExtension(protocol.compileTimeValue, annotationSerializer.valueProto(constantInitializer).build())
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package test
|
||||
|
||||
annotation class Ann
|
||||
|
||||
@field:Ann
|
||||
var x: Int = 5
|
||||
@delegate:Ann
|
||||
var y: Int by ::x
|
||||
|
||||
class A {
|
||||
@field:Ann
|
||||
var x: Int = 5
|
||||
@delegate:Ann
|
||||
var y: Int by ::x
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
@field:test.Ann public var x: kotlin.Int
|
||||
@delegate:test.Ann public var y: kotlin.Int
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
@field:test.Ann public final var x: kotlin.Int
|
||||
@delegate:test.Ann public final var y: kotlin.Int
|
||||
}
|
||||
|
||||
public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
annotation class Ann
|
||||
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int) = 10
|
||||
@Ann val @receiver:Ann Int.bar
|
||||
get() = 5
|
||||
|
||||
class A {
|
||||
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int) = 10
|
||||
@Ann val @receiver:Ann Int.bar
|
||||
get() = 5
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
@test.Ann public val @receiver:test.Ann kotlin.Int.bar: kotlin.Int
|
||||
@test.Ann public fun @receiver:test.Ann kotlin.Int.foo(/*0*/ @test.Ann arg: kotlin.Int): kotlin.Int
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
@test.Ann public final val @receiver:test.Ann kotlin.Int.bar: kotlin.Int
|
||||
@test.Ann public final fun @receiver:test.Ann kotlin.Int.foo(/*0*/ @test.Ann arg: kotlin.Int): kotlin.Int
|
||||
}
|
||||
|
||||
public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization.klib
|
||||
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
|
||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.TEST_PACKAGE_FQNAME
|
||||
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
||||
import org.jetbrains.kotlin.serialization.NonStableParameterNamesSerializationTest
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil.readModuleAsProto
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.test.KlibTestUtil
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor
|
||||
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.io.File
|
||||
|
||||
class KotlinKlibSerializerTest : TestCaseWithTmpdir() {
|
||||
private val BASE_DIR = "compiler/testData/serialization"
|
||||
|
||||
private fun doTest(fileName: String) {
|
||||
val source = "$BASE_DIR/$fileName"
|
||||
val klibName = File(source).nameWithoutExtension
|
||||
val klibFile = File(tmpdir, "$klibName.klib")
|
||||
KlibTestUtil.compileCommonSourcesToKlib(listOf(File(source)), klibName, klibFile)
|
||||
|
||||
val module = KlibTestUtil.deserializeKlibToCommonModule(klibFile)
|
||||
|
||||
RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile(
|
||||
module.getPackage(TEST_PACKAGE_FQNAME),
|
||||
RecursiveDescriptorComparator.DONT_INCLUDE_METHODS_OF_OBJECT,
|
||||
File(source.replace(".kt", ".txt"))
|
||||
)
|
||||
}
|
||||
|
||||
fun testSimple() {
|
||||
doTest("builtinsSerializer/simple.kt")
|
||||
}
|
||||
|
||||
fun testNestedClassesAndObjects() {
|
||||
doTest("builtinsSerializer/nestedClassesAndObjects.kt")
|
||||
}
|
||||
|
||||
fun testCompileTimeConstants() {
|
||||
doTest("builtinsSerializer/compileTimeConstants.kt")
|
||||
}
|
||||
|
||||
fun testAnnotationTargets() {
|
||||
doTest("builtinsSerializer/annotationTargets.kt")
|
||||
}
|
||||
|
||||
fun testAnnotatedEnumEntry() {
|
||||
doTest("builtinsSerializer/annotatedEnumEntry.kt")
|
||||
}
|
||||
|
||||
fun testPrimitives() {
|
||||
doTest("builtinsSerializer/annotationArguments/primitives.kt")
|
||||
}
|
||||
|
||||
fun testPrimitiveArrays() {
|
||||
doTest("builtinsSerializer/annotationArguments/primitiveArrays.kt")
|
||||
}
|
||||
|
||||
fun testString() {
|
||||
doTest("builtinsSerializer/annotationArguments/string.kt")
|
||||
}
|
||||
|
||||
fun testAnnotation() {
|
||||
doTest("builtinsSerializer/annotationArguments/annotation.kt")
|
||||
}
|
||||
|
||||
fun testEnum() {
|
||||
doTest("builtinsSerializer/annotationArguments/enum.kt")
|
||||
}
|
||||
|
||||
fun testPropertyAccessorAnnotations() {
|
||||
doTest("builtinsSerializer/propertyAccessorAnnotations.kt")
|
||||
}
|
||||
|
||||
fun testReceiverAnnotations() {
|
||||
doTest("klib/receiverAnnotations.kt")
|
||||
}
|
||||
|
||||
fun testFieldAnnotations() {
|
||||
doTest("klib/fieldAnnotations.kt")
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ extend org.jetbrains.kotlin.metadata.Constructor {
|
||||
|
||||
extend org.jetbrains.kotlin.metadata.Function {
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation function_annotation = 170;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation function_extension_receiver_annotation = 171;
|
||||
optional int32 function_file = 172 [(org.jetbrains.kotlin.metadata.skip_in_comparison) = true];
|
||||
optional string function_kdoc = 174 [(org.jetbrains.kotlin.metadata.skip_in_comparison) = true];
|
||||
optional DescriptorUniqId function_uniq_id = 173;
|
||||
@@ -81,6 +82,9 @@ extend org.jetbrains.kotlin.metadata.Property {
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_annotation = 170;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_getter_annotation = 177;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_setter_annotation = 178;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_backing_field_annotation = 181;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_delegated_field_annotation = 182;
|
||||
repeated org.jetbrains.kotlin.metadata.Annotation property_extension_receiver_annotation = 183;
|
||||
optional org.jetbrains.kotlin.metadata.Annotation.Argument.Value compile_time_value = 173;
|
||||
optional int32 property_file = 176 [(org.jetbrains.kotlin.metadata.skip_in_comparison) = true];
|
||||
optional string property_kdoc = 180 [(org.jetbrains.kotlin.metadata.skip_in_comparison) = true];
|
||||
|
||||
+68
@@ -16,12 +16,16 @@ public final class KlibMetadataProtoBuf {
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.constructorKdoc);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.constructorUniqId);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.functionAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.functionExtensionReceiverAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.functionFile);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.functionKdoc);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.functionUniqId);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyGetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertySetterAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyBackingFieldAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.compileTimeValue);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyFile);
|
||||
registry.add(org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.propertyKdoc);
|
||||
@@ -2661,6 +2665,22 @@ public final class KlibMetadataProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int FUNCTION_EXTENSION_RECEIVER_ANNOTATION_FIELD_NUMBER = 171;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Function { ... }</code>
|
||||
*/
|
||||
public static final
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.GeneratedExtension<
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Function,
|
||||
java.util.List<org.jetbrains.kotlin.metadata.ProtoBuf.Annotation>> functionExtensionReceiverAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Function.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
171,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int FUNCTION_FILE_FIELD_NUMBER = 172;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Function { ... }</code>
|
||||
@@ -2757,6 +2777,54 @@ public final class KlibMetadataProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int PROPERTY_BACKING_FIELD_ANNOTATION_FIELD_NUMBER = 181;
|
||||
/**
|
||||
* <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>> propertyBackingFieldAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
181,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int PROPERTY_DELEGATED_FIELD_ANNOTATION_FIELD_NUMBER = 182;
|
||||
/**
|
||||
* <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>> propertyDelegatedFieldAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
182,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int PROPERTY_EXTENSION_RECEIVER_ANNOTATION_FIELD_NUMBER = 183;
|
||||
/**
|
||||
* <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>> propertyExtensionReceiverAnnotation = org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.newRepeatedGeneratedExtension(
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Property.getDefaultInstance(),
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(),
|
||||
null,
|
||||
183,
|
||||
org.jetbrains.kotlin.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
false,
|
||||
org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.class);
|
||||
public static final int COMPILE_TIME_VALUE_FIELD_NUMBER = 173;
|
||||
/**
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Property { ... }</code>
|
||||
|
||||
+4
@@ -14,9 +14,13 @@ object KlibMetadataSerializerProtocol : SerializerExtensionProtocol(
|
||||
KlibMetadataProtoBuf.constructorAnnotation,
|
||||
KlibMetadataProtoBuf.classAnnotation,
|
||||
KlibMetadataProtoBuf.functionAnnotation,
|
||||
KlibMetadataProtoBuf.functionExtensionReceiverAnnotation,
|
||||
KlibMetadataProtoBuf.propertyAnnotation,
|
||||
KlibMetadataProtoBuf.propertyGetterAnnotation,
|
||||
KlibMetadataProtoBuf.propertySetterAnnotation,
|
||||
KlibMetadataProtoBuf.propertyExtensionReceiverAnnotation,
|
||||
KlibMetadataProtoBuf.propertyBackingFieldAnnotation,
|
||||
KlibMetadataProtoBuf.propertyDelegatedFieldAnnotation,
|
||||
KlibMetadataProtoBuf.enumEntryAnnotation,
|
||||
KlibMetadataProtoBuf.compileTimeValue,
|
||||
KlibMetadataProtoBuf.parameterAnnotation,
|
||||
|
||||
+4
@@ -26,9 +26,13 @@ open class SerializerExtensionProtocol(
|
||||
val constructorAnnotation: GeneratedExtension<ProtoBuf.Constructor, List<ProtoBuf.Annotation>>,
|
||||
val classAnnotation: GeneratedExtension<ProtoBuf.Class, List<ProtoBuf.Annotation>>,
|
||||
val functionAnnotation: GeneratedExtension<ProtoBuf.Function, List<ProtoBuf.Annotation>>,
|
||||
val functionExtensionReceiverAnnotation: 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 propertyExtensionReceiverAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>?,
|
||||
val propertyBackingFieldAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>?,
|
||||
val propertyDelegatedFieldAnnotation: 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>>,
|
||||
|
||||
+4
@@ -16,9 +16,13 @@ object BuiltInSerializerProtocol : SerializerExtensionProtocol(
|
||||
BuiltInsProtoBuf.constructorAnnotation,
|
||||
BuiltInsProtoBuf.classAnnotation,
|
||||
BuiltInsProtoBuf.functionAnnotation,
|
||||
functionExtensionReceiverAnnotation = null,
|
||||
BuiltInsProtoBuf.propertyAnnotation,
|
||||
BuiltInsProtoBuf.propertyGetterAnnotation,
|
||||
BuiltInsProtoBuf.propertySetterAnnotation,
|
||||
propertyExtensionReceiverAnnotation = null,
|
||||
propertyBackingFieldAnnotation = null,
|
||||
propertyDelegatedFieldAnnotation = null,
|
||||
BuiltInsProtoBuf.enumEntryAnnotation,
|
||||
BuiltInsProtoBuf.compileTimeValue,
|
||||
BuiltInsProtoBuf.parameterAnnotation,
|
||||
|
||||
+27
-5
@@ -60,11 +60,19 @@ class AnnotationAndConstantLoaderImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadPropertyBackingFieldAnnotations(container: ProtoContainer, proto: ProtoBuf.Property): List<AnnotationDescriptor> =
|
||||
emptyList()
|
||||
override fun loadPropertyBackingFieldAnnotations(container: ProtoContainer, proto: ProtoBuf.Property): List<AnnotationDescriptor> {
|
||||
val annotations = protocol.propertyBackingFieldAnnotation?.let { proto.getExtension(it) }.orEmpty()
|
||||
return annotations.map { annotationProto ->
|
||||
deserializer.deserializeAnnotation(annotationProto, container.nameResolver)
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadPropertyDelegateFieldAnnotations(container: ProtoContainer, proto: ProtoBuf.Property): List<AnnotationDescriptor> =
|
||||
emptyList()
|
||||
override fun loadPropertyDelegateFieldAnnotations(container: ProtoContainer, proto: ProtoBuf.Property): List<AnnotationDescriptor> {
|
||||
val annotations = protocol.propertyDelegatedFieldAnnotation?.let {proto.getExtension(it) }.orEmpty()
|
||||
return annotations.map { annotationProto ->
|
||||
deserializer.deserializeAnnotation(annotationProto, container.nameResolver)
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadEnumEntryAnnotations(container: ProtoContainer, proto: ProtoBuf.EnumEntry): List<AnnotationDescriptor> {
|
||||
val annotations = proto.getExtension(protocol.enumEntryAnnotation).orEmpty()
|
||||
@@ -90,7 +98,21 @@ class AnnotationAndConstantLoaderImpl(
|
||||
container: ProtoContainer,
|
||||
proto: MessageLite,
|
||||
kind: AnnotatedCallableKind
|
||||
): List<AnnotationDescriptor> = emptyList()
|
||||
): List<AnnotationDescriptor> {
|
||||
val annotations = when (proto) {
|
||||
is ProtoBuf.Function -> protocol.functionExtensionReceiverAnnotation?.let { proto.getExtension(it) }
|
||||
is ProtoBuf.Property -> when (kind) {
|
||||
AnnotatedCallableKind.PROPERTY, AnnotatedCallableKind.PROPERTY_GETTER, AnnotatedCallableKind.PROPERTY_SETTER -> {
|
||||
protocol.propertyExtensionReceiverAnnotation?.let { proto.getExtension(it) }
|
||||
}
|
||||
else -> error("Unsupported callable kind with property proto for receiver annotations: $kind")
|
||||
}
|
||||
else -> error("Unknown message: $proto")
|
||||
}.orEmpty()
|
||||
return annotations.map { annotationProto ->
|
||||
deserializer.deserializeAnnotation(annotationProto, container.nameResolver)
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadTypeAnnotations(proto: ProtoBuf.Type, nameResolver: NameResolver): List<AnnotationDescriptor> {
|
||||
return proto.getExtension(protocol.typeAnnotation).orEmpty().map { deserializer.deserializeAnnotation(it, nameResolver) }
|
||||
|
||||
@@ -17,9 +17,13 @@ object JsSerializerProtocol : SerializerExtensionProtocol(
|
||||
JsProtoBuf.constructorAnnotation,
|
||||
JsProtoBuf.classAnnotation,
|
||||
JsProtoBuf.functionAnnotation,
|
||||
functionExtensionReceiverAnnotation = null,
|
||||
JsProtoBuf.propertyAnnotation,
|
||||
JsProtoBuf.propertyGetterAnnotation,
|
||||
JsProtoBuf.propertySetterAnnotation,
|
||||
propertyExtensionReceiverAnnotation = null,
|
||||
propertyBackingFieldAnnotation = null,
|
||||
propertyDelegatedFieldAnnotation = null,
|
||||
JsProtoBuf.enumEntryAnnotation,
|
||||
JsProtoBuf.compileTimeValue,
|
||||
JsProtoBuf.parameterAnnotation,
|
||||
|
||||
@@ -1293,7 +1293,7 @@ __attribute__((swift_name("MySwiftArray")))
|
||||
__attribute__((swift_name("ObjCNameI1")))
|
||||
@protocol KtObjCNameI1
|
||||
@required
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1302,7 +1302,7 @@ __attribute__((swift_name("SwiftNameC2")))
|
||||
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1342,7 +1342,7 @@ __attribute__((swift_name("ObjCNameC4")))
|
||||
@interface KtObjCNameC4 : KtBase
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
|
||||
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@@ -1379,7 +1379,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ObjCNameBKt")))
|
||||
@interface KtObjCNameBKt : KtBase
|
||||
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
|
||||
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
|
||||
@end
|
||||
|
||||
__attribute__((swift_name("OverrideKotlinMethods2")))
|
||||
|
||||
@@ -1228,7 +1228,7 @@ __attribute__((swift_name("MySwiftArray")))
|
||||
__attribute__((swift_name("ObjCNameI1")))
|
||||
@protocol KtObjCNameI1
|
||||
@required
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1237,7 +1237,7 @@ __attribute__((swift_name("SwiftNameC2")))
|
||||
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1277,7 +1277,7 @@ __attribute__((swift_name("ObjCNameC4")))
|
||||
@interface KtObjCNameC4 : KtBase
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
|
||||
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@@ -1314,7 +1314,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ObjCNameBKt")))
|
||||
@interface KtObjCNameBKt : KtBase
|
||||
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
|
||||
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
|
||||
@end
|
||||
|
||||
__attribute__((swift_name("OverrideKotlinMethods2")))
|
||||
|
||||
@@ -1228,7 +1228,7 @@ __attribute__((swift_name("MySwiftArray")))
|
||||
__attribute__((swift_name("ObjCNameI1")))
|
||||
@protocol KtObjCNameI1
|
||||
@required
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1237,7 +1237,7 @@ __attribute__((swift_name("SwiftNameC2")))
|
||||
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
|
||||
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
|
||||
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
|
||||
@end
|
||||
|
||||
@@ -1277,7 +1277,7 @@ __attribute__((swift_name("ObjCNameC4")))
|
||||
@interface KtObjCNameC4 : KtBase
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
|
||||
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@@ -1314,7 +1314,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ObjCNameBKt")))
|
||||
@interface KtObjCNameBKt : KtBase
|
||||
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
|
||||
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
|
||||
@end
|
||||
|
||||
__attribute__((swift_name("OverrideKotlinMethods2")))
|
||||
|
||||
@@ -17,7 +17,7 @@ private func testObjCNameParameterNames() throws {
|
||||
|
||||
private func testObjCNameReceiverName() throws {
|
||||
let object = SwiftNameC2()
|
||||
try assertEquals(actual: ObjCNameBKt.getSomeValue(object), expected: 0)
|
||||
try assertEquals(actual: ObjCNameBKt.getSomeValue(of: object), expected: 0)
|
||||
}
|
||||
|
||||
private func testObjCNameMySwiftArray() throws {
|
||||
@@ -31,8 +31,8 @@ private func testObjCNameOverrides() throws {
|
||||
try assertEquals(actual: object.someOtherValue, expected: 0)
|
||||
object.someOtherValue = 1
|
||||
try assertEquals(actual: object.someOtherValue, expected: 1)
|
||||
try assertEquals(actual: object.someOtherFunction(2, otherParam: 4), expected: 8)
|
||||
try assertEquals(actual: ObjCNameC4().foo(3, objCParam: 5), expected: 15)
|
||||
try assertEquals(actual: object.someOtherFunction(receiver: 2, otherParam: 4), expected: 8)
|
||||
try assertEquals(actual: ObjCNameC4().foo(objCReceiver: 3, objCParam: 5), expected: 15)
|
||||
}
|
||||
|
||||
private func testObjCNameNestedClass() throws {
|
||||
|
||||
@@ -29,12 +29,10 @@ interface ObjCNameI1 {
|
||||
@ObjCName("someOtherValue")
|
||||
val someValue: Int
|
||||
@ObjCName("someOtherFunction")
|
||||
// KT-53317
|
||||
fun /* @receiver:ObjCName("receiver") */ Int.someFunction(@ObjCName("otherParam") param: Int): Int
|
||||
fun @receiver:ObjCName("receiver") Int.someFunction(@ObjCName("otherParam") param: Int): Int
|
||||
}
|
||||
|
||||
// KT-53317
|
||||
fun /* @receiver:ObjCName("of") */ ObjCNameI1.getSomeValue(): Int = someValue
|
||||
fun @receiver:ObjCName("of") ObjCNameI1.getSomeValue(): Int = someValue
|
||||
|
||||
@ObjCName(swiftName = "SwiftNameC2")
|
||||
class ObjCNameC2: ObjCNameI1 {
|
||||
@@ -61,8 +59,7 @@ class ObjCNameC3 {
|
||||
}
|
||||
|
||||
private interface ObjCNameI2 {
|
||||
// KT-53317
|
||||
fun /* @receiver:ObjCName("objCReceiver") */ Int.foo(@ObjCName("objCParam") param: Int): Int
|
||||
fun @receiver:ObjCName("objCReceiver") Int.foo(@ObjCName("objCParam") param: Int): Int
|
||||
}
|
||||
|
||||
class ObjCNameC4: ObjCNameI2 {
|
||||
|
||||
Reference in New Issue
Block a user