mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-19 15:51:29 +00:00
Compare commits
190 Commits
push/pdn_b
...
1.2.30
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f71d364d5 | ||
|
|
f4049e630c | ||
|
|
ad38c3e226 | ||
|
|
8ddcd36770 | ||
|
|
ec490af6ee | ||
|
|
0a92d9ccce | ||
|
|
e43175b16f | ||
|
|
3d798b4cd3 | ||
|
|
c425e02dff | ||
|
|
7150fc0d8f | ||
|
|
f100e83ec3 | ||
|
|
715431535a | ||
|
|
f5d8479635 | ||
|
|
2619dc5e0d | ||
|
|
97848dd194 | ||
|
|
814858a2b7 | ||
|
|
8acc3c0b97 | ||
|
|
0a829be3db | ||
|
|
5a0d10464a | ||
|
|
559e0848d8 | ||
|
|
44d21c0db5 | ||
|
|
e50c18bbd6 | ||
|
|
8719796d97 | ||
|
|
d2ff212b43 | ||
|
|
fbaf90bc60 | ||
|
|
88f8102bed | ||
|
|
c7533b91f9 | ||
|
|
f4c2f5d164 | ||
|
|
fb940cec71 | ||
|
|
25a136aeb2 | ||
|
|
9a00dc3355 | ||
|
|
fbc01468dc | ||
|
|
fc43cb4767 | ||
|
|
7ffb405968 | ||
|
|
cd95e7ae16 | ||
|
|
cb0d27ca0d | ||
|
|
f75a5ff905 | ||
|
|
fee60f4f40 | ||
|
|
64c1e9d345 | ||
|
|
3c61760a70 | ||
|
|
9a8f283d6b | ||
|
|
e089919ab8 | ||
|
|
73eb07b6c4 | ||
|
|
8abc113f14 | ||
|
|
66177fb184 | ||
|
|
6875bb4628 | ||
|
|
30945b8081 | ||
|
|
5a0dced10f | ||
|
|
a2a340dd74 | ||
|
|
b42592c947 | ||
|
|
c903ce5d00 | ||
|
|
ce09e4cbbb | ||
|
|
682c8723a6 | ||
|
|
18bdede561 | ||
|
|
d8b400a725 | ||
|
|
7c6641ae8c | ||
|
|
233b0627c5 | ||
|
|
b5fc34be29 | ||
|
|
592dc00fb4 | ||
|
|
71bb9326b6 | ||
|
|
68fac8bc2d | ||
|
|
594fa29d0f | ||
|
|
556dcc53b6 | ||
|
|
e4eabfa961 | ||
|
|
d16ad96a41 | ||
|
|
62dc54b449 | ||
|
|
6465536491 | ||
|
|
e37f801aeb | ||
|
|
5bb938331b | ||
|
|
4221ca0f8a | ||
|
|
e4cabda82d | ||
|
|
f3d9c09340 | ||
|
|
4e41040dd7 | ||
|
|
6785341ab1 | ||
|
|
17b17ed90e | ||
|
|
73c0ee4035 | ||
|
|
4da7a0b3b1 | ||
|
|
b09803c65e | ||
|
|
1d36a4601a | ||
|
|
e6126e399e | ||
|
|
e04c32ca4d | ||
|
|
5b4844b11e | ||
|
|
e12052d6eb | ||
|
|
df53bee809 | ||
|
|
8923464bb6 | ||
|
|
a9124635aa | ||
|
|
55f35404e1 | ||
|
|
15129e6e0b | ||
|
|
e7eec55da0 | ||
|
|
65f5c6d8ef | ||
|
|
3874facce0 | ||
|
|
5f4943fd6b | ||
|
|
c690b8d9db | ||
|
|
b7f87cf76e | ||
|
|
35c1d06dbc | ||
|
|
620fdf3881 | ||
|
|
e39e8632ac | ||
|
|
2c3a3bd5c4 | ||
|
|
5e65b6eca1 | ||
|
|
447f796066 | ||
|
|
82ba00112b | ||
|
|
6542559311 | ||
|
|
1e0589299a | ||
|
|
0493f3c864 | ||
|
|
5cd5b83d05 | ||
|
|
978003eadf | ||
|
|
100e148db8 | ||
|
|
8da4550f95 | ||
|
|
d5a49d7c7d | ||
|
|
2d589dec43 | ||
|
|
be1439f5fe | ||
|
|
3f3c6a9f71 | ||
|
|
005669a935 | ||
|
|
0a66b5c4de | ||
|
|
af8f232bbf | ||
|
|
e5f2c2580c | ||
|
|
3463d5a0d1 | ||
|
|
e6bb1610ec | ||
|
|
1471f08731 | ||
|
|
af7bb3f36b | ||
|
|
2dbae78a6c | ||
|
|
14561feada | ||
|
|
12f1f521d0 | ||
|
|
8778433836 | ||
|
|
dada8a4207 | ||
|
|
82ce8649c8 | ||
|
|
9620eb928f | ||
|
|
2ead25467c | ||
|
|
99892f352f | ||
|
|
fba0ababb4 | ||
|
|
c65e3e33cb | ||
|
|
e2e6b1af85 | ||
|
|
68d8c65242 | ||
|
|
047dc8e8cc | ||
|
|
852a0a07e0 | ||
|
|
08f78291f3 | ||
|
|
cfbb13f4c2 | ||
|
|
c107ead158 | ||
|
|
0061312f8e | ||
|
|
b5987627c7 | ||
|
|
4020ee6a85 | ||
|
|
b37a44ca07 | ||
|
|
5c681d6cb5 | ||
|
|
196acfb6fe | ||
|
|
db9bbc8202 | ||
|
|
5e80e1721b | ||
|
|
fcdbe482e2 | ||
|
|
90ce7369e8 | ||
|
|
aa8a6b1936 | ||
|
|
4eb6071140 | ||
|
|
eea6fa5f19 | ||
|
|
8e1222df83 | ||
|
|
b36a0e6ea8 | ||
|
|
3960dacde9 | ||
|
|
cb6a7b556a | ||
|
|
1aa9766ae1 | ||
|
|
7a94dadf17 | ||
|
|
304d21be91 | ||
|
|
1ba5a7e733 | ||
|
|
d4e5052bfc | ||
|
|
6a43ff2a9d | ||
|
|
0824ea9ad5 | ||
|
|
f42c282f90 | ||
|
|
8c1dee41e8 | ||
|
|
3ddeec6f3b | ||
|
|
99746b5094 | ||
|
|
34e8a720df | ||
|
|
17d4e92e6c | ||
|
|
5871a5e8e7 | ||
|
|
f99907977e | ||
|
|
1e0b0aa5ce | ||
|
|
93d8b2b9dc | ||
|
|
8cdababa48 | ||
|
|
50f34dbad0 | ||
|
|
026df68206 | ||
|
|
6e75ff5b6b | ||
|
|
0fa5bf7e58 | ||
|
|
6045110e94 | ||
|
|
f0141571b1 | ||
|
|
b5b355eac7 | ||
|
|
08536661bd | ||
|
|
05183068c2 | ||
|
|
1abf134c8f | ||
|
|
c462a74d35 | ||
|
|
36f796dfb9 | ||
|
|
d2833ccae1 | ||
|
|
05849b0ea3 | ||
|
|
a4d7488391 | ||
|
|
a21fb3f2e0 | ||
|
|
074429ff50 |
1
.idea/codeStyles/Project.xml
generated
1
.idea/codeStyles/Project.xml
generated
@@ -63,6 +63,7 @@
|
||||
<option name="CONTINUATION_INDENT_IN_SUPERTYPE_LISTS" value="false" />
|
||||
<option name="CONTINUATION_INDENT_IN_IF_CONDITIONS" value="false" />
|
||||
<option name="WRAP_EXPRESSION_BODY_FUNCTIONS" value="1" />
|
||||
<option name="IF_RPAREN_ON_NEW_LINE" value="true" />
|
||||
</JetCodeStyleSettings>
|
||||
<MarkdownNavigatorCodeStyleSettings>
|
||||
<option name="RIGHT_MARGIN" value="72" />
|
||||
|
||||
2
.idea/dictionaries/dzharkov.xml
generated
2
.idea/dictionaries/dzharkov.xml
generated
@@ -3,6 +3,8 @@
|
||||
<words>
|
||||
<w>checkcast</w>
|
||||
<w>coroutine</w>
|
||||
<w>experimentalities</w>
|
||||
<w>experimentality</w>
|
||||
<w>insn</w>
|
||||
<w>liveness</w>
|
||||
</words>
|
||||
|
||||
4913
ChangeLog.md
4913
ChangeLog.md
File diff suppressed because it is too large
Load Diff
@@ -19,12 +19,16 @@ package org.jetbrains.kotlin.incremental
|
||||
import com.intellij.util.io.DataExternalizer
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
||||
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
|
||||
import org.jetbrains.kotlin.incremental.storage.*
|
||||
import org.jetbrains.kotlin.incremental.storage.BasicStringMap
|
||||
import org.jetbrains.kotlin.incremental.storage.DirtyClassesFqNameMap
|
||||
import org.jetbrains.kotlin.incremental.storage.SourceToFqNameMap
|
||||
import org.jetbrains.kotlin.incremental.storage.StringToLongMapExternalizer
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
|
||||
import org.jetbrains.kotlin.serialization.js.JsProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
||||
import java.io.DataInput
|
||||
@@ -177,11 +181,7 @@ fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData>
|
||||
}
|
||||
|
||||
proto.`package`.apply {
|
||||
val packageFqName = if (hasExtension(JsProtoBuf.packageFqName)) {
|
||||
nameResolver.getPackageFqName(getExtension(JsProtoBuf.packageFqName))
|
||||
}
|
||||
else FqName.ROOT
|
||||
|
||||
val packageFqName = getExtensionOrNull(JsProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName) ?: FqName.ROOT
|
||||
val packagePartClassId = ClassId(packageFqName, Name.identifier(sourceFile.nameWithoutExtension.capitalize() + "Kt"))
|
||||
classes[packagePartClassId] = PackagePartProtoData(this, nameResolver, packageFqName)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,15 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: core/descriptors.jvm/src/jvm_package_table.debug.proto
|
||||
// source: core/descriptors.jvm/src/jvm_module.debug.proto
|
||||
|
||||
package org.jetbrains.kotlin.serialization.jvm;
|
||||
|
||||
public final class DebugJvmPackageTable {
|
||||
private DebugJvmPackageTable() {}
|
||||
public final class DebugModuleProtoBuf {
|
||||
private DebugModuleProtoBuf() {}
|
||||
public static void registerAllExtensions(
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistry registry) {
|
||||
}
|
||||
public interface PackageTableOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.serialization.jvm.PackageTable)
|
||||
public interface ModuleOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.serialization.jvm.Module)
|
||||
org.jetbrains.kotlin.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>
|
||||
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>
|
||||
getPackagePartsList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
@@ -28,7 +28,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index);
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
*
|
||||
@@ -44,7 +44,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getPackagePartsOrBuilderList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
@@ -53,7 +53,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
int index);
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>
|
||||
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>
|
||||
getMetadataPartsList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
@@ -72,7 +72,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index);
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
*
|
||||
@@ -88,7 +88,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getMetadataPartsOrBuilderList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
@@ -97,7 +97,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
int index);
|
||||
|
||||
/**
|
||||
@@ -140,25 +140,25 @@ public final class DebugJvmPackageTable {
|
||||
getJvmPackageNameBytes(int index);
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.PackageTable}
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.Module}
|
||||
*/
|
||||
public static final class PackageTable extends
|
||||
public static final class Module extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage implements
|
||||
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.serialization.jvm.PackageTable)
|
||||
PackageTableOrBuilder {
|
||||
// Use PackageTable.newBuilder() to construct.
|
||||
private PackageTable(org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<?> builder) {
|
||||
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.serialization.jvm.Module)
|
||||
ModuleOrBuilder {
|
||||
// Use Module.newBuilder() to construct.
|
||||
private Module(org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<?> builder) {
|
||||
super(builder);
|
||||
this.unknownFields = builder.getUnknownFields();
|
||||
}
|
||||
private PackageTable(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.UnknownFieldSet.getDefaultInstance(); }
|
||||
private Module(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.UnknownFieldSet.getDefaultInstance(); }
|
||||
|
||||
private static final PackageTable defaultInstance;
|
||||
public static PackageTable getDefaultInstance() {
|
||||
private static final Module defaultInstance;
|
||||
public static Module getDefaultInstance() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public PackageTable getDefaultInstanceForType() {
|
||||
public Module getDefaultInstanceForType() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public final class DebugJvmPackageTable {
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private PackageTable(
|
||||
private Module(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
@@ -193,18 +193,18 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
case 10: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>();
|
||||
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>();
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
packageParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.PARSER, extensionRegistry));
|
||||
packageParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.PARSER, extensionRegistry));
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>();
|
||||
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>();
|
||||
mutable_bitField0_ |= 0x00000002;
|
||||
}
|
||||
metadataParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.PARSER, extensionRegistry));
|
||||
metadataParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.PARSER, extensionRegistry));
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
@@ -239,33 +239,33 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
|
||||
}
|
||||
|
||||
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.Builder.class);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.Builder.class);
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<PackageTable> PARSER =
|
||||
new org.jetbrains.kotlin.protobuf.AbstractParser<PackageTable>() {
|
||||
public PackageTable parsePartialFrom(
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<Module> PARSER =
|
||||
new org.jetbrains.kotlin.protobuf.AbstractParser<Module>() {
|
||||
public Module parsePartialFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return new PackageTable(input, extensionRegistry);
|
||||
return new Module(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
@java.lang.Override
|
||||
public org.jetbrains.kotlin.protobuf.Parser<PackageTable> getParserForType() {
|
||||
public org.jetbrains.kotlin.protobuf.Parser<Module> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
public static final int PACKAGE_PARTS_FIELD_NUMBER = 1;
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> packageParts_;
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> packageParts_;
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
*
|
||||
@@ -273,7 +273,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getPackagePartsList() {
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getPackagePartsList() {
|
||||
return packageParts_;
|
||||
}
|
||||
/**
|
||||
@@ -283,7 +283,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getPackagePartsOrBuilderList() {
|
||||
return packageParts_;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index) {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index) {
|
||||
return packageParts_.get(index);
|
||||
}
|
||||
/**
|
||||
@@ -314,13 +314,13 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
int index) {
|
||||
return packageParts_.get(index);
|
||||
}
|
||||
|
||||
public static final int METADATA_PARTS_FIELD_NUMBER = 2;
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> metadataParts_;
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> metadataParts_;
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
*
|
||||
@@ -328,7 +328,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getMetadataPartsList() {
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getMetadataPartsList() {
|
||||
return metadataParts_;
|
||||
}
|
||||
/**
|
||||
@@ -338,7 +338,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getMetadataPartsOrBuilderList() {
|
||||
return metadataParts_;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index) {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index) {
|
||||
return metadataParts_.get(index);
|
||||
}
|
||||
/**
|
||||
@@ -369,7 +369,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
int index) {
|
||||
return metadataParts_.get(index);
|
||||
}
|
||||
@@ -500,53 +500,53 @@ public final class DebugJvmPackageTable {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(byte[] data)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(byte[] data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
byte[] data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(java.io.InputStream input)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseDelimitedFrom(java.io.InputStream input)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseDelimitedFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
@@ -555,7 +555,7 @@ public final class DebugJvmPackageTable {
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable prototype) {
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
@@ -567,25 +567,25 @@ public final class DebugJvmPackageTable {
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.PackageTable}
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.Module}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.PackageTable)
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTableOrBuilder {
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.Module)
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.ModuleOrBuilder {
|
||||
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
|
||||
}
|
||||
|
||||
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.Builder.class);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.newBuilder()
|
||||
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
@@ -630,23 +630,23 @@ public final class DebugJvmPackageTable {
|
||||
|
||||
public org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.getDefaultInstance();
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.getDefaultInstance();
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable build() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable result = buildPartial();
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module build() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable buildPartial() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable result = new org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable(this);
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module buildPartial() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module result = new org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (packagePartsBuilder_ == null) {
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
@@ -676,16 +676,16 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.protobuf.Message other) {
|
||||
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable) {
|
||||
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable)other);
|
||||
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module) {
|
||||
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable other) {
|
||||
if (other == org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.getDefaultInstance()) return this;
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module other) {
|
||||
if (other == org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.getDefaultInstance()) return this;
|
||||
if (packagePartsBuilder_ == null) {
|
||||
if (!other.packageParts_.isEmpty()) {
|
||||
if (packageParts_.isEmpty()) {
|
||||
@@ -772,11 +772,11 @@ public final class DebugJvmPackageTable {
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parsedMessage = null;
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable) e.getUnfinishedMessage();
|
||||
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
@@ -787,17 +787,17 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> packageParts_ =
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> packageParts_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensurePackagePartsIsMutable() {
|
||||
if (!((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>(packageParts_);
|
||||
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>(packageParts_);
|
||||
bitField0_ |= 0x00000001;
|
||||
}
|
||||
}
|
||||
|
||||
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder> packagePartsBuilder_;
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder> packagePartsBuilder_;
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
@@ -806,7 +806,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getPackagePartsList() {
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getPackagePartsList() {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
return java.util.Collections.unmodifiableList(packageParts_);
|
||||
} else {
|
||||
@@ -834,7 +834,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index) {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
return packageParts_.get(index);
|
||||
} else {
|
||||
@@ -849,7 +849,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setPackageParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -870,7 +870,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setPackageParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
ensurePackagePartsIsMutable();
|
||||
packageParts_.set(index, builderForValue.build());
|
||||
@@ -887,7 +887,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addPackageParts(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
public Builder addPackageParts(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -908,7 +908,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addPackageParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -929,7 +929,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addPackageParts(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
ensurePackagePartsIsMutable();
|
||||
packageParts_.add(builderForValue.build());
|
||||
@@ -947,7 +947,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addPackageParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
ensurePackagePartsIsMutable();
|
||||
packageParts_.add(index, builderForValue.build());
|
||||
@@ -965,7 +965,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAllPackageParts(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> values) {
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> values) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
ensurePackagePartsIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
@@ -1017,7 +1017,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder getPackagePartsBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder getPackagePartsBuilder(
|
||||
int index) {
|
||||
return getPackagePartsFieldBuilder().getBuilder(index);
|
||||
}
|
||||
@@ -1028,7 +1028,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
|
||||
int index) {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
return packageParts_.get(index); } else {
|
||||
@@ -1042,7 +1042,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getPackagePartsOrBuilderList() {
|
||||
if (packagePartsBuilder_ != null) {
|
||||
return packagePartsBuilder_.getMessageOrBuilderList();
|
||||
@@ -1057,9 +1057,9 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addPackagePartsBuilder() {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addPackagePartsBuilder() {
|
||||
return getPackagePartsFieldBuilder().addBuilder(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
@@ -1068,10 +1068,10 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addPackagePartsBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addPackagePartsBuilder(
|
||||
int index) {
|
||||
return getPackagePartsFieldBuilder().addBuilder(
|
||||
index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
|
||||
index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
|
||||
@@ -1080,16 +1080,16 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .class files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder>
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder>
|
||||
getPackagePartsBuilderList() {
|
||||
return getPackagePartsFieldBuilder().getBuilderList();
|
||||
}
|
||||
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getPackagePartsFieldBuilder() {
|
||||
if (packagePartsBuilder_ == null) {
|
||||
packagePartsBuilder_ = new org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>(
|
||||
packageParts_,
|
||||
((bitField0_ & 0x00000001) == 0x00000001),
|
||||
getParentForChildren(),
|
||||
@@ -1099,17 +1099,17 @@ public final class DebugJvmPackageTable {
|
||||
return packagePartsBuilder_;
|
||||
}
|
||||
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> metadataParts_ =
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> metadataParts_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureMetadataPartsIsMutable() {
|
||||
if (!((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>(metadataParts_);
|
||||
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>(metadataParts_);
|
||||
bitField0_ |= 0x00000002;
|
||||
}
|
||||
}
|
||||
|
||||
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder> metadataPartsBuilder_;
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder> metadataPartsBuilder_;
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
@@ -1118,7 +1118,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getMetadataPartsList() {
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getMetadataPartsList() {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
return java.util.Collections.unmodifiableList(metadataParts_);
|
||||
} else {
|
||||
@@ -1146,7 +1146,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index) {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
return metadataParts_.get(index);
|
||||
} else {
|
||||
@@ -1161,7 +1161,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setMetadataParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -1182,7 +1182,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setMetadataParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
ensureMetadataPartsIsMutable();
|
||||
metadataParts_.set(index, builderForValue.build());
|
||||
@@ -1199,7 +1199,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addMetadataParts(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
public Builder addMetadataParts(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -1220,7 +1220,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addMetadataParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -1241,7 +1241,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addMetadataParts(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
ensureMetadataPartsIsMutable();
|
||||
metadataParts_.add(builderForValue.build());
|
||||
@@ -1259,7 +1259,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addMetadataParts(
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
|
||||
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
ensureMetadataPartsIsMutable();
|
||||
metadataParts_.add(index, builderForValue.build());
|
||||
@@ -1277,7 +1277,7 @@ public final class DebugJvmPackageTable {
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAllMetadataParts(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> values) {
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> values) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
ensureMetadataPartsIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
@@ -1329,7 +1329,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder getMetadataPartsBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder getMetadataPartsBuilder(
|
||||
int index) {
|
||||
return getMetadataPartsFieldBuilder().getBuilder(index);
|
||||
}
|
||||
@@ -1340,7 +1340,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
|
||||
int index) {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
return metadataParts_.get(index); } else {
|
||||
@@ -1354,7 +1354,7 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getMetadataPartsOrBuilderList() {
|
||||
if (metadataPartsBuilder_ != null) {
|
||||
return metadataPartsBuilder_.getMessageOrBuilderList();
|
||||
@@ -1369,9 +1369,9 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addMetadataPartsBuilder() {
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addMetadataPartsBuilder() {
|
||||
return getMetadataPartsFieldBuilder().addBuilder(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
@@ -1380,10 +1380,10 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addMetadataPartsBuilder(
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addMetadataPartsBuilder(
|
||||
int index) {
|
||||
return getMetadataPartsFieldBuilder().addBuilder(
|
||||
index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
|
||||
index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
|
||||
@@ -1392,16 +1392,16 @@ public final class DebugJvmPackageTable {
|
||||
* Names of .kotlin_metadata files for each package
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder>
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder>
|
||||
getMetadataPartsBuilderList() {
|
||||
return getMetadataPartsFieldBuilder().getBuilderList();
|
||||
}
|
||||
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
|
||||
getMetadataPartsFieldBuilder() {
|
||||
if (metadataPartsBuilder_ == null) {
|
||||
metadataPartsBuilder_ = new org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>(
|
||||
metadataParts_,
|
||||
((bitField0_ & 0x00000002) == 0x00000002),
|
||||
getParentForChildren(),
|
||||
@@ -1549,15 +1549,15 @@ public final class DebugJvmPackageTable {
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.jvm.PackageTable)
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.jvm.Module)
|
||||
}
|
||||
|
||||
static {
|
||||
defaultInstance = new PackageTable(true);
|
||||
defaultInstance = new Module(true);
|
||||
defaultInstance.initFields();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.jvm.PackageTable)
|
||||
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.jvm.Module)
|
||||
}
|
||||
|
||||
public interface PackagePartsOrBuilder extends
|
||||
@@ -1919,14 +1919,14 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
}
|
||||
|
||||
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder.class);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder.class);
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<PackageParts> PARSER =
|
||||
@@ -2353,53 +2353,53 @@ public final class DebugJvmPackageTable {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(byte[] data)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(byte[] data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
byte[] data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(java.io.InputStream input)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseDelimitedFrom(java.io.InputStream input)
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseDelimitedFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
|
||||
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
@@ -2408,7 +2408,7 @@ public final class DebugJvmPackageTable {
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts prototype) {
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
@@ -2425,20 +2425,20 @@ public final class DebugJvmPackageTable {
|
||||
public static final class Builder extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.PackageParts)
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder {
|
||||
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
}
|
||||
|
||||
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder.class);
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.newBuilder()
|
||||
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
@@ -2479,23 +2479,23 @@ public final class DebugJvmPackageTable {
|
||||
|
||||
public org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance();
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance();
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts build() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts result = buildPartial();
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts build() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts buildPartial() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts result = new org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts(this);
|
||||
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts buildPartial() {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts result = new org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
@@ -2533,16 +2533,16 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.protobuf.Message other) {
|
||||
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts) {
|
||||
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts)other);
|
||||
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts) {
|
||||
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts other) {
|
||||
if (other == org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance()) return this;
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts other) {
|
||||
if (other == org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance()) return this;
|
||||
if (other.hasPackageFqName()) {
|
||||
bitField0_ |= 0x00000001;
|
||||
packageFqName_ = other.packageFqName_;
|
||||
@@ -2614,11 +2614,11 @@ public final class DebugJvmPackageTable {
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parsedMessage = null;
|
||||
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts) e.getUnfinishedMessage();
|
||||
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
@@ -3361,10 +3361,10 @@ public final class DebugJvmPackageTable {
|
||||
}
|
||||
|
||||
private static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
|
||||
private static
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable;
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable;
|
||||
private static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
|
||||
private static
|
||||
@@ -3379,21 +3379,20 @@ public final class DebugJvmPackageTable {
|
||||
descriptor;
|
||||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n6core/descriptors.jvm/src/jvm_package_t" +
|
||||
"able.debug.proto\022&org.jetbrains.kotlin.s" +
|
||||
"erialization.jvm\"\303\001\n\014PackageTable\022K\n\rpac" +
|
||||
"kage_parts\030\001 \003(\01324.org.jetbrains.kotlin." +
|
||||
"serialization.jvm.PackageParts\022L\n\016metada" +
|
||||
"ta_parts\030\002 \003(\01324.org.jetbrains.kotlin.se" +
|
||||
"rialization.jvm.PackageParts\022\030\n\020jvm_pack" +
|
||||
"age_name\030\003 \003(\t\"\366\001\n\014PackageParts\022\027\n\017packa" +
|
||||
"ge_fq_name\030\001 \002(\t\022\030\n\020short_class_name\030\002 \003" +
|
||||
"(\t\022*\n\036multifile_facade_short_name_id\030\003 \003",
|
||||
"(\005B\002\020\001\022#\n\033multifile_facade_short_name\030\004 " +
|
||||
"\003(\t\022.\n&class_with_jvm_package_name_short" +
|
||||
"_name\030\005 \003(\t\0222\n&class_with_jvm_package_na" +
|
||||
"me_package_id\030\006 \003(\005B\002\020\001B\026B\024DebugJvmPacka" +
|
||||
"geTable"
|
||||
"\n/core/descriptors.jvm/src/jvm_module.de" +
|
||||
"bug.proto\022&org.jetbrains.kotlin.serializ" +
|
||||
"ation.jvm\"\275\001\n\006Module\022K\n\rpackage_parts\030\001 " +
|
||||
"\003(\01324.org.jetbrains.kotlin.serialization" +
|
||||
".jvm.PackageParts\022L\n\016metadata_parts\030\002 \003(" +
|
||||
"\01324.org.jetbrains.kotlin.serialization.j" +
|
||||
"vm.PackageParts\022\030\n\020jvm_package_name\030\003 \003(" +
|
||||
"\t\"\366\001\n\014PackageParts\022\027\n\017package_fq_name\030\001 " +
|
||||
"\002(\t\022\030\n\020short_class_name\030\002 \003(\t\022*\n\036multifi" +
|
||||
"le_facade_short_name_id\030\003 \003(\005B\002\020\001\022#\n\033mul",
|
||||
"tifile_facade_short_name\030\004 \003(\t\022.\n&class_" +
|
||||
"with_jvm_package_name_short_name\030\005 \003(\t\0222" +
|
||||
"\n&class_with_jvm_package_name_package_id" +
|
||||
"\030\006 \003(\005B\002\020\001B\025B\023DebugModuleProtoBuf"
|
||||
};
|
||||
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
@@ -3407,11 +3406,11 @@ public final class DebugJvmPackageTable {
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor[] {
|
||||
}, assigner);
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor =
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor =
|
||||
getDescriptor().getMessageTypes().get(0);
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable = new
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable = new
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor,
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor,
|
||||
new java.lang.String[] { "PackageParts", "MetadataParts", "JvmPackageName", });
|
||||
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor =
|
||||
getDescriptor().getMessageTypes().get(1);
|
||||
@@ -9,9 +9,12 @@ import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
buildscript {
|
||||
extra["defaultSnapshotVersion"] = "1.2-SNAPSHOT"
|
||||
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.30-dev-441", onlySuccessBootstrap = false))
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.40-dev-165", onlySuccessBootstrap = false))
|
||||
|
||||
val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString()
|
||||
|
||||
val repos = listOfNotNull(
|
||||
mirrorRepo,
|
||||
bootstrapKotlinRepo,
|
||||
"https://jcenter.bintray.com/",
|
||||
"https://plugins.gradle.org/m2")
|
||||
@@ -162,6 +165,7 @@ val coreLibProjects = listOf(
|
||||
":kotlin-test:kotlin-test-common",
|
||||
":kotlin-test:kotlin-test-jvm",
|
||||
":kotlin-test:kotlin-test-junit",
|
||||
":kotlin-test:kotlin-test-testng",
|
||||
":kotlin-test:kotlin-test-js",
|
||||
":kotlin-reflect"
|
||||
)
|
||||
@@ -230,13 +234,15 @@ allprojects {
|
||||
// - some tests (in particular js and binary-compatibility-validator depend on the fixed (default) location
|
||||
// - idea seems unable to exclude common builddir from indexing
|
||||
// therefore it is disabled by default
|
||||
// buildDir = File(commonBuildDir, project.name)
|
||||
// buildDir = File(commonBuildDir, project.name)
|
||||
|
||||
val repos: List<String> by rootProject.extra
|
||||
repositories {
|
||||
for (repo in (rootProject.extra["repos"] as List<String>)) {
|
||||
maven { setUrl(repo) }
|
||||
for (repo in repos) {
|
||||
maven(repo)
|
||||
}
|
||||
}
|
||||
|
||||
configureJvmProject(javaHome!!, jvmTarget!!)
|
||||
|
||||
val commonCompilerArgs = listOf("-Xallow-kotlin-package")
|
||||
|
||||
@@ -22,7 +22,9 @@ import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_1_2_20_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
@@ -30,17 +32,14 @@ val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn
|
||||
val INTERCEPTED_NAME = Name.identifier("intercepted")
|
||||
val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")
|
||||
|
||||
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
|
||||
val COROUTINE_CONTEXT_FQ_NAME = COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
|
||||
val SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME = Name.identifier("suspendCoroutineUninterceptedOrReturn")
|
||||
|
||||
fun FunctionDescriptor.isBuiltInIntercepted(): Boolean {
|
||||
if (name != INTERCEPTED_NAME) return false
|
||||
val original =
|
||||
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(INTERCEPTED_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull() as CallableDescriptor
|
||||
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(INTERCEPTED_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull() as CallableDescriptor
|
||||
return DescriptorEquivalenceForOverrides.areEquivalent(original, this)
|
||||
}
|
||||
|
||||
@@ -50,22 +49,19 @@ fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
|
||||
val originalDeclaration = getBuiltInSuspendCoroutineOrReturn() ?: return false
|
||||
|
||||
return DescriptorEquivalenceForOverrides.areEquivalent(
|
||||
originalDeclaration, this
|
||||
originalDeclaration, this
|
||||
)
|
||||
}
|
||||
|
||||
fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
|
||||
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull()
|
||||
|
||||
fun FunctionDescriptor.isBuiltInCoroutineContext() =
|
||||
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe == COROUTINE_CONTEXT_FQ_NAME
|
||||
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull()
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(): Boolean {
|
||||
if (name != SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME) return false
|
||||
val original = module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull() as CallableDescriptor
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull() as CallableDescriptor
|
||||
return DescriptorEquivalenceForOverrides.areEquivalent(original, this)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import kotlin.Pair;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.io.FilesKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,14 +27,23 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.config.AnalysisFlag;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorUtilKt;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping;
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageParts;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable;
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl;
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.io.File;
|
||||
@@ -95,19 +105,25 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
}
|
||||
|
||||
private void writeModuleMappings() {
|
||||
JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
|
||||
JvmModuleProtoBuf.Module.Builder builder = JvmModuleProtoBuf.Module.newBuilder();
|
||||
String outputFilePath = getMappingFileName(state.getModuleName());
|
||||
|
||||
for (PackageParts part : ClassFileUtilsKt.addCompiledPartsAndSort(partsGroupedByPackage.values(), state)) {
|
||||
part.addTo(builder);
|
||||
}
|
||||
|
||||
if (builder.getPackagePartsCount() == 0) return;
|
||||
List<String> experimental = state.getLanguageVersionSettings().getFlag(AnalysisFlag.getExperimental());
|
||||
if (!experimental.isEmpty()) {
|
||||
writeExperimentalMarkers(state.getModule(), builder, experimental);
|
||||
}
|
||||
|
||||
JvmModuleProtoBuf.Module moduleProto = builder.build();
|
||||
if (moduleProto.getSerializedSize() == 0) return;
|
||||
|
||||
generators.put(outputFilePath, new OutAndSourceFileList(CollectionsKt.toList(packagePartSourceFiles)) {
|
||||
@Override
|
||||
public byte[] asBytes(ClassBuilderFactory factory) {
|
||||
return ClassFileUtilsKt.serializeToByteArray(builder);
|
||||
return ClassFileUtilsKt.serializeToByteArray(moduleProto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,6 +138,29 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
});
|
||||
}
|
||||
|
||||
private static void writeExperimentalMarkers(
|
||||
@NotNull ModuleDescriptor module,
|
||||
@NotNull JvmModuleProtoBuf.Module.Builder builder,
|
||||
@NotNull List<String> experimental
|
||||
) {
|
||||
StringTableImpl stringTable = new StringTableImpl();
|
||||
for (String fqName : experimental) {
|
||||
ClassDescriptor descriptor =
|
||||
DescriptorUtilKt.resolveClassByFqName(module, new FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED);
|
||||
if (descriptor != null) {
|
||||
ProtoBuf.Annotation.Builder annotation = ProtoBuf.Annotation.newBuilder();
|
||||
ClassId classId = DescriptorUtilsKt.getClassId(descriptor);
|
||||
if (classId != null) {
|
||||
annotation.setId(stringTable.getClassIdIndex(classId));
|
||||
builder.addAnnotation(annotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
Pair<ProtoBuf.StringTable, ProtoBuf.QualifiedNameTable> tables = stringTable.buildProto();
|
||||
builder.setStringTable(tables.getFirst());
|
||||
builder.setQualifiedNameTable(tables.getSecond());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<OutputFile> asList() {
|
||||
|
||||
@@ -384,10 +384,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (context.closure != null)
|
||||
genClosureFields(context.closure, v, typeMapper);
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
|
||||
|
||||
for (ExpressionCodegenExtension extension : ExpressionCodegenExtension.Companion.getInstances(state.getProject())) {
|
||||
extension.generateClassSyntheticParts(this);
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES
|
||||
|| extension.getShouldGenerateClassSyntheticPartsInLightClassesMode()
|
||||
) {
|
||||
extension.generateClassSyntheticParts(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,23 +95,33 @@ public class CodegenBinding {
|
||||
|
||||
@NotNull
|
||||
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull KtElement expression) {
|
||||
Type result = asmTypeForAnonymousClassOrNull(bindingContext, expression);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Type must not be null: " + expression.getText());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Type asmTypeForAnonymousClassOrNull(@NotNull BindingContext bindingContext, @NotNull KtElement expression) {
|
||||
if (expression instanceof KtObjectLiteralExpression) {
|
||||
expression = ((KtObjectLiteralExpression) expression).getObjectDeclaration();
|
||||
}
|
||||
|
||||
ClassDescriptor descriptor = bindingContext.get(CLASS, expression);
|
||||
if (descriptor != null) {
|
||||
return getAsmType(bindingContext, descriptor);
|
||||
return bindingContext.get(ASM_TYPE, descriptor);
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
|
||||
if (functionDescriptor != null) {
|
||||
return asmTypeForAnonymousClass(bindingContext, functionDescriptor);
|
||||
return asmTypeForAnonymousClassOrNull(bindingContext, functionDescriptor);
|
||||
}
|
||||
|
||||
VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression);
|
||||
if (variableDescriptor != null) {
|
||||
return asmTypeForAnonymousClass(bindingContext, variableDescriptor);
|
||||
return asmTypeForAnonymousClassOrNull(bindingContext, variableDescriptor);
|
||||
}
|
||||
|
||||
throw new KotlinExceptionWithAttachments("Couldn't compute ASM type for expression")
|
||||
@@ -120,7 +130,17 @@ public class CodegenBinding {
|
||||
|
||||
@NotNull
|
||||
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor descriptor) {
|
||||
return getAsmType(bindingContext, anonymousClassForCallable(bindingContext, descriptor));
|
||||
Type result = asmTypeForAnonymousClassOrNull(bindingContext, descriptor);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Type must not be null: " + descriptor);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Type asmTypeForAnonymousClassOrNull(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor descriptor) {
|
||||
return bindingContext.get(ASM_TYPE, anonymousClassForCallable(bindingContext, descriptor));
|
||||
}
|
||||
|
||||
public static boolean canHaveOuter(@NotNull BindingContext bindingContext, @NotNull ClassDescriptor classDescriptor) {
|
||||
@@ -216,7 +236,9 @@ public class CodegenBinding {
|
||||
@NotNull
|
||||
public static Type getAsmType(@NotNull BindingContext bindingContext, @NotNull ClassDescriptor klass) {
|
||||
Type type = bindingContext.get(ASM_TYPE, klass);
|
||||
assert type != null : "Type is not yet recorded for " + klass;
|
||||
if (type == null) {
|
||||
throw new IllegalStateException("Type is not yet recorded for " + klass);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageParts
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun ClassFileFactory.getClassFiles(): Iterable<OutputFile> {
|
||||
@@ -57,7 +57,7 @@ private fun Iterable<PackageParts>.addCompiledParts(state: GenerationState): Lis
|
||||
}
|
||||
}
|
||||
|
||||
fun JvmPackageTable.PackageTable.Builder.serializeToByteArray(): ByteArray {
|
||||
fun JvmModuleProtoBuf.Module.serializeToByteArray(): ByteArray {
|
||||
val moduleMapping = ByteArrayOutputStream(4096)
|
||||
val out = DataOutputStream(moduleMapping)
|
||||
val version = JvmMetadataVersion.INSTANCE.toArray()
|
||||
@@ -65,7 +65,7 @@ fun JvmPackageTable.PackageTable.Builder.serializeToByteArray(): ByteArray {
|
||||
for (number in version) {
|
||||
out.writeInt(number)
|
||||
}
|
||||
build().writeTo(out)
|
||||
writeTo(out)
|
||||
out.flush()
|
||||
return moduleMapping.toByteArray()
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilder
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.TransformationMethodVisitor
|
||||
import org.jetbrains.kotlin.codegen.inline.MaxStackFrameSizeAndLocalsCalculator
|
||||
import org.jetbrains.kotlin.codegen.inline.isAfterSuspendMarker
|
||||
import org.jetbrains.kotlin.codegen.inline.isBeforeSuspendMarker
|
||||
import org.jetbrains.kotlin.codegen.inline.isInlineMarker
|
||||
import org.jetbrains.kotlin.codegen.inline.*
|
||||
import org.jetbrains.kotlin.codegen.optimization.DeadCodeEliminationMethodTransformer
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.*
|
||||
import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer
|
||||
@@ -81,6 +78,13 @@ class CoroutineTransformerMethodVisitor(
|
||||
ReturnUnitMethodTransformer.transform(containingClassInternalName, methodNode)
|
||||
|
||||
if (allSuspensionPointsAreTailCalls(containingClassInternalName, methodNode, suspensionPoints)) {
|
||||
continuationIndex =
|
||||
if (isStatic(methodNode.access))
|
||||
Type.getArgumentTypes(methodNode.desc).size - 1
|
||||
else
|
||||
Type.getArgumentTypes(methodNode.desc).size
|
||||
replaceFakeContinuationsWithRealOnes(methodNode, continuationIndex)
|
||||
|
||||
dropSuspensionMarkers(methodNode, suspensionPoints)
|
||||
return
|
||||
}
|
||||
@@ -99,6 +103,8 @@ class CoroutineTransformerMethodVisitor(
|
||||
// Actual max stack might be increased during the previous phases
|
||||
updateMaxStack(methodNode)
|
||||
|
||||
replaceFakeContinuationsWithRealOnes(methodNode, continuationIndex)
|
||||
|
||||
// Remove unreachable suspension points
|
||||
// If we don't do this, then relevant frames will not be analyzed, that is unexpected from point of view of next steps (e.g. variable spilling)
|
||||
removeUnreachableSuspensionPointsAndExitPoints(methodNode, suspensionPoints)
|
||||
@@ -153,6 +159,14 @@ class CoroutineTransformerMethodVisitor(
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
}
|
||||
|
||||
private fun replaceFakeContinuationsWithRealOnes(methodNode: MethodNode, continuationIndex: Int) {
|
||||
val fakeContinuations = methodNode.instructions.asSequence().filter(::isFakeContinuationMarker)
|
||||
for (fakeContinuation in fakeContinuations) {
|
||||
methodNode.instructions.removeAll(listOf(fakeContinuation.previous.previous, fakeContinuation.previous))
|
||||
methodNode.instructions.set(fakeContinuation, VarInsnNode(Opcodes.ALOAD, continuationIndex))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createInsnForReadingLabel() =
|
||||
if (isForNamedFunction)
|
||||
MethodInsnNode(
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.backend.common.*
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
||||
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.codegen.topLevelClassAsmType
|
||||
import org.jetbrains.kotlin.codegen.topLevelClassInternalName
|
||||
@@ -32,6 +33,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
@@ -59,22 +61,23 @@ const val EXCEPTION_FIELD_NAME = "exception"
|
||||
|
||||
@JvmField
|
||||
val COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME =
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("jvm")).child(Name.identifier("internal"))
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("jvm")).child(Name.identifier("internal"))
|
||||
|
||||
@JvmField
|
||||
val CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME.topLevelClassAsmType()
|
||||
|
||||
@JvmField
|
||||
val COROUTINE_CONTEXT_ASM_TYPE = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineContext")).topLevelClassAsmType()
|
||||
val COROUTINE_CONTEXT_ASM_TYPE =
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineContext")).topLevelClassAsmType()
|
||||
|
||||
@JvmField
|
||||
val COROUTINE_IMPL_ASM_TYPE = COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl")).topLevelClassAsmType()
|
||||
|
||||
private val COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME =
|
||||
COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
|
||||
DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
|
||||
|
||||
private val INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME =
|
||||
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
|
||||
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
|
||||
|
||||
private val NORMALIZE_CONTINUATION_METHOD_NAME = "normalizeContinuation"
|
||||
private val GET_CONTEXT_METHOD_NAME = "getContext"
|
||||
@@ -94,41 +97,42 @@ val INITIAL_SUSPEND_DESCRIPTOR_FOR_DO_RESUME = object : FunctionDescriptor.UserD
|
||||
// So this function returns resolved call with descriptor looking like `fun <V> await(f: CompletableFuture<V>, machine: Continuation<V>): Unit`
|
||||
// and fake `this` expression that used as argument for second parameter
|
||||
fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
|
||||
project: Project,
|
||||
bindingContext: BindingContext
|
||||
project: Project,
|
||||
bindingContext: BindingContext
|
||||
): ResolvedCallWithRealDescriptor? {
|
||||
if (this is VariableAsFunctionResolvedCall) {
|
||||
val replacedFunctionCall =
|
||||
functionCall.replaceSuspensionFunctionWithRealDescriptor(project, bindingContext)
|
||||
?: return null
|
||||
functionCall.replaceSuspensionFunctionWithRealDescriptor(project, bindingContext)
|
||||
?: return null
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return replacedFunctionCall.copy(
|
||||
VariableAsFunctionResolvedCallImpl(
|
||||
replacedFunctionCall.resolvedCall as MutableResolvedCall<FunctionDescriptor>,
|
||||
variableCall.asMutableResolvedCall(bindingContext)
|
||||
)
|
||||
VariableAsFunctionResolvedCallImpl(
|
||||
replacedFunctionCall.resolvedCall as MutableResolvedCall<FunctionDescriptor>,
|
||||
variableCall.asMutableResolvedCall(bindingContext)
|
||||
)
|
||||
)
|
||||
}
|
||||
val function = candidateDescriptor as? FunctionDescriptor ?: return null
|
||||
if (!function.isSuspend || function.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) return null
|
||||
|
||||
val newCandidateDescriptor =
|
||||
when (function) {
|
||||
is FunctionImportedFromObject ->
|
||||
getOrCreateJvmSuspendFunctionView(function.callableFromObject, bindingContext).asImportedFromObject()
|
||||
is SimpleFunctionDescriptor ->
|
||||
getOrCreateJvmSuspendFunctionView(function, bindingContext)
|
||||
else ->
|
||||
throw AssertionError("Unexpected suspend function descriptor: $function")
|
||||
}
|
||||
when (function) {
|
||||
is FunctionImportedFromObject ->
|
||||
getOrCreateJvmSuspendFunctionView(function.callableFromObject, bindingContext).asImportedFromObject()
|
||||
is SimpleFunctionDescriptor ->
|
||||
getOrCreateJvmSuspendFunctionView(function, bindingContext)
|
||||
else ->
|
||||
throw AssertionError("Unexpected suspend function descriptor: $function")
|
||||
}
|
||||
|
||||
val newCall = ResolvedCallImpl(
|
||||
call,
|
||||
newCandidateDescriptor,
|
||||
dispatchReceiver, extensionReceiver, explicitReceiverKind,
|
||||
null, DelegatingBindingTrace(BindingTraceContext().bindingContext, "Temporary trace for unwrapped suspension function"),
|
||||
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY))
|
||||
call,
|
||||
newCandidateDescriptor,
|
||||
dispatchReceiver, extensionReceiver, explicitReceiverKind,
|
||||
null, DelegatingBindingTrace(BindingTraceContext().bindingContext, "Temporary trace for unwrapped suspension function"),
|
||||
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
|
||||
)
|
||||
|
||||
this.valueArguments.forEach {
|
||||
newCall.recordValueArgument(newCandidateDescriptor.valueParameters[it.key.index], it.value)
|
||||
@@ -138,15 +142,17 @@ fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
|
||||
val arguments = psiFactory.createCallArguments("(this)").arguments.single()
|
||||
val thisExpression = arguments.getArgumentExpression()!!
|
||||
newCall.recordValueArgument(
|
||||
newCandidateDescriptor.valueParameters.last(),
|
||||
ExpressionValueArgument(arguments))
|
||||
newCandidateDescriptor.valueParameters.last(),
|
||||
ExpressionValueArgument(arguments)
|
||||
)
|
||||
|
||||
val newTypeArguments = newCandidateDescriptor.typeParameters.map {
|
||||
Pair(it, typeArguments[candidateDescriptor.typeParameters[it.index]]!!.asTypeProjection())
|
||||
}.toMap()
|
||||
|
||||
newCall.setResultingSubstitutor(
|
||||
TypeConstructorSubstitution.createByParametersMap(newTypeArguments).buildSubstitutor())
|
||||
TypeConstructorSubstitution.createByParametersMap(newTypeArguments).buildSubstitutor()
|
||||
)
|
||||
|
||||
return ResolvedCallWithRealDescriptor(newCall, thisExpression)
|
||||
}
|
||||
@@ -161,19 +167,19 @@ private fun ResolvedCall<VariableDescriptor>.asMutableResolvedCall(bindingContex
|
||||
|
||||
private fun NewResolvedCallImpl<VariableDescriptor>.asDummyOldResolvedCall(bindingContext: BindingContext): ResolvedCallImpl<VariableDescriptor> {
|
||||
return ResolvedCallImpl(
|
||||
call,
|
||||
candidateDescriptor,
|
||||
dispatchReceiver, extensionReceiver, explicitReceiverKind,
|
||||
null, DelegatingBindingTrace(bindingContext, "Trace for old call"),
|
||||
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
|
||||
call,
|
||||
candidateDescriptor,
|
||||
dispatchReceiver, extensionReceiver, explicitReceiverKind,
|
||||
null, DelegatingBindingTrace(bindingContext, "Trace for old call"),
|
||||
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
|
||||
)
|
||||
}
|
||||
|
||||
fun ResolvedCall<*>.isSuspendNoInlineCall() =
|
||||
resultingDescriptor.safeAs<FunctionDescriptor>()
|
||||
?.let {
|
||||
it.isSuspend && (!it.isInline || it.isBuiltInSuspendCoroutineOrReturnInJvm() || it.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm())
|
||||
} == true
|
||||
resultingDescriptor.safeAs<FunctionDescriptor>()
|
||||
?.let {
|
||||
it.isSuspend && (!it.isInline || it.isBuiltInSuspendCoroutineOrReturnInJvm() || it.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm())
|
||||
} == true
|
||||
|
||||
fun CallableDescriptor.isSuspendFunctionNotSuspensionView(): Boolean {
|
||||
if (this !is FunctionDescriptor) return false
|
||||
@@ -193,14 +199,14 @@ fun <D : FunctionDescriptor> getOrCreateJvmSuspendFunctionView(function: D, bind
|
||||
bindingContext?.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, function)?.let { return it as D }
|
||||
|
||||
val continuationParameter = ValueParameterDescriptorImpl(
|
||||
function, null, function.valueParameters.size, Annotations.EMPTY, Name.identifier("continuation"),
|
||||
// Add j.l.Object to invoke(), because that is the type of parameters we have in FunctionN+1
|
||||
if (function.containingDeclaration.safeAs<ClassDescriptor>()?.defaultType?.isBuiltinFunctionalType == true)
|
||||
function.builtIns.nullableAnyType
|
||||
else
|
||||
function.getContinuationParameterTypeOfSuspendFunction(),
|
||||
/* declaresDefaultValue = */ false, /* isCrossinline = */ false,
|
||||
/* isNoinline = */ false, /* varargElementType = */ null, SourceElement.NO_SOURCE
|
||||
function, null, function.valueParameters.size, Annotations.EMPTY, Name.identifier("continuation"),
|
||||
// Add j.l.Object to invoke(), because that is the type of parameters we have in FunctionN+1
|
||||
if (function.containingDeclaration.safeAs<ClassDescriptor>()?.defaultType?.isBuiltinFunctionalType == true)
|
||||
function.builtIns.nullableAnyType
|
||||
else
|
||||
function.getContinuationParameterTypeOfSuspendFunction(),
|
||||
/* declaresDefaultValue = */ false, /* isCrossinline = */ false,
|
||||
/* isNoinline = */ false, /* varargElementType = */ null, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
return function.createCustomCopy {
|
||||
@@ -213,18 +219,18 @@ fun <D : FunctionDescriptor> getOrCreateJvmSuspendFunctionView(function: D, bind
|
||||
}
|
||||
|
||||
typealias FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder =
|
||||
FunctionDescriptor.CopyBuilder<out FunctionDescriptor>.(FunctionDescriptor)
|
||||
FunctionDescriptor.CopyBuilder<out FunctionDescriptor>.(FunctionDescriptor)
|
||||
-> FunctionDescriptor.CopyBuilder<out FunctionDescriptor>
|
||||
|
||||
fun <D : FunctionDescriptor> D.createCustomCopy(
|
||||
copySettings: FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder
|
||||
copySettings: FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder
|
||||
): D {
|
||||
|
||||
val newOriginal =
|
||||
if (original !== this)
|
||||
original.createCustomCopy(copySettings)
|
||||
else
|
||||
null
|
||||
if (original !== this)
|
||||
original.createCustomCopy(copySettings)
|
||||
else
|
||||
null
|
||||
|
||||
val result = newCopyBuilder().copySettings(this).setOriginal(newOriginal).build()!!
|
||||
|
||||
@@ -235,52 +241,52 @@ fun <D : FunctionDescriptor> D.createCustomCopy(
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction() =
|
||||
module.getContinuationOfTypeOrAny(returnType!!)
|
||||
module.getContinuationOfTypeOrAny(returnType!!)
|
||||
|
||||
fun ModuleDescriptor.getContinuationOfTypeOrAny(kotlinType: KotlinType) =
|
||||
module.findContinuationClassDescriptorOrNull(NoLookupLocation.FROM_BACKEND)?.defaultType?.let {
|
||||
KotlinTypeFactory.simpleType(
|
||||
it,
|
||||
arguments = listOf(kotlinType.asTypeProjection())
|
||||
)
|
||||
} ?: module.builtIns.nullableAnyType
|
||||
module.findContinuationClassDescriptorOrNull(NoLookupLocation.FROM_BACKEND)?.defaultType?.let {
|
||||
KotlinTypeFactory.simpleType(
|
||||
it,
|
||||
arguments = listOf(kotlinType.asTypeProjection())
|
||||
)
|
||||
} ?: module.builtIns.nullableAnyType
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm() =
|
||||
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true
|
||||
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true
|
||||
|
||||
fun createMethodNodeForSuspendCoroutineOrReturn(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
): MethodNode {
|
||||
assert(functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm()) {
|
||||
"functionDescriptor must be kotlin.coroutines.intrinsics.suspendOrReturn"
|
||||
}
|
||||
|
||||
val node =
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
node.visitVarInsn(Opcodes.ALOAD, 1)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
|
||||
NORMALIZE_CONTINUATION_METHOD_NAME,
|
||||
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
false
|
||||
Opcodes.INVOKESTATIC,
|
||||
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
|
||||
NORMALIZE_CONTINUATION_METHOD_NAME,
|
||||
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
false
|
||||
)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
|
||||
OperatorNameConventions.INVOKE.identifier,
|
||||
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
|
||||
true
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
|
||||
OperatorNameConventions.INVOKE.identifier,
|
||||
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
|
||||
true
|
||||
)
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
node.visitMaxs(2, 2)
|
||||
@@ -289,32 +295,32 @@ fun createMethodNodeForSuspendCoroutineOrReturn(
|
||||
}
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm() =
|
||||
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineUninterceptedOrReturn() == true
|
||||
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineUninterceptedOrReturn() == true
|
||||
|
||||
fun createMethodNodeForIntercepted(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
): MethodNode {
|
||||
assert(functionDescriptor.isBuiltInIntercepted()) {
|
||||
"functionDescriptor must be kotlin.coroutines.intrinsics.intercepted"
|
||||
}
|
||||
|
||||
val node =
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
|
||||
NORMALIZE_CONTINUATION_METHOD_NAME,
|
||||
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
false
|
||||
Opcodes.INVOKESTATIC,
|
||||
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
|
||||
NORMALIZE_CONTINUATION_METHOD_NAME,
|
||||
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
false
|
||||
)
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
node.visitMaxs(1, 1)
|
||||
@@ -328,24 +334,25 @@ fun createMethodNodeForCoroutineContext(functionDescriptor: FunctionDescriptor):
|
||||
}
|
||||
|
||||
val node =
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
null, null
|
||||
)
|
||||
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
CONTINUATION_ASM_TYPE.internalName,
|
||||
GET_CONTEXT_METHOD_NAME,
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE),
|
||||
true
|
||||
null, null
|
||||
)
|
||||
|
||||
val v = InstructionAdapter(node)
|
||||
|
||||
addFakeContinuationMarker(v)
|
||||
|
||||
v.invokeinterface(
|
||||
CONTINUATION_ASM_TYPE.internalName,
|
||||
GET_CONTEXT_METHOD_NAME,
|
||||
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE)
|
||||
)
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
v.areturn(COROUTINE_CONTEXT_ASM_TYPE)
|
||||
|
||||
node.visitMaxs(1, 1)
|
||||
|
||||
return node
|
||||
@@ -353,30 +360,30 @@ fun createMethodNodeForCoroutineContext(functionDescriptor: FunctionDescriptor):
|
||||
|
||||
|
||||
fun createMethodNodeForSuspendCoroutineUninterceptedOrReturn(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
): MethodNode {
|
||||
assert(functionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm()) {
|
||||
"functionDescriptor must be kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn"
|
||||
}
|
||||
|
||||
val node =
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
node.visitVarInsn(Opcodes.ALOAD, 1)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
|
||||
OperatorNameConventions.INVOKE.identifier,
|
||||
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
|
||||
true
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
|
||||
OperatorNameConventions.INVOKE.identifier,
|
||||
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
|
||||
true
|
||||
)
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
node.visitMaxs(2, 2)
|
||||
@@ -386,21 +393,21 @@ fun createMethodNodeForSuspendCoroutineUninterceptedOrReturn(
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <D : CallableDescriptor?> D.unwrapInitialDescriptorForSuspendFunction(): D =
|
||||
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
|
||||
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
|
||||
|
||||
|
||||
fun FunctionDescriptor.getOriginalSuspendFunctionView(bindingContext: BindingContext): FunctionDescriptor =
|
||||
if (isSuspend)
|
||||
getOrCreateJvmSuspendFunctionView(unwrapInitialDescriptorForSuspendFunction().original, bindingContext)
|
||||
else
|
||||
this
|
||||
if (isSuspend)
|
||||
getOrCreateJvmSuspendFunctionView(unwrapInitialDescriptorForSuspendFunction().original, bindingContext)
|
||||
else
|
||||
this
|
||||
|
||||
fun InstructionAdapter.loadCoroutineSuspendedMarker() {
|
||||
invokestatic(
|
||||
COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME.internalName,
|
||||
"get$COROUTINE_SUSPENDED_NAME",
|
||||
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
|
||||
false
|
||||
COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME.internalName,
|
||||
"get$COROUTINE_SUSPENDED_NAME",
|
||||
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -411,12 +418,12 @@ fun InstructionAdapter.invokeDoResumeWithUnit(thisName: String) {
|
||||
aconst(null)
|
||||
|
||||
invokevirtual(
|
||||
thisName,
|
||||
DO_RESUME_METHOD_NAME,
|
||||
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE, AsmTypes.OBJECT_TYPE, AsmTypes.JAVA_THROWABLE_TYPE),
|
||||
false
|
||||
thisName,
|
||||
DO_RESUME_METHOD_NAME,
|
||||
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE, AsmTypes.OBJECT_TYPE, AsmTypes.JAVA_THROWABLE_TYPE),
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
fun Method.getImplForOpenMethod(ownerInternalName: String) =
|
||||
Method("$name\$suspendImpl", returnType, arrayOf(Type.getObjectType(ownerInternalName)) + argumentTypes)
|
||||
Method("$name\$suspendImpl", returnType, arrayOf(Type.getObjectType(ownerInternalName)) + argumentTypes)
|
||||
|
||||
@@ -47,4 +47,7 @@ interface ExpressionCodegenExtension {
|
||||
fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null
|
||||
|
||||
fun generateClassSyntheticParts(codegen: ImplementationBodyCodegen) {}
|
||||
|
||||
val shouldGenerateClassSyntheticPartsInLightClassesMode: Boolean
|
||||
get() = false
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInCoroutineContext
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
@@ -41,6 +40,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil.isInlinableParameterExpression
|
||||
@@ -265,9 +265,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
addInlineMarker(codegen.v, true)
|
||||
}
|
||||
|
||||
if (functionDescriptor.isBuiltInCoroutineContext())
|
||||
invocationParamBuilder.addNextValueParameter(CONTINUATION_ASM_TYPE, false, continuationValue(), 0)
|
||||
|
||||
val parameters = invocationParamBuilder.buildParameters()
|
||||
|
||||
val info = RootInliningContext(
|
||||
|
||||
@@ -91,7 +91,8 @@ private const val INLINE_MARKER_FINALLY_START = "finallyStart"
|
||||
private const val INLINE_MARKER_FINALLY_END = "finallyEnd"
|
||||
private const val INLINE_MARKER_BEFORE_SUSPEND_ID = 0
|
||||
private const val INLINE_MARKER_AFTER_SUSPEND_ID = 1
|
||||
private const val INLINE_MARKET_RETURNS_UNIT = 2
|
||||
private const val INLINE_MARKER_RETURNS_UNIT = 2
|
||||
private const val INLINE_MARKER_FAKE_CONTINUATION = 3
|
||||
private val INTRINSIC_ARRAY_CONSTRUCTOR_TYPE = AsmUtil.asmTypeByClassId(classId)
|
||||
|
||||
internal fun getMethodNode(
|
||||
@@ -421,7 +422,7 @@ internal fun addSuspendMarker(v: InstructionAdapter, isStartNotEnd: Boolean) {
|
||||
}
|
||||
|
||||
private fun addReturnsUnitMarker(v: InstructionAdapter) {
|
||||
v.iconst(INLINE_MARKET_RETURNS_UNIT)
|
||||
v.iconst(INLINE_MARKER_RETURNS_UNIT)
|
||||
v.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC, INLINE_MARKER_CLASS_NAME,
|
||||
"mark",
|
||||
@@ -429,9 +430,26 @@ private fun addReturnsUnitMarker(v: InstructionAdapter) {
|
||||
)
|
||||
}
|
||||
|
||||
/* There are contexts when the continuation does not yet exist, for example, in inline lambdas, which are going to
|
||||
* be inlined into suspendable functions.
|
||||
* In such cases we just generate the marker which is going to be replaced with real continuation on generating state machine.
|
||||
* See [CoroutineTransformerMethodVisitor] for more info.
|
||||
*/
|
||||
internal fun addFakeContinuationMarker(v: InstructionAdapter) {
|
||||
v.iconst(INLINE_MARKER_FAKE_CONTINUATION)
|
||||
v.invokestatic(
|
||||
INLINE_MARKER_CLASS_NAME,
|
||||
"mark",
|
||||
"(I)V", false
|
||||
)
|
||||
v.aconst(null)
|
||||
}
|
||||
|
||||
internal fun isBeforeSuspendMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_BEFORE_SUSPEND_ID)
|
||||
internal fun isAfterSuspendMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_AFTER_SUSPEND_ID)
|
||||
internal fun isReturnsUnitMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKET_RETURNS_UNIT)
|
||||
internal fun isReturnsUnitMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_RETURNS_UNIT)
|
||||
internal fun isFakeContinuationMarker(insn: AbstractInsnNode) =
|
||||
insn.previous != null && isSuspendMarker(insn.previous, INLINE_MARKER_FAKE_CONTINUATION) && insn.opcode == Opcodes.ACONST_NULL
|
||||
|
||||
private fun isSuspendMarker(insn: AbstractInsnNode, id: Int) =
|
||||
isInlineMarker(insn, "mark") && insn.previous.intConstant == id
|
||||
|
||||
@@ -126,14 +126,6 @@ private fun ExpressionCodegen.createIntrinsifiedRangeValueOrNull(rangeCall: Reso
|
||||
CollectionIndicesRangeValue(rangeCall)
|
||||
isCharSequenceIndices(rangeCallee) ->
|
||||
CharSequenceIndicesRangeValue(rangeCall)
|
||||
isArrayOrPrimitiveArrayWithIndex(rangeCallee) ->
|
||||
ArrayWithIndexRangeValue(rangeCall)
|
||||
isIterableWithIndex(rangeCallee) ->
|
||||
IterableWithIndexRangeValue(rangeCall)
|
||||
isSequenceWithIndex(rangeCallee) ->
|
||||
SequenceWithIndexRangeValue(rangeCall)
|
||||
isCharSequenceWithIndex(rangeCallee) ->
|
||||
CharSequenceWithIndexRangeValue(rangeCall)
|
||||
isComparableRangeTo(rangeCallee) ->
|
||||
ComparableRangeLiteralRangeValue(this, rangeCall)
|
||||
isPrimitiveProgressionReverse(rangeCallee) ->
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.when;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.kotlin.codegen.FrameMap;
|
||||
import org.jetbrains.kotlin.psi.KtWhenEntry;
|
||||
import org.jetbrains.kotlin.psi.KtWhenExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
abstract public class SwitchCodegen {
|
||||
protected final KtWhenExpression expression;
|
||||
protected final boolean isStatement;
|
||||
protected final boolean isExhaustive;
|
||||
protected final ExpressionCodegen codegen;
|
||||
protected final BindingContext bindingContext;
|
||||
protected final Type subjectType;
|
||||
protected final Type resultType;
|
||||
protected final InstructionAdapter v;
|
||||
|
||||
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<>();
|
||||
protected final List<Label> entryLabels = new ArrayList<>();
|
||||
protected Label elseLabel = new Label();
|
||||
protected Label endLabel = new Label();
|
||||
protected Label defaultLabel;
|
||||
|
||||
protected final SwitchCodegenProvider switchCodegenProvider;
|
||||
|
||||
public SwitchCodegen(
|
||||
@NotNull KtWhenExpression expression, boolean isStatement,
|
||||
boolean isExhaustive, @NotNull ExpressionCodegen codegen,
|
||||
@Nullable Type subjectType
|
||||
) {
|
||||
this.expression = expression;
|
||||
this.isStatement = isStatement;
|
||||
this.isExhaustive = isExhaustive;
|
||||
this.codegen = codegen;
|
||||
this.bindingContext = codegen.getBindingContext();
|
||||
this.switchCodegenProvider = new SwitchCodegenProvider(codegen);
|
||||
|
||||
this.subjectType = subjectType != null ? subjectType : codegen.expressionType(expression.getSubjectExpression());
|
||||
resultType = isStatement ? Type.VOID_TYPE : codegen.expressionType(expression);
|
||||
v = codegen.v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates bytecode for entire when expression
|
||||
*/
|
||||
public void generate() {
|
||||
prepareConfiguration();
|
||||
|
||||
boolean hasElse = expression.getElseExpression() != null;
|
||||
|
||||
// if there is no else-entry and it's statement then default --- endLabel
|
||||
defaultLabel = (hasElse || !isStatement || isExhaustive) ? elseLabel : endLabel;
|
||||
|
||||
generateSubject();
|
||||
|
||||
generateSwitchInstructionByTransitionsTable();
|
||||
|
||||
generateEntries();
|
||||
|
||||
// there is no else-entry but this is not statement, so we should return Unit
|
||||
if (!hasElse && (!isStatement || isExhaustive)) {
|
||||
v.visitLabel(elseLabel);
|
||||
codegen.putUnitInstanceOntoStackForNonExhaustiveWhen(expression, isStatement);
|
||||
}
|
||||
|
||||
codegen.markLineNumber(expression, isStatement);
|
||||
v.mark(endLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up transitionsTable and maybe something else needed in a special case
|
||||
* Behaviour may be changed by overriding processConstant
|
||||
*/
|
||||
private void prepareConfiguration() {
|
||||
for (KtWhenEntry entry : expression.getEntries()) {
|
||||
Label entryLabel = new Label();
|
||||
|
||||
for (ConstantValue<?> constant : switchCodegenProvider.getConstantsFromEntry(entry)) {
|
||||
if (constant instanceof NullValue) continue;
|
||||
processConstant(constant, entryLabel);
|
||||
}
|
||||
|
||||
if (entry.isElse()) {
|
||||
elseLabel = entryLabel;
|
||||
}
|
||||
|
||||
entryLabels.add(entryLabel);
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected void processConstant(
|
||||
@NotNull ConstantValue<?> constant,
|
||||
@NotNull Label entryLabel
|
||||
);
|
||||
|
||||
protected void putTransitionOnce(int value, @NotNull Label entryLabel) {
|
||||
if (!transitionsTable.containsKey(value)) {
|
||||
transitionsTable.put(value, entryLabel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should generate int subject on top of the stack
|
||||
* Default implementation just run codegen for actual subject of expression
|
||||
* May also gen nullability check if needed
|
||||
*/
|
||||
protected void generateSubject() {
|
||||
codegen.gen(expression.getSubjectExpression(), subjectType);
|
||||
}
|
||||
|
||||
protected void generateNullCheckIfNeeded() {
|
||||
assert expression.getSubjectExpression() != null : "subject expression can't be null";
|
||||
KotlinType subjectJetType = bindingContext.getType(expression.getSubjectExpression());
|
||||
|
||||
assert subjectJetType != null : "subject type can't be null (i.e. void)";
|
||||
|
||||
if (TypeUtils.isNullableType(subjectJetType)) {
|
||||
int nullEntryIndex = findNullEntryIndex(expression);
|
||||
Label nullLabel = nullEntryIndex == -1 ? defaultLabel : entryLabels.get(nullEntryIndex);
|
||||
Label notNullLabel = new Label();
|
||||
|
||||
v.dup();
|
||||
v.ifnonnull(notNullLabel);
|
||||
|
||||
v.pop();
|
||||
|
||||
v.goTo(nullLabel);
|
||||
|
||||
v.visitLabel(notNullLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private int findNullEntryIndex(@NotNull KtWhenExpression expression) {
|
||||
int entryIndex = 0;
|
||||
for (KtWhenEntry entry : expression.getEntries()) {
|
||||
for (ConstantValue<?> constant : switchCodegenProvider.getConstantsFromEntry(entry)) {
|
||||
if (constant instanceof NullValue) {
|
||||
return entryIndex;
|
||||
}
|
||||
}
|
||||
|
||||
entryIndex++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void generateSwitchInstructionByTransitionsTable() {
|
||||
int[] keys = new int[transitionsTable.size()];
|
||||
Label[] labels = new Label[transitionsTable.size()];
|
||||
int i = 0;
|
||||
|
||||
for (Map.Entry<Integer, Label> transition : transitionsTable.entrySet()) {
|
||||
keys[i] = transition.getKey();
|
||||
labels[i] = transition.getValue();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
int nlabels = keys.length;
|
||||
int hi = keys[nlabels - 1];
|
||||
int lo = keys[0];
|
||||
|
||||
/*
|
||||
* Heuristic estimation if it's better to use tableswitch or lookupswitch.
|
||||
* From OpenJDK sources
|
||||
*/
|
||||
long table_space_cost = 4 + ((long) hi - lo + 1); // words
|
||||
long table_time_cost = 3; // comparisons
|
||||
long lookup_space_cost = 3 + 2 * (long) nlabels;
|
||||
//noinspection UnnecessaryLocalVariable
|
||||
long lookup_time_cost = nlabels;
|
||||
|
||||
boolean useTableSwitch = nlabels > 0 &&
|
||||
table_space_cost + 3 * table_time_cost <=
|
||||
lookup_space_cost + 3 * lookup_time_cost;
|
||||
|
||||
if (!useTableSwitch) {
|
||||
v.lookupswitch(defaultLabel, keys, labels);
|
||||
return;
|
||||
}
|
||||
|
||||
Label[] sparseLabels = new Label[hi - lo + 1];
|
||||
Arrays.fill(sparseLabels, defaultLabel);
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
sparseLabels[keys[i] - lo] = labels[i];
|
||||
}
|
||||
|
||||
v.tableswitch(lo, hi, defaultLabel, sparseLabels);
|
||||
}
|
||||
|
||||
protected void generateEntries() {
|
||||
// resolving entries' entryLabels and generating entries' code
|
||||
Iterator<Label> entryLabelsIterator = entryLabels.iterator();
|
||||
for (KtWhenEntry entry : expression.getEntries()) {
|
||||
v.visitLabel(entryLabelsIterator.next());
|
||||
|
||||
FrameMap.Mark mark = codegen.myFrameMap.mark();
|
||||
codegen.gen(entry.getExpression(), resultType);
|
||||
mark.dropTo();
|
||||
|
||||
if (!entry.isElse()) {
|
||||
v.goTo(endLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.`when`
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.psi.KtWhenExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import java.util.*
|
||||
|
||||
abstract class SwitchCodegen(
|
||||
@JvmField
|
||||
protected val expression: KtWhenExpression,
|
||||
protected val isStatement: Boolean,
|
||||
private val isExhaustive: Boolean,
|
||||
@JvmField
|
||||
protected val codegen: ExpressionCodegen,
|
||||
subjectType: Type?
|
||||
) {
|
||||
protected val bindingContext: BindingContext = codegen.bindingContext
|
||||
|
||||
@JvmField
|
||||
protected val subjectType = subjectType ?: codegen.expressionType(expression.subjectExpression)
|
||||
|
||||
protected val resultType: Type = if (isStatement) Type.VOID_TYPE else codegen.expressionType(expression)
|
||||
|
||||
@JvmField
|
||||
protected val v: InstructionAdapter = codegen.v
|
||||
|
||||
@JvmField
|
||||
protected val transitionsTable: NavigableMap<Int, Label> = TreeMap()
|
||||
|
||||
private val entryLabels: MutableList<Label> = ArrayList()
|
||||
private var elseLabel = Label()
|
||||
private var endLabel = Label()
|
||||
protected lateinit var defaultLabel: Label
|
||||
|
||||
private val switchCodegenProvider = SwitchCodegenProvider(codegen)
|
||||
|
||||
/**
|
||||
* Generates bytecode for entire when expression
|
||||
*/
|
||||
open fun generate() {
|
||||
prepareConfiguration()
|
||||
|
||||
val hasElse = expression.elseExpression != null
|
||||
|
||||
// if there is no else-entry and it's statement then default --- endLabel
|
||||
defaultLabel = if (hasElse || !isStatement || isExhaustive) elseLabel else endLabel
|
||||
|
||||
generateSubject()
|
||||
|
||||
generateSwitchInstructionByTransitionsTable()
|
||||
|
||||
generateEntries()
|
||||
|
||||
// there is no else-entry but this is not statement, so we should return Unit
|
||||
if (!hasElse && (!isStatement || isExhaustive)) {
|
||||
v.visitLabel(elseLabel)
|
||||
codegen.putUnitInstanceOntoStackForNonExhaustiveWhen(expression, isStatement)
|
||||
}
|
||||
|
||||
codegen.markLineNumber(expression, isStatement)
|
||||
v.mark(endLabel)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up transitionsTable and maybe something else needed in a special case
|
||||
* Behaviour may be changed by overriding processConstant
|
||||
*/
|
||||
private fun prepareConfiguration() {
|
||||
for (entry in expression.entries) {
|
||||
val entryLabel = Label()
|
||||
|
||||
for (constant in switchCodegenProvider.getConstantsFromEntry(entry)) {
|
||||
if (constant is NullValue || constant == null) continue
|
||||
processConstant(constant, entryLabel)
|
||||
}
|
||||
|
||||
if (entry.isElse) {
|
||||
elseLabel = entryLabel
|
||||
}
|
||||
|
||||
entryLabels.add(entryLabel)
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun processConstant(
|
||||
constant: ConstantValue<*>,
|
||||
entryLabel: Label
|
||||
)
|
||||
|
||||
protected fun putTransitionOnce(value: Int, entryLabel: Label) {
|
||||
if (!transitionsTable.containsKey(value)) {
|
||||
transitionsTable[value] = entryLabel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should generate int subject on top of the stack
|
||||
* Default implementation just run codegen for actual subject of expression
|
||||
* May also gen nullability check if needed
|
||||
*/
|
||||
protected open fun generateSubject() {
|
||||
codegen.gen(expression.subjectExpression, subjectType)
|
||||
}
|
||||
|
||||
protected fun generateNullCheckIfNeeded() {
|
||||
assert(expression.subjectExpression != null) { "subject expression can't be null" }
|
||||
val subjectJetType = bindingContext.getType(expression.subjectExpression!!) ?: error("subject type can't be null (i.e. void)")
|
||||
|
||||
if (TypeUtils.isNullableType(subjectJetType)) {
|
||||
val nullEntryIndex = findNullEntryIndex(expression)
|
||||
val nullLabel = if (nullEntryIndex == -1) defaultLabel else entryLabels[nullEntryIndex]
|
||||
val notNullLabel = Label()
|
||||
|
||||
with(v) {
|
||||
dup()
|
||||
ifnonnull(notNullLabel)
|
||||
pop()
|
||||
goTo(nullLabel)
|
||||
visitLabel(notNullLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun findNullEntryIndex(expression: KtWhenExpression) =
|
||||
expression.entries.withIndex().firstOrNull { (_, entry) ->
|
||||
switchCodegenProvider.getConstantsFromEntry(entry).any { it is NullValue }
|
||||
}?.index ?: -1
|
||||
|
||||
private fun generateSwitchInstructionByTransitionsTable() {
|
||||
val keys = transitionsTable.keys.toIntArray()
|
||||
|
||||
val labelsNumber = keys.size
|
||||
val maxValue = keys.last()
|
||||
val minValue = keys.first()
|
||||
val rangeLength = maxValue.toLong() - minValue.toLong() + 1L
|
||||
|
||||
// In modern JVM implementations it shouldn't matter very much for runtime performance
|
||||
// whether to choose lookupswitch or tableswitch.
|
||||
// The only metric that really matters is bytecode size and here we can estimate:
|
||||
// - lookupswitch: ~ 2 * labelsNumber
|
||||
// - tableswitch: ~ rangeLength
|
||||
if (rangeLength > 2L * labelsNumber || rangeLength > Int.MAX_VALUE) {
|
||||
val labels = transitionsTable.values.toTypedArray()
|
||||
v.lookupswitch(defaultLabel, keys, labels)
|
||||
return
|
||||
}
|
||||
|
||||
val sparseLabels = Array(rangeLength.toInt()) { index ->
|
||||
transitionsTable[index + minValue] ?: defaultLabel
|
||||
}
|
||||
|
||||
v.tableswitch(minValue, maxValue, defaultLabel, *sparseLabels)
|
||||
}
|
||||
|
||||
protected open fun generateEntries() {
|
||||
// resolving entries' entryLabels and generating entries' code
|
||||
val entryLabelsIterator = entryLabels.iterator()
|
||||
for (entry in expression.entries) {
|
||||
v.visitLabel(entryLabelsIterator.next())
|
||||
|
||||
val mark = codegen.myFrameMap.mark()
|
||||
codegen.gen(entry.expression, resultType)
|
||||
mark.dropTo()
|
||||
|
||||
if (!entry.isElse) {
|
||||
v.goTo(endLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
value = "-Xlegacy-smart-cast-after-try",
|
||||
description = "Allow var smart casts despite assignment in try block"
|
||||
)
|
||||
var legacySmartCastAfterTry by FreezableVar(false)
|
||||
var legacySmartCastAfterTry: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xeffect-system",
|
||||
@@ -137,11 +137,27 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var readDeserializedContracts: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xexperimental",
|
||||
valueDescription = "<fq.name>",
|
||||
description = "Enable and propagate usages of experimental API for marker annotation with the given fully qualified name"
|
||||
)
|
||||
var experimental: Array<String>? by FreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xuse-experimental",
|
||||
valueDescription = "<fq.name>",
|
||||
description = "Enable usages of COMPILATION-affecting experimental API for marker annotation with the given fully qualified name"
|
||||
)
|
||||
var useExperimental: Array<String>? by FreezableVar(null)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
put(AnalysisFlag.multiPlatformDoNotCheckActual, noCheckActual)
|
||||
put(AnalysisFlag.allowKotlinPackage, allowKotlinPackage)
|
||||
put(AnalysisFlag.experimental, experimental?.toList().orEmpty())
|
||||
put(AnalysisFlag.useExperimental, useExperimental?.toList().orEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY)
|
||||
annotation class Argument(
|
||||
val value: String,
|
||||
val shortName: String = "",
|
||||
|
||||
@@ -31,6 +31,10 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
|
||||
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = AggregatedReplStageState(compiler.createState(lock), evaluator.createState(lock), lock)
|
||||
|
||||
override fun compileAndEval(state: IReplStageState<*>, codeLine: ReplCodeLine, scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult {
|
||||
if (codeLine.code.trim().isEmpty()) {
|
||||
return ReplEvalResult.UnitResult()
|
||||
}
|
||||
|
||||
return state.lock.write {
|
||||
val aggregatedState = state.asState(AggregatedReplStageState::class.java)
|
||||
val compiled = compiler.compile(state, codeLine)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
interface="org.jetbrains.kotlin.idea.core.script.ScriptDefinitionContributor"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.scriptTemplatesProvider"
|
||||
interface="org.jetbrains.kotlin.idea.core.script.ScriptTemplatesProvider"
|
||||
interface="org.jetbrains.kotlin.script.ScriptTemplatesProvider"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.facetConfigurationExtension"
|
||||
interface="org.jetbrains.kotlin.idea.facet.KotlinFacetConfigurationExtension"/>
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.util.PsiFormatUtil
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTrackerImpl
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.sortedDiagnostics
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
@@ -33,12 +34,16 @@ import org.jetbrains.kotlin.resolve.AnalyzingUtils
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
|
||||
|
||||
class AnalyzerWithCompilerReport(private val messageCollector: MessageCollector) {
|
||||
class AnalyzerWithCompilerReport(
|
||||
private val messageCollector: MessageCollector,
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
lateinit var analysisResult: AnalysisResult
|
||||
|
||||
private fun reportIncompleteHierarchies() {
|
||||
@@ -94,6 +99,11 @@ class AnalyzerWithCompilerReport(private val messageCollector: MessageCollector)
|
||||
|
||||
fun analyzeAndReport(files: Collection<KtFile>, analyze: () -> AnalysisResult) {
|
||||
analysisResult = analyze()
|
||||
ExperimentalUsageChecker.checkCompilerArguments(
|
||||
analysisResult.moduleDescriptor, languageVersionSettings,
|
||||
reportError = { message -> messageCollector.report(ERROR, message) },
|
||||
reportWarning = { message -> messageCollector.report(WARNING, message) }
|
||||
)
|
||||
reportSyntaxErrors(files)
|
||||
reportDiagnostics(analysisResult.bindingContext.diagnostics, messageCollector)
|
||||
reportIncompleteHierarchies()
|
||||
|
||||
@@ -222,7 +222,9 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
return COMPILATION_ERROR;
|
||||
}
|
||||
|
||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(messageCollector);
|
||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
||||
messageCollector, CommonConfigurationKeysKt.getLanguageVersionSettings(configuration)
|
||||
);
|
||||
analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sourcesFiles, config));
|
||||
if (analyzerWithCompilerReport.hasErrors()) {
|
||||
return COMPILATION_ERROR;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||
import org.jetbrains.kotlin.js.resolve.getAnnotationsOnContainingJsModule
|
||||
import org.jetbrains.kotlin.load.kotlin.getJvmModuleNameForDeserializedDescriptor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
|
||||
|
||||
class CliModuleAnnotationsResolver : ModuleAnnotationsResolver {
|
||||
private val packagePartProviders = mutableListOf<PackagePartProvider>()
|
||||
|
||||
fun addPackagePartProvider(packagePartProvider: PackagePartProvider) {
|
||||
packagePartProviders += packagePartProvider
|
||||
}
|
||||
|
||||
override fun getAnnotationsOnContainingModule(descriptor: DeclarationDescriptor): List<ClassId> {
|
||||
getAnnotationsOnContainingJsModule(descriptor)?.let { return it }
|
||||
|
||||
val moduleName = getJvmModuleNameForDeserializedDescriptor(descriptor) ?: return emptyList()
|
||||
return packagePartProviders.flatMap { it.getAnnotationsOnBinaryModule(moduleName) }
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageParts
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
|
||||
import java.io.EOFException
|
||||
|
||||
@@ -31,7 +32,7 @@ class JvmPackagePartProvider(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
private val scope: GlobalSearchScope
|
||||
) : PackagePartProvider {
|
||||
private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping)
|
||||
private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping, val name: String)
|
||||
|
||||
private val deserializationConfiguration = CompilerDeserializationConfiguration(languageVersionSettings)
|
||||
|
||||
@@ -68,6 +69,12 @@ class JvmPackagePartProvider(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
|
||||
return loadedModules.mapNotNull { (_, mapping, name) ->
|
||||
if (name == moduleName) mapping.moduleData.annotations else null
|
||||
}.flatten()
|
||||
}
|
||||
|
||||
fun addRoots(roots: List<JavaRoot>) {
|
||||
for ((root, type) in roots) {
|
||||
if (type != JavaRoot.RootType.BINARY) continue
|
||||
@@ -83,7 +90,7 @@ class JvmPackagePartProvider(
|
||||
catch (e: EOFException) {
|
||||
throw RuntimeException("Error on reading package parts from $moduleFile in $root", e)
|
||||
}
|
||||
loadedModules.add(ModuleMappingInfo(root, mapping))
|
||||
loadedModules.add(ModuleMappingInfo(root, mapping, moduleFile.nameWithoutExtension))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.lang.MetaLanguage
|
||||
import com.intellij.lang.java.JavaParserDefinition
|
||||
import com.intellij.lang.jvm.facade.JvmElementProvider
|
||||
import com.intellij.lang.jvm.facade.JvmFacade
|
||||
import com.intellij.lang.jvm.facade.JvmFacadeImpl
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.TransactionGuard
|
||||
import com.intellij.openapi.application.TransactionGuardImpl
|
||||
@@ -100,6 +98,7 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
|
||||
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
|
||||
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
@@ -276,6 +275,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
return JvmPackagePartProvider(configuration.languageVersionSettings, scope).apply {
|
||||
addRoots(initialRoots)
|
||||
packagePartProviders += this
|
||||
(ModuleAnnotationsResolver.getInstance(project) as CliModuleAnnotationsResolver).addPackagePartProvider(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,6 +566,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
registerService(ScriptDependenciesProvider::class.java, CliScriptDependenciesProvider(projectEnvironment.project, scriptDefinitionProvider))
|
||||
registerService(KotlinJavaPsiFacade::class.java, KotlinJavaPsiFacade(this))
|
||||
registerService(KtLightClassForFacade.FacadeStubCache::class.java, KtLightClassForFacade.FacadeStubCache(this))
|
||||
registerService(ModuleAnnotationsResolver::class.java, CliModuleAnnotationsResolver())
|
||||
if (messageCollector != null) {
|
||||
registerService(ScriptReportSink::class.java, CliScriptReportSink(messageCollector))
|
||||
}
|
||||
|
||||
@@ -43,10 +43,7 @@ import org.jetbrains.kotlin.cli.jvm.config.*
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.javac.JavacWrapper
|
||||
@@ -364,7 +361,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
val collector = environment.messageCollector
|
||||
|
||||
val analysisStart = PerformanceCounter.currentTime()
|
||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector)
|
||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector, environment.configuration.languageVersionSettings)
|
||||
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
|
||||
val project = environment.project
|
||||
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNullTo(hashSetOf()) { module ->
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.jvm.repl.messages.unescapeLineBreaks
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
@@ -140,8 +141,12 @@ class ReplFromTerminal(
|
||||
}
|
||||
else if (split.size >= 2 && split[0] == "load") {
|
||||
val fileName = split[1]
|
||||
val scriptText = FileUtil.loadFile(File(fileName))
|
||||
eval(scriptText)
|
||||
try {
|
||||
val scriptText = FileUtil.loadFile(File(fileName))
|
||||
eval(scriptText)
|
||||
} catch (e: IOException) {
|
||||
writer.outputCompileError("Can not load script: ${e.message}")
|
||||
}
|
||||
return true
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragment.Companion.DOT_METADATA_FILE_EXTENSION
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.DataOutputStream
|
||||
import java.io.File
|
||||
@@ -62,7 +62,7 @@ open class MetadataSerializer(private val dependOnOldBuiltIns: Boolean) {
|
||||
return
|
||||
}
|
||||
|
||||
val analyzer = AnalyzerWithCompilerReport(messageCollector)
|
||||
val analyzer = AnalyzerWithCompilerReport(messageCollector, configuration.languageVersionSettings)
|
||||
analyzer.analyzeAndReport(files) {
|
||||
CommonAnalyzerFacade.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { _, content ->
|
||||
environment.createPackagePartProvider(content.moduleContentScope)
|
||||
@@ -121,11 +121,11 @@ open class MetadataSerializer(private val dependOnOldBuiltIns: Boolean) {
|
||||
}
|
||||
|
||||
val kotlinModuleFile = File(destDir, JvmCodegenUtil.getMappingFileName(JvmCodegenUtil.getModuleName(module)))
|
||||
val packageTableBytes = JvmPackageTable.PackageTable.newBuilder().apply {
|
||||
val packageTableBytes = JvmModuleProtoBuf.Module.newBuilder().apply {
|
||||
for (table in packageTable.values) {
|
||||
table.addTo(this)
|
||||
}
|
||||
}.serializeToByteArray()
|
||||
}.build().serializeToByteArray()
|
||||
|
||||
kotlinModuleFile.parentFile.mkdirs()
|
||||
kotlinModuleFile.writeBytes(packageTableBytes)
|
||||
|
||||
@@ -137,6 +137,8 @@ class CompileServiceImpl(
|
||||
private val sessions: MutableMap<Int, ClientOrSessionProxy<Any>> = hashMapOf()
|
||||
private val sessionsIdCounter = AtomicInteger(0)
|
||||
|
||||
val lastSessionId get() = sessionsIdCounter.get()
|
||||
|
||||
fun<T: Any> leaseSession(session: ClientOrSessionProxy<T>): Int = lock.write {
|
||||
val newId = getValidId(sessionsIdCounter) {
|
||||
it != CompileService.NO_SESSION && !sessions.containsKey(it)
|
||||
@@ -182,8 +184,13 @@ class CompileServiceImpl(
|
||||
|
||||
val aliveClientsCount: Int get() = clientProxies.size
|
||||
|
||||
private val _clientsCounter = AtomicInteger(0)
|
||||
|
||||
val clientsCounter get() = _clientsCounter.get()
|
||||
|
||||
fun addClient(aliveFlagPath: String?) {
|
||||
clientsLock.write {
|
||||
_clientsCounter.incrementAndGet()
|
||||
clientProxies.add(ClientOrSessionProxy(aliveFlagPath))
|
||||
}
|
||||
}
|
||||
@@ -352,70 +359,72 @@ class CompileServiceImpl(
|
||||
servicesFacade: CompilerServicesFacadeBase,
|
||||
compilationResults: CompilationResults?
|
||||
): CompileService.CallResult<Int> = ifAlive {
|
||||
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
|
||||
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
|
||||
val targetPlatform = compilationOptions.targetPlatform
|
||||
log.info("Starting compilation with args: " + compilerArguments.joinToString(" "))
|
||||
withValidClientOrSessionProxy(sessionId) {
|
||||
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
|
||||
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
|
||||
val targetPlatform = compilationOptions.targetPlatform
|
||||
log.info("Starting compilation with args: " + compilerArguments.joinToString(" "))
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val compiler = when (targetPlatform) {
|
||||
CompileService.TargetPlatform.JVM -> K2JVMCompiler()
|
||||
CompileService.TargetPlatform.JS -> K2JSCompiler()
|
||||
CompileService.TargetPlatform.METADATA -> K2MetadataCompiler()
|
||||
} as CLICompiler<CommonCompilerArguments>
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val compiler = when (targetPlatform) {
|
||||
CompileService.TargetPlatform.JVM -> K2JVMCompiler()
|
||||
CompileService.TargetPlatform.JS -> K2JSCompiler()
|
||||
CompileService.TargetPlatform.METADATA -> K2MetadataCompiler()
|
||||
} as CLICompiler<CommonCompilerArguments>
|
||||
|
||||
val k2PlatformArgs = compiler.createArguments()
|
||||
parseCommandLineArguments(compilerArguments.asList(), k2PlatformArgs)
|
||||
val argumentParseError = validateArguments(k2PlatformArgs.errors)
|
||||
if (argumentParseError != null) {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
|
||||
CompileService.CallResult.Good(ExitCode.COMPILATION_ERROR.code)
|
||||
}
|
||||
else when (compilationOptions.compilerMode) {
|
||||
CompilerMode.JPS_COMPILER -> {
|
||||
val jpsServicesFacade = servicesFacade as JpsCompilerServicesFacade
|
||||
|
||||
withIC(enabled = servicesFacade.hasIncrementalCaches()) {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
||||
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
|
||||
compiler.exec(messageCollector, services, k2PlatformArgs)
|
||||
}
|
||||
}
|
||||
val k2PlatformArgs = compiler.createArguments()
|
||||
parseCommandLineArguments(compilerArguments.asList(), k2PlatformArgs)
|
||||
val argumentParseError = validateArguments(k2PlatformArgs.errors)
|
||||
if (argumentParseError != null) {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
|
||||
CompileService.CallResult.Good(ExitCode.COMPILATION_ERROR.code)
|
||||
}
|
||||
CompilerMode.NON_INCREMENTAL_COMPILER -> {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
compiler.exec(messageCollector, Services.EMPTY, k2PlatformArgs)
|
||||
}
|
||||
}
|
||||
CompilerMode.INCREMENTAL_COMPILER -> {
|
||||
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
|
||||
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
|
||||
else when (compilationOptions.compilerMode) {
|
||||
CompilerMode.JPS_COMPILER -> {
|
||||
val jpsServicesFacade = servicesFacade as JpsCompilerServicesFacade
|
||||
|
||||
when (targetPlatform) {
|
||||
CompileService.TargetPlatform.JVM -> {
|
||||
val k2jvmArgs = k2PlatformArgs as K2JVMCompilerArguments
|
||||
|
||||
withIC {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
execIncrementalCompiler(k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
|
||||
messageCollector, daemonReporter)
|
||||
}
|
||||
withIC(enabled = servicesFacade.hasIncrementalCaches()) {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
|
||||
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
|
||||
compiler.exec(messageCollector, services, k2PlatformArgs)
|
||||
}
|
||||
}
|
||||
CompileService.TargetPlatform.JS -> {
|
||||
val k2jsArgs = k2PlatformArgs as K2JSCompilerArguments
|
||||
}
|
||||
CompilerMode.NON_INCREMENTAL_COMPILER -> {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
compiler.exec(messageCollector, Services.EMPTY, k2PlatformArgs)
|
||||
}
|
||||
}
|
||||
CompilerMode.INCREMENTAL_COMPILER -> {
|
||||
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
|
||||
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
|
||||
|
||||
withJsIC {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
execJsIncrementalCompiler(k2jsArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!, messageCollector)
|
||||
when (targetPlatform) {
|
||||
CompileService.TargetPlatform.JVM -> {
|
||||
val k2jvmArgs = k2PlatformArgs as K2JVMCompilerArguments
|
||||
|
||||
withIC {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
execIncrementalCompiler(k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
|
||||
messageCollector, daemonReporter)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
|
||||
CompileService.TargetPlatform.JS -> {
|
||||
val k2jsArgs = k2PlatformArgs as K2JSCompilerArguments
|
||||
|
||||
withJsIC {
|
||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||
execJsIncrementalCompiler(k2jsArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!, messageCollector)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
|
||||
|
||||
}
|
||||
}
|
||||
else -> throw IllegalStateException("Unknown compilation mode ${compilationOptions.compilerMode}")
|
||||
}
|
||||
else -> throw IllegalStateException("Unknown compilation mode ${compilationOptions.compilerMode}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,18 +810,23 @@ class CompileServiceImpl(
|
||||
|
||||
private fun shutdownWithDelay() {
|
||||
state.delayedShutdownQueued.set(true)
|
||||
val currentClientsCount = state.clientsCounter
|
||||
val currentSessionId = state.sessions.lastSessionId
|
||||
val currentCompilationsCount = compilationsCounter.get()
|
||||
log.info("Delayed shutdown in ${daemonOptions.shutdownDelayMilliseconds}ms")
|
||||
timer.schedule(daemonOptions.shutdownDelayMilliseconds) {
|
||||
state.delayedShutdownQueued.set(false)
|
||||
if (currentCompilationsCount == compilationsCounter.get()) {
|
||||
if (currentClientsCount == state.clientsCounter &&
|
||||
currentCompilationsCount == compilationsCounter.get() &&
|
||||
currentSessionId == state.sessions.lastSessionId)
|
||||
{
|
||||
ifAliveExclusiveUnit(minAliveness = Aliveness.LastSession) {
|
||||
log.fine("Execute delayed shutdown")
|
||||
shutdownNow()
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.info("Cancel delayed shutdown due to new client")
|
||||
log.info("Cancel delayed shutdown due to a new activity")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
|
||||
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.JvmMethodSignature
|
||||
@@ -62,8 +63,8 @@ private fun inlineAccessorsJvmNames(properties: List<ProtoBuf.Property>, nameRes
|
||||
}
|
||||
val inlineAccessors = arrayListOf<JvmMethodSignature>()
|
||||
propertiesWithInlineAccessors.forEach { proto ->
|
||||
if (proto.hasExtension(JvmProtoBuf.propertySignature)) {
|
||||
val signature = proto.getExtension(JvmProtoBuf.propertySignature)
|
||||
val signature = proto.getExtensionOrNull(JvmProtoBuf.propertySignature)
|
||||
if (signature != null) {
|
||||
if (proto.hasGetterFlags() && Flags.IS_INLINE_ACCESSOR.get(proto.getterFlags)) {
|
||||
inlineAccessors.add(signature.getter)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,9 @@ class IncrementalPackageFragmentProvider(
|
||||
|
||||
DeserializedPackageMemberScope(
|
||||
this, packageProto, nameResolver,
|
||||
JvmPackagePartSource(partName, facadeName, knownJvmBinaryClass = jvmBinaryClass),
|
||||
JvmPackagePartSource(
|
||||
partName, facadeName, packageProto, nameResolver, knownJvmBinaryClass = jvmBinaryClass
|
||||
),
|
||||
deserializationComponents, classNames = { emptyList() }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin.incremental
|
||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
@@ -42,4 +43,8 @@ class IncrementalPackagePartProvider(
|
||||
|
||||
// TODO
|
||||
override fun findMetadataPackageParts(packageFqName: String): List<String> = TODO()
|
||||
|
||||
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
|
||||
return parent.getAnnotationsOnBinaryModule(moduleName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
|
||||
fun getJvmModuleNameForDeserializedDescriptor(descriptor: DeclarationDescriptor): String? {
|
||||
val parent = DescriptorUtils.getParentOfType(descriptor, ClassOrPackageFragmentDescriptor::class.java, false)
|
||||
|
||||
when {
|
||||
parent is DeserializedClassDescriptor -> {
|
||||
val classProto = parent.classProto
|
||||
val nameResolver = parent.c.nameResolver
|
||||
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
|
||||
?.let(nameResolver::getString)
|
||||
?: JvmAbi.DEFAULT_MODULE_NAME
|
||||
}
|
||||
descriptor is DeserializedMemberDescriptor -> {
|
||||
val source = descriptor.containerSource
|
||||
if (source is JvmPackagePartSource) {
|
||||
val packageProto = source.packageProto
|
||||
val nameResolver = source.nameResolver
|
||||
return packageProto.getExtensionOrNull(JvmProtoBuf.packageModuleName)
|
||||
?.let(nameResolver::getString)
|
||||
?: JvmAbi.DEFAULT_MODULE_NAME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -70,7 +70,9 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val resolverForReferencedModule = referencedClassModule?.let { resolverForProject.tryGetResolverForModule(it as M) }
|
||||
|
||||
val resolverForModule = resolverForReferencedModule ?: run {
|
||||
val resolverForModule = resolverForReferencedModule?.takeIf {
|
||||
referencedClassModule.platform == JvmPlatform || referencedClassModule.platform == null
|
||||
} ?: run {
|
||||
// in case referenced class lies outside of our resolver, resolve the class as if it is inside our module
|
||||
// this leads to java class being resolved several times
|
||||
resolverForProject.resolverForModule(moduleInfo)
|
||||
|
||||
@@ -31,6 +31,9 @@ interface LegacyResolverWrapper
|
||||
internal class LegacyPackageDependencyResolverWrapper(
|
||||
val legacyResolver: ScriptDependenciesResolver
|
||||
) : kotlin.script.experimental.dependencies.DependenciesResolver, LegacyResolverWrapper {
|
||||
|
||||
private var previousDependencies: org.jetbrains.kotlin.script.KotlinScriptExternalDependencies? = null
|
||||
|
||||
override fun resolve(
|
||||
scriptContents: kotlin.script.dependencies.ScriptContents,
|
||||
environment: Environment
|
||||
@@ -45,7 +48,8 @@ internal class LegacyPackageDependencyResolverWrapper(
|
||||
environment,
|
||||
{ sev, msg, pos ->
|
||||
reports.add(ScriptReport(msg, sev.convertSeverity(), pos?.convertPosition()))
|
||||
}, null
|
||||
},
|
||||
previousDependencies
|
||||
).get() ?: return DependenciesResolver.ResolveResult.Failure(reports)
|
||||
|
||||
val dependencies = ScriptDependencies(
|
||||
@@ -55,6 +59,7 @@ internal class LegacyPackageDependencyResolverWrapper(
|
||||
sources = legacyDeps.sources.toList(),
|
||||
scripts = legacyDeps.scripts.toList()
|
||||
)
|
||||
previousDependencies = legacyDeps
|
||||
return DependenciesResolver.ResolveResult.Success(dependencies, reports)
|
||||
}
|
||||
|
||||
@@ -73,6 +78,9 @@ internal class ApiChangeDependencyResolverWrapper(
|
||||
) : kotlin.script.experimental.dependencies.DependenciesResolver,
|
||||
DependencyResolverWrapper<kotlin.script.dependencies.ScriptDependenciesResolver>,
|
||||
LegacyResolverWrapper {
|
||||
|
||||
private var previousDependencies: kotlin.script.dependencies.KotlinScriptExternalDependencies? = null
|
||||
|
||||
override fun resolve(
|
||||
scriptContents: kotlin.script.dependencies.ScriptContents,
|
||||
environment: Environment
|
||||
@@ -83,7 +91,8 @@ internal class ApiChangeDependencyResolverWrapper(
|
||||
environment,
|
||||
{ sev, msg, pos ->
|
||||
reports.add(ScriptReport(msg, sev.convertSeverity(), pos?.convertPosition()))
|
||||
}, null
|
||||
},
|
||||
previousDependencies
|
||||
).get() ?: return DependenciesResolver.ResolveResult.Failure(reports)
|
||||
|
||||
val dependencies = ScriptDependencies(
|
||||
@@ -93,6 +102,7 @@ internal class ApiChangeDependencyResolverWrapper(
|
||||
sources = legacyDeps.sources.toList(),
|
||||
scripts = legacyDeps.scripts.toList()
|
||||
)
|
||||
previousDependencies = legacyDeps
|
||||
return DependenciesResolver.ResolveResult.Success(dependencies, reports)
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +238,18 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, FqName> ILLEGAL_KOTLIN_VERSION_STRING_VALUE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> NEWER_VERSION_IN_SINCE_KOTLIN = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<PsiElement, FqName, Boolean> EXPERIMENTAL_API_USAGE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, FqName, Boolean> EXPERIMENTAL_API_USAGE_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, FqName, DeclarationDescriptor> EXPERIMENTAL_OVERRIDE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, FqName, DeclarationDescriptor> EXPERIMENTAL_OVERRIDE_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtAnnotationEntry> USE_EXPERIMENTAL_WITHOUT_ARGUMENTS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory1<KtAnnotationEntry, FqName> USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtAnnotationEntry, FqName> USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtAnnotationEntry, String> EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Const
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
@@ -984,6 +996,9 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_PROPERTY_ACCESS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtReturnExpression> RETURN_FOR_BUILT_IN_SUSPEND = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_WARNING = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.config.LanguageVersion;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||
@@ -33,6 +34,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
@@ -149,6 +151,27 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ILLEGAL_KOTLIN_VERSION_STRING_VALUE, "Invalid @{0} annotation value (should be ''major.minor'' or ''major.minor.patch'')", TO_STRING);
|
||||
MAP.put(NEWER_VERSION_IN_SINCE_KOTLIN, "The version is greater than the specified API version {0}", STRING);
|
||||
|
||||
RenderingContext.Key<FqName> getExperimentalFqName = new RenderingContext.Key<FqName>("getExperimentalFqName") {
|
||||
@Override
|
||||
public FqName compute(@NotNull Collection<?> objectsToRender) {
|
||||
return (FqName) CollectionsKt.first(objectsToRender);
|
||||
}
|
||||
};
|
||||
DiagnosticParameterRenderer<Boolean> renderUseExperimental = (useExperimentalAllowed, c) ->
|
||||
useExperimentalAllowed ? " or ''@UseExperimental(" + c.get(getExperimentalFqName) + "::class)''" : "";
|
||||
MAP.put(EXPERIMENTAL_API_USAGE, "This declaration is experimental and its usage should be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental);
|
||||
MAP.put(EXPERIMENTAL_API_USAGE_ERROR, "This declaration is experimental and its usage must be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental);
|
||||
|
||||
MAP.put(EXPERIMENTAL_OVERRIDE, "This declaration overrides experimental member of supertype ''{1}'' and should be annotated with ''@{0}''", TO_STRING, NAME);
|
||||
MAP.put(EXPERIMENTAL_OVERRIDE_ERROR, "This declaration overrides experimental member of supertype ''{1}'' and must be annotated with ''@{0}''", TO_STRING, NAME);
|
||||
|
||||
MAP.put(USE_EXPERIMENTAL_WITHOUT_ARGUMENTS, "@UseExperimental without any arguments has no effect");
|
||||
MAP.put(USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER, "Annotation ''{0}'' is not an experimental API marker, therefore its usage in @UseExperimental is ignored", TO_STRING);
|
||||
MAP.put(USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT,
|
||||
"Experimental annotation ''{0}'' has impact other than COMPILATION, therefore its usage in @UseExperimental is forbidden", TO_STRING);
|
||||
MAP.put(EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT, "Experimental annotation with changesMayBreak = [] is not allowed");
|
||||
MAP.put(EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET, "Experimental annotation cannot be used on the following code elements: {0}. Please remove these targets", STRING);
|
||||
|
||||
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
|
||||
MAP.put(REDUNDANT_OPEN_IN_INTERFACE, "Modifier 'open' is redundant for abstract interface members");
|
||||
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
|
||||
@@ -873,6 +896,9 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend function ''{0}'' should be called only from a coroutine or another suspend function", NAME);
|
||||
MAP.put(ILLEGAL_SUSPEND_PROPERTY_ACCESS, "Suspend property ''{0}'' should be accessed only from a coroutine or suspend function", NAME);
|
||||
MAP.put(ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
|
||||
MAP.put(NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND, "''suspend'' function can only be called in a form of modifier of a lambda: suspend { ... }");
|
||||
MAP.put(RETURN_FOR_BUILT_IN_SUSPEND, "Using implicit label for this lambda is prohibited");
|
||||
MAP.put(MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND, "Calls having a form of ''suspend {}'' are deprecated because ''suspend'' in the context will have a meaning of a modifier. Add empty argument list to the call: ''suspend() { ... }''");
|
||||
|
||||
MAP.put(PLUGIN_ERROR, "{0}", (d, c) -> d.getText());
|
||||
MAP.put(PLUGIN_WARNING, "{0}", (d, c) -> d.getText());
|
||||
|
||||
@@ -29,17 +29,12 @@ sealed class RenderingContext {
|
||||
class Impl(private val objectsToRender: Collection<Any?>) : RenderingContext() {
|
||||
private val data = linkedMapOf<Key<*>, Any?>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T> get(key: Key<T>): T {
|
||||
if (!data.containsKey(key)) {
|
||||
val result = key.compute(objectsToRender)
|
||||
data[key] = result
|
||||
return result
|
||||
}
|
||||
return data[key] as T
|
||||
return data[key] as? T ?: key.compute(objectsToRender).also { data[key] = it }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object Empty : RenderingContext() {
|
||||
override fun <T> get(key: Key<T>): T {
|
||||
return key.compute(emptyList())
|
||||
@@ -65,4 +60,4 @@ sealed class RenderingContext {
|
||||
return Impl(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbacksImpl
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
|
||||
import org.jetbrains.kotlin.resolve.lazy.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
|
||||
@@ -63,6 +64,10 @@ fun StorageComponentContainer.configureModule(
|
||||
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
||||
useImpl<SupertypeLoopCheckerImpl>()
|
||||
useImpl<KotlinResolutionStatelessCallbacksImpl>()
|
||||
|
||||
useImpl<ExperimentalUsageChecker>()
|
||||
useImpl<ExperimentalUsageChecker.Overrides>()
|
||||
useImpl<ExperimentalUsageChecker.ClassifierUsage>()
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.configureModule(
|
||||
|
||||
@@ -19,14 +19,12 @@ package org.jetbrains.kotlin.psi;
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceService;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
|
||||
|
||||
public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
|
||||
public KtElementImpl(@NotNull ASTNode node) {
|
||||
@@ -96,4 +94,10 @@ public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
|
||||
public KtElement getPsiOrParent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
PsiElement substitute = KtPsiUtilKt.getParentSubstitute(this);
|
||||
return substitute != null ? substitute : super.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -117,4 +118,10 @@ public class KtElementImplStub<T extends StubElement<?>> extends StubBasedPsiEle
|
||||
public KtElement getPsiOrParent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
PsiElement substitute = KtPsiUtilKt.getParentSubstitute(this);
|
||||
return substitute != null ? substitute : super.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
@@ -32,6 +33,9 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinStubWithFqName;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.psi.KtPsiFactoryKt.KtPsiFactory;
|
||||
|
||||
@@ -78,21 +82,32 @@ abstract class KtNamedDeclarationStub<T extends KotlinStubWithFqName<?>> extends
|
||||
return findChildByType(KtTokens.IDENTIFIER);
|
||||
}
|
||||
|
||||
private static final Set<String> FUNCTIONLIKE_CONVENTIONS = ImmutableSet.of(
|
||||
OperatorNameConventions.INVOKE.asString(),
|
||||
OperatorNameConventions.GET.asString()
|
||||
);
|
||||
|
||||
private static boolean shouldDropOperatorKeyword(String oldName, String newName) {
|
||||
return !OperatorConventions.isConventionName(Name.identifier(newName)) ||
|
||||
FUNCTIONLIKE_CONVENTIONS.contains(oldName) != FUNCTIONLIKE_CONVENTIONS.contains(newName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
PsiElement identifier = getNameIdentifier();
|
||||
if (identifier == null) return null;
|
||||
|
||||
KtModifierList modifierList = getModifierList();
|
||||
if (modifierList != null &&
|
||||
modifierList.hasModifier(KtTokens.OPERATOR_KEYWORD) &&
|
||||
!OperatorConventions.isConventionName(Name.identifier(name))) {
|
||||
removeModifier(KtTokens.OPERATOR_KEYWORD);
|
||||
if (modifierList != null && modifierList.hasModifier(KtTokens.OPERATOR_KEYWORD)) {
|
||||
if (shouldDropOperatorKeyword(getName(), name)) {
|
||||
removeModifier(KtTokens.OPERATOR_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
PsiElement newIdentifier = KtPsiFactory(this).createNameIdentifierIfPossible(name);
|
||||
PsiElement newIdentifier =
|
||||
KtPsiFactory(this).createNameIdentifierIfPossible(KtPsiUtilKt.quoteIfNeeded(name));
|
||||
if (newIdentifier != null) {
|
||||
identifier.replace(newIdentifier);
|
||||
KtPsiUtilKt.astReplace(identifier, newIdentifier);
|
||||
}
|
||||
else {
|
||||
identifier.delete();
|
||||
@@ -157,17 +172,4 @@ abstract class KtNamedDeclarationStub<T extends KotlinStubWithFqName<?>> extends
|
||||
}
|
||||
return KtNamedDeclarationUtil.getFQName(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() throws IncorrectOperationException {
|
||||
KtClassOrObject classOrObject = KtPsiUtilKt.getContainingClassOrObject(this);
|
||||
|
||||
super.delete();
|
||||
|
||||
if (classOrObject instanceof KtObjectDeclaration
|
||||
&& ((KtObjectDeclaration) classOrObject).isCompanion()
|
||||
&& classOrObject.getDeclarations().isEmpty()) {
|
||||
classOrObject.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,11 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
|
||||
}
|
||||
|
||||
fun createCompanionObject(): KtObjectDeclaration {
|
||||
return createClass("class A {\n companion object{\n}\n}").companionObjects.first()
|
||||
return createCompanionObject("companion object {\n}")
|
||||
}
|
||||
|
||||
fun createCompanionObject(text: String): KtObjectDeclaration {
|
||||
return createClass("class A {\n $text\n}").companionObjects.first()
|
||||
}
|
||||
|
||||
fun createFileAnnotation(annotationText: String): KtAnnotationEntry {
|
||||
|
||||
@@ -920,6 +920,11 @@ public class KtPsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isLabeledFunctionLiteral(@NotNull KtFunctionLiteral functionLiteral) {
|
||||
// KtFunctionLiteral -> KtLambdaExpression -> KtLabeledExpression
|
||||
return functionLiteral.getParent().getParent() instanceof KtLabeledExpression;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtExpression getLastElementDeparenthesized(
|
||||
@Nullable KtExpression expression,
|
||||
|
||||
@@ -42,11 +42,11 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
|
||||
}
|
||||
|
||||
public R visitSecondaryConstructor(@NotNull KtSecondaryConstructor constructor, D data) {
|
||||
return visitDeclaration(constructor, data);
|
||||
return visitNamedDeclaration(constructor, data);
|
||||
}
|
||||
|
||||
public R visitPrimaryConstructor(@NotNull KtPrimaryConstructor constructor, D data) {
|
||||
return visitDeclaration(constructor, data);
|
||||
return visitNamedDeclaration(constructor, data);
|
||||
}
|
||||
|
||||
public R visitNamedFunction(@NotNull KtNamedFunction function, D data) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.psi.psiUtil
|
||||
|
||||
import com.intellij.extapi.psi.StubBasedPsiElementBase
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiParameter
|
||||
@@ -27,6 +28,7 @@ import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.KotlinLexer
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -154,6 +156,9 @@ fun KtExpression.getQualifiedExpressionForReceiverOrThis(): KtExpression {
|
||||
fun KtExpression.isDotReceiver(): Boolean =
|
||||
(parent as? KtDotQualifiedExpression)?.receiverExpression == this
|
||||
|
||||
fun KtExpression.getPossiblyQualifiedCallExpression(): KtCallExpression? =
|
||||
((this as? KtQualifiedExpression)?.selectorExpression ?: this) as? KtCallExpression
|
||||
|
||||
// ---------- Block expression -------------------------------------------------------------------------------------------------------------
|
||||
|
||||
fun KtElement.blockExpressionsOrSingle(): Sequence<KtElement> =
|
||||
@@ -568,4 +573,20 @@ fun KtExpression.getLabeledParent(labelName: String): KtLabeledExpression? {
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun PsiElement.astReplace(newElement: PsiElement) = parent.node.replaceChild(node, newElement.node)
|
||||
|
||||
var KtElement.parentSubstitute: PsiElement? by UserDataProperty(Key.create<PsiElement>("PARENT_SUBSTITUTE"))
|
||||
|
||||
fun String?.isIdentifier(): Boolean {
|
||||
if (this == null || isEmpty()) return false
|
||||
|
||||
val lexer = KotlinLexer()
|
||||
lexer.start(this, 0, length)
|
||||
if (lexer.tokenType !== KtTokens.IDENTIFIER) return false
|
||||
lexer.advance()
|
||||
return lexer.tokenType == null
|
||||
}
|
||||
|
||||
fun String.quoteIfNeeded(): String = if (this.isIdentifier()) this else "`$this`"
|
||||
@@ -95,7 +95,7 @@ fun PsiElement.nextLeaf(filter: (PsiElement) -> Boolean): PsiElement? {
|
||||
}
|
||||
|
||||
fun <T : PsiElement> PsiElement.getParentOfTypesAndPredicate(
|
||||
strict: Boolean = false, vararg parentClasses: Class<T>, predicate: (T) -> Boolean
|
||||
strict: Boolean = false, vararg parentClasses: Class<out T>, predicate: (T) -> Boolean
|
||||
): T? {
|
||||
var element = if (strict) parent else this
|
||||
while (element != null) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
@@ -193,6 +194,8 @@ class AnnotationChecker(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets")
|
||||
|
||||
private fun applicableTargetSet(entry: KtAnnotationEntry, trace: BindingTrace): Set<KotlinTarget> {
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return KotlinTarget.DEFAULT_TARGET_SET
|
||||
// For descriptor with error type, all targets are considered as possible
|
||||
@@ -207,10 +210,12 @@ class AnnotationChecker(
|
||||
}
|
||||
|
||||
fun applicableTargetSet(classDescriptor: ClassDescriptor): Set<KotlinTarget>? {
|
||||
val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target)
|
||||
?: return null
|
||||
val valueArguments = targetEntryDescriptor.allValueArguments
|
||||
val valueArgument = valueArguments.entries.firstOrNull()?.value as? ArrayValue ?: return null
|
||||
val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target) ?: return null
|
||||
return loadAnnotationTargets(targetEntryDescriptor)
|
||||
}
|
||||
|
||||
fun loadAnnotationTargets(targetEntryDescriptor: AnnotationDescriptor): Set<KotlinTarget>? {
|
||||
val valueArgument = targetEntryDescriptor.allValueArguments[TARGET_ALLOWED_TARGETS] as? ArrayValue ?: return null
|
||||
return valueArgument.value.filterIsInstance<EnumValue>().mapNotNull {
|
||||
KotlinTarget.valueOrNull(it.enumEntryName.asString())
|
||||
}.toSet()
|
||||
|
||||
@@ -227,7 +227,7 @@ class LazyTopDownAnalyzer(
|
||||
|
||||
checkClassifierUsages(
|
||||
declarations, classifierUsageCheckers,
|
||||
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver)
|
||||
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver, moduleDescriptor)
|
||||
)
|
||||
|
||||
return c
|
||||
|
||||
@@ -278,8 +278,9 @@ public class ModifiersChecker {
|
||||
|
||||
|
||||
public void runDeclarationCheckers(@NotNull KtDeclaration declaration, @NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationCheckerContext context =
|
||||
new DeclarationCheckerContext(trace, languageVersionSettings, deprecationResolver, expectActualTracker);
|
||||
DeclarationCheckerContext context = new DeclarationCheckerContext(
|
||||
trace, languageVersionSettings, deprecationResolver, moduleDescriptor, expectActualTracker
|
||||
);
|
||||
for (DeclarationChecker checker : declarationCheckers) {
|
||||
checker.check(declaration, descriptor, context);
|
||||
}
|
||||
@@ -301,19 +302,22 @@ public class ModifiersChecker {
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
private final ExpectActualTracker expectActualTracker;
|
||||
private final DeprecationResolver deprecationResolver;
|
||||
private final ModuleDescriptor moduleDescriptor;
|
||||
|
||||
public ModifiersChecker(
|
||||
@NotNull AnnotationChecker annotationChecker,
|
||||
@NotNull Iterable<DeclarationChecker> declarationCheckers,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings,
|
||||
@NotNull ExpectActualTracker expectActualTracker,
|
||||
@NotNull DeprecationResolver deprecationResolver
|
||||
@NotNull DeprecationResolver deprecationResolver,
|
||||
@NotNull ModuleDescriptor moduleDescriptor
|
||||
) {
|
||||
this.annotationChecker = annotationChecker;
|
||||
this.declarationCheckers = declarationCheckers;
|
||||
this.languageVersionSettings = languageVersionSettings;
|
||||
this.expectActualTracker = expectActualTracker;
|
||||
this.deprecationResolver = deprecationResolver;
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
interface ModuleAnnotationsResolver {
|
||||
fun getAnnotationsOnContainingModule(descriptor: DeclarationDescriptor): List<ClassId>
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project): ModuleAnnotationsResolver =
|
||||
ServiceManager.getService(project, ModuleAnnotationsResolver::class.java)
|
||||
}
|
||||
}
|
||||
@@ -100,12 +100,16 @@ private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker,
|
||||
CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker, MissingDependencyClassChecker,
|
||||
CallableReferenceCompatibilityChecker(), LateinitIntrinsicApplicabilityChecker,
|
||||
UnderscoreUsageChecker, AssigningNamedArgumentToVarargChecker()
|
||||
UnderscoreUsageChecker, AssigningNamedArgumentToVarargChecker(),
|
||||
LambdaWithSuspendModifierCallChecker
|
||||
)
|
||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
|
||||
DeprecatedClassifierUsageChecker(), ApiVersionClassifierUsageChecker, MissingDependencyClassChecker.ClassifierUsage
|
||||
)
|
||||
private val DEFAULT_ANNOTATION_CHECKERS = listOf<AdditionalAnnotationChecker>(
|
||||
ExperimentalMarkerDeclarationAnnotationChecker
|
||||
)
|
||||
|
||||
|
||||
abstract class PlatformConfigurator(
|
||||
@@ -114,7 +118,7 @@ abstract class PlatformConfigurator(
|
||||
additionalCallCheckers: List<CallChecker>,
|
||||
additionalTypeCheckers: List<AdditionalTypeChecker>,
|
||||
additionalClassifierUsageCheckers: List<ClassifierUsageChecker>,
|
||||
private val additionalAnnotationCheckers: List<AdditionalAnnotationChecker>,
|
||||
additionalAnnotationCheckers: List<AdditionalAnnotationChecker>,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val overloadFilter: OverloadFilter,
|
||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
||||
@@ -127,6 +131,7 @@ abstract class PlatformConfigurator(
|
||||
private val typeCheckers: List<AdditionalTypeChecker> = DEFAULT_TYPE_CHECKERS + additionalTypeCheckers
|
||||
private val classifierUsageCheckers: List<ClassifierUsageChecker> =
|
||||
DEFAULT_CLASSIFIER_USAGE_CHECKERS + additionalClassifierUsageCheckers
|
||||
private val annotationCheckers: List<AdditionalAnnotationChecker> = DEFAULT_ANNOTATION_CHECKERS + additionalAnnotationCheckers
|
||||
|
||||
abstract fun configureModuleComponents(container: StorageComponentContainer)
|
||||
|
||||
@@ -136,7 +141,7 @@ abstract class PlatformConfigurator(
|
||||
callCheckers.forEach { useInstance(it) }
|
||||
typeCheckers.forEach { useInstance(it) }
|
||||
classifierUsageCheckers.forEach { useInstance(it) }
|
||||
additionalAnnotationCheckers.forEach { useInstance(it) }
|
||||
annotationCheckers.forEach { useInstance(it) }
|
||||
useInstance(identifierChecker)
|
||||
useInstance(overloadFilter)
|
||||
useInstance(platformToKotlinClassMap)
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.contracts.EffectSystem
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.CONSTRAINT_SYSTEM_COMPLETER
|
||||
@@ -48,7 +47,6 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -61,8 +59,7 @@ class CallCompleter(
|
||||
private val candidateResolver: CandidateResolver,
|
||||
private val dataFlowAnalyzer: DataFlowAnalyzer,
|
||||
private val callCheckers: Iterable<CallChecker>,
|
||||
private val builtIns: KotlinBuiltIns,
|
||||
private val languageVersionSettings: LanguageVersionSettings,
|
||||
private val moduleDescriptor: ModuleDescriptor,
|
||||
private val deprecationResolver: DeprecationResolver,
|
||||
private val effectSystem: EffectSystem
|
||||
) {
|
||||
@@ -90,7 +87,7 @@ class CallCompleter(
|
||||
if (calleeExpression != null && !calleeExpression.isFakeElement) calleeExpression
|
||||
else resolvedCall.call.callElement
|
||||
|
||||
val callCheckerContext = CallCheckerContext(context, languageVersionSettings, deprecationResolver)
|
||||
val callCheckerContext = CallCheckerContext(context, deprecationResolver, moduleDescriptor)
|
||||
for (callChecker in callCheckers) {
|
||||
callChecker.check(resolvedCall, reportOn, callCheckerContext)
|
||||
|
||||
@@ -205,7 +202,7 @@ class CallCompleter(
|
||||
updateSystemIfNeeded { builder ->
|
||||
val returnTypeInSystem = builder.typeInSystem(returnType)
|
||||
if (returnTypeInSystem != null) {
|
||||
builder.addSubtypeConstraint(returnTypeInSystem, builtIns.unitType, EXPECTED_TYPE_POSITION.position())
|
||||
builder.addSubtypeConstraint(returnTypeInSystem, moduleDescriptor.builtIns.unitType, EXPECTED_TYPE_POSITION.position())
|
||||
val system = builder.build()
|
||||
if (system.status.isSuccessful()) system else null
|
||||
} else null
|
||||
|
||||
@@ -185,11 +185,11 @@ class CallExpressionResolver(
|
||||
}
|
||||
|
||||
fun getCallExpressionTypeInfo(
|
||||
callExpression: KtCallExpression, receiver: ReceiverValue?,
|
||||
callOperationNode: ASTNode?, context: ExpressionTypingContext
|
||||
callExpression: KtCallExpression,
|
||||
context: ExpressionTypingContext
|
||||
): KotlinTypeInfo {
|
||||
val typeInfo = getCallExpressionTypeInfoWithoutFinalTypeCheck(
|
||||
callExpression, receiver, callOperationNode, context, context.dataFlowInfo
|
||||
callExpression, null, null, context, context.dataFlowInfo
|
||||
)
|
||||
if (context.contextDependency == INDEPENDENT) {
|
||||
dataFlowAnalyzer.checkType(typeInfo.type, callExpression, context)
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DeprecationResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
@@ -36,11 +37,11 @@ interface CallChecker {
|
||||
fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext)
|
||||
}
|
||||
|
||||
class CallCheckerContext(
|
||||
class CallCheckerContext @JvmOverloads constructor(
|
||||
val resolutionContext: ResolutionContext<*>,
|
||||
override val trace: BindingTrace,
|
||||
override val languageVersionSettings: LanguageVersionSettings,
|
||||
override val deprecationResolver: DeprecationResolver
|
||||
override val deprecationResolver: DeprecationResolver,
|
||||
override val moduleDescriptor: ModuleDescriptor,
|
||||
override val trace: BindingTrace = resolutionContext.trace
|
||||
) : CheckerContext {
|
||||
val scope: LexicalScope
|
||||
get() = resolutionContext.scope
|
||||
@@ -51,11 +52,8 @@ class CallCheckerContext(
|
||||
val isAnnotationContext: Boolean
|
||||
get() = resolutionContext.isAnnotationContext
|
||||
|
||||
constructor(
|
||||
c: ResolutionContext<*>,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
deprecationResolver: DeprecationResolver
|
||||
) : this(c, c.trace, languageVersionSettings, deprecationResolver)
|
||||
override val languageVersionSettings: LanguageVersionSettings
|
||||
get() = resolutionContext.languageVersionSettings
|
||||
}
|
||||
|
||||
// Use this utility to avoid premature computation of deferred return type of a resolved callable descriptor.
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.Call
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isCallableReference
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object LambdaWithSuspendModifierCallChecker : CallChecker {
|
||||
@JvmField
|
||||
val KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME = FqName("kotlin.suspend")
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor
|
||||
val call = resolvedCall.call
|
||||
val callName = call.referencedName()
|
||||
|
||||
if (callName != "suspend" && descriptor.name.asString() != "suspend") return
|
||||
|
||||
when (descriptor.fqNameOrNull()) {
|
||||
KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME -> {
|
||||
if (!call.hasFormOfSuspendModifierForLambda() || call.explicitReceiver != null) {
|
||||
context.trace.report(Errors.NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND.on(reportOn))
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (call.hasFormOfSuspendModifierForLambda()) {
|
||||
context.trace.report(Errors.MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND.on(reportOn))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Call.hasFormOfSuspendModifierForLambda() =
|
||||
referencedName() == "suspend"
|
||||
&& !isCallableReference()
|
||||
&& typeArguments.isEmpty()
|
||||
&& (hasNoArgumentListButDanglingLambdas() || isInfixWithRightLambda())
|
||||
|
||||
private fun Call.referencedName() =
|
||||
calleeExpression?.safeAs<KtSimpleNameExpression>()?.getReferencedName()
|
||||
|
||||
private fun Call.hasNoArgumentListButDanglingLambdas() =
|
||||
valueArgumentList?.leftParenthesis == null && functionLiteralArguments.isNotEmpty()
|
||||
|
||||
private fun Call.isInfixWithRightLambda() =
|
||||
isInfixCall(this)
|
||||
&& callElement.safeAs<KtBinaryExpression>()?.right is KtLambdaExpression
|
||||
}
|
||||
@@ -23,12 +23,15 @@ import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspensionAnnotation
|
||||
@@ -43,15 +46,28 @@ import org.jetbrains.kotlin.types.typeUtil.supertypes
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
val COROUTINE_CONTEXT_1_2_20_FQ_NAME = DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
val COROUTINE_CONTEXT_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
|
||||
fun FqName.isBuiltInCorouineContext() =
|
||||
this == COROUTINE_CONTEXT_1_2_20_FQ_NAME || this == COROUTINE_CONTEXT_FQ_NAME
|
||||
|
||||
fun FunctionDescriptor.isBuiltInCoroutineContext() =
|
||||
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe?.isBuiltInCorouineContext() == true
|
||||
|
||||
fun PropertyDescriptor.isBuiltInCoroutineContext() = this.fqNameSafe.isBuiltInCorouineContext()
|
||||
|
||||
object CoroutineSuspendCallChecker : CallChecker {
|
||||
private val ALLOWED_SCOPE_KINDS = setOf(LexicalScopeKind.FUNCTION_INNER_SCOPE, LexicalScopeKind.FUNCTION_HEADER_FOR_DESTRUCTURING)
|
||||
private val COROUTINE_CONTEXT_FQ_NAME = FqName("kotlin.coroutines.experimental.intrinsics.coroutineContext")
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor
|
||||
when (descriptor) {
|
||||
is FunctionDescriptor -> if (!descriptor.isSuspend) return
|
||||
is PropertyDescriptor -> if (descriptor.fqNameSafe != COROUTINE_CONTEXT_FQ_NAME) return
|
||||
is PropertyDescriptor -> when (descriptor.fqNameSafe) {
|
||||
COROUTINE_CONTEXT_1_2_20_FQ_NAME, COROUTINE_CONTEXT_FQ_NAME -> {}
|
||||
else -> return
|
||||
}
|
||||
else -> return
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.contracts.EffectSystem
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -59,10 +57,8 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import java.util.*
|
||||
|
||||
|
||||
class KotlinToResolvedCallTransformer(
|
||||
private val callCheckers: Iterable<CallChecker>,
|
||||
private val languageFeatureSettings: LanguageVersionSettings,
|
||||
private val dataFlowAnalyzer: DataFlowAnalyzer,
|
||||
private val argumentTypeResolver: ArgumentTypeResolver,
|
||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||
@@ -70,9 +66,8 @@ class KotlinToResolvedCallTransformer(
|
||||
private val expressionTypingServices: ExpressionTypingServices,
|
||||
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
|
||||
private val additionalDiagnosticReporter: AdditionalDiagnosticReporter,
|
||||
private val effectSystem: EffectSystem
|
||||
private val moduleDescriptor: ModuleDescriptor
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private val REPORT_MISSING_NEW_INFERENCE_DIAGNOSTIC
|
||||
get() = false
|
||||
@@ -103,9 +98,8 @@ class KotlinToResolvedCallTransformer(
|
||||
CallResolutionResult.Type.ERROR, CallResolutionResult.Type.COMPLETED -> {
|
||||
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor()
|
||||
val ktPrimitiveCompleter = ResolvedAtomCompleter(
|
||||
resultSubstitutor, context.trace, context, this,
|
||||
expressionTypingServices, argumentTypeResolver, doubleColonExpressionResolver,
|
||||
languageFeatureSettings, deprecationResolver
|
||||
resultSubstitutor, context.trace, context, this, expressionTypingServices, argumentTypeResolver,
|
||||
doubleColonExpressionResolver, deprecationResolver, moduleDescriptor
|
||||
)
|
||||
|
||||
for (subKtPrimitive in candidate.subResolvedAtoms) {
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.builtins.replaceReturnType
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
@@ -50,15 +50,14 @@ class ResolvedAtomCompleter(
|
||||
private val resultSubstitutor: NewTypeSubstitutor,
|
||||
private val trace: BindingTrace,
|
||||
private val topLevelCallContext: BasicCallResolutionContext,
|
||||
|
||||
private val kotlinToResolvedCallTransformer: KotlinToResolvedCallTransformer,
|
||||
private val expressionTypingServices: ExpressionTypingServices,
|
||||
private val argumentTypeResolver: ArgumentTypeResolver,
|
||||
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
deprecationResolver: DeprecationResolver
|
||||
deprecationResolver: DeprecationResolver,
|
||||
moduleDescriptor: ModuleDescriptor
|
||||
) {
|
||||
private val callCheckerContext = CallCheckerContext(topLevelCallContext, languageVersionSettings, deprecationResolver)
|
||||
private val callCheckerContext = CallCheckerContext(topLevelCallContext, deprecationResolver, moduleDescriptor)
|
||||
|
||||
private fun complete(resolvedAtom: ResolvedAtom) {
|
||||
when (resolvedAtom) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DeprecationResolver
|
||||
|
||||
@@ -26,4 +27,6 @@ interface CheckerContext {
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
|
||||
val deprecationResolver: DeprecationResolver
|
||||
|
||||
val moduleDescriptor: ModuleDescriptor
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ interface ClassifierUsageChecker {
|
||||
class ClassifierUsageCheckerContext(
|
||||
override val trace: BindingTrace,
|
||||
override val languageVersionSettings: LanguageVersionSettings,
|
||||
override val deprecationResolver: DeprecationResolver
|
||||
override val deprecationResolver: DeprecationResolver,
|
||||
override val moduleDescriptor: ModuleDescriptor
|
||||
) : CheckerContext
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
@@ -31,5 +32,6 @@ class DeclarationCheckerContext(
|
||||
override val trace: BindingTrace,
|
||||
override val languageVersionSettings: LanguageVersionSettings,
|
||||
override val deprecationResolver: DeprecationResolver,
|
||||
override val moduleDescriptor: ModuleDescriptor,
|
||||
val expectActualTracker: ExpectActualTracker
|
||||
) : CheckerContext
|
||||
|
||||
@@ -222,7 +222,7 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
||||
else -> true
|
||||
}
|
||||
|
||||
private fun findExpectedForActual(
|
||||
fun findExpectedForActual(
|
||||
actual: MemberDescriptor,
|
||||
commonModule: ModuleDescriptor
|
||||
): Map<Compatibility, List<MemberDescriptor>>? {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.resolve.AdditionalAnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
|
||||
object ExperimentalMarkerDeclarationAnnotationChecker : AdditionalAnnotationChecker {
|
||||
private val WRONG_TARGETS_FOR_MARKER = setOf(KotlinTarget.EXPRESSION, KotlinTarget.FILE)
|
||||
|
||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
var isAnnotatedWithExperimental = false
|
||||
|
||||
for (entry in entries) {
|
||||
val annotation = trace.bindingContext.get(BindingContext.ANNOTATION, entry)
|
||||
when (annotation?.fqName) {
|
||||
ExperimentalUsageChecker.USE_EXPERIMENTAL_FQ_NAME -> {
|
||||
val annotationClasses =
|
||||
(annotation.allValueArguments[ExperimentalUsageChecker.USE_EXPERIMENTAL_ANNOTATION_CLASS] as? ArrayValue)?.value.orEmpty()
|
||||
checkUseExperimentalUsage(annotationClasses, trace, entry)
|
||||
}
|
||||
ExperimentalUsageChecker.EXPERIMENTAL_FQ_NAME -> {
|
||||
val impact = (annotation.allValueArguments[ExperimentalUsageChecker.IMPACT] as? ArrayValue)?.value
|
||||
checkExperimentalUsage(impact, trace, entry)
|
||||
isAnnotatedWithExperimental = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isAnnotatedWithExperimental) {
|
||||
checkMarkerTargets(entries, trace)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkUseExperimentalUsage(annotationClasses: List<ConstantValue<*>>, trace: BindingTrace, entry: KtAnnotationEntry) {
|
||||
if (annotationClasses.isEmpty()) {
|
||||
trace.report(Errors.USE_EXPERIMENTAL_WITHOUT_ARGUMENTS.on(entry))
|
||||
return
|
||||
}
|
||||
|
||||
for (annotationClass in annotationClasses) {
|
||||
val classDescriptor =
|
||||
(annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor as? ClassDescriptor
|
||||
?: continue
|
||||
val experimentality = with(ExperimentalUsageChecker) {
|
||||
classDescriptor.loadExperimentalityForMarkerAnnotation()
|
||||
}
|
||||
if (experimentality == null) {
|
||||
trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER.on(entry, classDescriptor.fqNameSafe))
|
||||
} else if (!experimentality.isCompilationOnly) {
|
||||
trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT.on(entry, experimentality.annotationFqName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkExperimentalUsage(impact: List<ConstantValue<*>>?, trace: BindingTrace, entry: KtAnnotationEntry) {
|
||||
if (impact != null && impact.isEmpty()) {
|
||||
trace.report(Errors.EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT.on(entry))
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkMarkerTargets(entries: List<KtAnnotationEntry>, trace: BindingTrace) {
|
||||
val targetEntry =
|
||||
entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) }
|
||||
.entries
|
||||
.firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltIns.FQ_NAMES.target }
|
||||
?: return
|
||||
val (entry, descriptor) = targetEntry
|
||||
val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return
|
||||
val wrongTargets = allowedTargets.intersect(WRONG_TARGETS_FOR_MARKER)
|
||||
if (wrongTargets.isNotEmpty()) {
|
||||
trace.report(
|
||||
Errors.EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET.on(entry, wrongTargets.joinToString(transform = KotlinTarget::description))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.AnalysisFlag
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.utils.SmartSet
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
|
||||
|
||||
internal data class Experimentality(
|
||||
val markerDescriptor: ClassDescriptor,
|
||||
val annotationFqName: FqName,
|
||||
val severity: Severity,
|
||||
val impact: List<Impact>
|
||||
) {
|
||||
val isCompilationOnly: Boolean get() = impact.all(Impact.COMPILATION::equals)
|
||||
|
||||
enum class Severity { WARNING, ERROR }
|
||||
enum class Impact { COMPILATION, LINKAGE_OR_RUNTIME }
|
||||
|
||||
companion object {
|
||||
val DEFAULT_SEVERITY = Severity.ERROR
|
||||
val DEFAULT_IMPACT = listOf(Impact.COMPILATION, Impact.LINKAGE_OR_RUNTIME)
|
||||
}
|
||||
}
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
checkExperimental(resolvedCall.resultingDescriptor, reportOn, context, moduleAnnotationsResolver)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal val EXPERIMENTAL_FQ_NAME = FqName("kotlin.Experimental")
|
||||
internal val USE_EXPERIMENTAL_FQ_NAME = FqName("kotlin.UseExperimental")
|
||||
internal val USE_EXPERIMENTAL_ANNOTATION_CLASS = Name.identifier("markerClass")
|
||||
|
||||
private val LEVEL = Name.identifier("level")
|
||||
private val WARNING_LEVEL = Name.identifier("WARNING")
|
||||
private val ERROR_LEVEL = Name.identifier("ERROR")
|
||||
|
||||
internal val IMPACT = Name.identifier("changesMayBreak")
|
||||
private val COMPILATION_IMPACT = Name.identifier("COMPILATION")
|
||||
private val LINKAGE_IMPACT = Name.identifier("LINKAGE")
|
||||
private val RUNTIME_IMPACT = Name.identifier("RUNTIME")
|
||||
|
||||
private fun checkExperimental(
|
||||
descriptor: DeclarationDescriptor,
|
||||
element: PsiElement,
|
||||
context: CheckerContext,
|
||||
moduleAnnotationsResolver: ModuleAnnotationsResolver
|
||||
) {
|
||||
val experimentalities = descriptor.loadExperimentalities(moduleAnnotationsResolver)
|
||||
if (experimentalities.isNotEmpty()) {
|
||||
checkExperimental(
|
||||
experimentalities, element, context.trace.bindingContext, context.languageVersionSettings,
|
||||
context.moduleDescriptor
|
||||
) { experimentality, isBodyUsageOfSourceOnlyExperimentality ->
|
||||
val diagnostic = when (experimentality.severity) {
|
||||
Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_API_USAGE
|
||||
Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_API_USAGE_ERROR
|
||||
}
|
||||
context.trace.report(diagnostic.on(element, experimentality.annotationFqName, isBodyUsageOfSourceOnlyExperimentality))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkExperimental(
|
||||
experimentalities: Collection<Experimentality>,
|
||||
element: PsiElement,
|
||||
bindingContext: BindingContext,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
module: ModuleDescriptor,
|
||||
report: (experimentality: Experimentality, isBodyUsageOfCompilationExperimentality: Boolean) -> Unit
|
||||
) {
|
||||
val isBodyUsageExceptPublicInline = element.isBodyUsage(bindingContext, allowPublicInline = false)
|
||||
val isBodyUsage = isBodyUsageExceptPublicInline || element.isBodyUsage(bindingContext, allowPublicInline = true)
|
||||
|
||||
for (experimentality in experimentalities) {
|
||||
val isBodyUsageOfCompilationExperimentality =
|
||||
experimentality.isCompilationOnly && isBodyUsage
|
||||
|
||||
val isBodyUsageInSameModule =
|
||||
experimentality.markerDescriptor.module == module && isBodyUsageExceptPublicInline
|
||||
|
||||
val annotationFqName = experimentality.annotationFqName
|
||||
val isExperimentalityAccepted =
|
||||
isBodyUsageInSameModule ||
|
||||
(isBodyUsageOfCompilationExperimentality &&
|
||||
element.hasContainerAnnotatedWithUseExperimental(annotationFqName, bindingContext, languageVersionSettings)) ||
|
||||
element.propagates(annotationFqName, bindingContext, languageVersionSettings)
|
||||
|
||||
if (!isExperimentalityAccepted) {
|
||||
report(experimentality, isBodyUsageOfCompilationExperimentality)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.loadExperimentalities(
|
||||
moduleAnnotationsResolver: ModuleAnnotationsResolver
|
||||
): Set<Experimentality> {
|
||||
val result = SmartSet.create<Experimentality>()
|
||||
|
||||
for (annotation in annotations) {
|
||||
result.addIfNotNull(annotation.annotationClass?.loadExperimentalityForMarkerAnnotation())
|
||||
}
|
||||
|
||||
val container = containingDeclaration
|
||||
if (container is ClassDescriptor && this !is ConstructorDescriptor) {
|
||||
result.addAll(container.loadExperimentalities(moduleAnnotationsResolver))
|
||||
}
|
||||
|
||||
for (moduleAnnotationClassId in moduleAnnotationsResolver.getAnnotationsOnContainingModule(this)) {
|
||||
val annotationClass = module.findClassAcrossModuleDependencies(moduleAnnotationClassId)
|
||||
result.addIfNotNull(annotationClass?.loadExperimentalityForMarkerAnnotation())
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.loadExperimentalityForMarkerAnnotation(): Experimentality? {
|
||||
val experimental = annotations.findAnnotation(EXPERIMENTAL_FQ_NAME) ?: return null
|
||||
|
||||
val severity = when ((experimental.allValueArguments[LEVEL] as? EnumValue)?.enumEntryName) {
|
||||
WARNING_LEVEL -> Experimentality.Severity.WARNING
|
||||
ERROR_LEVEL -> Experimentality.Severity.ERROR
|
||||
else -> Experimentality.DEFAULT_SEVERITY
|
||||
}
|
||||
|
||||
val impact = (experimental.allValueArguments[IMPACT] as? ArrayValue)?.value?.mapNotNull { impact ->
|
||||
when ((impact as? EnumValue)?.enumEntryName) {
|
||||
COMPILATION_IMPACT -> Experimentality.Impact.COMPILATION
|
||||
LINKAGE_IMPACT, RUNTIME_IMPACT -> Experimentality.Impact.LINKAGE_OR_RUNTIME
|
||||
else -> null
|
||||
}
|
||||
} ?: Experimentality.DEFAULT_IMPACT
|
||||
|
||||
return Experimentality(this, fqNameSafe, severity, impact)
|
||||
}
|
||||
|
||||
// Returns true if this element appears in the body of some function and is not visible in any non-local declaration signature.
|
||||
// If that's the case, one can opt-in to using the corresponding experimental API by annotating this element (or any of its
|
||||
// enclosing declarations) with @UseExperimental(X::class), not requiring propagation of the experimental annotation to the call sites.
|
||||
// (Note that this is allowed only if X's impact is [COMPILATION].)
|
||||
private fun PsiElement.isBodyUsage(bindingContext: BindingContext, allowPublicInline: Boolean): Boolean {
|
||||
return anyParentMatches { element, parent ->
|
||||
element == (parent as? KtDeclarationWithBody)?.bodyExpression?.takeIf {
|
||||
allowPublicInline || !parent.isPublicInline(bindingContext)
|
||||
} ||
|
||||
element == (parent as? KtDeclarationWithInitializer)?.initializer ||
|
||||
element == (parent as? KtClassInitializer)?.body ||
|
||||
element == (parent as? KtParameter)?.defaultValue ||
|
||||
element == (parent as? KtSuperTypeCallEntry)?.valueArgumentList ||
|
||||
element == (parent as? KtDelegatedSuperTypeEntry)?.delegateExpression ||
|
||||
element == (parent as? KtPropertyDelegate)?.expression
|
||||
}
|
||||
}
|
||||
|
||||
private fun PsiElement.isPublicInline(bindingContext: BindingContext): Boolean {
|
||||
val descriptor = when (this) {
|
||||
is KtFunction -> bindingContext.get(BindingContext.FUNCTION, this)
|
||||
is KtPropertyAccessor -> bindingContext.get(BindingContext.PROPERTY_ACCESSOR, this)
|
||||
else -> null
|
||||
}
|
||||
return descriptor != null && descriptor.isInline && descriptor.effectiveVisibility().let {
|
||||
it == EffectiveVisibility.Public ||
|
||||
it == EffectiveVisibility.ProtectedBound ||
|
||||
it is EffectiveVisibility.Protected
|
||||
}
|
||||
}
|
||||
|
||||
// Checks whether any of the non-local enclosing declarations is annotated with annotationFqName, effectively requiring
|
||||
// propagation for the experimental annotation to the call sites
|
||||
private fun PsiElement.propagates(
|
||||
annotationFqName: FqName,
|
||||
bindingContext: BindingContext,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): Boolean =
|
||||
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlag.experimental) ||
|
||||
anyParentMatches { element, _ ->
|
||||
if (element is KtDeclaration) {
|
||||
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||
descriptor != null && !DescriptorUtils.isLocal(descriptor) &&
|
||||
descriptor.annotations.hasAnnotation(annotationFqName)
|
||||
} else false
|
||||
}
|
||||
|
||||
// Checks whether there's an element lexically above the tree, that is annotated with `@UseExperimental(X::class)`
|
||||
// where annotationFqName is the FQ name of X
|
||||
private fun PsiElement.hasContainerAnnotatedWithUseExperimental(
|
||||
annotationFqName: FqName,
|
||||
bindingContext: BindingContext,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): Boolean =
|
||||
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlag.useExperimental) ||
|
||||
anyParentMatches { element, _ ->
|
||||
element is KtAnnotated && element.annotationEntries.any { entry ->
|
||||
bindingContext.get(BindingContext.ANNOTATION, entry)?.isUseExperimental(annotationFqName) == true
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun PsiElement.anyParentMatches(predicate: (element: PsiElement, parent: PsiElement?) -> Boolean): Boolean {
|
||||
var element = this
|
||||
while (true) {
|
||||
val parent = element.parent
|
||||
if (predicate(element, parent)) return true
|
||||
element = parent ?: return false
|
||||
}
|
||||
}
|
||||
|
||||
private fun AnnotationDescriptor.isUseExperimental(annotationFqName: FqName): Boolean {
|
||||
if (fqName != USE_EXPERIMENTAL_FQ_NAME) return false
|
||||
|
||||
val annotationClasses = allValueArguments[USE_EXPERIMENTAL_ANNOTATION_CLASS]
|
||||
return annotationClasses is ArrayValue && annotationClasses.value.any { annotationClass ->
|
||||
(annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor?.fqNameSafe == annotationFqName
|
||||
}
|
||||
}
|
||||
|
||||
fun checkCompilerArguments(
|
||||
module: ModuleDescriptor,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
reportError: (String) -> Unit,
|
||||
reportWarning: (String) -> Unit
|
||||
) {
|
||||
// Ideally, we should run full resolution (with all classifier usage checkers) on classifiers used in "-Xexperimental" and
|
||||
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
|
||||
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
|
||||
val deprecationResolver = DeprecationResolver(LockBasedStorageManager(), languageVersionSettings)
|
||||
|
||||
fun checkAnnotation(fqName: String, allowNonCompilationImpact: Boolean): Boolean {
|
||||
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_NON_TRACKED_SCOPE)
|
||||
val experimentality = descriptor?.loadExperimentalityForMarkerAnnotation()
|
||||
val message = when {
|
||||
descriptor == null ->
|
||||
"Experimental API marker $fqName is unresolved. " +
|
||||
"Please make sure it's present in the module dependencies"
|
||||
experimentality == null ->
|
||||
"Class $fqName is not an experimental API marker annotation"
|
||||
!allowNonCompilationImpact && !experimentality.impact.all(Experimentality.Impact.COMPILATION::equals) ->
|
||||
"Experimental API marker $fqName has impact other than COMPILATION, " +
|
||||
"therefore it can't be used with -Xuse-experimental"
|
||||
else -> {
|
||||
for (deprecation in deprecationResolver.getDeprecations(descriptor)) {
|
||||
val report = when (deprecation.deprecationLevel) {
|
||||
DeprecationLevelValue.WARNING -> reportWarning
|
||||
DeprecationLevelValue.ERROR, DeprecationLevelValue.HIDDEN -> reportError
|
||||
}
|
||||
report("Experimental API marker $fqName is deprecated" + deprecation.message?.let { ". $it" }.orEmpty())
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
reportError(message)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
val validExperimental =
|
||||
languageVersionSettings.getFlag(AnalysisFlag.experimental)
|
||||
.filter { checkAnnotation(it, allowNonCompilationImpact = true) }
|
||||
val validUseExperimental =
|
||||
languageVersionSettings.getFlag(AnalysisFlag.useExperimental)
|
||||
.filter { checkAnnotation(it, allowNonCompilationImpact = false) }
|
||||
|
||||
for (fqName in validExperimental.intersect(validUseExperimental)) {
|
||||
reportError("'-Xuse-experimental=$fqName' has no effect because '-Xexperimental=$fqName' is used")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ClassifierUsage(project: Project) : ClassifierUsageChecker {
|
||||
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
|
||||
|
||||
override fun check(targetDescriptor: ClassifierDescriptor, element: PsiElement, context: ClassifierUsageCheckerContext) {
|
||||
checkExperimental(targetDescriptor, element, context, moduleAnnotationsResolver)
|
||||
}
|
||||
}
|
||||
|
||||
class Overrides(project: Project) : DeclarationChecker {
|
||||
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
|
||||
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (descriptor !is CallableMemberDescriptor) return
|
||||
|
||||
val experimentalOverridden = descriptor.overriddenDescriptors.flatMap { member ->
|
||||
member.loadExperimentalities(moduleAnnotationsResolver).map { experimentality -> experimentality to member }
|
||||
}.toMap()
|
||||
|
||||
val module = descriptor.module
|
||||
|
||||
for ((experimentality, member) in experimentalOverridden) {
|
||||
checkExperimental(
|
||||
listOf(experimentality), declaration, context.trace.bindingContext, context.languageVersionSettings, module
|
||||
) { _, _ ->
|
||||
val diagnostic = when (experimentality.severity) {
|
||||
Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_OVERRIDE
|
||||
Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_OVERRIDE_ERROR
|
||||
}
|
||||
val reportOn = (declaration as? KtNamedDeclaration)?.nameIdentifier ?: declaration
|
||||
context.trace.report(diagnostic.on(reportOn, experimentality.annotationFqName, member.containingDeclaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
@@ -200,10 +201,8 @@ class DeprecationResolver(
|
||||
descriptor.checkSinceKotlinVersionAccessibility(languageVersionSettings)
|
||||
}
|
||||
|
||||
fun getDeprecations(
|
||||
descriptor: DeclarationDescriptor
|
||||
) = deprecations(descriptor.original)
|
||||
|
||||
fun getDeprecations(descriptor: DeclarationDescriptor): List<Deprecation> =
|
||||
deprecations(descriptor.original)
|
||||
|
||||
fun isDeprecatedHidden(descriptor: DeclarationDescriptor): Boolean =
|
||||
getDeprecations(descriptor).any { it.deprecationLevel == HIDDEN }
|
||||
@@ -301,7 +300,7 @@ class DeprecationResolver(
|
||||
ProtoBuf.VersionRequirement.VersionKind.API_VERSION ->
|
||||
languageVersionSettings.apiVersion
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION ->
|
||||
ApiVersion.LATEST_STABLE
|
||||
KotlinCompilerVersion.getVersion()?.let((ApiVersion)::parse)
|
||||
else -> null
|
||||
}
|
||||
if (currentVersion != null && currentVersion < requiredVersion) {
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.types;
|
||||
@@ -24,11 +13,13 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
import org.jetbrains.kotlin.utils.DFS;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jetbrains.kotlin.types.Variance.IN_VARIANCE;
|
||||
import static org.jetbrains.kotlin.types.Variance.OUT_VARIANCE;
|
||||
@@ -147,7 +138,23 @@ public class CommonSupertypes {
|
||||
}
|
||||
commonSupertypes = computeCommonRawSupertypes(merge);
|
||||
}
|
||||
assert !commonSupertypes.isEmpty() : commonSupertypes + " <- " + types;
|
||||
|
||||
if (commonSupertypes.isEmpty()) {
|
||||
StringBuilder info = new StringBuilder();
|
||||
for (SimpleType type : types) {
|
||||
String superTypes = type.getConstructor().getSupertypes().stream()
|
||||
.map(CommonSupertypes::renderTypeFully)
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
info
|
||||
.append("Info about ").append(renderTypeFully(type)).append(": ").append('\n')
|
||||
.append("- Supertypes: ").append(superTypes).append('\n')
|
||||
.append("- DeclarationDescriptor class: ").append(classOfDeclarationDescriptor(type)).append('\n')
|
||||
.append("- TypeConstructor class: ").append(type.getConstructor().getClass()).append('\n')
|
||||
.append('\n');
|
||||
}
|
||||
throw new IllegalStateException("There is no common supertype for: " + types + " \n" + info.toString());
|
||||
}
|
||||
|
||||
// constructor of the supertype -> all of its instantiations occurring as supertypes
|
||||
Map.Entry<TypeConstructor, Set<SimpleType>> entry = commonSupertypes.entrySet().iterator().next();
|
||||
@@ -157,6 +164,21 @@ public class CommonSupertypes {
|
||||
return TypeUtils.makeNullableIfNeeded(result, nullable);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String renderTypeFully(@NotNull KotlinType type) {
|
||||
return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Class<?> classOfDeclarationDescriptor(@NotNull KotlinType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor != null) {
|
||||
return descriptor.getClass();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Raw supertypes are superclasses w/o type arguments
|
||||
// @return TypeConstructor -> all instantiations of this constructor occurring as supertypes
|
||||
@NotNull
|
||||
|
||||
@@ -713,7 +713,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@Override
|
||||
public KotlinTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext context) {
|
||||
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
|
||||
return callExpressionResolver.getCallExpressionTypeInfo(expression, null, null, context);
|
||||
return callExpressionResolver.getCallExpressionTypeInfo(expression, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -939,7 +939,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
// Call must be validated with the actual, not temporary trace in order to report operator diagnostic
|
||||
// Only unary assignment expressions (++, --) and +=/... must be checked, normal assignments have the proper trace
|
||||
CallCheckerContext callCheckerContext =
|
||||
new CallCheckerContext(context, trace, components.languageVersionSettings, components.deprecationResolver);
|
||||
new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor, trace);
|
||||
for (CallChecker checker : components.callCheckers) {
|
||||
checker.check(resolvedCall, expression, callCheckerContext);
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@NotNull
|
||||
private CallCheckerContext createCallCheckerContext(@NotNull ExpressionTypingContext context) {
|
||||
return new CallCheckerContext(context, components.languageVersionSettings, components.deprecationResolver);
|
||||
return new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||
import org.jetbrains.kotlin.resolve.ModifierCheckerCore;
|
||||
import org.jetbrains.kotlin.resolve.ModifiersChecker;
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.LambdaWithSuspendModifierCallChecker;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
@@ -55,6 +57,7 @@ import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.*;
|
||||
@@ -663,6 +666,22 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
}
|
||||
else if (labelTargetElement instanceof KtFunctionLiteral
|
||||
&& Objects.equals(expression.getLabelName(), "suspend")) {
|
||||
KtExpression callExpression = KtPsiUtil.getParentCallIfPresent((KtFunction) labelTargetElement);
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall =
|
||||
CallUtilKt.getResolvedCall(callExpression, context.trace.getBindingContext());
|
||||
|
||||
if (resolvedCall != null &&
|
||||
!KtPsiUtil.isLabeledFunctionLiteral((KtFunctionLiteral) labelTargetElement) &&
|
||||
Objects.equals(
|
||||
DescriptorUtilsKt.fqNameOrNull(resolvedCall.getResultingDescriptor()),
|
||||
LambdaWithSuspendModifierCallChecker.KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
|
||||
)
|
||||
) {
|
||||
context.trace.report(RETURN_FOR_BUILT_IN_SUSPEND.on(expression));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ sealed class KtLightFieldImpl<D : PsiField>(
|
||||
|
||||
fun lazy(
|
||||
dummyDelegate: PsiField,
|
||||
origin: LightMemberOriginForDeclaration,
|
||||
origin: LightMemberOriginForDeclaration?,
|
||||
containingClass: KtLightClass,
|
||||
computeRealDelegate: () -> PsiField
|
||||
): KtLightField {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
||||
import org.jetbrains.kotlin.asJava.classes.cannotModify
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
@@ -36,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
@@ -174,7 +176,7 @@ class KtLightAnnotationForSourceEntry(
|
||||
override fun getType(): PsiType? = delegate.type
|
||||
}
|
||||
|
||||
inner class LightStringLiteral(
|
||||
inner class LightPsiLiteral(
|
||||
delegate: PsiLiteralExpression,
|
||||
parent: PsiElement,
|
||||
valueOrigin: AnnotationValueOrigin
|
||||
@@ -201,6 +203,9 @@ class KtLightAnnotationForSourceEntry(
|
||||
wrapAnnotationValue(memberValue, this, {
|
||||
originalExpression.let { ktOrigin ->
|
||||
when {
|
||||
ktOrigin is KtCallExpression
|
||||
&& memberValue is PsiAnnotation
|
||||
&& isAnnotationConstructorCall(ktOrigin, memberValue) -> ktOrigin
|
||||
ktOrigin is KtValueArgumentList -> ktOrigin.arguments.getOrNull(i)?.getArgumentExpression()
|
||||
ktOrigin is KtCallElement -> ktOrigin.valueArguments.getOrNull(i)?.getArgumentExpression()
|
||||
ktOrigin is KtCollectionLiteralExpression -> ktOrigin.getInnerExpressions().getOrNull(i)
|
||||
@@ -225,7 +230,7 @@ class KtLightAnnotationForSourceEntry(
|
||||
|
||||
private fun wrapAnnotationValue(value: PsiAnnotationMemberValue, parent: PsiElement, ktOrigin: AnnotationValueOrigin): PsiAnnotationMemberValue =
|
||||
when {
|
||||
value is PsiLiteralExpression && value.value is String -> LightStringLiteral(value, parent, ktOrigin)
|
||||
value is PsiLiteralExpression -> LightPsiLiteral(value, parent, ktOrigin)
|
||||
value is PsiClassObjectAccessExpression -> LightClassLiteral(value, parent, ktOrigin)
|
||||
value is PsiExpression -> LightExpressionValue(value, parent, ktOrigin)
|
||||
value is PsiArrayInitializerMemberValue -> LightArrayInitializerValue(value, parent, ktOrigin)
|
||||
@@ -256,6 +261,25 @@ class KtLightAnnotationForSourceEntry(
|
||||
|
||||
override fun findDeclaredAttributeValue(name: String?) = clsDelegate.findDeclaredAttributeValue(name)?.let { wrapAnnotationValue(it) }
|
||||
|
||||
override fun getParameterList(): PsiAnnotationParameterList = KtLightAnnotationParameterList(super.getParameterList())
|
||||
|
||||
inner class KtLightAnnotationParameterList(private val list: PsiAnnotationParameterList) : KtLightElementBase(this),
|
||||
PsiAnnotationParameterList {
|
||||
override val kotlinOrigin get() = null
|
||||
override fun getAttributes(): Array<PsiNameValuePair> = list.attributes.map { KtLightPsiNameValuePair(it) }.toTypedArray()
|
||||
|
||||
inner class KtLightPsiNameValuePair(private val psiNameValuePair: PsiNameValuePair) : KtLightElementBase(this),
|
||||
PsiNameValuePair {
|
||||
override fun setValue(newValue: PsiAnnotationMemberValue): PsiAnnotationMemberValue = psiNameValuePair.setValue(newValue)
|
||||
override fun getNameIdentifier(): PsiIdentifier? = psiNameValuePair.nameIdentifier
|
||||
override fun getLiteralValue(): String? = (value as? PsiLiteralValue)?.value?.toString()
|
||||
override val kotlinOrigin: KtElement? = null
|
||||
|
||||
override fun getValue(): PsiAnnotationMemberValue? = psiNameValuePair.value?.let { wrapAnnotationValue(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun delete() = kotlinOrigin.delete()
|
||||
|
||||
override fun toString() = "@$qualifiedName"
|
||||
@@ -338,6 +362,9 @@ private fun KtElement.getResolvedCall(): ResolvedCall<out CallableDescriptor>? {
|
||||
return this.getResolvedCall(context)
|
||||
}
|
||||
|
||||
private fun isAnnotationConstructorCall(callExpression: KtCallExpression, psiAnnotation: PsiAnnotation) =
|
||||
(callExpression.getResolvedCall()?.resultingDescriptor as? ClassConstructorDescriptor)?.constructedClass?.fqNameUnsafe?.toString() == psiAnnotation.qualifiedName
|
||||
|
||||
private fun PsiElement.asKtCall(): KtCallElement? = (this as? KtElement)?.getResolvedCall()?.call?.callElement as? KtCallElement
|
||||
|
||||
private fun psiReport(psiElement: PsiElement?): String {
|
||||
|
||||
@@ -164,15 +164,31 @@ private val DEFAULT_IMPLS_CLASS_NAME = Name.identifier(JvmAbi.DEFAULT_IMPLS_CLAS
|
||||
fun FqName.defaultImplsChild() = child(DEFAULT_IMPLS_CLASS_NAME)
|
||||
|
||||
@Suppress("unused")
|
||||
fun KtAnnotationEntry.toLightAnnotation(): PsiAnnotation? {
|
||||
fun KtElement.toLightAnnotation(): PsiAnnotation? {
|
||||
val ktDeclaration = getStrictParentOfType<KtModifierList>()?.parent as? KtDeclaration ?: return null
|
||||
for (lightElement in ktDeclaration.toLightElements()) {
|
||||
if (lightElement !is PsiModifierListOwner) continue
|
||||
lightElement.modifierList?.annotations?.firstOrNull { it is KtLightAnnotationForSourceEntry && it.kotlinOrigin == this }?.let { return it }
|
||||
for (rootAnnotation in lightElement.modifierList?.annotations ?: continue) {
|
||||
for (annotation in rootAnnotation.withNestedAnnotations()) {
|
||||
if (annotation is KtLightAnnotationForSourceEntry && annotation.kotlinOrigin == this)
|
||||
return annotation
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun PsiAnnotation.withNestedAnnotations(): Sequence<PsiAnnotation> {
|
||||
fun handleValue(memberValue: PsiAnnotationMemberValue?): Sequence<PsiAnnotation> =
|
||||
when (memberValue) {
|
||||
is PsiArrayInitializerMemberValue ->
|
||||
memberValue.initializers.asSequence().flatMap { handleValue(it) }
|
||||
is PsiAnnotation -> memberValue.withNestedAnnotations()
|
||||
else -> emptySequence()
|
||||
}
|
||||
return sequenceOf(this) + parameterList.attributes.asSequence().flatMap { handleValue(it.value) }
|
||||
}
|
||||
|
||||
fun propertyNameByAccessor(name: String, accessor: KtLightMethod): String? {
|
||||
val toRename = accessor.kotlinOrigin ?: return null
|
||||
if (toRename !is KtProperty && toRename !is KtParameter) return null
|
||||
|
||||
@@ -94,7 +94,7 @@ class TowerResolver {
|
||||
name: Name
|
||||
): Collection<C> = scopeTower.run(processor, AllCandidatesCollector(), false, name)
|
||||
|
||||
fun <C : Candidate> ImplicitScopeTower.run(
|
||||
private fun <C : Candidate> ImplicitScopeTower.run(
|
||||
processor: ScopeTowerProcessor<C>,
|
||||
resultCollector: ResultCollector<C>,
|
||||
useOrder: Boolean,
|
||||
|
||||
2
compiler/testData/cli/js/jsExtraHelp.out
vendored
2
compiler/testData/cli/js/jsExtraHelp.out
vendored
@@ -7,6 +7,7 @@ where advanced options include:
|
||||
-Xcoroutines={enable|warn|error}
|
||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||
-Xeffect-system Enable experimental language feature: effect system
|
||||
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
|
||||
-Xmulti-platform Enable experimental language support for multi-platform projects
|
||||
@@ -18,6 +19,7 @@ where advanced options include:
|
||||
-Xrepeat=<count> Repeat compilation (for performance analysis)
|
||||
-Xreport-output-files Report source to output files mapping
|
||||
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
|
||||
-Xuse-experimental=<fq.name> Enable usages of COMPILATION-affecting experimental API for marker annotation with the given fully qualified name
|
||||
|
||||
Advanced options are non-standard and may be changed or removed without any notice.
|
||||
OK
|
||||
|
||||
8
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.args
vendored
Normal file
8
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.args
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
$TESTDATA_DIR$/experimentalAndUseExperimentalWithSameAnnotation.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xskip-runtime-version-check
|
||||
-language-version
|
||||
1.3
|
||||
-Xexperimental=org.test.ExperimentalAPI
|
||||
-Xuse-experimental=org.test.ExperimentalAPI
|
||||
4
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt
vendored
Normal file
4
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
package org.test
|
||||
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
|
||||
annotation class ExperimentalAPI
|
||||
3
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.out
vendored
Normal file
3
compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.out
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
|
||||
error: '-Xuse-experimental=org.test.ExperimentalAPI' has no effect because '-Xexperimental=org.test.ExperimentalAPI' is used
|
||||
COMPILATION_ERROR
|
||||
10
compiler/testData/cli/jvm/experimentalDeprecated.args
vendored
Normal file
10
compiler/testData/cli/jvm/experimentalDeprecated.args
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
$TESTDATA_DIR$/experimentalDeprecated.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xskip-runtime-version-check
|
||||
-language-version
|
||||
1.3
|
||||
-Xexperimental=org.test.BinaryError
|
||||
-Xexperimental=org.test.BinaryHidden
|
||||
-Xuse-experimental=org.test.SourceError
|
||||
-Xuse-experimental=org.test.SourceHidden
|
||||
17
compiler/testData/cli/jvm/experimentalDeprecated.kt
vendored
Normal file
17
compiler/testData/cli/jvm/experimentalDeprecated.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
package org.test
|
||||
|
||||
@Deprecated("BinaryError", level = DeprecationLevel.ERROR)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
|
||||
annotation class BinaryError
|
||||
|
||||
@Deprecated("BinaryHidden", level = DeprecationLevel.HIDDEN)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
|
||||
annotation class BinaryHidden
|
||||
|
||||
@Deprecated("SourceError", level = DeprecationLevel.ERROR)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
|
||||
annotation class SourceError
|
||||
|
||||
@Deprecated("SourceHidden", level = DeprecationLevel.HIDDEN)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
|
||||
annotation class SourceHidden
|
||||
6
compiler/testData/cli/jvm/experimentalDeprecated.out
vendored
Normal file
6
compiler/testData/cli/jvm/experimentalDeprecated.out
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
|
||||
error: experimental API marker org.test.BinaryError is deprecated. BinaryError
|
||||
error: experimental API marker org.test.BinaryHidden is deprecated. BinaryHidden
|
||||
error: experimental API marker org.test.SourceError is deprecated. SourceError
|
||||
error: experimental API marker org.test.SourceHidden is deprecated. SourceHidden
|
||||
COMPILATION_ERROR
|
||||
8
compiler/testData/cli/jvm/experimentalDeprecatedWarning.args
vendored
Normal file
8
compiler/testData/cli/jvm/experimentalDeprecatedWarning.args
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
$TESTDATA_DIR$/experimentalDeprecatedWarning.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xskip-runtime-version-check
|
||||
-language-version
|
||||
1.3
|
||||
-Xuse-experimental=org.test.SourceWarning
|
||||
-Xexperimental=org.test.BinaryWarning
|
||||
9
compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt
vendored
Normal file
9
compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.test
|
||||
|
||||
@Deprecated("BinaryWarning", level = DeprecationLevel.WARNING)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
|
||||
annotation class BinaryWarning
|
||||
|
||||
@Deprecated("SourceWarning", level = DeprecationLevel.WARNING)
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
|
||||
annotation class SourceWarning
|
||||
4
compiler/testData/cli/jvm/experimentalDeprecatedWarning.out
vendored
Normal file
4
compiler/testData/cli/jvm/experimentalDeprecatedWarning.out
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
|
||||
warning: experimental API marker org.test.BinaryWarning is deprecated. BinaryWarning
|
||||
warning: experimental API marker org.test.SourceWarning is deprecated. SourceWarning
|
||||
OK
|
||||
5
compiler/testData/cli/jvm/experimentalIsNotAnnotation.args
vendored
Normal file
5
compiler/testData/cli/jvm/experimentalIsNotAnnotation.args
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/experimentalIsNotAnnotation.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xexperimental=org.test.NotAnAnnotation1
|
||||
-Xuse-experimental=org.test.NotAnAnnotation2
|
||||
4
compiler/testData/cli/jvm/experimentalIsNotAnnotation.kt
vendored
Normal file
4
compiler/testData/cli/jvm/experimentalIsNotAnnotation.kt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
package org.test
|
||||
|
||||
enum class NotAnAnnotation1
|
||||
interface NotAnAnnotation2
|
||||
3
compiler/testData/cli/jvm/experimentalIsNotAnnotation.out
vendored
Normal file
3
compiler/testData/cli/jvm/experimentalIsNotAnnotation.out
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
error: class org.test.NotAnAnnotation1 is not an experimental API marker annotation
|
||||
error: class org.test.NotAnAnnotation2 is not an experimental API marker annotation
|
||||
COMPILATION_ERROR
|
||||
5
compiler/testData/cli/jvm/experimentalIsNotMarker.args
vendored
Normal file
5
compiler/testData/cli/jvm/experimentalIsNotMarker.args
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/experimentalIsNotMarker.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xexperimental=org.test.NotAMarker1
|
||||
-Xuse-experimental=org.test.NotAMarker2
|
||||
4
compiler/testData/cli/jvm/experimentalIsNotMarker.kt
vendored
Normal file
4
compiler/testData/cli/jvm/experimentalIsNotMarker.kt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
package org.test
|
||||
|
||||
annotation class NotAMarker1
|
||||
annotation class NotAMarker2
|
||||
3
compiler/testData/cli/jvm/experimentalIsNotMarker.out
vendored
Normal file
3
compiler/testData/cli/jvm/experimentalIsNotMarker.out
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
error: class org.test.NotAMarker1 is not an experimental API marker annotation
|
||||
error: class org.test.NotAMarker2 is not an experimental API marker annotation
|
||||
COMPILATION_ERROR
|
||||
7
compiler/testData/cli/jvm/experimentalNested.args
vendored
Normal file
7
compiler/testData/cli/jvm/experimentalNested.args
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
$TESTDATA_DIR$/experimentalNested.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xskip-runtime-version-check
|
||||
-language-version
|
||||
1.3
|
||||
-Xexperimental=org.test.Outer.Nested
|
||||
9
compiler/testData/cli/jvm/experimentalNested.kt
vendored
Normal file
9
compiler/testData/cli/jvm/experimentalNested.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.test
|
||||
|
||||
class Outer {
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.LINKAGE])
|
||||
annotation class Nested
|
||||
}
|
||||
|
||||
@Outer.Nested
|
||||
fun foo() {}
|
||||
2
compiler/testData/cli/jvm/experimentalNested.out
vendored
Normal file
2
compiler/testData/cli/jvm/experimentalNested.out
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
|
||||
OK
|
||||
8
compiler/testData/cli/jvm/experimentalRuntimeScope.args
vendored
Normal file
8
compiler/testData/cli/jvm/experimentalRuntimeScope.args
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
$TESTDATA_DIR$/experimentalRuntimeScope.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xskip-runtime-version-check
|
||||
-language-version
|
||||
1.3
|
||||
-Xexperimental=org.test.Experimental1
|
||||
-Xuse-experimental=org.test.Experimental2
|
||||
7
compiler/testData/cli/jvm/experimentalRuntimeScope.kt
vendored
Normal file
7
compiler/testData/cli/jvm/experimentalRuntimeScope.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package org.test
|
||||
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.LINKAGE])
|
||||
annotation class Experimental1
|
||||
|
||||
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
|
||||
annotation class Experimental2
|
||||
3
compiler/testData/cli/jvm/experimentalRuntimeScope.out
vendored
Normal file
3
compiler/testData/cli/jvm/experimentalRuntimeScope.out
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
|
||||
error: experimental API marker org.test.Experimental2 has impact other than COMPILATION, therefore it can't be used with -Xuse-experimental
|
||||
COMPILATION_ERROR
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user