Support array class literals in annotation serializer/deserializer

Note that this change brings an incompatibility: `Array<Foo>::class`
will be seen as `Foo::class` by the old deserializer. We consider this
OK because the compiler never had any logic that relied on reading class
literal arguments correctly (otherwise it wouldn't have worked because
it could only see `Array<*>::class` before this commit), and the support
of annotations on types in JVM reflection is only available in the
upcoming 1.3 release (KT-16795)

 #KT-22069 Fixed
This commit is contained in:
Alexander Udalov
2018-09-04 18:24:01 +03:00
parent f3f93ed6cc
commit f90303315d
11 changed files with 549 additions and 189 deletions
@@ -977,6 +977,11 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkEqualsAnnotationArgumentValueArrayElement(old, new)) return false
if (old.hasArrayDimensionCount() != new.hasArrayDimensionCount()) return false
if (old.hasArrayDimensionCount()) {
if (old.arrayDimensionCount != new.arrayDimensionCount) return false
}
if (old.hasFlags() != new.hasFlags()) return false
if (old.hasFlags()) {
if (old.flags != new.flags) return false
@@ -2166,6 +2171,10 @@ fun ProtoBuf.Annotation.Argument.Value.hashCode(stringIndexes: (Int) -> Int, fqN
hashCode = 31 * hashCode + getArrayElement(i).hashCode(stringIndexes, fqNameIndexes)
}
if (hasArrayDimensionCount()) {
hashCode = 31 * hashCode + arrayDimensionCount
}
if (hasFlags()) {
hashCode = 31 * hashCode + flags
}
@@ -2633,6 +2633,35 @@ public final class DebugProtoBuf {
org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.Argument.ValueOrBuilder getArrayElementOrBuilder(
int index);
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
boolean hasArrayDimensionCount();
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
int getArrayDimensionCount();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
@@ -2765,10 +2794,15 @@ public final class DebugProtoBuf {
break;
}
case 80: {
bitField0_ |= 0x00000100;
bitField0_ |= 0x00000200;
flags_ = input.readInt32();
break;
}
case 88: {
bitField0_ |= 0x00000100;
arrayDimensionCount_ = input.readInt32();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -3174,6 +3208,41 @@ public final class DebugProtoBuf {
return arrayElement_.get(index);
}
public static final int ARRAY_DIMENSION_COUNT_FIELD_NUMBER = 11;
private int arrayDimensionCount_;
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public boolean hasArrayDimensionCount() {
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public int getArrayDimensionCount() {
return arrayDimensionCount_;
}
public static final int FLAGS_FIELD_NUMBER = 10;
private int flags_;
/**
@@ -3184,7 +3253,7 @@ public final class DebugProtoBuf {
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -3207,6 +3276,7 @@ public final class DebugProtoBuf {
enumValueId_ = 0;
annotation_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Annotation.getDefaultInstance();
arrayElement_ = java.util.Collections.emptyList();
arrayDimensionCount_ = 0;
flags_ = 0;
}
private byte memoizedIsInitialized = -1;
@@ -3261,9 +3331,12 @@ public final class DebugProtoBuf {
for (int i = 0; i < arrayElement_.size(); i++) {
output.writeMessage(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000200) == 0x00000200)) {
output.writeInt32(10, flags_);
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
output.writeInt32(11, arrayDimensionCount_);
}
getUnknownFields().writeTo(output);
}
@@ -3309,10 +3382,14 @@ public final class DebugProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000200) == 0x00000200)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(10, flags_);
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(11, arrayDimensionCount_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -3458,8 +3535,10 @@ public final class DebugProtoBuf {
} else {
arrayElementBuilder_.clear();
}
flags_ = 0;
arrayDimensionCount_ = 0;
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0;
bitField0_ = (bitField0_ & ~0x00000400);
return this;
}
@@ -3536,6 +3615,10 @@ public final class DebugProtoBuf {
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000100;
}
result.arrayDimensionCount_ = arrayDimensionCount_;
if (((from_bitField0_ & 0x00000400) == 0x00000400)) {
to_bitField0_ |= 0x00000200;
}
result.flags_ = flags_;
result.bitField0_ = to_bitField0_;
onBuilt();
@@ -3603,6 +3686,9 @@ public final class DebugProtoBuf {
}
}
}
if (other.hasArrayDimensionCount()) {
setArrayDimensionCount(other.getArrayDimensionCount());
}
if (other.hasFlags()) {
setFlags(other.getFlags());
}
@@ -4268,6 +4354,78 @@ public final class DebugProtoBuf {
return arrayElementBuilder_;
}
private int arrayDimensionCount_ ;
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public boolean hasArrayDimensionCount() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public int getArrayDimensionCount() {
return arrayDimensionCount_;
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public Builder setArrayDimensionCount(int value) {
bitField0_ |= 0x00000200;
arrayDimensionCount_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public Builder clearArrayDimensionCount() {
bitField0_ = (bitField0_ & ~0x00000200);
arrayDimensionCount_ = 0;
onChanged();
return this;
}
private int flags_ ;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -4277,7 +4435,7 @@ public final class DebugProtoBuf {
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
return ((bitField0_ & 0x00000400) == 0x00000400);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -4297,7 +4455,7 @@ public final class DebugProtoBuf {
* </pre>
*/
public Builder setFlags(int value) {
bitField0_ |= 0x00000200;
bitField0_ |= 0x00000400;
flags_ = value;
onChanged();
return this;
@@ -4310,7 +4468,7 @@ public final class DebugProtoBuf {
* </pre>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000200);
bitField0_ = (bitField0_ & ~0x00000400);
flags_ = 0;
onChanged();
return this;
@@ -34137,12 +34295,12 @@ public final class DebugProtoBuf {
"name\030\002 \002(\005\022[\n\004kind\030\003 \001(\0162D.org.jetbrains" +
".kotlin.metadata.QualifiedNameTable.Qual",
"ifiedName.Kind:\007PACKAGE\")\n\004Kind\022\t\n\005CLASS" +
"\020\000\022\013\n\007PACKAGE\020\001\022\t\n\005LOCAL\020\002\"\364\005\n\nAnnotatio" +
"\020\000\022\013\n\007PACKAGE\020\001\022\t\n\005LOCAL\020\002\"\226\006\n\nAnnotatio" +
"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" +
".Argument\032\215\005\n\010Argument\022\025\n\007name_id\030\001 \002(\005B" +
".Argument\032\257\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" +
"lin.metadata.Annotation.Argument.Value\032\240" +
"lin.metadata.Annotation.Argument.Value\032\302" +
"\004\n\005Value\022K\n\004type\030\001 \001(\0162=.org.jetbrains.k" +
"otlin.metadata.Annotation.Argument.Value" +
".Type\022\021\n\tint_value\030\002 \001(\022\022\023\n\013float_value\030",
@@ -34152,167 +34310,168 @@ public final class DebugProtoBuf {
"on\030\010 \001(\0132).org.jetbrains.kotlin.metadata" +
".Annotation\022O\n\rarray_element\030\t \003(\01328.org" +
".jetbrains.kotlin.metadata.Annotation.Ar" +
"gument.Value\022\020\n\005flags\030\n \001(\005:\0010\"\230\001\n\004Type\022" +
"\010\n\004BYTE\020\000\022\010\n\004CHAR\020\001\022\t\n\005SHORT\020\002\022\007\n\003INT\020\003\022" +
"\010\n\004LONG\020\004\022\t\n\005FLOAT\020\005\022\n\n\006DOUBLE\020\006\022\013\n\007BOOL" +
"EAN\020\007\022\n\n\006STRING\020\010\022\t\n\005CLASS\020\t\022\010\n\004ENUM\020\n\022\016",
"\n\nANNOTATION\020\013\022\t\n\005ARRAY\020\014\"\373\005\n\004Type\022>\n\010ar" +
"gument\030\002 \003(\0132,.org.jetbrains.kotlin.meta" +
"data.Type.Argument\022\027\n\010nullable\030\003 \001(\010:\005fa" +
"lse\022+\n\035flexible_type_capabilities_id\030\004 \001" +
"(\005B\004\230\265\030\001\022A\n\024flexible_upper_bound\030\005 \001(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\037\n\027f" +
"lexible_upper_bound_id\030\010 \001(\005\022\030\n\nclass_na" +
"me\030\006 \001(\005B\004\220\265\030\001\022\026\n\016type_parameter\030\007 \001(\005\022!" +
"\n\023type_parameter_name\030\t \001(\005B\004\210\265\030\001\022\035\n\017typ" +
"e_alias_name\030\014 \001(\005B\004\220\265\030\001\0227\n\nouter_type\030\n",
"gument.Value\022 \n\025array_dimension_count\030\013 " +
"\001(\005:\0010\022\020\n\005flags\030\n \001(\005:\0010\"\230\001\n\004Type\022\010\n\004BYT" +
"E\020\000\022\010\n\004CHAR\020\001\022\t\n\005SHORT\020\002\022\007\n\003INT\020\003\022\010\n\004LON" +
"G\020\004\022\t\n\005FLOAT\020\005\022\n\n\006DOUBLE\020\006\022\013\n\007BOOLEAN\020\007\022",
"\n\n\006STRING\020\010\022\t\n\005CLASS\020\t\022\010\n\004ENUM\020\n\022\016\n\nANNO" +
"TATION\020\013\022\t\n\005ARRAY\020\014\"\373\005\n\004Type\022>\n\010argument" +
"\030\002 \003(\0132,.org.jetbrains.kotlin.metadata.T" +
"ype.Argument\022\027\n\010nullable\030\003 \001(\010:\005false\022+\n" +
"\035flexible_type_capabilities_id\030\004 \001(\005B\004\230\265" +
"\030\001\022A\n\024flexible_upper_bound\030\005 \001(\0132#.org.j" +
"etbrains.kotlin.metadata.Type\022\037\n\027flexibl" +
"e_upper_bound_id\030\010 \001(\005\022\030\n\nclass_name\030\006 \001" +
"(\005B\004\220\265\030\001\022\026\n\016type_parameter\030\007 \001(\005\022!\n\023type" +
"_parameter_name\030\t \001(\005B\004\210\265\030\001\022\035\n\017type_alia",
"s_name\030\014 \001(\005B\004\220\265\030\001\0227\n\nouter_type\030\n \001(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\025\n\ro" +
"uter_type_id\030\013 \001(\005\022=\n\020abbreviated_type\030\r" +
" \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\025\n\router_type_id\030\013 \001(\005\022=\n\020abbreviated_" +
"type\030\r \001(\0132#.org.jetbrains.kotlin.metada" +
"ta.Type\022\033\n\023abbreviated_type_id\030\016 \001(\005\022\r\n\005" +
"flags\030\001 \001(\005\032\322\001\n\010Argument\022P\n\nprojection\030\001" +
" \001(\01627.org.jetbrains.kotlin.metadata.Typ" +
"e.Argument.Projection:\003INV\0221\n\004type\030\002 \001(\013" +
"2#.org.jetbrains.kotlin.metadata.Type\022\017\n" +
"\007type_id\030\003 \001(\005\"0\n\nProjection\022\006\n\002IN\020\000\022\007\n\003" +
"OUT\020\001\022\007\n\003INV\020\002\022\010\n\004STAR\020\003*\005\010d\020\310\001\"\230\002\n\rType",
"Parameter\022\n\n\002id\030\001 \002(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030" +
"\001\022\026\n\007reified\030\003 \001(\010:\005false\022L\n\010variance\030\004 " +
"\001(\01625.org.jetbrains.kotlin.metadata.Type" +
"Parameter.Variance:\003INV\0228\n\013upper_bound\030\005" +
" \003(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\032\n\016upper_bound_id\030\006 \003(\005B\002\020\001\"$\n\010Varianc" +
"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" +
"lass\022\020\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B" +
"\004\220\265\030\001\022#\n\025companion_object_name\030\004 \001(\005B\004\210\265" +
"\030\001\022D\n\016type_parameter\030\005 \003(\0132,.org.jetbrai",
"ns.kotlin.metadata.TypeParameter\0226\n\tsupe" +
"rtype\030\006 \003(\0132#.org.jetbrains.kotlin.metad" +
"ata.Type\022\030\n\014supertype_id\030\002 \003(\005B\002\020\001\022!\n\021ne" +
"sted_class_name\030\007 \003(\005B\006\020\001\210\265\030\001\022?\n\013constru" +
"ctor\030\010 \003(\0132*.org.jetbrains.kotlin.metada" +
"ta.Constructor\0229\n\010function\030\t \003(\0132\'.org.j" +
"etbrains.kotlin.metadata.Function\0229\n\010pro" +
"perty\030\n \003(\0132\'.org.jetbrains.kotlin.metad" +
"ata.Property\022<\n\ntype_alias\030\013 \003(\0132(.org.j" +
"etbrains.kotlin.metadata.TypeAlias\022<\n\nen",
"um_entry\030\r \003(\0132(.org.jetbrains.kotlin.me" +
"tadata.EnumEntry\022\'\n\027sealed_subclass_fq_n" +
"ame\030\020 \003(\005B\006\020\001\220\265\030\001\022<\n\ntype_table\030\036 \001(\0132(." +
"org.jetbrains.kotlin.metadata.TypeTable\022" +
"\033\n\023version_requirement\030\037 \003(\005\022Y\n\031version_" +
"requirement_table\030 \001(\01326.org.jetbrains." +
"kotlin.metadata.VersionRequirementTable\"" +
"x\n\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENU" +
"M_CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_" +
"CLASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020",
"\006*\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010function\030\003 \003(\0132" +
"\'.org.jetbrains.kotlin.metadata.Function" +
"\0229\n\010property\030\004 \003(\0132\'.org.jetbrains.kotli" +
"n.metadata.Property\022<\n\ntype_alias\030\005 \003(\0132" +
"(.org.jetbrains.kotlin.metadata.TypeAlia" +
"s\022<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.ko" +
"tlin.metadata.TypeTable\022Y\n\031version_requi" +
"rement_table\030 \001(\01326.org.jetbrains.kotli" +
"n.metadata.VersionRequirementTable*\005\010d\020\310" +
"\001\"Z\n\tTypeTable\0221\n\004type\030\001 \003(\0132#.org.jetbr",
"ains.kotlin.metadata.Type\022\032\n\016first_nulla" +
"ble\030\002 \001(\005:\002-1\"\214\001\n\013Constructor\022\020\n\005flags\030\001" +
" \001(\005:\0016\022F\n\017value_parameter\030\002 \003(\0132-.org.j" +
"etbrains.kotlin.metadata.ValueParameter\022" +
"\033\n\023version_requirement\030\037 \003(\005*\006\010d\020\270\224\001\"\232\004\n" +
"\010Function\022\020\n\005flags\030\t \001(\005:\0016\022\024\n\told_flags" +
"\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013return_" +
"type\030\003 \001(\0132#.org.jetbrains.kotlin.metada" +
"ta.Type\022\026\n\016return_type_id\030\007 \001(\005\022D\n\016type_" +
"parameter\030\004 \003(\0132,.org.jetbrains.kotlin.m",
"etadata.TypeParameter\022:\n\rreceiver_type\030\005" +
"e\022\033\n\023abbreviated_type_id\030\016 \001(\005\022\r\n\005flags\030" +
"\001 \001(\005\032\322\001\n\010Argument\022P\n\nprojection\030\001 \001(\01627" +
".org.jetbrains.kotlin.metadata.Type.Argu" +
"ment.Projection:\003INV\0221\n\004type\030\002 \001(\0132#.org" +
".jetbrains.kotlin.metadata.Type\022\017\n\007type_" +
"id\030\003 \001(\005\"0\n\nProjection\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022",
"\007\n\003INV\020\002\022\010\n\004STAR\020\003*\005\010d\020\310\001\"\230\002\n\rTypeParame" +
"ter\022\n\n\002id\030\001 \002(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022\026\n\007r" +
"eified\030\003 \001(\010:\005false\022L\n\010variance\030\004 \001(\01625." +
"org.jetbrains.kotlin.metadata.TypeParame" +
"ter.Variance:\003INV\0228\n\013upper_bound\030\005 \003(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\032\n\016u" +
"pper_bound_id\030\006 \003(\005B\002\020\001\"$\n\010Variance\022\006\n\002I" +
"N\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\244\007\n\005Class\022\020" +
"\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B\004\220\265\030\001\022" +
"#\n\025companion_object_name\030\004 \001(\005B\004\210\265\030\001\022D\n\016",
"type_parameter\030\005 \003(\0132,.org.jetbrains.kot" +
"lin.metadata.TypeParameter\0226\n\tsupertype\030" +
"\006 \003(\0132#.org.jetbrains.kotlin.metadata.Ty" +
"pe\022\030\n\014supertype_id\030\002 \003(\005B\002\020\001\022!\n\021nested_c" +
"lass_name\030\007 \003(\005B\006\020\001\210\265\030\001\022?\n\013constructor\030\010" +
" \003(\0132*.org.jetbrains.kotlin.metadata.Con" +
"structor\0229\n\010function\030\t \003(\0132\'.org.jetbrai" +
"ns.kotlin.metadata.Function\0229\n\010property\030" +
"\n \003(\0132\'.org.jetbrains.kotlin.metadata.Pr" +
"operty\022<\n\ntype_alias\030\013 \003(\0132(.org.jetbrai",
"ns.kotlin.metadata.TypeAlias\022<\n\nenum_ent" +
"ry\030\r \003(\0132(.org.jetbrains.kotlin.metadata" +
".EnumEntry\022\'\n\027sealed_subclass_fq_name\030\020 " +
"\003(\005B\006\020\001\220\265\030\001\022<\n\ntype_table\030\036 \001(\0132(.org.je" +
"tbrains.kotlin.metadata.TypeTable\022\033\n\023ver" +
"sion_requirement\030\037 \003(\005\022Y\n\031version_requir" +
"ement_table\030 \001(\01326.org.jetbrains.kotlin" +
".metadata.VersionRequirementTable\"x\n\004Kin" +
"d\022\t\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_CLAS" +
"S\020\002\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_CLASS\020",
"\004\022\n\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020\006*\006\010d\020" +
"\270\224\001\"\335\002\n\007Package\0229\n\010function\030\003 \003(\0132\'.org." +
"jetbrains.kotlin.metadata.Function\0229\n\010pr" +
"operty\030\004 \003(\0132\'.org.jetbrains.kotlin.meta" +
"data.Property\022<\n\ntype_alias\030\005 \003(\0132(.org." +
"jetbrains.kotlin.metadata.TypeAlias\022<\n\nt" +
"ype_table\030\036 \001(\0132(.org.jetbrains.kotlin.m" +
"etadata.TypeTable\022Y\n\031version_requirement" +
"_table\030 \001(\01326.org.jetbrains.kotlin.meta" +
"data.VersionRequirementTable*\005\010d\020\310\001\"Z\n\tT",
"ypeTable\0221\n\004type\030\001 \003(\0132#.org.jetbrains.k" +
"otlin.metadata.Type\022\032\n\016first_nullable\030\002 " +
"\001(\005:\002-1\"\214\001\n\013Constructor\022\020\n\005flags\030\001 \001(\005:\001" +
"6\022F\n\017value_parameter\030\002 \003(\0132-.org.jetbrai" +
"ns.kotlin.metadata.ValueParameter\022\033\n\023ver" +
"sion_requirement\030\037 \003(\005*\006\010d\020\270\224\001\"\232\004\n\010Funct" +
"ion\022\020\n\005flags\030\t \001(\005:\0016\022\024\n\told_flags\030\001 \001(\005" +
":\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013return_type\030\003" +
" \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\030\n\020receiver_type_id\030\010 \001(\005\022F\n\017value_par" +
"ameter\030\006 \003(\0132-.org.jetbrains.kotlin.meta" +
"data.ValueParameter\022<\n\ntype_table\030\036 \001(\0132" +
"(.org.jetbrains.kotlin.metadata.TypeTabl" +
"e\022\033\n\023version_requirement\030\037 \003(\005\0229\n\010contra" +
"ct\030 \001(\0132\'.org.jetbrains.kotlin.metadata" +
".Contract*\006\010d\020\270\224\001\"\331\003\n\010Property\022\022\n\005flags\030" +
"\013 \001(\005:\003518\022\027\n\told_flags\030\001 \001(\005:\0042054\022\022\n\004n",
"ame\030\002 \002(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.o" +
"rg.jetbrains.kotlin.metadata.Type\022\026\n\016ret" +
"urn_type_id\030\t \001(\005\022D\n\016type_parameter\030\004 \003(" +
"\0132,.org.jetbrains.kotlin.metadata.TypePa" +
"rameter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jet" +
"brains.kotlin.metadata.Type\022\030\n\020receiver_" +
"type_id\030\n \001(\005\022M\n\026setter_value_parameter\030" +
"\006 \001(\0132-.org.jetbrains.kotlin.metadata.Va" +
"lueParameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014se" +
"tter_flags\030\010 \001(\005\022\033\n\023version_requirement\030",
"\037 \003(\005*\006\010d\020\270\224\001\"\343\001\n\016ValueParameter\022\020\n\005flag" +
"s\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003" +
" \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\017\n\007type_id\030\005 \001(\005\022@\n\023vararg_element_typ" +
"e\030\004 \001(\0132#.org.jetbrains.kotlin.metadata." +
"Type\022\036\n\026vararg_element_type_id\030\006 \001(\005*\005\010d" +
"\020\310\001\"\212\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004n" +
"ame\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_parameter\030\003 \003(\0132" +
",.org.jetbrains.kotlin.metadata.TypePara" +
"meter\022<\n\017underlying_type\030\004 \001(\0132#.org.jet",
"brains.kotlin.metadata.Type\022\032\n\022underlyin" +
"g_type_id\030\005 \001(\005\022:\n\rexpanded_type\030\006 \001(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\030\n\020e" +
"xpanded_type_id\030\007 \001(\005\022=\n\nannotation\030\010 \003(" +
"\0132).org.jetbrains.kotlin.metadata.Annota" +
"tion\022\033\n\023version_requirement\030\037 \003(\005*\005\010d\020\310\001" +
"\"&\n\tEnumEntry\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001" +
"\"\225\003\n\022VersionRequirement\022\017\n\007version\030\001 \001(\005" +
"\022\024\n\014version_full\030\002 \001(\005\022M\n\005level\030\003 \001(\01627." +
"org.jetbrains.kotlin.metadata.VersionReq",
"uirement.Level:\005ERROR\022\022\n\nerror_code\030\004 \001(" +
"\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind" +
"\030\006 \001(\0162=.org.jetbrains.kotlin.metadata.V" +
"ersionRequirement.VersionKind:\020LANGUAGE_" +
"VERSION\"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001" +
"\022\n\n\006HIDDEN\020\002\"J\n\013VersionKind\022\024\n\020LANGUAGE_" +
"VERSION\020\000\022\024\n\020COMPILER_VERSION\020\001\022\017\n\013API_V" +
"ERSION\020\002\"a\n\027VersionRequirementTable\022F\n\013r" +
"equirement\030\001 \003(\01321.org.jetbrains.kotlin." +
"metadata.VersionRequirement\"\217\002\n\017PackageF",
"ragment\022;\n\007strings\030\001 \001(\0132*.org.jetbrains" +
".kotlin.metadata.StringTable\022J\n\017qualifie" +
"d_names\030\002 \001(\01321.org.jetbrains.kotlin.met" +
"adata.QualifiedNameTable\0227\n\007package\030\003 \001(" +
"\0132&.org.jetbrains.kotlin.metadata.Packag" +
"e\0223\n\005class\030\004 \003(\0132$.org.jetbrains.kotlin." +
"metadata.Class*\005\010d\020\310\001\"A\n\010Contract\0225\n\006eff" +
"ect\030\001 \003(\0132%.org.jetbrains.kotlin.metadat" +
"a.Effect\"\306\003\n\006Effect\022E\n\013effect_type\030\001 \001(\016" +
"20.org.jetbrains.kotlin.metadata.Effect.",
"EffectType\022N\n\033effect_constructor_argumen" +
"t\030\002 \003(\0132).org.jetbrains.kotlin.metadata." +
"Expression\022S\n conclusion_of_conditional_" +
"effect\030\003 \001(\0132).org.jetbrains.kotlin.meta" +
"data.Expression\022B\n\004kind\030\004 \001(\01624.org.jetb" +
"rains.kotlin.metadata.Effect.InvocationK" +
"ind\"C\n\nEffectType\022\024\n\020RETURNS_CONSTANT\020\000\022" +
"\t\n\005CALLS\020\001\022\024\n\020RETURNS_NOT_NULL\020\002\"G\n\016Invo" +
"cationKind\022\020\n\014AT_MOST_ONCE\020\000\022\020\n\014EXACTLY_" +
"ONCE\020\001\022\021\n\rAT_LEAST_ONCE\020\002\"\237\003\n\nExpression",
"\022\020\n\005flags\030\001 \001(\005:\0010\022!\n\031value_parameter_re" +
"ference\030\002 \001(\005\022O\n\016constant_value\030\003 \001(\01627." +
"org.jetbrains.kotlin.metadata.Expression" +
".ConstantValue\022=\n\020is_instance_type\030\004 \001(\013" +
"2#.org.jetbrains.kotlin.metadata.Type\022\033\n" +
"\023is_instance_type_id\030\005 \001(\005\022?\n\014and_argume" +
"nt\030\006 \003(\0132).org.jetbrains.kotlin.metadata" +
".Expression\022>\n\013or_argument\030\007 \003(\0132).org.j" +
"etbrains.kotlin.metadata.Expression\".\n\rC" +
"onstantValue\022\010\n\004TRUE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NUL",
"L\020\002*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010" +
"ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010" +
"INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n" +
"\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL" +
"\020\005*Q\n\nMemberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAK" +
"E_OVERRIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESI" +
"ZED\020\003B\017B\rDebugProtoBuf"
"e\022\026\n\016return_type_id\030\007 \001(\005\022D\n\016type_parame",
"ter\030\004 \003(\0132,.org.jetbrains.kotlin.metadat" +
"a.TypeParameter\022:\n\rreceiver_type\030\005 \001(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\030\n\020r" +
"eceiver_type_id\030\010 \001(\005\022F\n\017value_parameter" +
"\030\006 \003(\0132-.org.jetbrains.kotlin.metadata.V" +
"alueParameter\022<\n\ntype_table\030\036 \001(\0132(.org." +
"jetbrains.kotlin.metadata.TypeTable\022\033\n\023v" +
"ersion_requirement\030\037 \003(\005\0229\n\010contract\030 \001" +
"(\0132\'.org.jetbrains.kotlin.metadata.Contr" +
"act*\006\010d\020\270\224\001\"\331\003\n\010Property\022\022\n\005flags\030\013 \001(\005:",
"\003518\022\027\n\told_flags\030\001 \001(\005:\0042054\022\022\n\004name\030\002 " +
"\002(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.jet" +
"brains.kotlin.metadata.Type\022\026\n\016return_ty" +
"pe_id\030\t \001(\005\022D\n\016type_parameter\030\004 \003(\0132,.or" +
"g.jetbrains.kotlin.metadata.TypeParamete" +
"r\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetbrains" +
".kotlin.metadata.Type\022\030\n\020receiver_type_i" +
"d\030\n \001(\005\022M\n\026setter_value_parameter\030\006 \001(\0132" +
"-.org.jetbrains.kotlin.metadata.ValuePar" +
"ameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_f",
"lags\030\010 \001(\005\022\033\n\023version_requirement\030\037 \003(\005*" +
"\006\010d\020\270\224\001\"\343\001\n\016ValueParameter\022\020\n\005flags\030\001 \001(" +
"\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003 \001(\0132#" +
".org.jetbrains.kotlin.metadata.Type\022\017\n\007t" +
"ype_id\030\005 \001(\005\022@\n\023vararg_element_type\030\004 \001(" +
"\0132#.org.jetbrains.kotlin.metadata.Type\022\036" +
"\n\026vararg_element_type_id\030\006 \001(\005*\005\010d\020\310\001\"\212\003" +
"\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 " +
"\002(\005B\004\210\265\030\001\022D\n\016type_parameter\030\003 \003(\0132,.org." +
"jetbrains.kotlin.metadata.TypeParameter\022",
"<\n\017underlying_type\030\004 \001(\0132#.org.jetbrains" +
".kotlin.metadata.Type\022\032\n\022underlying_type" +
"_id\030\005 \001(\005\022:\n\rexpanded_type\030\006 \001(\0132#.org.j" +
"etbrains.kotlin.metadata.Type\022\030\n\020expande" +
"d_type_id\030\007 \001(\005\022=\n\nannotation\030\010 \003(\0132).or" +
"g.jetbrains.kotlin.metadata.Annotation\022\033" +
"\n\023version_requirement\030\037 \003(\005*\005\010d\020\310\001\"&\n\tEn" +
"umEntry\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022V" +
"ersionRequirement\022\017\n\007version\030\001 \001(\005\022\024\n\014ve" +
"rsion_full\030\002 \001(\005\022M\n\005level\030\003 \001(\01627.org.je",
"tbrains.kotlin.metadata.VersionRequireme" +
"nt.Level:\005ERROR\022\022\n\nerror_code\030\004 \001(\005\022\025\n\007m" +
"essage\030\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind\030\006 \001(\016" +
"2=.org.jetbrains.kotlin.metadata.Version" +
"Requirement.VersionKind:\020LANGUAGE_VERSIO" +
"N\"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HI" +
"DDEN\020\002\"J\n\013VersionKind\022\024\n\020LANGUAGE_VERSIO" +
"N\020\000\022\024\n\020COMPILER_VERSION\020\001\022\017\n\013API_VERSION" +
"\020\002\"a\n\027VersionRequirementTable\022F\n\013require" +
"ment\030\001 \003(\01321.org.jetbrains.kotlin.metada",
"ta.VersionRequirement\"\217\002\n\017PackageFragmen" +
"t\022;\n\007strings\030\001 \001(\0132*.org.jetbrains.kotli" +
"n.metadata.StringTable\022J\n\017qualified_name" +
"s\030\002 \001(\01321.org.jetbrains.kotlin.metadata." +
"QualifiedNameTable\0227\n\007package\030\003 \001(\0132&.or" +
"g.jetbrains.kotlin.metadata.Package\0223\n\005c" +
"lass\030\004 \003(\0132$.org.jetbrains.kotlin.metada" +
"ta.Class*\005\010d\020\310\001\"A\n\010Contract\0225\n\006effect\030\001 " +
"\003(\0132%.org.jetbrains.kotlin.metadata.Effe" +
"ct\"\306\003\n\006Effect\022E\n\013effect_type\030\001 \001(\01620.org",
".jetbrains.kotlin.metadata.Effect.Effect" +
"Type\022N\n\033effect_constructor_argument\030\002 \003(" +
"\0132).org.jetbrains.kotlin.metadata.Expres" +
"sion\022S\n conclusion_of_conditional_effect" +
"\030\003 \001(\0132).org.jetbrains.kotlin.metadata.E" +
"xpression\022B\n\004kind\030\004 \001(\01624.org.jetbrains." +
"kotlin.metadata.Effect.InvocationKind\"C\n" +
"\nEffectType\022\024\n\020RETURNS_CONSTANT\020\000\022\t\n\005CAL" +
"LS\020\001\022\024\n\020RETURNS_NOT_NULL\020\002\"G\n\016Invocation" +
"Kind\022\020\n\014AT_MOST_ONCE\020\000\022\020\n\014EXACTLY_ONCE\020\001",
"\022\021\n\rAT_LEAST_ONCE\020\002\"\237\003\n\nExpression\022\020\n\005fl" +
"ags\030\001 \001(\005:\0010\022!\n\031value_parameter_referenc" +
"e\030\002 \001(\005\022O\n\016constant_value\030\003 \001(\01627.org.je" +
"tbrains.kotlin.metadata.Expression.Const" +
"antValue\022=\n\020is_instance_type\030\004 \001(\0132#.org" +
".jetbrains.kotlin.metadata.Type\022\033\n\023is_in" +
"stance_type_id\030\005 \001(\005\022?\n\014and_argument\030\006 \003" +
"(\0132).org.jetbrains.kotlin.metadata.Expre" +
"ssion\022>\n\013or_argument\030\007 \003(\0132).org.jetbrai" +
"ns.kotlin.metadata.Expression\".\n\rConstan",
"tValue\022\010\n\004TRUE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n" +
"\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRA" +
"CT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010INTERN" +
"AL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBL" +
"IC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\n" +
"MemberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAKE_OVER" +
"RIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED\020\003B" +
"\017B\rDebugProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -34362,7 +34521,7 @@ public final class DebugProtoBuf {
internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_metadata_Annotation_Argument_Value_descriptor,
new java.lang.String[] { "Type", "IntValue", "FloatValue", "DoubleValue", "StringValue", "ClassId", "EnumValueId", "Annotation", "ArrayElement", "Flags", });
new java.lang.String[] { "Type", "IntValue", "FloatValue", "DoubleValue", "StringValue", "ClassId", "EnumValueId", "Annotation", "ArrayElement", "ArrayDimensionCount", "Flags", });
internal_static_org_jetbrains_kotlin_metadata_Type_descriptor =
getDescriptor().getMessageTypes().get(3);
internal_static_org_jetbrains_kotlin_metadata_Type_fieldAccessorTable = new
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.serialization
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
@@ -99,11 +100,23 @@ class AnnotationSerializer(private val stringTable: DescriptorAwareStringTable)
}
override fun visitKClassValue(value: KClassValue, data: Unit) {
val descriptor = value.value.constructor.declarationDescriptor as? ClassDescriptor
?: throw UnsupportedOperationException("Class literal annotation argument should be a class: $value")
var kotlinType = value.value
var arrayDimensions = 0
while (KotlinBuiltIns.isArray(kotlinType)) {
// We only support invariant projections and non-null array element types, see KT-26568
kotlinType = kotlinType.arguments.single().type
arrayDimensions++
}
val descriptor = kotlinType.constructor.declarationDescriptor as? ClassDescriptor
?: throw UnsupportedOperationException("Class literal annotation argument should be a class: $value")
type = Type.CLASS
classId = stringTable.getFqNameIndex(descriptor)
if (arrayDimensions > 0) {
arrayDimensionCount = arrayDimensions
}
}
override fun visitLongValue(value: LongValue, data: Unit) {
@@ -11,6 +11,13 @@ class A {
fun simple(s: @Ann(Simple::class) String) {}
fun generic(s: @Ann(Generic::class) String) {}
fun innerGeneric(s: @Ann(InnerGeneric.Inner::class) String) {}
fun arrays(
s: @Ann(Array<Int>::class) Array<Int>,
t: @Ann(Array<IntArray>::class) Array<IntArray>,
u: @Ann(Array<Array<Int>>::class) Array<Array<Int>>,
v: @Ann(Array<Array<Array<String>>>::class) Array<Array<Array<String>>>
) {}
}
class Simple
@@ -2,6 +2,7 @@ package test
public final class A {
/*primary*/ public constructor A()
public final fun arrays(/*0*/ s: @test.Ann(klass = kotlin.Array<kotlin.Int>::class) kotlin.Array<kotlin.Int>, /*1*/ t: @test.Ann(klass = kotlin.Array<kotlin.IntArray>::class) kotlin.Array<kotlin.IntArray>, /*2*/ u: @test.Ann(klass = kotlin.Array<kotlin.Array<kotlin.Int>>::class) kotlin.Array<kotlin.Array<kotlin.Int>>, /*3*/ v: @test.Ann(klass = kotlin.Array<kotlin.Array<kotlin.Array<kotlin.String>>>::class) kotlin.Array<kotlin.Array<kotlin.Array<kotlin.String>>>): kotlin.Unit
public final fun generic(/*0*/ s: @test.Ann(klass = test.Generic<*>::class) kotlin.String): kotlin.Unit
public final fun innerGeneric(/*0*/ s: @test.Ann(klass = test.InnerGeneric<*, *>.Inner<*, *>::class) kotlin.String): kotlin.Unit
public final fun simple(/*0*/ s: @test.Ann(klass = test.Simple::class) kotlin.String): kotlin.Unit
@@ -33,7 +33,7 @@ class JsMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
companion object {
@JvmField
val INSTANCE = JsMetadataVersion(1, 2, 4)
val INSTANCE = JsMetadataVersion(1, 2, 5)
@JvmField
val INVALID_VERSION = JsMetadataVersion()
@@ -79,7 +79,7 @@ class AnnotationDeserializer(private val module: ModuleDescriptor, private val n
StringValue(nameResolver.getString(value.stringValue))
}
Type.CLASS -> {
resolveClassLiteralValue(nameResolver.getClassId(value.classId))
resolveClassLiteralValue(nameResolver.getClassId(value.classId), value.arrayDimensionCount)
}
Type.ENUM -> {
EnumValue(nameResolver.getClassId(value.classId), nameResolver.getName(value.enumValueId))
@@ -128,13 +128,17 @@ 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, arrayDimensions: Int): ConstantValue<*> {
// 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
val starProjectedType = resolveClass(classId).defaultType.replaceArgumentsWithStarProjections()
var type = resolveClass(classId).defaultType.replaceArgumentsWithStarProjections()
repeat(arrayDimensions) {
// We only support invariant projections and non-null array element types, see KT-26568
type = builtIns.getArrayType(Variance.INVARIANT, type)
}
val kClass = resolveClass(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.kClass.toSafe()))
val type = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kClass, listOf(TypeProjectionImpl(starProjectedType)))
return KClassValue(type)
return KClassValue(KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kClass, listOf(TypeProjectionImpl(type))))
}
private fun resolveArrayElementType(value: Value, nameResolver: NameResolver): SimpleType =
@@ -20,7 +20,7 @@ class JvmMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
companion object {
@JvmField
val INSTANCE = JvmMetadataVersion(1, 1, 12)
val INSTANCE = JvmMetadataVersion(1, 1, 13)
@JvmField
val INVALID_VERSION = JvmMetadataVersion()
+9
View File
@@ -84,6 +84,15 @@ message Annotation {
repeated Value array_element = 9;
// If type = CLASS, the number of dimensions of the array of the class specified in class_id.
// E.g. if class_id = kotlin/String, this annotation argument value denotes:
// - String::class, if array_dimension_count = 0
// - Array<String>::class, if array_dimension_count = 1
// - Array<Array<String>>::class, if array_dimension_count = 2
// - etc.
// Other forms of array class literals are not supported by this format, see KT-26568
optional int32 array_dimension_count = 11 [default = 0];
/*
isUnsigned
*/
@@ -2201,6 +2201,35 @@ public final class ProtoBuf {
*/
int getArrayElementCount();
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
boolean hasArrayDimensionCount();
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
int getArrayDimensionCount();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
@@ -2332,10 +2361,15 @@ public final class ProtoBuf {
break;
}
case 80: {
bitField0_ |= 0x00000100;
bitField0_ |= 0x00000200;
flags_ = input.readInt32();
break;
}
case 88: {
bitField0_ |= 0x00000100;
arrayDimensionCount_ = input.readInt32();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -2703,6 +2737,41 @@ public final class ProtoBuf {
return arrayElement_.get(index);
}
public static final int ARRAY_DIMENSION_COUNT_FIELD_NUMBER = 11;
private int arrayDimensionCount_;
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public boolean hasArrayDimensionCount() {
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public int getArrayDimensionCount() {
return arrayDimensionCount_;
}
public static final int FLAGS_FIELD_NUMBER = 10;
private int flags_;
/**
@@ -2713,7 +2782,7 @@ public final class ProtoBuf {
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -2736,6 +2805,7 @@ public final class ProtoBuf {
enumValueId_ = 0;
annotation_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance();
arrayElement_ = java.util.Collections.emptyList();
arrayDimensionCount_ = 0;
flags_ = 0;
}
private byte memoizedIsInitialized = -1;
@@ -2790,9 +2860,12 @@ public final class ProtoBuf {
for (int i = 0; i < arrayElement_.size(); i++) {
output.writeMessage(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000200) == 0x00000200)) {
output.writeInt32(10, flags_);
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
output.writeInt32(11, arrayDimensionCount_);
}
output.writeRawBytes(unknownFields);
}
@@ -2838,10 +2911,14 @@ public final class ProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000200) == 0x00000200)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(10, flags_);
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(11, arrayDimensionCount_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -2954,8 +3031,10 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000080);
arrayElement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
flags_ = 0;
arrayDimensionCount_ = 0;
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0;
bitField0_ = (bitField0_ & ~0x00000400);
return this;
}
@@ -3019,6 +3098,10 @@ public final class ProtoBuf {
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000100;
}
result.arrayDimensionCount_ = arrayDimensionCount_;
if (((from_bitField0_ & 0x00000400) == 0x00000400)) {
to_bitField0_ |= 0x00000200;
}
result.flags_ = flags_;
result.bitField0_ = to_bitField0_;
return result;
@@ -3060,6 +3143,9 @@ public final class ProtoBuf {
}
}
if (other.hasArrayDimensionCount()) {
setArrayDimensionCount(other.getArrayDimensionCount());
}
if (other.hasFlags()) {
setFlags(other.getFlags());
}
@@ -3555,6 +3641,78 @@ public final class ProtoBuf {
return this;
}
private int arrayDimensionCount_ ;
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public boolean hasArrayDimensionCount() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public int getArrayDimensionCount() {
return arrayDimensionCount_;
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public Builder setArrayDimensionCount(int value) {
bitField0_ |= 0x00000200;
arrayDimensionCount_ = value;
return this;
}
/**
* <code>optional int32 array_dimension_count = 11 [default = 0];</code>
*
* <pre>
* If type = CLASS, the number of dimensions of the array of the class specified in class_id.
* E.g. if class_id = kotlin/String, this annotation argument value denotes:
* - String::class, if array_dimension_count = 0
* - Array&lt;String&gt;::class, if array_dimension_count = 1
* - Array&lt;Array&lt;String&gt;&gt;::class, if array_dimension_count = 2
* - etc.
* Other forms of array class literals are not supported by this format, see KT-26568
* </pre>
*/
public Builder clearArrayDimensionCount() {
bitField0_ = (bitField0_ & ~0x00000200);
arrayDimensionCount_ = 0;
return this;
}
private int flags_ ;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -3564,7 +3722,7 @@ public final class ProtoBuf {
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
return ((bitField0_ & 0x00000400) == 0x00000400);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
@@ -3584,7 +3742,7 @@ public final class ProtoBuf {
* </pre>
*/
public Builder setFlags(int value) {
bitField0_ |= 0x00000200;
bitField0_ |= 0x00000400;
flags_ = value;
return this;
@@ -3597,7 +3755,7 @@ public final class ProtoBuf {
* </pre>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000200);
bitField0_ = (bitField0_ & ~0x00000400);
flags_ = 0;
return this;
@@ -19,7 +19,7 @@ class BuiltInsBinaryVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
companion object {
@JvmField
val INSTANCE = BuiltInsBinaryVersion(1, 0, 5)
val INSTANCE = BuiltInsBinaryVersion(1, 0, 6)
@JvmField
val INVALID_VERSION = BuiltInsBinaryVersion()