'SuspendFunction$n' should not be visible in member scopes (should be unresolved).
'SuspendFunction$n' class descriptors are created on demand by KotlinBuiltIns (and cached). On serialization, types constructed with 'SuspendFunction$n' are written as 'Function$n' with extra flag (SUSPEND_TYPE). On deserialization, corresponding 'SuspendFunction$n' classes are used.
This commit is contained in:
committed by
Stanislav Erokhin
parent
a70ac0160d
commit
80bd916f5d
@@ -488,6 +488,11 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
|
||||
if (old.abbreviatedTypeId != new.abbreviatedTypeId) return false
|
||||
}
|
||||
|
||||
if (old.hasFlags() != new.hasFlags()) return false
|
||||
if (old.hasFlags()) {
|
||||
if (old.flags != new.flags) return false
|
||||
}
|
||||
|
||||
if (old.getExtensionCount(JvmProtoBuf.typeAnnotation) != new.getExtensionCount(JvmProtoBuf.typeAnnotation)) return false
|
||||
|
||||
for(i in 0..old.getExtensionCount(JvmProtoBuf.typeAnnotation) - 1) {
|
||||
@@ -1361,6 +1366,10 @@ fun ProtoBuf.Type.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
|
||||
hashCode = 31 * hashCode + abbreviatedTypeId
|
||||
}
|
||||
|
||||
if (hasFlags()) {
|
||||
hashCode = 31 * hashCode + flags
|
||||
}
|
||||
|
||||
for(i in 0..getExtensionCount(JvmProtoBuf.typeAnnotation) - 1) {
|
||||
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.typeAnnotation, i).hashCode(stringIndexes, fqNameIndexes)
|
||||
}
|
||||
|
||||
@@ -5509,6 +5509,23 @@ public final class DebugProtoBuf {
|
||||
* <code>optional int32 abbreviated_type_id = 14;</code>
|
||||
*/
|
||||
int getAbbreviatedTypeId();
|
||||
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasFlags();
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
int getFlags();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.Type}
|
||||
@@ -5563,6 +5580,11 @@ public final class DebugProtoBuf {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
bitField0_ |= 0x00001000;
|
||||
flags_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
argument_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.DebugProtoBuf.Type.Argument>();
|
||||
@@ -6812,6 +6834,29 @@ public final class DebugProtoBuf {
|
||||
return abbreviatedTypeId_;
|
||||
}
|
||||
|
||||
public static final int FLAGS_FIELD_NUMBER = 1;
|
||||
private int flags_;
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasFlags() {
|
||||
return ((bitField0_ & 0x00001000) == 0x00001000);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public int getFlags() {
|
||||
return flags_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
argument_ = java.util.Collections.emptyList();
|
||||
nullable_ = false;
|
||||
@@ -6826,6 +6871,7 @@ public final class DebugProtoBuf {
|
||||
outerTypeId_ = 0;
|
||||
abbreviatedType_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.Type.getDefaultInstance();
|
||||
abbreviatedTypeId_ = 0;
|
||||
flags_ = 0;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -6871,6 +6917,9 @@ public final class DebugProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage
|
||||
.ExtendableMessage<org.jetbrains.kotlin.serialization.DebugProtoBuf.Type>.ExtensionWriter extensionWriter =
|
||||
newExtensionWriter();
|
||||
if (((bitField0_ & 0x00001000) == 0x00001000)) {
|
||||
output.writeInt32(1, flags_);
|
||||
}
|
||||
for (int i = 0; i < argument_.size(); i++) {
|
||||
output.writeMessage(2, argument_.get(i));
|
||||
}
|
||||
@@ -6920,6 +6969,10 @@ public final class DebugProtoBuf {
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00001000) == 0x00001000)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32Size(1, flags_);
|
||||
}
|
||||
for (int i = 0; i < argument_.size(); i++) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(2, argument_.get(i));
|
||||
@@ -7137,6 +7190,8 @@ public final class DebugProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000800);
|
||||
abbreviatedTypeId_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00001000);
|
||||
flags_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00002000);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -7234,6 +7289,10 @@ public final class DebugProtoBuf {
|
||||
to_bitField0_ |= 0x00000800;
|
||||
}
|
||||
result.abbreviatedTypeId_ = abbreviatedTypeId_;
|
||||
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
|
||||
to_bitField0_ |= 0x00001000;
|
||||
}
|
||||
result.flags_ = flags_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
onBuilt();
|
||||
return result;
|
||||
@@ -7312,6 +7371,9 @@ public final class DebugProtoBuf {
|
||||
if (other.hasAbbreviatedTypeId()) {
|
||||
setAbbreviatedTypeId(other.getAbbreviatedTypeId());
|
||||
}
|
||||
if (other.hasFlags()) {
|
||||
setFlags(other.getFlags());
|
||||
}
|
||||
this.mergeExtensionFields(other);
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
@@ -8316,6 +8378,54 @@ public final class DebugProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
private int flags_ ;
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasFlags() {
|
||||
return ((bitField0_ & 0x00002000) == 0x00002000);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public int getFlags() {
|
||||
return flags_;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setFlags(int value) {
|
||||
bitField0_ |= 0x00002000;
|
||||
flags_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearFlags() {
|
||||
bitField0_ = (bitField0_ & ~0x00002000);
|
||||
flags_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.Type)
|
||||
}
|
||||
|
||||
@@ -27159,7 +27269,7 @@ public final class DebugProtoBuf {
|
||||
"\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\007BOOLE",
|
||||
"AN\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\"\212\006\n\004Type\022C\n\010arg" +
|
||||
"\nANNOTATION\020\013\022\t\n\005ARRAY\020\014\"\231\006\n\004Type\022C\n\010arg" +
|
||||
"ument\030\002 \003(\01321.org.jetbrains.kotlin.seria" +
|
||||
"lization.Type.Argument\022\027\n\010nullable\030\003 \001(\010" +
|
||||
":\005false\022+\n\035flexible_type_capabilities_id" +
|
||||
@@ -27173,115 +27283,115 @@ public final class DebugProtoBuf {
|
||||
"ialization.Type\022\025\n\router_type_id\030\013 \001(\005\022B" +
|
||||
"\n\020abbreviated_type\030\r \001(\0132(.org.jetbrains" +
|
||||
".kotlin.serialization.Type\022\033\n\023abbreviate" +
|
||||
"d_type_id\030\016 \001(\005\032\334\001\n\010Argument\022U\n\nprojecti" +
|
||||
"on\030\001 \001(\0162<.org.jetbrains.kotlin.serializ" +
|
||||
"ation.Type.Argument.Projection:\003INV\0226\n\004t" +
|
||||
"ype\030\002 \001(\0132(.org.jetbrains.kotlin.seriali" +
|
||||
"zation.Type\022\017\n\007type_id\030\003 \001(\005\"0\n\nProjecti",
|
||||
"on\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\"\236\002\n\rTypeParameter\022\n\n\002id\030\001 \002(\005\022\022\n\004n" +
|
||||
"ame\030\002 \002(\005B\004\210\265\030\001\022\026\n\007reified\030\003 \001(\010:\005false\022" +
|
||||
"Q\n\010variance\030\004 \001(\0162:.org.jetbrains.kotlin" +
|
||||
".serialization.TypeParameter.Variance:\003I" +
|
||||
"NV\022=\n\013upper_bound\030\005 \003(\0132(.org.jetbrains." +
|
||||
"kotlin.serialization.Type\022\026\n\016upper_bound" +
|
||||
"_id\030\006 \003(\005\"$\n\010Variance\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022\007" +
|
||||
"\n\003INV\020\002*\005\010d\020\350\007\"\236\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_o",
|
||||
"bject_name\030\004 \001(\005B\004\210\265\030\001\022I\n\016type_parameter" +
|
||||
"\030\005 \003(\01321.org.jetbrains.kotlin.serializat" +
|
||||
"ion.TypeParameter\022;\n\tsupertype\030\006 \003(\0132(.o" +
|
||||
"rg.jetbrains.kotlin.serialization.Type\022\030" +
|
||||
"\n\014supertype_id\030\002 \003(\005B\002\020\001\022!\n\021nested_class" +
|
||||
"_name\030\007 \003(\005B\006\020\001\210\265\030\001\022D\n\013constructor\030\010 \003(\013" +
|
||||
"2/.org.jetbrains.kotlin.serialization.Co" +
|
||||
"nstructor\022>\n\010function\030\t \003(\0132,.org.jetbra" +
|
||||
"ins.kotlin.serialization.Function\022>\n\010pro" +
|
||||
"perty\030\n \003(\0132,.org.jetbrains.kotlin.seria",
|
||||
"lization.Property\022A\n\ntype_alias\030\013 \003(\0132-." +
|
||||
"org.jetbrains.kotlin.serialization.TypeA" +
|
||||
"lias\022A\n\nenum_entry\030\r \003(\0132-.org.jetbrains" +
|
||||
".kotlin.serialization.EnumEntry\022A\n\ntype_" +
|
||||
"table\030\036 \001(\0132-.org.jetbrains.kotlin.seria" +
|
||||
"lization.TypeTable\022\027\n\017sinceKotlinInfo\030\037 " +
|
||||
"\001(\005\022Y\n\027since_kotlin_info_table\030 \001(\01328.o" +
|
||||
"rg.jetbrains.kotlin.serialization.SinceK" +
|
||||
"otlinInfoTable\"x\n\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINT" +
|
||||
"ERFACE\020\001\022\016\n\nENUM_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\020CO" +
|
||||
"MPANION_OBJECT\020\006*\005\010d\020\310\001\"\361\002\n\007Package\022>\n\010f" +
|
||||
"unction\030\003 \003(\0132,.org.jetbrains.kotlin.ser" +
|
||||
"ialization.Function\022>\n\010property\030\004 \003(\0132,." +
|
||||
"org.jetbrains.kotlin.serialization.Prope" +
|
||||
"rty\022A\n\ntype_alias\030\005 \003(\0132-.org.jetbrains." +
|
||||
"kotlin.serialization.TypeAlias\022A\n\ntype_t" +
|
||||
"able\030\036 \001(\0132-.org.jetbrains.kotlin.serial" +
|
||||
"ization.TypeTable\022Y\n\027since_kotlin_info_t" +
|
||||
"able\030 \001(\01328.org.jetbrains.kotlin.serial",
|
||||
"ization.SinceKotlinInfoTable*\005\010d\020\310\001\"_\n\tT" +
|
||||
"ypeTable\0226\n\004type\030\001 \003(\0132(.org.jetbrains.k" +
|
||||
"otlin.serialization.Type\022\032\n\016first_nullab" +
|
||||
"le\030\002 \001(\005:\002-1\"\214\001\n\013Constructor\022\020\n\005flags\030\001 " +
|
||||
"\001(\005:\0016\022K\n\017value_parameter\030\002 \003(\01322.org.je" +
|
||||
"tbrains.kotlin.serialization.ValueParame" +
|
||||
"ter\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d\020\310\001\"\363\003\n\010" +
|
||||
"Function\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\022=\n\013return_t" +
|
||||
"ype\030\003 \001(\0132(.org.jetbrains.kotlin.seriali",
|
||||
"zation.Type\022\026\n\016return_type_id\030\007 \001(\005\022I\n\016t" +
|
||||
"ype_parameter\030\004 \003(\01321.org.jetbrains.kotl" +
|
||||
"in.serialization.TypeParameter\022?\n\rreceiv" +
|
||||
"er_type\030\005 \001(\0132(.org.jetbrains.kotlin.ser" +
|
||||
"ialization.Type\022\030\n\020receiver_type_id\030\010 \001(" +
|
||||
"\005\022K\n\017value_parameter\030\006 \003(\01322.org.jetbrai" +
|
||||
"ns.kotlin.serialization.ValueParameter\022A" +
|
||||
"\n\ntype_table\030\036 \001(\0132-.org.jetbrains.kotli" +
|
||||
"n.serialization.TypeTable\022\027\n\017sinceKotlin" +
|
||||
"Info\030\037 \001(\005*\005\010d\020\310\001\"\350\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\022=\n\013return_type\030\003 \001(\0132(.o" +
|
||||
"rg.jetbrains.kotlin.serialization.Type\022\026" +
|
||||
"\n\016return_type_id\030\t \001(\005\022I\n\016type_parameter" +
|
||||
"\030\004 \003(\01321.org.jetbrains.kotlin.serializat" +
|
||||
"ion.TypeParameter\022?\n\rreceiver_type\030\005 \001(\013" +
|
||||
"2(.org.jetbrains.kotlin.serialization.Ty" +
|
||||
"pe\022\030\n\020receiver_type_id\030\n \001(\005\022R\n\026setter_v" +
|
||||
"alue_parameter\030\006 \001(\01322.org.jetbrains.kot" +
|
||||
"lin.serialization.ValueParameter\022\024\n\014gett",
|
||||
"er_flags\030\007 \001(\005\022\024\n\014setter_flags\030\010 \001(\005\022\027\n\017" +
|
||||
"sinceKotlinInfo\030\037 \001(\005*\005\010d\020\310\001\"\355\001\n\016ValuePa" +
|
||||
"rameter\022\020\n\005flags\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B" +
|
||||
"\004\210\265\030\001\0226\n\004type\030\003 \001(\0132(.org.jetbrains.kotl" +
|
||||
"in.serialization.Type\022\017\n\007type_id\030\005 \001(\005\022E" +
|
||||
"\n\023vararg_element_type\030\004 \001(\0132(.org.jetbra" +
|
||||
"ins.kotlin.serialization.Type\022\036\n\026vararg_" +
|
||||
"element_type_id\030\006 \001(\005*\005\010d\020\310\001\"\232\003\n\tTypeAli" +
|
||||
"as\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001" +
|
||||
"\022I\n\016type_parameter\030\003 \003(\01321.org.jetbrains",
|
||||
".kotlin.serialization.TypeParameter\022A\n\017u" +
|
||||
"nderlying_type\030\004 \001(\0132(.org.jetbrains.kot" +
|
||||
"lin.serialization.Type\022\032\n\022underlying_typ" +
|
||||
"e_id\030\005 \001(\005\022?\n\rexpanded_type\030\006 \001(\0132(.org." +
|
||||
"jetbrains.kotlin.serialization.Type\022\030\n\020e" +
|
||||
"xpanded_type_id\030\007 \001(\005\022B\n\nannotation\030\010 \003(" +
|
||||
"\0132..org.jetbrains.kotlin.serialization.A" +
|
||||
"nnotation\022\027\n\017sinceKotlinInfo\030\037 \001(\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\"\341\001\n\017SinceKotlinInfo\022\017\n\007version\030\001 \001(\005\022\024",
|
||||
"\n\014version_full\030\002 \001(\005\022O\n\005level\030\003 \001(\01629.or" +
|
||||
"g.jetbrains.kotlin.serialization.SinceKo" +
|
||||
"tlinInfo.Level:\005ERROR\022\022\n\nerror_code\030\004 \001(" +
|
||||
"\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\"+\n\005Level\022\013\n\007WAR" +
|
||||
"NING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"Y\n\024SinceKo" +
|
||||
"tlinInfoTable\022A\n\004info\030\001 \003(\01323.org.jetbra" +
|
||||
"ins.kotlin.serialization.SinceKotlinInfo" +
|
||||
"*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABS" +
|
||||
"TRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010INT" +
|
||||
"ERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006P",
|
||||
"UBLIC\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\rFAKE_O" +
|
||||
"VERRIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED" +
|
||||
"\020\003B\017B\rDebugProtoBuf"
|
||||
"d_type_id\030\016 \001(\005\022\r\n\005flags\030\001 \001(\005\032\334\001\n\010Argum" +
|
||||
"ent\022U\n\nprojection\030\001 \001(\0162<.org.jetbrains." +
|
||||
"kotlin.serialization.Type.Argument.Proje" +
|
||||
"ction:\003INV\0226\n\004type\030\002 \001(\0132(.org.jetbrains" +
|
||||
".kotlin.serialization.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\003IN" +
|
||||
"V\020\002\022\010\n\004STAR\020\003*\005\010d\020\310\001\"\236\002\n\rTypeParameter\022\n" +
|
||||
"\n\002id\030\001 \002(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022\026\n\007reifie" +
|
||||
"d\030\003 \001(\010:\005false\022Q\n\010variance\030\004 \001(\0162:.org.j" +
|
||||
"etbrains.kotlin.serialization.TypeParame" +
|
||||
"ter.Variance:\003INV\022=\n\013upper_bound\030\005 \003(\0132(" +
|
||||
".org.jetbrains.kotlin.serialization.Type" +
|
||||
"\022\026\n\016upper_bound_id\030\006 \003(\005\"$\n\010Variance\022\006\n\002" +
|
||||
"IN\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\236\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\022I\n" +
|
||||
"\016type_parameter\030\005 \003(\01321.org.jetbrains.ko" +
|
||||
"tlin.serialization.TypeParameter\022;\n\tsupe" +
|
||||
"rtype\030\006 \003(\0132(.org.jetbrains.kotlin.seria" +
|
||||
"lization.Type\022\030\n\014supertype_id\030\002 \003(\005B\002\020\001\022" +
|
||||
"!\n\021nested_class_name\030\007 \003(\005B\006\020\001\210\265\030\001\022D\n\013co" +
|
||||
"nstructor\030\010 \003(\0132/.org.jetbrains.kotlin.s" +
|
||||
"erialization.Constructor\022>\n\010function\030\t \003" +
|
||||
"(\0132,.org.jetbrains.kotlin.serialization." +
|
||||
"Function\022>\n\010property\030\n \003(\0132,.org.jetbrai",
|
||||
"ns.kotlin.serialization.Property\022A\n\ntype" +
|
||||
"_alias\030\013 \003(\0132-.org.jetbrains.kotlin.seri" +
|
||||
"alization.TypeAlias\022A\n\nenum_entry\030\r \003(\0132" +
|
||||
"-.org.jetbrains.kotlin.serialization.Enu" +
|
||||
"mEntry\022A\n\ntype_table\030\036 \001(\0132-.org.jetbrai" +
|
||||
"ns.kotlin.serialization.TypeTable\022\027\n\017sin" +
|
||||
"ceKotlinInfo\030\037 \001(\005\022Y\n\027since_kotlin_info_" +
|
||||
"table\030 \001(\01328.org.jetbrains.kotlin.seria" +
|
||||
"lization.SinceKotlinInfoTable\"x\n\004Kind\022\t\n" +
|
||||
"\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_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*\005\010d\020\310\001\"\361" +
|
||||
"\002\n\007Package\022>\n\010function\030\003 \003(\0132,.org.jetbr" +
|
||||
"ains.kotlin.serialization.Function\022>\n\010pr" +
|
||||
"operty\030\004 \003(\0132,.org.jetbrains.kotlin.seri" +
|
||||
"alization.Property\022A\n\ntype_alias\030\005 \003(\0132-" +
|
||||
".org.jetbrains.kotlin.serialization.Type" +
|
||||
"Alias\022A\n\ntype_table\030\036 \001(\0132-.org.jetbrain" +
|
||||
"s.kotlin.serialization.TypeTable\022Y\n\027sinc" +
|
||||
"e_kotlin_info_table\030 \001(\01328.org.jetbrain",
|
||||
"s.kotlin.serialization.SinceKotlinInfoTa" +
|
||||
"ble*\005\010d\020\310\001\"_\n\tTypeTable\0226\n\004type\030\001 \003(\0132(." +
|
||||
"org.jetbrains.kotlin.serialization.Type\022" +
|
||||
"\032\n\016first_nullable\030\002 \001(\005:\002-1\"\214\001\n\013Construc" +
|
||||
"tor\022\020\n\005flags\030\001 \001(\005:\0016\022K\n\017value_parameter" +
|
||||
"\030\002 \003(\01322.org.jetbrains.kotlin.serializat" +
|
||||
"ion.ValueParameter\022\027\n\017sinceKotlinInfo\030\037 " +
|
||||
"\001(\005*\005\010d\020\310\001\"\363\003\n\010Function\022\020\n\005flags\030\t \001(\005:\001" +
|
||||
"6\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210" +
|
||||
"\265\030\001\022=\n\013return_type\030\003 \001(\0132(.org.jetbrains",
|
||||
".kotlin.serialization.Type\022\026\n\016return_typ" +
|
||||
"e_id\030\007 \001(\005\022I\n\016type_parameter\030\004 \003(\01321.org" +
|
||||
".jetbrains.kotlin.serialization.TypePara" +
|
||||
"meter\022?\n\rreceiver_type\030\005 \001(\0132(.org.jetbr" +
|
||||
"ains.kotlin.serialization.Type\022\030\n\020receiv" +
|
||||
"er_type_id\030\010 \001(\005\022K\n\017value_parameter\030\006 \003(" +
|
||||
"\01322.org.jetbrains.kotlin.serialization.V" +
|
||||
"alueParameter\022A\n\ntype_table\030\036 \001(\0132-.org." +
|
||||
"jetbrains.kotlin.serialization.TypeTable" +
|
||||
"\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d\020\310\001\"\350\003\n\010Pro",
|
||||
"perty\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\022=\n\013return" +
|
||||
"_type\030\003 \001(\0132(.org.jetbrains.kotlin.seria" +
|
||||
"lization.Type\022\026\n\016return_type_id\030\t \001(\005\022I\n" +
|
||||
"\016type_parameter\030\004 \003(\01321.org.jetbrains.ko" +
|
||||
"tlin.serialization.TypeParameter\022?\n\rrece" +
|
||||
"iver_type\030\005 \001(\0132(.org.jetbrains.kotlin.s" +
|
||||
"erialization.Type\022\030\n\020receiver_type_id\030\n " +
|
||||
"\001(\005\022R\n\026setter_value_parameter\030\006 \001(\01322.or" +
|
||||
"g.jetbrains.kotlin.serialization.ValuePa",
|
||||
"rameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_" +
|
||||
"flags\030\010 \001(\005\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d" +
|
||||
"\020\310\001\"\355\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\0226\n\004type\030\003 \001(\0132(.org" +
|
||||
".jetbrains.kotlin.serialization.Type\022\017\n\007" +
|
||||
"type_id\030\005 \001(\005\022E\n\023vararg_element_type\030\004 \001" +
|
||||
"(\0132(.org.jetbrains.kotlin.serialization." +
|
||||
"Type\022\036\n\026vararg_element_type_id\030\006 \001(\005*\005\010d" +
|
||||
"\020\310\001\"\232\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\022I\n\016type_parameter\030\003 \003(\0132",
|
||||
"1.org.jetbrains.kotlin.serialization.Typ" +
|
||||
"eParameter\022A\n\017underlying_type\030\004 \001(\0132(.or" +
|
||||
"g.jetbrains.kotlin.serialization.Type\022\032\n" +
|
||||
"\022underlying_type_id\030\005 \001(\005\022?\n\rexpanded_ty" +
|
||||
"pe\030\006 \001(\0132(.org.jetbrains.kotlin.serializ" +
|
||||
"ation.Type\022\030\n\020expanded_type_id\030\007 \001(\005\022B\n\n" +
|
||||
"annotation\030\010 \003(\0132..org.jetbrains.kotlin." +
|
||||
"serialization.Annotation\022\027\n\017sinceKotlinI" +
|
||||
"nfo\030\037 \001(\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\"\341\001\n\017SinceKotlinInfo\022\017\n\007",
|
||||
"version\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022O\n\005l" +
|
||||
"evel\030\003 \001(\01629.org.jetbrains.kotlin.serial" +
|
||||
"ization.SinceKotlinInfo.Level:\005ERROR\022\022\n\n" +
|
||||
"error_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\"" +
|
||||
"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDD" +
|
||||
"EN\020\002\"Y\n\024SinceKotlinInfoTable\022A\n\004info\030\001 \003" +
|
||||
"(\01323.org.jetbrains.kotlin.serialization." +
|
||||
"SinceKotlinInfo*9\n\010Modality\022\t\n\005FINAL\020\000\022\010" +
|
||||
"\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVi" +
|
||||
"sibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tP",
|
||||
"ROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THI" +
|
||||
"S\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013DECLARAT" +
|
||||
"ION\020\000\022\021\n\rFAKE_OVERRIDE\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() {
|
||||
@@ -27337,7 +27447,7 @@ public final class DebugProtoBuf {
|
||||
internal_static_org_jetbrains_kotlin_serialization_Type_fieldAccessorTable = new
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_org_jetbrains_kotlin_serialization_Type_descriptor,
|
||||
new java.lang.String[] { "Argument", "Nullable", "FlexibleTypeCapabilitiesId", "FlexibleUpperBound", "FlexibleUpperBoundId", "ClassName", "TypeParameter", "TypeParameterName", "TypeAliasName", "OuterType", "OuterTypeId", "AbbreviatedType", "AbbreviatedTypeId", });
|
||||
new java.lang.String[] { "Argument", "Nullable", "FlexibleTypeCapabilitiesId", "FlexibleUpperBound", "FlexibleUpperBoundId", "ClassName", "TypeParameter", "TypeParameterName", "TypeAliasName", "OuterType", "OuterTypeId", "AbbreviatedType", "AbbreviatedTypeId", "Flags", });
|
||||
internal_static_org_jetbrains_kotlin_serialization_Type_Argument_descriptor =
|
||||
internal_static_org_jetbrains_kotlin_serialization_Type_descriptor.getNestedTypes().get(0);
|
||||
internal_static_org_jetbrains_kotlin_serialization_Type_Argument_fieldAccessorTable = new
|
||||
|
||||
+17
-1
@@ -17,6 +17,8 @@
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.getFunctionalClassKind
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -25,6 +27,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.Interner
|
||||
import java.io.ByteArrayOutputStream
|
||||
@@ -455,12 +458,25 @@ class DescriptorSerializer private constructor(
|
||||
}
|
||||
|
||||
private fun fillFromPossiblyInnerType(builder: ProtoBuf.Type.Builder, type: PossiblyInnerType) {
|
||||
val classifierDescriptor = type.classifierDescriptor
|
||||
val classifierDescriptor: ClassifierDescriptorWithTypeParameters
|
||||
val isSuspendType: Boolean
|
||||
|
||||
val originalClassifierDescriptor = type.classifierDescriptor
|
||||
if (originalClassifierDescriptor.getFunctionalClassKind() == FunctionClassDescriptor.Kind.SuspendFunction) {
|
||||
classifierDescriptor = originalClassifierDescriptor.builtIns.getFunction(originalClassifierDescriptor.declaredTypeParameters.size)
|
||||
isSuspendType = true
|
||||
}
|
||||
else {
|
||||
classifierDescriptor = originalClassifierDescriptor
|
||||
isSuspendType = false
|
||||
}
|
||||
|
||||
val classifierId = getClassifierId(classifierDescriptor)
|
||||
when (classifierDescriptor) {
|
||||
is ClassDescriptor -> builder.className = classifierId
|
||||
is TypeAliasDescriptor -> builder.typeAliasName = classifierId
|
||||
}
|
||||
builder.flags = Flags.getTypeFlags(isSuspendType)
|
||||
|
||||
for (projection in type.arguments) {
|
||||
builder.addArgument(typeArgument(projection))
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ typealias Test4 = <!WRONG_MODIFIER_TARGET!>suspend<!> Action
|
||||
typealias Test5 = List<suspend () -> Unit>
|
||||
typealias Test6 = <!WRONG_MODIFIER_TARGET!>suspend<!> List<() -> Unit>
|
||||
typealias Test7 = <!WRONG_MODIFIER_TARGET!>suspend<!> SAM
|
||||
typealias Test8 = SuspendFunction0<Unit>
|
||||
typealias Test8 = <!WRONG_MODIFIER_TARGET!>suspend<!> <!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
||||
typealias Test9 = suspend (() -> Unit) -> Unit
|
||||
typealias Test10 = suspend (suspend () -> Unit) -> Unit
|
||||
typealias Test11 = suspend () -> (suspend () -> Unit)
|
||||
|
||||
Vendored
+1
-1
@@ -17,5 +17,5 @@ public typealias Test4 = Action
|
||||
public typealias Test5 = kotlin.collections.List<suspend () -> kotlin.Unit>
|
||||
public typealias Test6 = kotlin.collections.List<() -> kotlin.Unit>
|
||||
public typealias Test7 = SAM
|
||||
public typealias Test8 = suspend () -> kotlin.Unit
|
||||
public typealias Test8 = [ERROR : SuspendFunction0<Unit>]<kotlin.Unit>
|
||||
public typealias Test9 = suspend (() -> kotlin.Unit) -> kotlin.Unit
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
typealias Test1 = <!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
||||
typealias Test2 = kotlin.<!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
||||
typealias Test3 = kotlin.coroutines.<!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public typealias Test1 = [ERROR : SuspendFunction0<Unit>]<kotlin.Unit>
|
||||
public typealias Test2 = [ERROR : kotlin.SuspendFunction0<Unit>]<kotlin.Unit>
|
||||
public typealias Test3 = [ERROR : kotlin.coroutines.SuspendFunction0<Unit>]<kotlin.Unit>
|
||||
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
fun test1(): suspend () -> Unit = null!!
|
||||
fun test2(): suspend (Int, String) -> Int = null!!
|
||||
fun test3(): suspend Int.(String) -> Int = null!!
|
||||
fun test4(): List<suspend () -> Unit> = null!!
|
||||
fun test5(): suspend (suspend () -> Unit) -> Unit = null!!
|
||||
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
public fun test1(): suspend () -> kotlin.Unit
|
||||
public fun test2(): suspend (kotlin.Int, kotlin.String) -> kotlin.Int
|
||||
public fun test3(): suspend kotlin.Int.(kotlin.String) -> kotlin.Int
|
||||
public fun test4(): kotlin.collections.List<suspend () -> kotlin.Unit>
|
||||
public fun test5(): suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
||||
@@ -4466,6 +4466,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType/noInvokeForSuspendFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionNIsUnresolved.kt")
|
||||
public void testSuspendFunctionNIsUnresolved() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType/suspendFunctionNIsUnresolved.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/tailCalls")
|
||||
|
||||
@@ -4805,6 +4805,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuspendFunction.kt")
|
||||
public void testSuspendFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/SuspendFunction.kt");
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Unit.kt")
|
||||
public void testUnit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/Unit.kt");
|
||||
|
||||
+6
@@ -3038,6 +3038,12 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuspendFunction.kt")
|
||||
public void testSuspendFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/SuspendFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Unit.kt")
|
||||
public void testUnit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/Unit.kt");
|
||||
|
||||
+6
@@ -3040,6 +3040,12 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuspendFunction.kt")
|
||||
public void testSuspendFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/SuspendFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Unit.kt")
|
||||
public void testUnit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/Unit.kt");
|
||||
|
||||
@@ -22,6 +22,7 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.functions.BuiltInFictitiousFunctionClassFactory;
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor;
|
||||
@@ -38,6 +39,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AdditionalClassPartsProvider;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ClassDescriptorFactory;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.PlatformDependentDeclarationFilter;
|
||||
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
@@ -74,6 +76,8 @@ public abstract class KotlinBuiltIns {
|
||||
private final NotNullLazyValue<Primitives> primitives;
|
||||
private final NotNullLazyValue<PackageFragments> packageFragments;
|
||||
|
||||
private final MemoizedFunctionToNotNull<Integer, ClassDescriptor> suspendFunctionClasses;
|
||||
|
||||
private final StorageManager storageManager;
|
||||
|
||||
public static final FqNames FQ_NAMES = new FqNames();
|
||||
@@ -119,6 +123,18 @@ public abstract class KotlinBuiltIns {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
this.suspendFunctionClasses = storageManager.createMemoizedFunction(new Function1<Integer, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor invoke(Integer arity) {
|
||||
return new FunctionClassDescriptor(
|
||||
getStorageManager(),
|
||||
packageFragments.invoke().coroutinePackageFragment,
|
||||
FunctionClassDescriptor.Kind.SuspendFunction,
|
||||
arity
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void createBuiltInsModule() {
|
||||
@@ -531,11 +547,6 @@ public abstract class KotlinBuiltIns {
|
||||
return "Function" + parameterCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getSuspendFunctionName(int parameterCount) {
|
||||
return "SuspendFunction" + parameterCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassId getFunctionClassId(int parameterCount) {
|
||||
return new ClassId(BUILT_INS_PACKAGE_FQ_NAME, Name.identifier(getFunctionName(parameterCount)));
|
||||
@@ -548,7 +559,8 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getSuspendFunction(int parameterCount) {
|
||||
return getBuiltInClassByName(getSuspendFunctionName(parameterCount));
|
||||
// SuspendFunction$n is not visible through member scope, and is created independently.
|
||||
return suspendFunctionClasses.invoke(parameterCount);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-1
@@ -51,6 +51,9 @@ class BuiltInFictitiousFunctionClassFactory(
|
||||
@JvmStatic fun getFunctionalClassKind(className: String, packageFqName: FqName) =
|
||||
parseClassName(className, packageFqName)?.kind
|
||||
|
||||
@JvmStatic fun getFunctionalClassArity(className: String, packageFqName: FqName) =
|
||||
parseClassName(className, packageFqName)?.arity
|
||||
|
||||
@JvmStatic fun isFunctionClassName(className: String, packageFqName: FqName) =
|
||||
getFunctionalClassKind(className, packageFqName) == Kind.Function
|
||||
|
||||
@@ -72,7 +75,7 @@ class BuiltInFictitiousFunctionClassFactory(
|
||||
|
||||
override fun shouldCreateClass(packageFqName: FqName, name: Name): Boolean {
|
||||
val string = name.asString()
|
||||
return (string.startsWith("Function") || string.startsWith("KFunction") || string.startsWith("SuspendFunction")) // an optimization
|
||||
return (string.startsWith("Function") || string.startsWith("KFunction")) // an optimization
|
||||
&& parseClassName(string, packageFqName) != null
|
||||
}
|
||||
|
||||
@@ -85,6 +88,9 @@ class BuiltInFictitiousFunctionClassFactory(
|
||||
val packageFqName = classId.packageFqName
|
||||
val (kind, arity) = parseClassName(className, packageFqName) ?: return null
|
||||
|
||||
// SuspendFunction$n can't be created by classId
|
||||
if (kind == Kind.SuspendFunction) return null
|
||||
|
||||
val containingPackageFragment = module.getPackage(packageFqName).fragments.filterIsInstance<BuiltInsPackageFragment>().first()
|
||||
|
||||
return FunctionClassDescriptor(storageManager, containingPackageFragment, kind, arity)
|
||||
|
||||
+2
-7
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.builtins.functions
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COROUTINES_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractClassDescriptor
|
||||
@@ -50,18 +51,12 @@ class FunctionClassDescriptor(
|
||||
|
||||
enum class Kind(val packageFqName: FqName, val classNamePrefix: String) {
|
||||
Function(BUILT_INS_PACKAGE_FQ_NAME, "Function"),
|
||||
SuspendFunction(BUILT_INS_PACKAGE_FQ_NAME, "SuspendFunction"),
|
||||
SuspendFunction(COROUTINES_PACKAGE_FQ_NAME, "SuspendFunction"),
|
||||
KFunction(KOTLIN_REFLECT_FQ_NAME, "KFunction");
|
||||
|
||||
fun numberedClassName(arity: Int) = Name.identifier("$classNamePrefix$arity")
|
||||
|
||||
companion object {
|
||||
fun byPackage(fqName: FqName) = when (fqName) {
|
||||
BUILT_INS_PACKAGE_FQ_NAME -> Function
|
||||
KOTLIN_REFLECT_FQ_NAME -> KFunction
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun byClassNamePrefix(packageFqName: FqName, className: String) =
|
||||
Kind.values().firstOrNull { it.packageFqName == packageFqName && className.startsWith(it.classNamePrefix) }
|
||||
}
|
||||
|
||||
@@ -138,6 +138,11 @@ message Type {
|
||||
optional Type abbreviated_type = 13;
|
||||
optional int32 abbreviated_type_id = 14;
|
||||
|
||||
/*
|
||||
suspend
|
||||
*/
|
||||
optional int32 flags = 1;
|
||||
|
||||
extensions 100 to 199;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.protobuf.Internal;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class Flags {
|
||||
private Flags() {}
|
||||
|
||||
// Common
|
||||
// Types
|
||||
public static final BooleanFlagField SUSPEND_TYPE = FlagField.booleanFirst();
|
||||
|
||||
// Common for declarations
|
||||
|
||||
public static final BooleanFlagField HAS_ANNOTATIONS = FlagField.booleanFirst();
|
||||
public static final FlagField<ProtoBuf.Visibility> VISIBILITY = FlagField.after(HAS_ANNOTATIONS, ProtoBuf.Visibility.values());
|
||||
@@ -78,6 +82,10 @@ public class Flags {
|
||||
|
||||
// ---
|
||||
|
||||
public static int getTypeFlags(boolean isSuspend) {
|
||||
return SUSPEND_TYPE.toFlags(isSuspend);
|
||||
}
|
||||
|
||||
public static int getClassFlags(
|
||||
boolean hasAnnotations,
|
||||
Visibility visibility,
|
||||
|
||||
@@ -4489,6 +4489,23 @@ public final class ProtoBuf {
|
||||
* <code>optional int32 abbreviated_type_id = 14;</code>
|
||||
*/
|
||||
int getAbbreviatedTypeId();
|
||||
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasFlags();
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
int getFlags();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.Type}
|
||||
@@ -4541,6 +4558,11 @@ public final class ProtoBuf {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
bitField0_ |= 0x00001000;
|
||||
flags_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
argument_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.ProtoBuf.Type.Argument>();
|
||||
@@ -5601,6 +5623,29 @@ public final class ProtoBuf {
|
||||
return abbreviatedTypeId_;
|
||||
}
|
||||
|
||||
public static final int FLAGS_FIELD_NUMBER = 1;
|
||||
private int flags_;
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasFlags() {
|
||||
return ((bitField0_ & 0x00001000) == 0x00001000);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public int getFlags() {
|
||||
return flags_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
argument_ = java.util.Collections.emptyList();
|
||||
nullable_ = false;
|
||||
@@ -5615,6 +5660,7 @@ public final class ProtoBuf {
|
||||
outerTypeId_ = 0;
|
||||
abbreviatedType_ = org.jetbrains.kotlin.serialization.ProtoBuf.Type.getDefaultInstance();
|
||||
abbreviatedTypeId_ = 0;
|
||||
flags_ = 0;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -5660,6 +5706,9 @@ public final class ProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite
|
||||
.ExtendableMessage<org.jetbrains.kotlin.serialization.ProtoBuf.Type>.ExtensionWriter extensionWriter =
|
||||
newExtensionWriter();
|
||||
if (((bitField0_ & 0x00001000) == 0x00001000)) {
|
||||
output.writeInt32(1, flags_);
|
||||
}
|
||||
for (int i = 0; i < argument_.size(); i++) {
|
||||
output.writeMessage(2, argument_.get(i));
|
||||
}
|
||||
@@ -5709,6 +5758,10 @@ public final class ProtoBuf {
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00001000) == 0x00001000)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32Size(1, flags_);
|
||||
}
|
||||
for (int i = 0; i < argument_.size(); i++) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(2, argument_.get(i));
|
||||
@@ -5881,6 +5934,8 @@ public final class ProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000800);
|
||||
abbreviatedTypeId_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00001000);
|
||||
flags_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00002000);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -5957,6 +6012,10 @@ public final class ProtoBuf {
|
||||
to_bitField0_ |= 0x00000800;
|
||||
}
|
||||
result.abbreviatedTypeId_ = abbreviatedTypeId_;
|
||||
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
|
||||
to_bitField0_ |= 0x00001000;
|
||||
}
|
||||
result.flags_ = flags_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -6009,6 +6068,9 @@ public final class ProtoBuf {
|
||||
if (other.hasAbbreviatedTypeId()) {
|
||||
setAbbreviatedTypeId(other.getAbbreviatedTypeId());
|
||||
}
|
||||
if (other.hasFlags()) {
|
||||
setFlags(other.getFlags());
|
||||
}
|
||||
this.mergeExtensionFields(other);
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
@@ -6731,6 +6793,54 @@ public final class ProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
private int flags_ ;
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasFlags() {
|
||||
return ((bitField0_ & 0x00002000) == 0x00002000);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public int getFlags() {
|
||||
return flags_;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setFlags(int value) {
|
||||
bitField0_ |= 0x00002000;
|
||||
flags_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 flags = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
*suspend
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearFlags() {
|
||||
bitField0_ = (bitField0_ & ~0x00002000);
|
||||
flags_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.Type)
|
||||
}
|
||||
|
||||
|
||||
+20
-2
@@ -16,11 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.functions.BuiltInFictitiousFunctionClassFactory
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedTypeParameterDescriptor
|
||||
@@ -105,8 +108,13 @@ class TypeDeserializer(
|
||||
private fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor =
|
||||
when {
|
||||
proto.hasClassName() -> {
|
||||
classDescriptors(proto.className)?.typeConstructor
|
||||
?: c.components.notFoundClasses.getClass(proto, c.nameResolver, c.typeTable)
|
||||
if (Flags.SUSPEND_TYPE.get(proto.flags)) {
|
||||
getSuspendFunctionTypeConstructor(proto)
|
||||
}
|
||||
else {
|
||||
classDescriptors(proto.className)?.typeConstructor
|
||||
?: c.components.notFoundClasses.getClass(proto, c.nameResolver, c.typeTable)
|
||||
}
|
||||
}
|
||||
proto.hasTypeParameter() ->
|
||||
typeParameterTypeConstructor(proto.typeParameter)
|
||||
@@ -124,6 +132,16 @@ class TypeDeserializer(
|
||||
else -> ErrorUtils.createErrorTypeConstructor("Unknown type")
|
||||
}
|
||||
|
||||
private fun getSuspendFunctionTypeConstructor(proto: ProtoBuf.Type): TypeConstructor {
|
||||
val classId = c.nameResolver.getClassId(proto.className)
|
||||
val arity = BuiltInFictitiousFunctionClassFactory.getFunctionalClassArity(classId.shortClassName.asString(), classId.packageFqName)
|
||||
|
||||
return if (arity != null)
|
||||
c.containingDeclaration.builtIns.getSuspendFunction(arity - 1).typeConstructor
|
||||
else
|
||||
ErrorUtils.createErrorTypeConstructor("Class is not a FunctionN ${classId.asString()}")
|
||||
}
|
||||
|
||||
private fun typeParameterTypeConstructor(typeParameterId: Int): TypeConstructor? =
|
||||
typeParameterDescriptors.get(typeParameterId)?.typeConstructor ?:
|
||||
parent?.typeParameterTypeConstructor(typeParameterId)
|
||||
|
||||
+1
-2
@@ -127,9 +127,8 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
if (!type.hasClassName() && !type.hasTypeAliasName()) return emptySet()
|
||||
|
||||
val result = hashSetOf<KtModifierKeywordToken>()
|
||||
val classId = c.nameResolver.getClassId(if (type.hasClassName()) type.className else type.typeAliasName)
|
||||
|
||||
if (classId.asSingleFqName().toUnsafe().getFunctionalClassKind() == FunctionClassDescriptor.Kind.SuspendFunction) {
|
||||
if (Flags.SUSPEND_TYPE.get(type.flags)) {
|
||||
result.add(KtTokens.SUSPEND_KEYWORD)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package test
|
||||
|
||||
public final class TypeModifiers public constructor() {
|
||||
public final val function: () -> kotlin.Unit /* compiled code */
|
||||
|
||||
public final val functionOnSuspendFunction: (suspend () -> kotlin.Unit).() -> kotlin.Unit /* compiled code */
|
||||
|
||||
public final val suspendExtFunction: suspend kotlin.Any.() -> kotlin.Unit /* compiled code */
|
||||
|
||||
public final val suspendFunction: suspend () -> kotlin.Unit /* compiled code */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
class TypeModifiers {
|
||||
val function: () -> Unit = null!!
|
||||
|
||||
val suspendFunction: suspend () -> Unit = null!!
|
||||
|
||||
val suspendExtFunction: suspend Any.() -> Unit = null!!
|
||||
|
||||
val functionOnSuspendFunction: (suspend () -> Unit).() -> Unit = null!!
|
||||
}
|
||||
+6
@@ -150,4 +150,10 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeModifiers")
|
||||
public void testTypeModifiers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeModifiers/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -156,4 +156,10 @@ public class CommonDecompiledTextTestGenerated extends AbstractCommonDecompiledT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeModifiers")
|
||||
public void testTypeModifiers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeModifiers/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3038,6 +3038,12 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuspendFunction.kt")
|
||||
public void testSuspendFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/SuspendFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Unit.kt")
|
||||
public void testUnit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/type/Unit.kt");
|
||||
|
||||
Reference in New Issue
Block a user