Write is_unsigned flag into metadata for an annotation arguments

Instead of adding new kind of types, we'll use flag to disambiguate
 usual types from unsigned ones, this approach has two advantages:
 - less changes in the metadata format
 - it allows naturally extend format for unsigned arrays,
  which will be supported later

 #KT-25310 Fixed
 #KT-25273 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-07-06 01:41:13 +03:00
parent 8c075bc622
commit 0c6757a8b0
13 changed files with 487 additions and 169 deletions
@@ -990,6 +990,11 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkEqualsAnnotationArgumentValueArrayElement(old, new)) return false if (!checkEqualsAnnotationArgumentValueArrayElement(old, new)) return false
if (old.hasFlags() != new.hasFlags()) return false
if (old.hasFlags()) {
if (old.flags != new.flags) return false
}
return true return true
} }
@@ -2120,6 +2125,10 @@ fun ProtoBuf.Annotation.Argument.Value.hashCode(stringIndexes: (Int) -> Int, fqN
hashCode = 31 * hashCode + getArrayElement(i).hashCode(stringIndexes, fqNameIndexes) hashCode = 31 * hashCode + getArrayElement(i).hashCode(stringIndexes, fqNameIndexes)
} }
if (hasFlags()) {
hashCode = 31 * hashCode + flags
}
return hashCode return hashCode
} }
@@ -2632,6 +2632,23 @@ public final class DebugProtoBuf {
*/ */
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.ValueOrBuilder getArrayElementOrBuilder( org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.ValueOrBuilder getArrayElementOrBuilder(
int index); int index);
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
boolean hasFlags();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
int getFlags();
} }
/** /**
* Protobuf type {@code org.jetbrains.kotlin.metadata.Annotation.Argument.Value} * Protobuf type {@code org.jetbrains.kotlin.metadata.Annotation.Argument.Value}
@@ -2747,6 +2764,11 @@ public final class DebugProtoBuf {
arrayElement_.add(input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.Value.PARSER, extensionRegistry)); arrayElement_.add(input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.Value.PARSER, extensionRegistry));
break; break;
} }
case 80: {
bitField0_ |= 0x00000100;
flags_ = input.readInt32();
break;
}
} }
} }
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -3152,6 +3174,29 @@ public final class DebugProtoBuf {
return arrayElement_.get(index); return arrayElement_.get(index);
} }
public static final int FLAGS_FIELD_NUMBER = 10;
private int flags_;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
private void initFields() { private void initFields() {
type_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.Value.Type.BYTE; type_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.Value.Type.BYTE;
intValue_ = 0L; intValue_ = 0L;
@@ -3162,6 +3207,7 @@ public final class DebugProtoBuf {
enumValueId_ = 0; enumValueId_ = 0;
annotation_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance(); annotation_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance();
arrayElement_ = java.util.Collections.emptyList(); arrayElement_ = java.util.Collections.emptyList();
flags_ = 0;
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@@ -3215,6 +3261,9 @@ public final class DebugProtoBuf {
for (int i = 0; i < arrayElement_.size(); i++) { for (int i = 0; i < arrayElement_.size(); i++) {
output.writeMessage(9, arrayElement_.get(i)); output.writeMessage(9, arrayElement_.get(i));
} }
if (((bitField0_ & 0x00000100) == 0x00000100)) {
output.writeInt32(10, flags_);
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@@ -3260,6 +3309,10 @@ public final class DebugProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(9, arrayElement_.get(i)); .computeMessageSize(9, arrayElement_.get(i));
} }
if (((bitField0_ & 0x00000100) == 0x00000100)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(10, flags_);
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@@ -3405,6 +3458,8 @@ public final class DebugProtoBuf {
} else { } else {
arrayElementBuilder_.clear(); arrayElementBuilder_.clear();
} }
flags_ = 0;
bitField0_ = (bitField0_ & ~0x00000200);
return this; return this;
} }
@@ -3478,6 +3533,10 @@ public final class DebugProtoBuf {
} else { } else {
result.arrayElement_ = arrayElementBuilder_.build(); result.arrayElement_ = arrayElementBuilder_.build();
} }
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000100;
}
result.flags_ = flags_;
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
@@ -3544,6 +3603,9 @@ public final class DebugProtoBuf {
} }
} }
} }
if (other.hasFlags()) {
setFlags(other.getFlags());
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@@ -4206,6 +4268,54 @@ public final class DebugProtoBuf {
return arrayElementBuilder_; return arrayElementBuilder_;
} }
private int flags_ ;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder setFlags(int value) {
bitField0_ |= 0x00000200;
flags_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.metadata.Annotation.Argument.Value) // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.metadata.Annotation.Argument.Value)
} }
@@ -33542,12 +33652,12 @@ public final class DebugProtoBuf {
"name\030\002 \002(\005\022[\n\004kind\030\003 \001(\0162D.org.jetbrains" + "name\030\002 \002(\005\022[\n\004kind\030\003 \001(\0162D.org.jetbrains" +
".kotlin.metadata.QualifiedNameTable.Qual", ".kotlin.metadata.QualifiedNameTable.Qual",
"ifiedName.Kind:\007PACKAGE\")\n\004Kind\022\t\n\005CLASS" + "ifiedName.Kind:\007PACKAGE\")\n\004Kind\022\t\n\005CLASS" +
"\020\000\022\013\n\007PACKAGE\020\001\022\t\n\005LOCAL\020\002\"\342\005\n\nAnnotatio" + "\020\000\022\013\n\007PACKAGE\020\001\022\t\n\005LOCAL\020\002\"\364\005\n\nAnnotatio" +
"n\022\020\n\002id\030\001 \002(\005B\004\220\265\030\001\022D\n\010argument\030\002 \003(\01322." + "n\022\020\n\002id\030\001 \002(\005B\004\220\265\030\001\022D\n\010argument\030\002 \003(\01322." +
"org.jetbrains.kotlin.metadata.Annotation" + "org.jetbrains.kotlin.metadata.Annotation" +
".Argument\032\373\004\n\010Argument\022\025\n\007name_id\030\001 \002(\005B" + ".Argument\032\215\005\n\010Argument\022\025\n\007name_id\030\001 \002(\005B" +
"\004\210\265\030\001\022G\n\005value\030\002 \002(\01328.org.jetbrains.kot" + "\004\210\265\030\001\022G\n\005value\030\002 \002(\01328.org.jetbrains.kot" +
"lin.metadata.Annotation.Argument.Value\032\216" + "lin.metadata.Annotation.Argument.Value\032\240" +
"\004\n\005Value\022K\n\004type\030\001 \001(\0162=.org.jetbrains.k" + "\004\n\005Value\022K\n\004type\030\001 \001(\0162=.org.jetbrains.k" +
"otlin.metadata.Annotation.Argument.Value" + "otlin.metadata.Annotation.Argument.Value" +
".Type\022\021\n\tint_value\030\002 \001(\022\022\023\n\013float_value\030", ".Type\022\021\n\tint_value\030\002 \001(\022\022\023\n\013float_value\030",
@@ -33557,167 +33667,167 @@ public final class DebugProtoBuf {
"on\030\010 \001(\0132).org.jetbrains.kotlin.metadata" + "on\030\010 \001(\0132).org.jetbrains.kotlin.metadata" +
".Annotation\022O\n\rarray_element\030\t \003(\01328.org" + ".Annotation\022O\n\rarray_element\030\t \003(\01328.org" +
".jetbrains.kotlin.metadata.Annotation.Ar" + ".jetbrains.kotlin.metadata.Annotation.Ar" +
"gument.Value\"\230\001\n\004Type\022\010\n\004BYTE\020\000\022\010\n\004CHAR\020" + "gument.Value\022\020\n\005flags\030\n \001(\005:\0010\"\230\001\n\004Type\022" +
"\001\022\t\n\005SHORT\020\002\022\007\n\003INT\020\003\022\010\n\004LONG\020\004\022\t\n\005FLOAT" + "\010\n\004BYTE\020\000\022\010\n\004CHAR\020\001\022\t\n\005SHORT\020\002\022\007\n\003INT\020\003\022" +
"\020\005\022\n\n\006DOUBLE\020\006\022\013\n\007BOOLEAN\020\007\022\n\n\006STRING\020\010\022" + "\010\n\004LONG\020\004\022\t\n\005FLOAT\020\005\022\n\n\006DOUBLE\020\006\022\013\n\007BOOL" +
"\t\n\005CLASS\020\t\022\010\n\004ENUM\020\n\022\016\n\nANNOTATION\020\013\022\t\n\005", "EAN\020\007\022\n\n\006STRING\020\010\022\t\n\005CLASS\020\t\022\010\n\004ENUM\020\n\022\016",
"ARRAY\020\014\"\373\005\n\004Type\022>\n\010argument\030\002 \003(\0132,.org" + "\n\nANNOTATION\020\013\022\t\n\005ARRAY\020\014\"\373\005\n\004Type\022>\n\010ar" +
".jetbrains.kotlin.metadata.Type.Argument" + "gument\030\002 \003(\0132,.org.jetbrains.kotlin.meta" +
"\022\027\n\010nullable\030\003 \001(\010:\005false\022+\n\035flexible_ty" + "data.Type.Argument\022\027\n\010nullable\030\003 \001(\010:\005fa" +
"pe_capabilities_id\030\004 \001(\005B\004\230\265\030\001\022A\n\024flexib" + "lse\022+\n\035flexible_type_capabilities_id\030\004 \001" +
"le_upper_bound\030\005 \001(\0132#.org.jetbrains.kot" + "(\005B\004\230\265\030\001\022A\n\024flexible_upper_bound\030\005 \001(\0132#" +
"lin.metadata.Type\022\037\n\027flexible_upper_boun" + ".org.jetbrains.kotlin.metadata.Type\022\037\n\027f" +
"d_id\030\010 \001(\005\022\030\n\nclass_name\030\006 \001(\005B\004\220\265\030\001\022\026\n\016" + "lexible_upper_bound_id\030\010 \001(\005\022\030\n\nclass_na" +
"type_parameter\030\007 \001(\005\022!\n\023type_parameter_n" + "me\030\006 \001(\005B\004\220\265\030\001\022\026\n\016type_parameter\030\007 \001(\005\022!" +
"ame\030\t \001(\005B\004\210\265\030\001\022\035\n\017type_alias_name\030\014 \001(\005" + "\n\023type_parameter_name\030\t \001(\005B\004\210\265\030\001\022\035\n\017typ" +
"B\004\220\265\030\001\0227\n\nouter_type\030\n \001(\0132#.org.jetbrai", "e_alias_name\030\014 \001(\005B\004\220\265\030\001\0227\n\nouter_type\030\n",
"ns.kotlin.metadata.Type\022\025\n\router_type_id" + " \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"\030\013 \001(\005\022=\n\020abbreviated_type\030\r \001(\0132#.org.j" + "e\022\025\n\router_type_id\030\013 \001(\005\022=\n\020abbreviated_" +
"etbrains.kotlin.metadata.Type\022\033\n\023abbrevi" + "type\030\r \001(\0132#.org.jetbrains.kotlin.metada" +
"ated_type_id\030\016 \001(\005\022\r\n\005flags\030\001 \001(\005\032\322\001\n\010Ar" + "ta.Type\022\033\n\023abbreviated_type_id\030\016 \001(\005\022\r\n\005" +
"gument\022P\n\nprojection\030\001 \001(\01627.org.jetbrai" + "flags\030\001 \001(\005\032\322\001\n\010Argument\022P\n\nprojection\030\001" +
"ns.kotlin.metadata.Type.Argument.Project" + " \001(\01627.org.jetbrains.kotlin.metadata.Typ" +
"ion:\003INV\0221\n\004type\030\002 \001(\0132#.org.jetbrains.k" + "e.Argument.Projection:\003INV\0221\n\004type\030\002 \001(\013" +
"otlin.metadata.Type\022\017\n\007type_id\030\003 \001(\005\"0\n\n" + "2#.org.jetbrains.kotlin.metadata.Type\022\017\n" +
"Projection\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002\022\010\n\004" + "\007type_id\030\003 \001(\005\"0\n\nProjection\022\006\n\002IN\020\000\022\007\n\003" +
"STAR\020\003*\005\010d\020\310\001\"\230\002\n\rTypeParameter\022\n\n\002id\030\001 ", "OUT\020\001\022\007\n\003INV\020\002\022\010\n\004STAR\020\003*\005\010d\020\310\001\"\230\002\n\rType",
"\002(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022\026\n\007reified\030\003 \001(\010" + "Parameter\022\n\n\002id\030\001 \002(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030" +
":\005false\022L\n\010variance\030\004 \001(\01625.org.jetbrain" + "\001\022\026\n\007reified\030\003 \001(\010:\005false\022L\n\010variance\030\004 " +
"s.kotlin.metadata.TypeParameter.Variance" + "\001(\01625.org.jetbrains.kotlin.metadata.Type" +
":\003INV\0228\n\013upper_bound\030\005 \003(\0132#.org.jetbrai" + "Parameter.Variance:\003INV\0228\n\013upper_bound\030\005" +
"ns.kotlin.metadata.Type\022\032\n\016upper_bound_i" + " \003(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"d\030\006 \003(\005B\002\020\001\"$\n\010Variance\022\006\n\002IN\020\000\022\007\n\003OUT\020\001" + "e\022\032\n\016upper_bound_id\030\006 \003(\005B\002\020\001\"$\n\010Varianc" +
"\022\007\n\003INV\020\002*\005\010d\020\350\007\"\244\007\n\005Class\022\020\n\005flags\030\001 \001(" + "e\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\244\007\n\005C" +
"\005:\0016\022\025\n\007fq_name\030\003 \002(\005B\004\220\265\030\001\022#\n\025companion" + "lass\022\020\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B" +
"_object_name\030\004 \001(\005B\004\210\265\030\001\022D\n\016type_paramet" + "\004\220\265\030\001\022#\n\025companion_object_name\030\004 \001(\005B\004\210\265" +
"er\030\005 \003(\0132,.org.jetbrains.kotlin.metadata", "\030\001\022D\n\016type_parameter\030\005 \003(\0132,.org.jetbrai",
".TypeParameter\0226\n\tsupertype\030\006 \003(\0132#.org." + "ns.kotlin.metadata.TypeParameter\0226\n\tsupe" +
"jetbrains.kotlin.metadata.Type\022\030\n\014supert" + "rtype\030\006 \003(\0132#.org.jetbrains.kotlin.metad" +
"ype_id\030\002 \003(\005B\002\020\001\022!\n\021nested_class_name\030\007 " + "ata.Type\022\030\n\014supertype_id\030\002 \003(\005B\002\020\001\022!\n\021ne" +
"\003(\005B\006\020\001\210\265\030\001\022?\n\013constructor\030\010 \003(\0132*.org.j" + "sted_class_name\030\007 \003(\005B\006\020\001\210\265\030\001\022?\n\013constru" +
"etbrains.kotlin.metadata.Constructor\0229\n\010" + "ctor\030\010 \003(\0132*.org.jetbrains.kotlin.metada" +
"function\030\t \003(\0132\'.org.jetbrains.kotlin.me" + "ta.Constructor\0229\n\010function\030\t \003(\0132\'.org.j" +
"tadata.Function\0229\n\010property\030\n \003(\0132\'.org." + "etbrains.kotlin.metadata.Function\0229\n\010pro" +
"jetbrains.kotlin.metadata.Property\022<\n\nty" + "perty\030\n \003(\0132\'.org.jetbrains.kotlin.metad" +
"pe_alias\030\013 \003(\0132(.org.jetbrains.kotlin.me" + "ata.Property\022<\n\ntype_alias\030\013 \003(\0132(.org.j" +
"tadata.TypeAlias\022<\n\nenum_entry\030\r \003(\0132(.o", "etbrains.kotlin.metadata.TypeAlias\022<\n\nen",
"rg.jetbrains.kotlin.metadata.EnumEntry\022\'" + "um_entry\030\r \003(\0132(.org.jetbrains.kotlin.me" +
"\n\027sealed_subclass_fq_name\030\020 \003(\005B\006\020\001\220\265\030\001\022" + "tadata.EnumEntry\022\'\n\027sealed_subclass_fq_n" +
"<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.kotl" + "ame\030\020 \003(\005B\006\020\001\220\265\030\001\022<\n\ntype_table\030\036 \001(\0132(." +
"in.metadata.TypeTable\022\033\n\023version_require" + "org.jetbrains.kotlin.metadata.TypeTable\022" +
"ment\030\037 \001(\005\022Y\n\031version_requirement_table\030" + "\033\n\023version_requirement\030\037 \001(\005\022Y\n\031version_" +
" \001(\01326.org.jetbrains.kotlin.metadata.Ve" + "requirement_table\030 \001(\01326.org.jetbrains." +
"rsionRequirementTable\"x\n\004Kind\022\t\n\005CLASS\020\000" + "kotlin.metadata.VersionRequirementTable\"" +
"\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_CLASS\020\002\022\016\n\nENUM_" + "x\n\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENU" +
"ENTRY\020\003\022\024\n\020ANNOTATION_CLASS\020\004\022\n\n\006OBJECT\020" + "M_CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_" +
"\005\022\024\n\020COMPANION_OBJECT\020\006*\006\010d\020\270\224\001\"\335\002\n\007Pack", "CLASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020",
"age\0229\n\010function\030\003 \003(\0132\'.org.jetbrains.ko" + "\006*\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010function\030\003 \003(\0132" +
"tlin.metadata.Function\0229\n\010property\030\004 \003(\013" + "\'.org.jetbrains.kotlin.metadata.Function" +
"2\'.org.jetbrains.kotlin.metadata.Propert" + "\0229\n\010property\030\004 \003(\0132\'.org.jetbrains.kotli" +
"y\022<\n\ntype_alias\030\005 \003(\0132(.org.jetbrains.ko" + "n.metadata.Property\022<\n\ntype_alias\030\005 \003(\0132" +
"tlin.metadata.TypeAlias\022<\n\ntype_table\030\036 " + "(.org.jetbrains.kotlin.metadata.TypeAlia" +
"\001(\0132(.org.jetbrains.kotlin.metadata.Type" + "s\022<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.ko" +
"Table\022Y\n\031version_requirement_table\030 \001(\013" + "tlin.metadata.TypeTable\022Y\n\031version_requi" +
"26.org.jetbrains.kotlin.metadata.Version" + "rement_table\030 \001(\01326.org.jetbrains.kotli" +
"RequirementTable*\005\010d\020\310\001\"Z\n\tTypeTable\0221\n\004" + "n.metadata.VersionRequirementTable*\005\010d\020\310" +
"type\030\001 \003(\0132#.org.jetbrains.kotlin.metada", "\001\"Z\n\tTypeTable\0221\n\004type\030\001 \003(\0132#.org.jetbr",
"ta.Type\022\032\n\016first_nullable\030\002 \001(\005:\002-1\"\214\001\n\013" + "ains.kotlin.metadata.Type\022\032\n\016first_nulla" +
"Constructor\022\020\n\005flags\030\001 \001(\005:\0016\022F\n\017value_p" + "ble\030\002 \001(\005:\002-1\"\214\001\n\013Constructor\022\020\n\005flags\030\001" +
"arameter\030\002 \003(\0132-.org.jetbrains.kotlin.me" + " \001(\005:\0016\022F\n\017value_parameter\030\002 \003(\0132-.org.j" +
"tadata.ValueParameter\022\033\n\023version_require" + "etbrains.kotlin.metadata.ValueParameter\022" +
"ment\030\037 \001(\005*\006\010d\020\270\224\001\"\232\004\n\010Function\022\020\n\005flags" + "\033\n\023version_requirement\030\037 \001(\005*\006\010d\020\270\224\001\"\232\004\n" +
"\030\t \001(\005:\0016\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030" + "\010Function\022\020\n\005flags\030\t \001(\005:\0016\022\024\n\told_flags" +
"\002 \002(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.j" + "\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013return_" +
"etbrains.kotlin.metadata.Type\022\026\n\016return_" + "type\030\003 \001(\0132#.org.jetbrains.kotlin.metada" +
"type_id\030\007 \001(\005\022D\n\016type_parameter\030\004 \003(\0132,." + "ta.Type\022\026\n\016return_type_id\030\007 \001(\005\022D\n\016type_" +
"org.jetbrains.kotlin.metadata.TypeParame", "parameter\030\004 \003(\0132,.org.jetbrains.kotlin.m",
"ter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetbrai" + "etadata.TypeParameter\022:\n\rreceiver_type\030\005" +
"ns.kotlin.metadata.Type\022\030\n\020receiver_type" + " \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"_id\030\010 \001(\005\022F\n\017value_parameter\030\006 \003(\0132-.org" + "e\022\030\n\020receiver_type_id\030\010 \001(\005\022F\n\017value_par" +
".jetbrains.kotlin.metadata.ValueParamete" + "ameter\030\006 \003(\0132-.org.jetbrains.kotlin.meta" +
"r\022<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.ko" + "data.ValueParameter\022<\n\ntype_table\030\036 \001(\0132" +
"tlin.metadata.TypeTable\022\033\n\023version_requi" + "(.org.jetbrains.kotlin.metadata.TypeTabl" +
"rement\030\037 \001(\005\0229\n\010contract\030 \001(\0132\'.org.jet" + "e\022\033\n\023version_requirement\030\037 \001(\005\0229\n\010contra" +
"brains.kotlin.metadata.Contract*\006\010d\020\270\224\001\"" + "ct\030 \001(\0132\'.org.jetbrains.kotlin.metadata" +
"\331\003\n\010Property\022\022\n\005flags\030\013 \001(\005:\003518\022\027\n\told_" + ".Contract*\006\010d\020\270\224\001\"\331\003\n\010Property\022\022\n\005flags\030" +
"flags\030\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n", "\013 \001(\005:\003518\022\027\n\told_flags\030\001 \001(\005:\0042054\022\022\n\004n",
"\013return_type\030\003 \001(\0132#.org.jetbrains.kotli" + "ame\030\002 \002(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.o" +
"n.metadata.Type\022\026\n\016return_type_id\030\t \001(\005\022" + "rg.jetbrains.kotlin.metadata.Type\022\026\n\016ret" +
"D\n\016type_parameter\030\004 \003(\0132,.org.jetbrains." + "urn_type_id\030\t \001(\005\022D\n\016type_parameter\030\004 \003(" +
"kotlin.metadata.TypeParameter\022:\n\rreceive" + "\0132,.org.jetbrains.kotlin.metadata.TypePa" +
"r_type\030\005 \001(\0132#.org.jetbrains.kotlin.meta" + "rameter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jet" +
"data.Type\022\030\n\020receiver_type_id\030\n \001(\005\022M\n\026s" + "brains.kotlin.metadata.Type\022\030\n\020receiver_" +
"etter_value_parameter\030\006 \001(\0132-.org.jetbra" + "type_id\030\n \001(\005\022M\n\026setter_value_parameter\030" +
"ins.kotlin.metadata.ValueParameter\022\024\n\014ge" + "\006 \001(\0132-.org.jetbrains.kotlin.metadata.Va" +
"tter_flags\030\007 \001(\005\022\024\n\014setter_flags\030\010 \001(\005\022\033" + "lueParameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014se" +
"\n\023version_requirement\030\037 \001(\005*\006\010d\020\270\224\001\"\343\001\n\016", "tter_flags\030\010 \001(\005\022\033\n\023version_requirement\030",
"ValueParameter\022\020\n\005flags\030\001 \001(\005:\0010\022\022\n\004name" + "\037 \001(\005*\006\010d\020\270\224\001\"\343\001\n\016ValueParameter\022\020\n\005flag" +
"\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003 \001(\0132#.org.jetbrai" + "s\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003" +
"ns.kotlin.metadata.Type\022\017\n\007type_id\030\005 \001(\005" + " \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"\022@\n\023vararg_element_type\030\004 \001(\0132#.org.jetb" + "e\022\017\n\007type_id\030\005 \001(\005\022@\n\023vararg_element_typ" +
"rains.kotlin.metadata.Type\022\036\n\026vararg_ele" + "e\030\004 \001(\0132#.org.jetbrains.kotlin.metadata." +
"ment_type_id\030\006 \001(\005*\005\010d\020\310\001\"\212\003\n\tTypeAlias\022" + "Type\022\036\n\026vararg_element_type_id\030\006 \001(\005*\005\010d" +
"\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022D\n" + "\020\310\001\"\212\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004n" +
"\016type_parameter\030\003 \003(\0132,.org.jetbrains.ko" + "ame\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_parameter\030\003 \003(\0132" +
"tlin.metadata.TypeParameter\022<\n\017underlyin" + ",.org.jetbrains.kotlin.metadata.TypePara" +
"g_type\030\004 \001(\0132#.org.jetbrains.kotlin.meta", "meter\022<\n\017underlying_type\030\004 \001(\0132#.org.jet",
"data.Type\022\032\n\022underlying_type_id\030\005 \001(\005\022:\n" + "brains.kotlin.metadata.Type\022\032\n\022underlyin" +
"\rexpanded_type\030\006 \001(\0132#.org.jetbrains.kot" + "g_type_id\030\005 \001(\005\022:\n\rexpanded_type\030\006 \001(\0132#" +
"lin.metadata.Type\022\030\n\020expanded_type_id\030\007 " + ".org.jetbrains.kotlin.metadata.Type\022\030\n\020e" +
"\001(\005\022=\n\nannotation\030\010 \003(\0132).org.jetbrains." + "xpanded_type_id\030\007 \001(\005\022=\n\nannotation\030\010 \003(" +
"kotlin.metadata.Annotation\022\033\n\023version_re" + "\0132).org.jetbrains.kotlin.metadata.Annota" +
"quirement\030\037 \001(\005*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004n" + "tion\022\033\n\023version_requirement\030\037 \001(\005*\005\010d\020\310\001" +
"ame\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022VersionRequir" + "\"&\n\tEnumEntry\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001" +
"ement\022\017\n\007version\030\001 \001(\005\022\024\n\014version_full\030\002" + "\"\225\003\n\022VersionRequirement\022\017\n\007version\030\001 \001(\005" +
" \001(\005\022M\n\005level\030\003 \001(\01627.org.jetbrains.kotl" + "\022\024\n\014version_full\030\002 \001(\005\022M\n\005level\030\003 \001(\01627." +
"in.metadata.VersionRequirement.Level:\005ER", "org.jetbrains.kotlin.metadata.VersionReq",
"ROR\022\022\n\nerror_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005" + "uirement.Level:\005ERROR\022\022\n\nerror_code\030\004 \001(" +
"B\004\230\265\030\001\022e\n\014version_kind\030\006 \001(\0162=.org.jetbr" + "\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind" +
"ains.kotlin.metadata.VersionRequirement." + "\030\006 \001(\0162=.org.jetbrains.kotlin.metadata.V" +
"VersionKind:\020LANGUAGE_VERSION\"+\n\005Level\022\013" + "ersionRequirement.VersionKind:\020LANGUAGE_" +
"\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"J\n\013Ve" + "VERSION\"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001" +
"rsionKind\022\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020COMPI" + "\022\n\n\006HIDDEN\020\002\"J\n\013VersionKind\022\024\n\020LANGUAGE_" +
"LER_VERSION\020\001\022\017\n\013API_VERSION\020\002\"a\n\027Versio" + "VERSION\020\000\022\024\n\020COMPILER_VERSION\020\001\022\017\n\013API_V" +
"nRequirementTable\022F\n\013requirement\030\001 \003(\01321" + "ERSION\020\002\"a\n\027VersionRequirementTable\022F\n\013r" +
".org.jetbrains.kotlin.metadata.VersionRe" + "equirement\030\001 \003(\01321.org.jetbrains.kotlin." +
"quirement\"\217\002\n\017PackageFragment\022;\n\007strings", "metadata.VersionRequirement\"\217\002\n\017PackageF",
"\030\001 \001(\0132*.org.jetbrains.kotlin.metadata.S" + "ragment\022;\n\007strings\030\001 \001(\0132*.org.jetbrains" +
"tringTable\022J\n\017qualified_names\030\002 \001(\01321.or" + ".kotlin.metadata.StringTable\022J\n\017qualifie" +
"g.jetbrains.kotlin.metadata.QualifiedNam" + "d_names\030\002 \001(\01321.org.jetbrains.kotlin.met" +
"eTable\0227\n\007package\030\003 \001(\0132&.org.jetbrains." + "adata.QualifiedNameTable\0227\n\007package\030\003 \001(" +
"kotlin.metadata.Package\0223\n\005class\030\004 \003(\0132$" + "\0132&.org.jetbrains.kotlin.metadata.Packag" +
".org.jetbrains.kotlin.metadata.Class*\005\010d" + "e\0223\n\005class\030\004 \003(\0132$.org.jetbrains.kotlin." +
"\020\310\001\"A\n\010Contract\0225\n\006effect\030\001 \003(\0132%.org.je" + "metadata.Class*\005\010d\020\310\001\"A\n\010Contract\0225\n\006eff" +
"tbrains.kotlin.metadata.Effect\"\306\003\n\006Effec" + "ect\030\001 \003(\0132%.org.jetbrains.kotlin.metadat" +
"t\022E\n\013effect_type\030\001 \001(\01620.org.jetbrains.k" + "a.Effect\"\306\003\n\006Effect\022E\n\013effect_type\030\001 \001(\016" +
"otlin.metadata.Effect.EffectType\022N\n\033effe", "20.org.jetbrains.kotlin.metadata.Effect.",
"ct_constructor_argument\030\002 \003(\0132).org.jetb" + "EffectType\022N\n\033effect_constructor_argumen" +
"rains.kotlin.metadata.Expression\022S\n conc" + "t\030\002 \003(\0132).org.jetbrains.kotlin.metadata." +
"lusion_of_conditional_effect\030\003 \001(\0132).org" + "Expression\022S\n conclusion_of_conditional_" +
".jetbrains.kotlin.metadata.Expression\022B\n" + "effect\030\003 \001(\0132).org.jetbrains.kotlin.meta" +
"\004kind\030\004 \001(\01624.org.jetbrains.kotlin.metad" + "data.Expression\022B\n\004kind\030\004 \001(\01624.org.jetb" +
"ata.Effect.InvocationKind\"C\n\nEffectType\022" + "rains.kotlin.metadata.Effect.InvocationK" +
"\024\n\020RETURNS_CONSTANT\020\000\022\t\n\005CALLS\020\001\022\024\n\020RETU" + "ind\"C\n\nEffectType\022\024\n\020RETURNS_CONSTANT\020\000\022" +
"RNS_NOT_NULL\020\002\"G\n\016InvocationKind\022\020\n\014AT_M" + "\t\n\005CALLS\020\001\022\024\n\020RETURNS_NOT_NULL\020\002\"G\n\016Invo" +
"OST_ONCE\020\000\022\020\n\014EXACTLY_ONCE\020\001\022\021\n\rAT_LEAST" + "cationKind\022\020\n\014AT_MOST_ONCE\020\000\022\020\n\014EXACTLY_" +
"_ONCE\020\002\"\237\003\n\nExpression\022\020\n\005flags\030\001 \001(\005:\0010", "ONCE\020\001\022\021\n\rAT_LEAST_ONCE\020\002\"\237\003\n\nExpression",
"\022!\n\031value_parameter_reference\030\002 \001(\005\022O\n\016c" + "\022\020\n\005flags\030\001 \001(\005:\0010\022!\n\031value_parameter_re" +
"onstant_value\030\003 \001(\01627.org.jetbrains.kotl" + "ference\030\002 \001(\005\022O\n\016constant_value\030\003 \001(\01627." +
"in.metadata.Expression.ConstantValue\022=\n\020" + "org.jetbrains.kotlin.metadata.Expression" +
"is_instance_type\030\004 \001(\0132#.org.jetbrains.k" + ".ConstantValue\022=\n\020is_instance_type\030\004 \001(\013" +
"otlin.metadata.Type\022\033\n\023is_instance_type_" + "2#.org.jetbrains.kotlin.metadata.Type\022\033\n" +
"id\030\005 \001(\005\022?\n\014and_argument\030\006 \003(\0132).org.jet" + "\023is_instance_type_id\030\005 \001(\005\022?\n\014and_argume" +
"brains.kotlin.metadata.Expression\022>\n\013or_" + "nt\030\006 \003(\0132).org.jetbrains.kotlin.metadata" +
"argument\030\007 \003(\0132).org.jetbrains.kotlin.me" + ".Expression\022>\n\013or_argument\030\007 \003(\0132).org.j" +
"tadata.Expression\".\n\rConstantValue\022\010\n\004TR" + "etbrains.kotlin.metadata.Expression\".\n\rC" +
"UE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n\010Modality\022\t\n", "onstantValue\022\010\n\004TRUE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NUL",
"\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEAL" + "L\020\002*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010" +
"ED\020\003*b\n\nVisibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIV" + "ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010" +
"ATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIV" + "INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n" +
"ATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017" + "\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL" +
"\n\013DECLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDE" + "\020\005*Q\n\nMemberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAK" +
"LEGATION\020\002\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProt" + "E_OVERRIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESI" +
"oBuf" "ZED\020\003B\017B\rDebugProtoBuf"
}; };
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -33767,7 +33877,7 @@ public final class DebugProtoBuf {
internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_fieldAccessorTable = new internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable( org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_descriptor, internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_descriptor,
new java.lang.String[] { "Type", "IntValue", "FloatValue", "DoubleValue", "StringValue", "ClassId", "EnumValueId", "Annotation", "ArrayElement", }); new java.lang.String[] { "Type", "IntValue", "FloatValue", "DoubleValue", "StringValue", "ClassId", "EnumValueId", "Annotation", "ArrayElement", "Flags", });
internal_static_org_jetbrains_kotlin_metadata_Type_descriptor = internal_static_org_jetbrains_kotlin_metadata_Type_descriptor =
getDescriptor().getMessageTypes().get(3); getDescriptor().getMessageTypes().get(3);
internal_static_org_jetbrains_kotlin_metadata_Type_fieldAccessorTable = new internal_static_org_jetbrains_kotlin_metadata_Type_fieldAccessorTable = new
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value
import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.resolve.constants.* import org.jetbrains.kotlin.resolve.constants.*
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.ErrorUtils
@@ -127,21 +128,25 @@ class AnnotationSerializer(private val stringTable: DescriptorAwareStringTable)
override fun visitUByteValue(value: UByteValue, data: Unit?) { override fun visitUByteValue(value: UByteValue, data: Unit?) {
type = Type.BYTE type = Type.BYTE
intValue = value.value.toLong() intValue = value.value.toLong()
flags = Flags.IS_UNSIGNED.toFlags(true)
} }
override fun visitUShortValue(value: UShortValue, data: Unit?) { override fun visitUShortValue(value: UShortValue, data: Unit?) {
type = Type.SHORT type = Type.SHORT
intValue = value.value.toLong() intValue = value.value.toLong()
flags = Flags.IS_UNSIGNED.toFlags(true)
} }
override fun visitUIntValue(value: UIntValue, data: Unit?) { override fun visitUIntValue(value: UIntValue, data: Unit?) {
type = Type.INT type = Type.INT
intValue = value.value.toLong() intValue = value.value.toLong()
flags = Flags.IS_UNSIGNED.toFlags(true)
} }
override fun visitULongValue(value: ULongValue, data: Unit?) { override fun visitULongValue(value: ULongValue, data: Unit?) {
type = Type.LONG type = Type.LONG
intValue = value.value intValue = value.value
flags = Flags.IS_UNSIGNED.toFlags(true)
} }
}, Unit) }, Unit)
} }
@@ -0,0 +1,21 @@
// WITH_UNSIGNED
// FILE: A.kt
@kotlin.annotation.Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
annotation class Anno(val u: UInt)
object ForTest {
@Anno(0u)
fun f(a: @Anno(43u) String) {}
}
// FILE: B.kt
fun box(): String {
val result = (ForTest::f.annotations.first() as Anno).u // force annotation deserialization
if (result != 0u) return "Fail"
return "OK"
}
@@ -0,0 +1,16 @@
// WITH_UNSIGNED
package test
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER)
annotation class Ann(
val ubyte: UByte,
val ushort: UShort,
val uint: UInt,
val ulong: ULong
)
class A {
fun unsigned(s: @Ann(1u, 2u, 3u, 4u) String) {}
fun <@Ann(0xFFu, 0xFFFFu, 0xFFFF_FFFFu, 0xFFFF_FFFF_FFFF_FFFFuL) T> typeParam() {}
}
@@ -0,0 +1,19 @@
package test
public final class A {
/*primary*/ public constructor A()
public final fun </*0*/ @test.Ann(ubyte = -1.toUByte(), uint = -1.toUInt(), ulong = -1.toULong(), ushort = -1.toUShort()) T> typeParam(): kotlin.Unit
public final fun unsigned(/*0*/ s: @test.Ann(ubyte = 1.toUByte(), uint = 3.toUInt(), ulong = 4.toULong(), ushort = 2.toUShort()) kotlin.String): kotlin.Unit
}
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public final annotation class Ann : kotlin.Annotation {
/*primary*/ public constructor Ann(/*0*/ ubyte: kotlin.UByte, /*1*/ ushort: kotlin.UShort, /*2*/ uint: kotlin.UInt, /*3*/ ulong: kotlin.ULong)
public final val ubyte: kotlin.UByte
public final fun <get-ubyte>(): kotlin.UByte
public final val uint: kotlin.UInt
public final fun <get-uint>(): kotlin.UInt
public final val ulong: kotlin.ULong
public final fun <get-ulong>(): kotlin.ULong
public final val ushort: kotlin.UShort
public final fun <get-ushort>(): kotlin.UShort
}
@@ -272,4 +272,9 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
public void testTypeAliasesKt13181() throws Exception { public void testTypeAliasesKt13181() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/typeAliasesKt13181.kt"); runTest("compiler/testData/compileKotlinAgainstKotlin/typeAliasesKt13181.kt");
} }
@TestMetadata("unsignedTypesInAnnotations.kt")
public void testUnsignedTypesInAnnotations() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/unsignedTypesInAnnotations.kt");
}
} }
@@ -4557,6 +4557,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
public void testConstValInMultifileClass() throws Exception { public void testConstValInMultifileClass() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/ConstValInMultifileClass.kt"); runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/ConstValInMultifileClass.kt");
} }
@TestMetadata("WithUnsignedTypeParameters.kt")
public void testWithUnsignedTypeParameters() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/WithUnsignedTypeParameters.kt");
}
} }
@TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib/contracts") @TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib/contracts")
@@ -4557,6 +4557,11 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT
public void testConstValInMultifileClass() throws Exception { public void testConstValInMultifileClass() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/ConstValInMultifileClass.kt"); runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/ConstValInMultifileClass.kt");
} }
@TestMetadata("WithUnsignedTypeParameters.kt")
public void testWithUnsignedTypeParameters() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlinWithStdlib/annotations/WithUnsignedTypeParameters.kt");
}
} }
@TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib/contracts") @TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib/contracts")
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation
import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument
import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value
import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.metadata.deserialization.NameResolver import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -67,12 +68,14 @@ class AnnotationDeserializer(private val module: ModuleDescriptor, private val n
value: Value, value: Value,
nameResolver: NameResolver nameResolver: NameResolver
): ConstantValue<*> { ): ConstantValue<*> {
val isUnsigned = Flags.IS_UNSIGNED.get(value.flags)
val result: ConstantValue<*> = when (value.type) { val result: ConstantValue<*> = when (value.type) {
Type.BYTE -> ByteValue(value.intValue.toByte()) Type.BYTE -> value.intValue.toByte().letIf(isUnsigned, ::UByteValue, ::ByteValue)
Type.CHAR -> CharValue(value.intValue.toChar()) Type.CHAR -> CharValue(value.intValue.toChar())
Type.SHORT -> ShortValue(value.intValue.toShort()) Type.SHORT -> value.intValue.toShort().letIf(isUnsigned, ::UShortValue, ::ShortValue)
Type.INT -> IntValue(value.intValue.toInt()) Type.INT -> value.intValue.toInt().letIf(isUnsigned, ::UIntValue, ::IntValue)
Type.LONG -> LongValue(value.intValue) Type.LONG -> value.intValue.letIf(isUnsigned, ::ULongValue, ::LongValue)
Type.FLOAT -> FloatValue(value.floatValue) Type.FLOAT -> FloatValue(value.floatValue)
Type.DOUBLE -> DoubleValue(value.doubleValue) Type.DOUBLE -> DoubleValue(value.doubleValue)
Type.BOOLEAN -> BooleanValue(value.intValue != 0L) Type.BOOLEAN -> BooleanValue(value.intValue != 0L)
@@ -126,6 +129,9 @@ class AnnotationDeserializer(private val module: ModuleDescriptor, private val n
} }
} }
private inline fun <T, R> T.letIf(predicate: Boolean, f: (T) -> R, g: (T) -> R): R =
if (predicate) f(this) else g(this)
private fun resolveClassLiteralValue(classId: ClassId): ConstantValue<*> { private fun resolveClassLiteralValue(classId: ClassId): ConstantValue<*> {
// If value refers to a class named test.Foo.Bar where both Foo and Bar have generic type parameters, // If value refers to a class named test.Foo.Bar where both Foo and Bar have generic type parameters,
// we're constructing a type `KClass<test.Foo<*>.Bar<*>>` below // we're constructing a type `KClass<test.Foo<*>.Bar<*>>` below
+5
View File
@@ -83,6 +83,11 @@ message Annotation {
optional Annotation annotation = 8; optional Annotation annotation = 8;
repeated Value array_element = 9; repeated Value array_element = 9;
/*
isUnsigned
*/
optional int32 flags = 10 [default = 0];
} }
required int32 name_id = 1 [(name_id_in_table) = true]; required int32 name_id = 1 [(name_id_in_table) = true];
@@ -2200,6 +2200,23 @@ public final class ProtoBuf {
* <code>repeated .org.jetbrains.kotlin.metadata.Annotation.Argument.Value array_element = 9;</code> * <code>repeated .org.jetbrains.kotlin.metadata.Annotation.Argument.Value array_element = 9;</code>
*/ */
int getArrayElementCount(); int getArrayElementCount();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
boolean hasFlags();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
int getFlags();
} }
/** /**
* Protobuf type {@code org.jetbrains.kotlin.metadata.Annotation.Argument.Value} * Protobuf type {@code org.jetbrains.kotlin.metadata.Annotation.Argument.Value}
@@ -2314,6 +2331,11 @@ public final class ProtoBuf {
arrayElement_.add(input.readMessage(org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.PARSER, extensionRegistry)); arrayElement_.add(input.readMessage(org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.PARSER, extensionRegistry));
break; break;
} }
case 80: {
bitField0_ |= 0x00000100;
flags_ = input.readInt32();
break;
}
} }
} }
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -2681,6 +2703,29 @@ public final class ProtoBuf {
return arrayElement_.get(index); return arrayElement_.get(index);
} }
public static final int FLAGS_FIELD_NUMBER = 10;
private int flags_;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
private void initFields() { private void initFields() {
type_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type.BYTE; type_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type.BYTE;
intValue_ = 0L; intValue_ = 0L;
@@ -2691,6 +2736,7 @@ public final class ProtoBuf {
enumValueId_ = 0; enumValueId_ = 0;
annotation_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance(); annotation_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance();
arrayElement_ = java.util.Collections.emptyList(); arrayElement_ = java.util.Collections.emptyList();
flags_ = 0;
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@@ -2744,6 +2790,9 @@ public final class ProtoBuf {
for (int i = 0; i < arrayElement_.size(); i++) { for (int i = 0; i < arrayElement_.size(); i++) {
output.writeMessage(9, arrayElement_.get(i)); output.writeMessage(9, arrayElement_.get(i));
} }
if (((bitField0_ & 0x00000100) == 0x00000100)) {
output.writeInt32(10, flags_);
}
output.writeRawBytes(unknownFields); output.writeRawBytes(unknownFields);
} }
@@ -2789,6 +2838,10 @@ public final class ProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(9, arrayElement_.get(i)); .computeMessageSize(9, arrayElement_.get(i));
} }
if (((bitField0_ & 0x00000100) == 0x00000100)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(10, flags_);
}
size += unknownFields.size(); size += unknownFields.size();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@@ -2901,6 +2954,8 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000080); bitField0_ = (bitField0_ & ~0x00000080);
arrayElement_ = java.util.Collections.emptyList(); arrayElement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100); bitField0_ = (bitField0_ & ~0x00000100);
flags_ = 0;
bitField0_ = (bitField0_ & ~0x00000200);
return this; return this;
} }
@@ -2961,6 +3016,10 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000100); bitField0_ = (bitField0_ & ~0x00000100);
} }
result.arrayElement_ = arrayElement_; result.arrayElement_ = arrayElement_;
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000100;
}
result.flags_ = flags_;
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
return result; return result;
} }
@@ -3001,6 +3060,9 @@ public final class ProtoBuf {
} }
} }
if (other.hasFlags()) {
setFlags(other.getFlags());
}
setUnknownFields( setUnknownFields(
getUnknownFields().concat(other.unknownFields)); getUnknownFields().concat(other.unknownFields));
return this; return this;
@@ -3493,6 +3555,54 @@ public final class ProtoBuf {
return this; return this;
} }
private int flags_ ;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder setFlags(int value) {
bitField0_ |= 0x00000200;
flags_ = value;
return this;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.metadata.Annotation.Argument.Value) // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.metadata.Annotation.Argument.Value)
} }
@@ -77,6 +77,8 @@ public class Flags {
public static final BooleanFlagField IS_NEGATED = FlagField.booleanFirst(); public static final BooleanFlagField IS_NEGATED = FlagField.booleanFirst();
public static final BooleanFlagField IS_NULL_CHECK_PREDICATE = FlagField.booleanAfter(IS_NEGATED); public static final BooleanFlagField IS_NULL_CHECK_PREDICATE = FlagField.booleanAfter(IS_NEGATED);
// Annotations
public static final BooleanFlagField IS_UNSIGNED = FlagField.booleanFirst();
// --- // ---