mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-29 08:31:29 +00:00
Compare commits
329 Commits
rr/mitropo
...
v1.2.0_163
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4cdc34083 | ||
|
|
e2795def1c | ||
|
|
e92180d08a | ||
|
|
8eaec55c91 | ||
|
|
1f3131e040 | ||
|
|
0ce3a9165d | ||
|
|
dd1a2d16f5 | ||
|
|
253dc97f73 | ||
|
|
62faec694a | ||
|
|
d207ec6267 | ||
|
|
a037cea3dd | ||
|
|
1c15b3d9f9 | ||
|
|
6c5c3fe20e | ||
|
|
1d9867430f | ||
|
|
bb9edc95fb | ||
|
|
df90db8765 | ||
|
|
9b6c6210f9 | ||
|
|
0610d2e23f | ||
|
|
d86c2622e3 | ||
|
|
5486dc24a3 | ||
|
|
decf2f04bc | ||
|
|
9adec40dee | ||
|
|
46ee84c0d4 | ||
|
|
f3d337039b | ||
|
|
991a994885 | ||
|
|
fe06ab6fce | ||
|
|
a8075b3ee8 | ||
|
|
936892414e | ||
|
|
e161829322 | ||
|
|
7c8399681a | ||
|
|
601e91ae94 | ||
|
|
900bc2d747 | ||
|
|
f92f7471a5 | ||
|
|
972f550b77 | ||
|
|
9025993eb2 | ||
|
|
825e48224c | ||
|
|
cc3b18ed73 | ||
|
|
8c75dfe0ff | ||
|
|
63fb0d2489 | ||
|
|
aa34664089 | ||
|
|
8ccc8024db | ||
|
|
212736cc59 | ||
|
|
0244701be6 | ||
|
|
e2a918a539 | ||
|
|
f5d66e229f | ||
|
|
50bd6485ec | ||
|
|
44a1a1d59a | ||
|
|
392e4165a1 | ||
|
|
29fcfdf70b | ||
|
|
b58f688719 | ||
|
|
2ed970904e | ||
|
|
84b6d90003 | ||
|
|
2d1bf80afb | ||
|
|
9dca07318e | ||
|
|
ecf0bf80f4 | ||
|
|
f18f2f61d2 | ||
|
|
a33915f4cd | ||
|
|
1b8755b191 | ||
|
|
80fd99f1a7 | ||
|
|
76ee6bca39 | ||
|
|
8b8bf426f4 | ||
|
|
994c730cf3 | ||
|
|
3fd22034e6 | ||
|
|
3224c57ee6 | ||
|
|
5da6a2038d | ||
|
|
87eb263225 | ||
|
|
9735d4fc25 | ||
|
|
7f95238cd3 | ||
|
|
4a5197c28c | ||
|
|
e319e20225 | ||
|
|
79c111025b | ||
|
|
75d640fdbb | ||
|
|
d0ba7650d2 | ||
|
|
e7dd406ecf | ||
|
|
b3f2bebe69 | ||
|
|
af7d3d972b | ||
|
|
4cd557b52f | ||
|
|
e87ce68c7e | ||
|
|
19ea9f8b50 | ||
|
|
a180553749 | ||
|
|
9179f6a4bd | ||
|
|
a39b89dcff | ||
|
|
acea1d5568 | ||
|
|
8516c2f417 | ||
|
|
3bd8208f70 | ||
|
|
d50555eeef | ||
|
|
7f708c14ed | ||
|
|
2bada3f854 | ||
|
|
be7983e6e4 | ||
|
|
58101cf7ef | ||
|
|
5cd16863b0 | ||
|
|
779ac2bcc9 | ||
|
|
ce8bcf37d7 | ||
|
|
e69a417b6b | ||
|
|
2c297995fd | ||
|
|
e013120107 | ||
|
|
02cafe52c4 | ||
|
|
33c7d0c6d7 | ||
|
|
4b309f204c | ||
|
|
11874e5364 | ||
|
|
5bb76dca5d | ||
|
|
78f7ea15cb | ||
|
|
ec1ecf3afd | ||
|
|
f2867caae2 | ||
|
|
2ddfcffbd6 | ||
|
|
11f3dbae6c | ||
|
|
66c17fc25b | ||
|
|
e4870c8066 | ||
|
|
1f3a27e93a | ||
|
|
b3e4f97f31 | ||
|
|
4547eb4ef9 | ||
|
|
76e0820fc3 | ||
|
|
1d35468910 | ||
|
|
9fe34a6ae4 | ||
|
|
b67aca628f | ||
|
|
c140117233 | ||
|
|
c46aeefa3b | ||
|
|
5f575e5361 | ||
|
|
206b0d4c7a | ||
|
|
f5bcef7ae5 | ||
|
|
e34a6fd6ce | ||
|
|
2705effc4d | ||
|
|
df31a44af8 | ||
|
|
8097d2c864 | ||
|
|
041fac9920 | ||
|
|
5ac0c0221d | ||
|
|
d4f6f092d3 | ||
|
|
1cfed4558d | ||
|
|
e0fcd4debd | ||
|
|
418838bef7 | ||
|
|
41a21ee0fb | ||
|
|
7ab192b543 | ||
|
|
2fb868af66 | ||
|
|
47976fddfc | ||
|
|
99e98af4d1 | ||
|
|
e7b58d12fb | ||
|
|
be1c2d15b9 | ||
|
|
c4f33b18e7 | ||
|
|
b8996eee33 | ||
|
|
326d065860 | ||
|
|
eb2c81ba80 | ||
|
|
b9eed1f364 | ||
|
|
a717b26b95 | ||
|
|
4d29b78346 | ||
|
|
b852e7b79d | ||
|
|
66f46df5ad | ||
|
|
f811a9c3c7 | ||
|
|
772803a966 | ||
|
|
cef1e31de9 | ||
|
|
c9199b7c0b | ||
|
|
5ab718d00d | ||
|
|
8be542cadd | ||
|
|
a343357e9b | ||
|
|
092efea7f6 | ||
|
|
29934000ab | ||
|
|
194c29d639 | ||
|
|
4172a5e4ae | ||
|
|
979cfb3c89 | ||
|
|
d908b591e4 | ||
|
|
253bba46d8 | ||
|
|
182129b773 | ||
|
|
69d89b1434 | ||
|
|
c658be73ca | ||
|
|
6c45aa053c | ||
|
|
ca42f877b7 | ||
|
|
f28e2cce7a | ||
|
|
b989462b00 | ||
|
|
da379047f4 | ||
|
|
c3e1019f80 | ||
|
|
b757db523f | ||
|
|
ae5133a95b | ||
|
|
12f31475ff | ||
|
|
58a2e192d8 | ||
|
|
7c7d4db79a | ||
|
|
9dc8dad252 | ||
|
|
1448aa8546 | ||
|
|
e60947c2cc | ||
|
|
ec0897810e | ||
|
|
26d88be96d | ||
|
|
6cc1e71b5e | ||
|
|
a17cdeeba2 | ||
|
|
fc9516ddf4 | ||
|
|
7516667d7e | ||
|
|
3afd09f97d | ||
|
|
9bfc3402fe | ||
|
|
fb39961b95 | ||
|
|
9a771d38c4 | ||
|
|
aa3fd0db18 | ||
|
|
a284fdf329 | ||
|
|
38cd527050 | ||
|
|
977da95aee | ||
|
|
9f2dbb05c0 | ||
|
|
4286cceda8 | ||
|
|
c4b33b0822 | ||
|
|
54fe95f5d5 | ||
|
|
40a098f239 | ||
|
|
dcf3039f01 | ||
|
|
c88f3a9c08 | ||
|
|
66550e1bf5 | ||
|
|
98f83be9b2 | ||
|
|
f005b45233 | ||
|
|
e7f648653d | ||
|
|
9464b10ace | ||
|
|
a4d81ba206 | ||
|
|
b6bc8eb28d | ||
|
|
4ae5a14e52 | ||
|
|
91891fc213 | ||
|
|
2f7110d91b | ||
|
|
41ca822170 | ||
|
|
0cfa11f98f | ||
|
|
bfcb4a5ee4 | ||
|
|
11f17519b4 | ||
|
|
576f85032f | ||
|
|
e382182b87 | ||
|
|
9be7c63a56 | ||
|
|
de9448ff00 | ||
|
|
a4eccab182 | ||
|
|
20fca3e731 | ||
|
|
b283544cbe | ||
|
|
8dddfc5390 | ||
|
|
c05f2581dc | ||
|
|
db28e34996 | ||
|
|
416470d901 | ||
|
|
ef76ab47af | ||
|
|
52ea816d9c | ||
|
|
1c690ee27c | ||
|
|
f197f36e23 | ||
|
|
a0d4f81931 | ||
|
|
59a644e04a | ||
|
|
f0afa9d9be | ||
|
|
ef5bf215bf | ||
|
|
06fb3f6ade | ||
|
|
2518a61702 | ||
|
|
b7cc8b2627 | ||
|
|
0f07e7dc04 | ||
|
|
7145007c77 | ||
|
|
d95d56838b | ||
|
|
3fcbb4307f | ||
|
|
22de8cac5e | ||
|
|
ed7b563cb7 | ||
|
|
32c555fbe3 | ||
|
|
e1f3b4c2de | ||
|
|
cf445ab977 | ||
|
|
22604abfc7 | ||
|
|
c394037339 | ||
|
|
55209fd60f | ||
|
|
32de211e88 | ||
|
|
7c3d079eeb | ||
|
|
afd83dc86e | ||
|
|
79925cfe2f | ||
|
|
99ab812cee | ||
|
|
1506a72fc3 | ||
|
|
66bc20ccf9 | ||
|
|
292800c295 | ||
|
|
fa18ac4690 | ||
|
|
4e01178e7b | ||
|
|
7b0f1eadd3 | ||
|
|
65d4ea40f4 | ||
|
|
7af997424f | ||
|
|
881316d2af | ||
|
|
2181290c64 | ||
|
|
6f82d464c1 | ||
|
|
c6d232a16e | ||
|
|
edca38584e | ||
|
|
73cf115bd7 | ||
|
|
e308dd02d8 | ||
|
|
2058b5d750 | ||
|
|
a284f9d28b | ||
|
|
85e3cded24 | ||
|
|
d6d785c2bf | ||
|
|
8c751b402f | ||
|
|
7124c690c6 | ||
|
|
7dcb68bccd | ||
|
|
059133ea06 | ||
|
|
766ba407fd | ||
|
|
200fd2852e | ||
|
|
3000ee65b4 | ||
|
|
f9a8113d1b | ||
|
|
c40572548f | ||
|
|
1142cb1486 | ||
|
|
9a1681087f | ||
|
|
09ead0edad | ||
|
|
97616416dc | ||
|
|
55e8e84063 | ||
|
|
216bdcbd41 | ||
|
|
f2628d4f70 | ||
|
|
97399b99ee | ||
|
|
71867c4b73 | ||
|
|
f9449308d7 | ||
|
|
478611eb52 | ||
|
|
64e1c88ac1 | ||
|
|
06cb9127f4 | ||
|
|
0d80bcc8cf | ||
|
|
db0d95eea8 | ||
|
|
fd839dcb05 | ||
|
|
81f53bb1e5 | ||
|
|
88f061c152 | ||
|
|
8a3a4df93a | ||
|
|
2f1d4c15c9 | ||
|
|
4c3b9d58fb | ||
|
|
46b005bafc | ||
|
|
5d4d444f97 | ||
|
|
7a5051128a | ||
|
|
fa2d276718 | ||
|
|
7b873eb8ce | ||
|
|
979c7c06ef | ||
|
|
6e0e4a634e | ||
|
|
c7bc8b280c | ||
|
|
d363f5be7e | ||
|
|
e8b944ebbf | ||
|
|
ead2cb374a | ||
|
|
ba040ebd61 | ||
|
|
f3921a3d24 | ||
|
|
2d50bef4f7 | ||
|
|
323ec39ac6 | ||
|
|
acb2850260 | ||
|
|
0da4bf4c08 | ||
|
|
765fe92165 | ||
|
|
ed4f3d3bf6 | ||
|
|
7e49e17ce5 | ||
|
|
5052ae5cf8 | ||
|
|
24e218afc8 | ||
|
|
ab6360a7d5 | ||
|
|
058b832b71 | ||
|
|
b460b89df5 | ||
|
|
c7253584c5 | ||
|
|
c4e4298eac | ||
|
|
e4b4475235 | ||
|
|
7cddd345f8 |
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -6,6 +6,7 @@
|
||||
</properties>
|
||||
</component>
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="javax.inject.Inject" />
|
||||
</list>
|
||||
|
||||
3794
ChangeLog.md
3794
ChangeLog.md
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
|
||||
@@ -58,18 +59,23 @@ data class JvmBuildMetaInfo(
|
||||
}
|
||||
}
|
||||
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo =
|
||||
JvmBuildMetaInfo(isEAP = KotlinCompilerVersion.isPreRelease(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = args.languageVersion ?: LanguageVersion.LATEST_STABLE.versionString,
|
||||
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch)
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo {
|
||||
val languageVersion = args.languageVersion?.let((LanguageVersion)::fromVersionString) ?: LanguageVersion.LATEST_STABLE
|
||||
|
||||
return JvmBuildMetaInfo(
|
||||
isEAP = languageVersion.shouldWritePreReleaseFlag(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = languageVersion.versionString,
|
||||
apiVersionString = args.apiVersion ?: languageVersion.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch
|
||||
)
|
||||
}
|
||||
|
||||
@@ -287,7 +287,9 @@ open class IncrementalJvmCache(
|
||||
fun remove(className: JvmClassName, changesCollector: ChangesCollector) {
|
||||
val key = className.internalName
|
||||
val oldValue = storage[key] ?: return
|
||||
changesCollector.collectProtoChanges(oldData = oldValue.toProtoData(className.packageFqName), newData = null)
|
||||
if (key != MODULE_MAPPING_FILE_NAME) {
|
||||
changesCollector.collectProtoChanges(oldData = oldValue.toProtoData(className.packageFqName), newData = null)
|
||||
}
|
||||
storage.remove(key)
|
||||
}
|
||||
|
||||
|
||||
@@ -44837,6 +44837,19 @@ public final class DebugJsAstProtoBuf {
|
||||
*/
|
||||
int getSuperNameId();
|
||||
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
java.util.List<java.lang.Integer> getInterfaceNameIdList();
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
int getInterfaceNameIdCount();
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
int getInterfaceNameId(int index);
|
||||
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.js.ast.GlobalBlock post_declaration_block = 3;</code>
|
||||
*/
|
||||
@@ -44925,6 +44938,27 @@ public final class DebugJsAstProtoBuf {
|
||||
bitField0_ |= 0x00000004;
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
interfaceNameId_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
mutable_bitField0_ |= 0x00000004;
|
||||
}
|
||||
interfaceNameId_.add(input.readInt32());
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
int length = input.readRawVarint32();
|
||||
int limit = input.pushLimit(length);
|
||||
if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) {
|
||||
interfaceNameId_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
mutable_bitField0_ |= 0x00000004;
|
||||
}
|
||||
while (input.getBytesUntilLimit() > 0) {
|
||||
interfaceNameId_.add(input.readInt32());
|
||||
}
|
||||
input.popLimit(limit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
@@ -44933,6 +44967,9 @@ public final class DebugJsAstProtoBuf {
|
||||
throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
interfaceNameId_ = java.util.Collections.unmodifiableList(interfaceNameId_);
|
||||
}
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
@@ -44995,6 +45032,28 @@ public final class DebugJsAstProtoBuf {
|
||||
return superNameId_;
|
||||
}
|
||||
|
||||
public static final int INTERFACE_NAME_ID_FIELD_NUMBER = 4;
|
||||
private java.util.List<java.lang.Integer> interfaceNameId_;
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public java.util.List<java.lang.Integer>
|
||||
getInterfaceNameIdList() {
|
||||
return interfaceNameId_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public int getInterfaceNameIdCount() {
|
||||
return interfaceNameId_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public int getInterfaceNameId(int index) {
|
||||
return interfaceNameId_.get(index);
|
||||
}
|
||||
|
||||
public static final int POST_DECLARATION_BLOCK_FIELD_NUMBER = 3;
|
||||
private org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock postDeclarationBlock_;
|
||||
/**
|
||||
@@ -45019,6 +45078,7 @@ public final class DebugJsAstProtoBuf {
|
||||
private void initFields() {
|
||||
nameId_ = 0;
|
||||
superNameId_ = 0;
|
||||
interfaceNameId_ = java.util.Collections.emptyList();
|
||||
postDeclarationBlock_ = org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.getDefaultInstance();
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@@ -45053,6 +45113,9 @@ public final class DebugJsAstProtoBuf {
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
output.writeMessage(3, postDeclarationBlock_);
|
||||
}
|
||||
for (int i = 0; i < interfaceNameId_.size(); i++) {
|
||||
output.writeInt32(4, interfaceNameId_.get(i));
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
@@ -45074,6 +45137,15 @@ public final class DebugJsAstProtoBuf {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(3, postDeclarationBlock_);
|
||||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (int i = 0; i < interfaceNameId_.size(); i++) {
|
||||
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32SizeNoTag(interfaceNameId_.get(i));
|
||||
}
|
||||
size += dataSize;
|
||||
size += 1 * getInterfaceNameIdList().size();
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
@@ -45196,12 +45268,14 @@ public final class DebugJsAstProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
superNameId_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
interfaceNameId_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
if (postDeclarationBlockBuilder_ == null) {
|
||||
postDeclarationBlock_ = org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.getDefaultInstance();
|
||||
} else {
|
||||
postDeclarationBlockBuilder_.clear();
|
||||
}
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -45238,7 +45312,12 @@ public final class DebugJsAstProtoBuf {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.superNameId_ = superNameId_;
|
||||
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
interfaceNameId_ = java.util.Collections.unmodifiableList(interfaceNameId_);
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
}
|
||||
result.interfaceNameId_ = interfaceNameId_;
|
||||
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
to_bitField0_ |= 0x00000004;
|
||||
}
|
||||
if (postDeclarationBlockBuilder_ == null) {
|
||||
@@ -45268,6 +45347,16 @@ public final class DebugJsAstProtoBuf {
|
||||
if (other.hasSuperNameId()) {
|
||||
setSuperNameId(other.getSuperNameId());
|
||||
}
|
||||
if (!other.interfaceNameId_.isEmpty()) {
|
||||
if (interfaceNameId_.isEmpty()) {
|
||||
interfaceNameId_ = other.interfaceNameId_;
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
} else {
|
||||
ensureInterfaceNameIdIsMutable();
|
||||
interfaceNameId_.addAll(other.interfaceNameId_);
|
||||
}
|
||||
onChanged();
|
||||
}
|
||||
if (other.hasPostDeclarationBlock()) {
|
||||
mergePostDeclarationBlock(other.getPostDeclarationBlock());
|
||||
}
|
||||
@@ -45372,6 +45461,72 @@ public final class DebugJsAstProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
private java.util.List<java.lang.Integer> interfaceNameId_ = java.util.Collections.emptyList();
|
||||
private void ensureInterfaceNameIdIsMutable() {
|
||||
if (!((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
interfaceNameId_ = new java.util.ArrayList<java.lang.Integer>(interfaceNameId_);
|
||||
bitField0_ |= 0x00000004;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public java.util.List<java.lang.Integer>
|
||||
getInterfaceNameIdList() {
|
||||
return java.util.Collections.unmodifiableList(interfaceNameId_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public int getInterfaceNameIdCount() {
|
||||
return interfaceNameId_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public int getInterfaceNameId(int index) {
|
||||
return interfaceNameId_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public Builder setInterfaceNameId(
|
||||
int index, int value) {
|
||||
ensureInterfaceNameIdIsMutable();
|
||||
interfaceNameId_.set(index, value);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public Builder addInterfaceNameId(int value) {
|
||||
ensureInterfaceNameIdIsMutable();
|
||||
interfaceNameId_.add(value);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public Builder addAllInterfaceNameId(
|
||||
java.lang.Iterable<? extends java.lang.Integer> values) {
|
||||
ensureInterfaceNameIdIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
values, interfaceNameId_);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated int32 interface_name_id = 4;</code>
|
||||
*/
|
||||
public Builder clearInterfaceNameId() {
|
||||
interfaceNameId_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
private org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock postDeclarationBlock_ = org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.getDefaultInstance();
|
||||
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
|
||||
org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock, org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.Builder, org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlockOrBuilder> postDeclarationBlockBuilder_;
|
||||
@@ -45379,7 +45534,7 @@ public final class DebugJsAstProtoBuf {
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.js.ast.GlobalBlock post_declaration_block = 3;</code>
|
||||
*/
|
||||
public boolean hasPostDeclarationBlock() {
|
||||
return ((bitField0_ & 0x00000004) == 0x00000004);
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.js.ast.GlobalBlock post_declaration_block = 3;</code>
|
||||
@@ -45404,7 +45559,7 @@ public final class DebugJsAstProtoBuf {
|
||||
} else {
|
||||
postDeclarationBlockBuilder_.setMessage(value);
|
||||
}
|
||||
bitField0_ |= 0x00000004;
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@@ -45418,7 +45573,7 @@ public final class DebugJsAstProtoBuf {
|
||||
} else {
|
||||
postDeclarationBlockBuilder_.setMessage(builderForValue.build());
|
||||
}
|
||||
bitField0_ |= 0x00000004;
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@@ -45426,7 +45581,7 @@ public final class DebugJsAstProtoBuf {
|
||||
*/
|
||||
public Builder mergePostDeclarationBlock(org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock value) {
|
||||
if (postDeclarationBlockBuilder_ == null) {
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004) &&
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008) &&
|
||||
postDeclarationBlock_ != org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.getDefaultInstance()) {
|
||||
postDeclarationBlock_ =
|
||||
org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.newBuilder(postDeclarationBlock_).mergeFrom(value).buildPartial();
|
||||
@@ -45437,7 +45592,7 @@ public final class DebugJsAstProtoBuf {
|
||||
} else {
|
||||
postDeclarationBlockBuilder_.mergeFrom(value);
|
||||
}
|
||||
bitField0_ |= 0x00000004;
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@@ -45450,14 +45605,14 @@ public final class DebugJsAstProtoBuf {
|
||||
} else {
|
||||
postDeclarationBlockBuilder_.clear();
|
||||
}
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.js.ast.GlobalBlock post_declaration_block = 3;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.GlobalBlock.Builder getPostDeclarationBlockBuilder() {
|
||||
bitField0_ |= 0x00000004;
|
||||
bitField0_ |= 0x00000008;
|
||||
onChanged();
|
||||
return getPostDeclarationBlockFieldBuilder().getBuilder();
|
||||
}
|
||||
@@ -49376,33 +49531,34 @@ public final class DebugJsAstProtoBuf {
|
||||
"expression\030\002 \002(\01325.org.jetbrains.kotlin." +
|
||||
"serialization.js.ast.Expression\"3\n\013NameB" +
|
||||
"inding\022\024\n\014signature_id\030\001 \002(\005\022\016\n\006nameId\030\002" +
|
||||
" \002(\005\"\214\001\n\nClassModel\022\017\n\007name_id\030\001 \002(\005\022\025\n\r" +
|
||||
"super_name_id\030\002 \001(\005\022V\n\026post_declaration_" +
|
||||
"block\030\003 \001(\01326.org.jetbrains.kotlin.seria" +
|
||||
"lization.js.ast.GlobalBlock\";\n\014InlineMod" +
|
||||
"ule\022\024\n\014signature_id\030\001 \002(\005\022\025\n\rexpression_" +
|
||||
"id\030\002 \002(\005\"\034\n\013StringTable\022\r\n\005entry\030\001 \003(\t\"K" +
|
||||
"\n\tNameTable\022>\n\005entry\030\001 \003(\0132/.org.jetbrai",
|
||||
"ns.kotlin.serialization.js.ast.Name\"\263\001\n\004" +
|
||||
"Name\022\021\n\ttemporary\030\001 \002(\010\022\022\n\nidentifier\030\002 " +
|
||||
"\001(\005\022\025\n\rlocal_name_id\030\003 \001(\005\022\027\n\010imported\030\004" +
|
||||
" \001(\010:\005false\022T\n\020special_function\030\005 \001(\0162:." +
|
||||
"org.jetbrains.kotlin.serialization.js.as" +
|
||||
"t.SpecialFunction\"\346\001\n\005Chunk\022L\n\014string_ta" +
|
||||
"ble\030\001 \002(\01326.org.jetbrains.kotlin.seriali" +
|
||||
"zation.js.ast.StringTable\022H\n\nname_table\030" +
|
||||
"\002 \002(\01324.org.jetbrains.kotlin.serializati" +
|
||||
"on.js.ast.NameTable\022E\n\010fragment\030\003 \002(\01323.",
|
||||
"org.jetbrains.kotlin.serialization.js.as" +
|
||||
"t.Fragment*@\n\013SideEffects\022\021\n\rAFFECTS_STA" +
|
||||
"TE\020\001\022\024\n\020DEPENDS_ON_STATE\020\002\022\010\n\004PURE\020\003*?\n\016" +
|
||||
"InlineStrategy\022\017\n\013AS_FUNCTION\020\000\022\014\n\010IN_PL" +
|
||||
"ACE\020\001\022\016\n\nNOT_INLINE\020\002*\275\001\n\017SpecialFunctio" +
|
||||
"n\022\032\n\026DEFINE_INLINE_FUNCTION\020\001\022\021\n\rWRAP_FU" +
|
||||
"NCTION\020\002\022\021\n\rTO_BOXED_CHAR\020\003\022\016\n\nUNBOX_CHA" +
|
||||
"R\020\004\022\020\n\014SUSPEND_CALL\020\005\022\024\n\020COROUTINE_RESUL" +
|
||||
"T\020\006\022\030\n\024COROUTINE_CONTROLLER\020\007\022\026\n\022COROUTI" +
|
||||
"NE_RECEIVER\020\010B\024B\022DebugJsAstProtoBuf"
|
||||
" \002(\005\"\247\001\n\nClassModel\022\017\n\007name_id\030\001 \002(\005\022\025\n\r" +
|
||||
"super_name_id\030\002 \001(\005\022\031\n\021interface_name_id" +
|
||||
"\030\004 \003(\005\022V\n\026post_declaration_block\030\003 \001(\01326" +
|
||||
".org.jetbrains.kotlin.serialization.js.a" +
|
||||
"st.GlobalBlock\";\n\014InlineModule\022\024\n\014signat" +
|
||||
"ure_id\030\001 \002(\005\022\025\n\rexpression_id\030\002 \002(\005\"\034\n\013S" +
|
||||
"tringTable\022\r\n\005entry\030\001 \003(\t\"K\n\tNameTable\022>",
|
||||
"\n\005entry\030\001 \003(\0132/.org.jetbrains.kotlin.ser" +
|
||||
"ialization.js.ast.Name\"\263\001\n\004Name\022\021\n\ttempo" +
|
||||
"rary\030\001 \002(\010\022\022\n\nidentifier\030\002 \001(\005\022\025\n\rlocal_" +
|
||||
"name_id\030\003 \001(\005\022\027\n\010imported\030\004 \001(\010:\005false\022T" +
|
||||
"\n\020special_function\030\005 \001(\0162:.org.jetbrains" +
|
||||
".kotlin.serialization.js.ast.SpecialFunc" +
|
||||
"tion\"\346\001\n\005Chunk\022L\n\014string_table\030\001 \002(\01326.o" +
|
||||
"rg.jetbrains.kotlin.serialization.js.ast" +
|
||||
".StringTable\022H\n\nname_table\030\002 \002(\01324.org.j" +
|
||||
"etbrains.kotlin.serialization.js.ast.Nam",
|
||||
"eTable\022E\n\010fragment\030\003 \002(\01323.org.jetbrains" +
|
||||
".kotlin.serialization.js.ast.Fragment*@\n" +
|
||||
"\013SideEffects\022\021\n\rAFFECTS_STATE\020\001\022\024\n\020DEPEN" +
|
||||
"DS_ON_STATE\020\002\022\010\n\004PURE\020\003*?\n\016InlineStrateg" +
|
||||
"y\022\017\n\013AS_FUNCTION\020\000\022\014\n\010IN_PLACE\020\001\022\016\n\nNOT_" +
|
||||
"INLINE\020\002*\275\001\n\017SpecialFunction\022\032\n\026DEFINE_I" +
|
||||
"NLINE_FUNCTION\020\001\022\021\n\rWRAP_FUNCTION\020\002\022\021\n\rT" +
|
||||
"O_BOXED_CHAR\020\003\022\016\n\nUNBOX_CHAR\020\004\022\020\n\014SUSPEN" +
|
||||
"D_CALL\020\005\022\024\n\020COROUTINE_RESULT\020\006\022\030\n\024COROUT" +
|
||||
"INE_CONTROLLER\020\007\022\026\n\022COROUTINE_RECEIVER\020\010",
|
||||
"B\024B\022DebugJsAstProtoBuf"
|
||||
};
|
||||
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
@@ -49715,7 +49871,7 @@ public final class DebugJsAstProtoBuf {
|
||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_ClassModel_fieldAccessorTable = new
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_ClassModel_descriptor,
|
||||
new java.lang.String[] { "NameId", "SuperNameId", "PostDeclarationBlock", });
|
||||
new java.lang.String[] { "NameId", "SuperNameId", "InterfaceNameId", "PostDeclarationBlock", });
|
||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_InlineModule_descriptor =
|
||||
getDescriptor().getMessageTypes().get(50);
|
||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_InlineModule_fieldAccessorTable = new
|
||||
|
||||
@@ -117,7 +117,7 @@ extra["versions.ant"] = "1.8.2"
|
||||
extra["versions.android"] = "2.3.1"
|
||||
|
||||
extra["ideaCoreSdkJars"] = arrayOf("annotations", "asm-all", "guava", "intellij-core", "jdom", "jna", "log4j", "picocontainer",
|
||||
"snappy-in-java", "streamex", "trove4j", "xpp3-1.1.4-min", "xstream")
|
||||
"snappy-in-java", "trove4j", "xpp3-1.1.4-min", "xstream")
|
||||
|
||||
extra["compilerModules"] = arrayOf(":compiler:util",
|
||||
":compiler:container",
|
||||
@@ -478,7 +478,9 @@ fun jdkPath(version: String): String = jdkPathIfFound(version)
|
||||
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.isFork = true
|
||||
options.forkOptions.javaHome = file(javaHome)
|
||||
options.compilerArgs.add("-proc:none")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<property environment="env"/>
|
||||
<property name="tools.jar" value="${env.JDK_18}/lib/tools.jar"/>
|
||||
|
||||
<property name="java.target" value="1.8"/>
|
||||
<property name="java.target" value="1.6"/>
|
||||
|
||||
<condition property="bootstrap.or.local.build" value="true" else="false">
|
||||
<or>
|
||||
@@ -387,20 +387,19 @@
|
||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/annotations.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/asm-all.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/guava-21.0.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/guava-19.0.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/intellij-core.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/jdom.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/jna.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/log4j.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/picocontainer.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/snappy-in-java-0.5.1.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/streamex-0.6.2.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/trove4j.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/xpp3-1.1.4-min.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/xstream-1.4.8.jar"/>
|
||||
<zipfileset src="${idea.sdk}/lib/jna-platform.jar"/>
|
||||
<zipfileset src="${idea.sdk}/lib/oromatcher.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${idea.sdk}/jps/jps-model.jar" excludes="META-INF/services/**"/>
|
||||
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
|
||||
<zipfileset src="${dependencies}/jline3.jar"/>
|
||||
<zipfileset src="${dependencies}/jansi.jar"/>
|
||||
<zipfileset src="${dependencies}/javaslang-2.0.6.jar"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
buildscript {
|
||||
val buildSrcKotlinVersion: String by extra(findProperty("buildSrc.kotlin.version")?.toString() ?: embeddedKotlinVersion)
|
||||
extra["buildSrcKotlinRepo"] = findProperty("buildSrc.kotlin.repo")
|
||||
extra["versions.shadow"] = "2.0.1"
|
||||
|
||||
repositories {
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
@@ -34,6 +35,7 @@ repositories {
|
||||
}
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-dev") // for dex-method-list
|
||||
// maven { setUrl("https://repo.gradle.org/gradle/libs-releases-local") }
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -42,6 +44,7 @@ dependencies {
|
||||
// compile("net.rubygrapefruit:native-platform:0.14")
|
||||
// TODO: adding the dep to the plugin breaks the build unexpectedly, resolve and uncomment
|
||||
// compile("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["bootstrap_kotlin_version"]}")
|
||||
compile("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||
}
|
||||
|
||||
samWithReceiver {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.ConfigurablePublishArtifact
|
||||
import org.gradle.api.artifacts.*
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ConfigurationContainer
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||
import org.gradle.api.plugins.BasePluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
@@ -61,18 +59,13 @@ fun<T> Project.runtimeJarArtifactBy(task: Task, artifactRef: T, body: Configurab
|
||||
addArtifact("runtimeJar", task, artifactRef, body)
|
||||
}
|
||||
|
||||
fun Project.buildVersion(): Dependency {
|
||||
val cfg = configurations.create("build-version")
|
||||
return dependencies.add(cfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
}
|
||||
|
||||
fun<T: Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
val buildVersionCfg = configurations.create("buildVersion")
|
||||
dependencies.add(buildVersionCfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
extra["runtimeJarTask"] = task
|
||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
||||
configurations.getOrCreate("archives").artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
|
||||
}
|
||||
return task.apply {
|
||||
setupPublicJar()
|
||||
from(buildVersionCfg) { into("META-INF") }
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
body()
|
||||
project.runtimeJarArtifactBy(this, this)
|
||||
@@ -139,7 +132,7 @@ fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit
|
||||
|
||||
task("idea-plugin") {
|
||||
dependsOn(pluginTask)
|
||||
}
|
||||
}
|
||||
|
||||
return pluginTask
|
||||
}
|
||||
|
||||
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
@@ -0,0 +1,130 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.task
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
|
||||
|
||||
val packagesToRelocate =
|
||||
listOf( "com.intellij",
|
||||
"com.google",
|
||||
"com.sampullara",
|
||||
"org.apache",
|
||||
"org.jdom",
|
||||
"org.picocontainer",
|
||||
"org.jline",
|
||||
"gnu",
|
||||
"org.fusesource")
|
||||
|
||||
// The shaded compiler "dummy" is used to rewrite dependencies in projects that are used with the embeddable compiler
|
||||
// on the runtime and use some shaded dependencies from the compiler
|
||||
// To speed-up rewriting process we want to have this dummy as small as possible.
|
||||
// But due to the shadow plugin bug (https://github.com/johnrengelman/shadow/issues/262) it is not possible to use
|
||||
// packagesToRelocate list to for the include list. Therefore the exclude list has to be created.
|
||||
val packagesToExcludeFromDummy =
|
||||
listOf("org/jetbrains/kotlin/**",
|
||||
"org/intellij/lang/annotations/**",
|
||||
"org/jetbrains/jps/**",
|
||||
"META-INF/**",
|
||||
"com/sun/jna/**",
|
||||
"com/thoughtworks/xstream/**",
|
||||
"javaslang/**",
|
||||
"*.proto",
|
||||
"messages/**",
|
||||
"net/sf/cglib/**",
|
||||
"one/util/streamex/**",
|
||||
"org/iq80/snappy/**",
|
||||
"org/jline/**",
|
||||
"org/json/**",
|
||||
"org/xmlpull/**",
|
||||
"*.txt")
|
||||
|
||||
private fun ShadowJar.configureEmbeddableCompilerRelocation(withJavaxInject: Boolean = true) {
|
||||
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
||||
packagesToRelocate.forEach {
|
||||
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
||||
}
|
||||
if (withJavaxInject) {
|
||||
relocate("javax.inject", "$kotlinEmbeddableRootPackage.javax.inject")
|
||||
}
|
||||
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
||||
// TODO: remove "it." after #KT-12848 get addressed
|
||||
exclude("org.fusesource.jansi.internal.CLibrary")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.compilerShadowJar(taskName: String, body: ShadowJar.() -> Unit): Jar {
|
||||
|
||||
val compilerJar = configurations.getOrCreate("compilerJar")
|
||||
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler", configuration = "runtimeJar"))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerJar)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.embeddableCompiler(taskName: String = "embeddable", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
configureEmbeddableCompilerRelocation()
|
||||
body()
|
||||
}
|
||||
|
||||
fun Project.compilerDummyForDependenciesRewriting(taskName: String = "compilerDummy", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
exclude(packagesToExcludeFromDummy)
|
||||
body()
|
||||
}
|
||||
|
||||
const val COMPILER_DUMMY_JAR_CONFIGURATION_NAME = "compilerDummyJar"
|
||||
|
||||
fun Project.compilerDummyJar(task: Jar, body: Jar.() -> Unit = {}) {
|
||||
task.body()
|
||||
addArtifact(COMPILER_DUMMY_JAR_CONFIGURATION_NAME, task, task)
|
||||
}
|
||||
|
||||
fun Project.embeddableCompilerDummyForDependenciesRewriting(taskName: String = "embeddable", body: Jar.() -> Unit = {}): Jar {
|
||||
val compilerDummyJar = configurations.getOrCreate("compilerDummyJar")
|
||||
dependencies.add(compilerDummyJar.name,
|
||||
dependencies.project(":kotlin-compiler-embeddable", configuration = COMPILER_DUMMY_JAR_CONFIGURATION_NAME))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerDummyJar)
|
||||
configureEmbeddableCompilerRelocation(withJavaxInject = false)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, body: Jar.() -> Unit = {}): Jar {
|
||||
val originalFiles by lazy {
|
||||
val jarContents = zipTree(originalJarTask.outputs.files.singleFile).files
|
||||
val basePath = jarContents.find { it.name == "MANIFEST.MF" }?.parentFile?.parentFile ?: throw GradleException("cannot determine the jar root dir")
|
||||
jarContents.map { it.relativeTo(basePath).path }.toSet()
|
||||
}
|
||||
return task<Jar>("rewrittenDepsJar") {
|
||||
originalJarTask.apply {
|
||||
classifier = "original"
|
||||
}
|
||||
shadowJarTask.apply {
|
||||
dependsOn(originalJarTask)
|
||||
from(originalJarTask)// { include("**") }
|
||||
classifier = "shadow"
|
||||
}
|
||||
dependsOn(shadowJarTask)
|
||||
from(project.zipTree(shadowJarTask.outputs.files.singleFile)) { include { originalFiles.any { originalFile -> it.file.canonicalPath.endsWith(originalFile) } } }
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedCompiler(originalJarTask: Jar, body: Jar.() -> Unit = {}): Jar =
|
||||
rewriteDepsToShadedJar(originalJarTask, embeddableCompilerDummyForDependenciesRewriting(), body)
|
||||
@@ -29,8 +29,8 @@ public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
|
||||
|
||||
public void doTest() {
|
||||
initProject();
|
||||
rebuildAllModules();
|
||||
buildAllModules().assertSuccessful();
|
||||
rebuildAll();
|
||||
makeAll().assertSuccessful();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,47 +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;
|
||||
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
|
||||
public class ClassBuilderOnDemand extends DelegatingClassBuilder {
|
||||
private final NotNullLazyValue<ClassBuilder> classBuilder;
|
||||
|
||||
public ClassBuilderOnDemand(@NotNull Function0<ClassBuilder> createClassBuilder) {
|
||||
this.classBuilder = LockBasedStorageManager.NO_LOCKS.createLazyValue(createClassBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected ClassBuilder getDelegate() {
|
||||
return classBuilder.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
if (isComputed()) {
|
||||
classBuilder.invoke().done();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isComputed() {
|
||||
return classBuilder.isComputed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
|
||||
class ClassBuilderOnDemand(createClassBuilder: () -> ClassBuilder) : DelegatingClassBuilder() {
|
||||
private val classBuilder = LockBasedStorageManager.NO_LOCKS.createLazyValue(createClassBuilder)
|
||||
|
||||
val isComputed: Boolean
|
||||
get() = classBuilder.isComputed()
|
||||
|
||||
override fun getDelegate() = classBuilder()
|
||||
|
||||
fun ensureGenerated() {
|
||||
classBuilder()
|
||||
}
|
||||
|
||||
override fun done() {
|
||||
if (isComputed) {
|
||||
classBuilder().done()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.codegen.when.SwitchCodegen;
|
||||
import org.jetbrains.kotlin.codegen.when.SwitchCodegenProvider;
|
||||
import org.jetbrains.kotlin.config.ApiVersion;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
|
||||
@@ -307,7 +308,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
RuntimeAssertionInfo runtimeAssertionInfo = null;
|
||||
if (selector instanceof KtExpression) {
|
||||
runtimeAssertionInfo = bindingContext.get(JvmBindingContextSlices.RUNTIME_ASSERTION_INFO, (KtExpression) selector);
|
||||
KtExpression expression = (KtExpression) selector;
|
||||
runtimeAssertionInfo = bindingContext.get(JvmBindingContextSlices.RUNTIME_ASSERTION_INFO, expression);
|
||||
if (runtimeAssertionInfo == null &&
|
||||
state.getLanguageVersionSettings().supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
||||
runtimeAssertionInfo = bindingContext.get(JvmBindingContextSlices.BODY_RUNTIME_ASSERTION_INFO, expression);
|
||||
}
|
||||
}
|
||||
|
||||
if (BuiltinSpecialBridgesKt.isValueArgumentForCallToMethodWithTypeCheckBarrier(selector, bindingContext)) return stackValue;
|
||||
@@ -1717,12 +1723,22 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
private boolean shouldGenerateSingletonAsThisOrOuterFromContext(ClassDescriptor classDescriptor) {
|
||||
return isPossiblyUninitializedSingleton(classDescriptor) &&
|
||||
isInsideSingleton(classDescriptor) &&
|
||||
isThisInitialized(classDescriptor);
|
||||
}
|
||||
if (!isPossiblyUninitializedSingleton(classDescriptor)) return false;
|
||||
if (!isInsideSingleton(classDescriptor)) return false;
|
||||
|
||||
// We are inside a singleton class 'S' with possibly uninitialized static instance
|
||||
// (enum entry, interface companion object).
|
||||
// Such singleton can be referenced by name, or as an explicit or implicit 'this'.
|
||||
// For a given singleton class 'S' we either use 'this@S' from context (local or captured),
|
||||
// or 'S' as a static instance.
|
||||
//
|
||||
// Local or captured 'this@S' should be used if:
|
||||
// - we are in the constructor for 'S',
|
||||
// and corresponding instance is initialized by super or delegating constructor call;
|
||||
// - we are in any other member of 'S' or any of its inner classes.
|
||||
//
|
||||
// Otherwise, a static instance should be used.
|
||||
|
||||
private boolean isThisInitialized(ClassDescriptor classDescriptor) {
|
||||
CodegenContext context = this.context;
|
||||
while (context != null) {
|
||||
if (context instanceof ConstructorContext) {
|
||||
@@ -1732,9 +1748,24 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return constructorContext.isThisInitialized();
|
||||
}
|
||||
}
|
||||
else if (context instanceof ClassContext) {
|
||||
ClassDescriptor contextClass = ((ClassContext) context).getContextDescriptor();
|
||||
if (isInInnerClassesChainFor(contextClass, classDescriptor)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
context = context.getParentContext();
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInInnerClassesChainFor(ClassDescriptor innerClass, ClassDescriptor outerClass) {
|
||||
if (innerClass == outerClass) return true;
|
||||
if (!innerClass.isInner()) return false;
|
||||
|
||||
DeclarationDescriptor containingDeclaration = innerClass.getContainingDeclaration();
|
||||
if (!(containingDeclaration instanceof ClassDescriptor)) return false;
|
||||
return isInInnerClassesChainFor((ClassDescriptor) containingDeclaration, outerClass);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -2784,7 +2815,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private StackValue generateCallableReferenceReceiver(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
public StackValue generateCallableReferenceReceiver(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
if (descriptor.getExtensionReceiverParameter() == null && descriptor.getDispatchReceiverParameter() == null) return null;
|
||||
|
||||
|
||||
@@ -317,7 +317,10 @@ class MultifileClassCodegenImpl(
|
||||
}
|
||||
|
||||
private fun writeKotlinMultifileFacadeAnnotationIfNeeded() {
|
||||
if (!state.classBuilderMode.generateMetadata) return
|
||||
if (!state.classBuilderMode.generateMetadata) {
|
||||
classBuilder.ensureGenerated()
|
||||
return
|
||||
}
|
||||
if (files.any { it.isScript() }) return
|
||||
|
||||
val extraFlags = if (shouldGeneratePartHierarchy) JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG else 0
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.TypeMapperUtilsKt;
|
||||
import org.jetbrains.kotlin.codegen.when.SwitchCodegenProvider;
|
||||
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.coroutines.CoroutineUtilKt;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
@@ -56,6 +57,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionsOnDeclarationBodyChecker;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
@@ -86,6 +88,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
private final JvmRuntimeTypes runtimeTypes;
|
||||
private final TypeMappingConfiguration<Type> typeMappingConfiguration;
|
||||
private final SwitchCodegenProvider switchCodegenProvider;
|
||||
private final LanguageVersionSettings languageVersionSettings;
|
||||
private final ClassBuilderMode classBuilderMode;
|
||||
|
||||
public CodegenAnnotatingVisitor(@NotNull GenerationState state) {
|
||||
this.bindingTrace = state.getBindingTrace();
|
||||
@@ -94,6 +98,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
this.runtimeTypes = state.getJvmRuntimeTypes();
|
||||
this.typeMappingConfiguration = state.getTypeMapper().getTypeMappingConfiguration();
|
||||
this.switchCodegenProvider = new SwitchCodegenProvider(state);
|
||||
this.languageVersionSettings = state.getLanguageVersionSettings();
|
||||
this.classBuilderMode = state.getClassBuilderMode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -411,6 +417,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
// working around a problem with shallow analysis
|
||||
if (descriptor == null) return;
|
||||
|
||||
checkRuntimeAsserionsOnDeclarationBody(property, descriptor);
|
||||
|
||||
if (descriptor instanceof LocalVariableDescriptor) {
|
||||
recordLocalVariablePropertyMetadata((LocalVariableDescriptor) descriptor);
|
||||
}
|
||||
@@ -447,6 +455,14 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
nameStack.pop();
|
||||
}
|
||||
|
||||
private void checkRuntimeAsserionsOnDeclarationBody(@NotNull KtDeclaration declaration, DeclarationDescriptor descriptor) {
|
||||
if (classBuilderMode.generateBodies) {
|
||||
// NB This is required only for bodies generation.
|
||||
// In light class generation can cause recursion in types resolution.
|
||||
RuntimeAssertionsOnDeclarationBodyChecker.check(declaration, descriptor, bindingTrace, languageVersionSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Type getMetadataOwner(@NotNull KtProperty property) {
|
||||
for (int i = classStack.size() - 1; i >= 0; i--) {
|
||||
@@ -469,12 +485,24 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
return Type.getObjectType(JvmFileClassUtil.getFileClassInternalName(property.getContainingKtFile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPropertyAccessor(@NotNull KtPropertyAccessor accessor) {
|
||||
PropertyAccessorDescriptor accessorDescriptor = bindingContext.get(PROPERTY_ACCESSOR, accessor);
|
||||
if (accessorDescriptor != null) {
|
||||
checkRuntimeAsserionsOnDeclarationBody(accessor, accessorDescriptor);
|
||||
}
|
||||
|
||||
super.visitPropertyAccessor(accessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNamedFunction(@NotNull KtNamedFunction function) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, function);
|
||||
// working around a problem with shallow analysis
|
||||
if (functionDescriptor == null) return;
|
||||
|
||||
checkRuntimeAsserionsOnDeclarationBody(function, functionDescriptor);
|
||||
|
||||
String nameForClassOrPackageMember = getNameForClassOrPackageMember(functionDescriptor);
|
||||
|
||||
if (functionDescriptor instanceof SimpleFunctionDescriptor && functionDescriptor.isSuspend()) {
|
||||
|
||||
@@ -185,6 +185,11 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
}
|
||||
|
||||
private fun canSkipStackSpillingOnInline(methodNode: MethodNode): Boolean {
|
||||
// Temporary disable this optimization until
|
||||
// https://issuetracker.google.com/issues/68796377 is fixed
|
||||
// or until d8 substitute dex
|
||||
return false
|
||||
|
||||
// Stack spilling before inline function 'f' call is required if:
|
||||
// - 'f' is a suspend function
|
||||
// - 'f' has try-catch blocks
|
||||
|
||||
@@ -36,9 +36,9 @@ object LateinitIsInitialized : IntrinsicPropertyGetter() {
|
||||
private fun getStackValue(resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): StackValue? {
|
||||
val expression =
|
||||
(resolvedCall.extensionReceiver as? ExpressionReceiver)?.expression as? KtCallableReferenceExpression ?: return null
|
||||
val referenceResolvedCall = expression.callableReference.getResolvedCallWithAssert(codegen.bindingContext)
|
||||
|
||||
// TODO: support properties imported from objects as soon as KT-18982 is fixed
|
||||
val receiver = expression.receiverExpression?.let(codegen::gen) ?: StackValue.none()
|
||||
val receiver = codegen.generateCallableReferenceReceiver(referenceResolvedCall) ?: StackValue.none()
|
||||
|
||||
val target = expression.callableReference.getResolvedCallWithAssert(codegen.bindingContext).resultingDescriptor
|
||||
return codegen.intermediateValueForProperty(target as PropertyDescriptor, true, false, null, false, receiver, null, true)
|
||||
|
||||
@@ -79,18 +79,22 @@ class PopBackwardPropagationTransformer : MethodTransformer() {
|
||||
private fun analyzeMethodBody(): Array<out Frame<SourceValue>?> {
|
||||
val frames = Analyzer<SourceValue>(HazardsTrackingInterpreter()).analyze("fake", methodNode)
|
||||
|
||||
postprocessDupNxM(frames)
|
||||
postprocessStackHazards(frames)
|
||||
|
||||
return frames
|
||||
}
|
||||
|
||||
private fun postprocessDupNxM(frames: Array<out Frame<SourceValue>?>) {
|
||||
private fun postprocessStackHazards(frames: Array<out Frame<SourceValue>?>) {
|
||||
val insns = methodNode.instructions.toArray()
|
||||
for (i in frames.indices) {
|
||||
val frame = frames[i] ?: continue
|
||||
val insn = insns[i]
|
||||
|
||||
when (insn.opcode) {
|
||||
Opcodes.POP2 -> {
|
||||
val top2 = frame.peekWords(2) ?: throwIncorrectBytecode(insn, frame)
|
||||
top2.forEach { it.insns.markAsDontTouch() }
|
||||
}
|
||||
Opcodes.DUP_X1 -> {
|
||||
val top2 = frame.peekWords(1, 1) ?: throwIncorrectBytecode(insn, frame)
|
||||
top2.forEach { it.insns.markAsDontTouch() }
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
@@ -37,7 +36,7 @@ fun writeKotlinMetadata(
|
||||
av.visit(JvmAnnotationNames.BYTECODE_VERSION_FIELD_NAME, JvmBytecodeBinaryVersion.INSTANCE.toArray())
|
||||
av.visit(JvmAnnotationNames.KIND_FIELD_NAME, kind.id)
|
||||
var flags = extraFlags
|
||||
if (KotlinCompilerVersion.isPreRelease() && state.languageVersionSettings.languageVersion == LanguageVersion.LATEST_STABLE) {
|
||||
if (state.languageVersionSettings.shouldWritePreReleaseFlag()) {
|
||||
flags = flags or JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG
|
||||
}
|
||||
if (flags != 0) {
|
||||
@@ -51,4 +50,4 @@ fun writeSyntheticClassMetadata(cb: ClassBuilder, state: GenerationState) {
|
||||
writeKotlinMetadata(cb, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0) { _ ->
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var coroutinesState: String? by FreezableVar(WARN)
|
||||
|
||||
@Argument(
|
||||
value = "-Xlegacy-smart-cast-after-try",
|
||||
description = "Allow var smart casts despite assignment in try block"
|
||||
)
|
||||
var legacySmartCastAfterTry by FreezableVar(false)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
|
||||
@@ -106,16 +106,16 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java")
|
||||
var noParamAssertions: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xstrict-java-nullability-assertions", description = "Generate nullability assertions for non-null Java expressions")
|
||||
var strictJavaNullabilityAssertions: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xno-optimize", description = "Disable optimizations")
|
||||
var noOptimize: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xnormalize-constructor-calls",
|
||||
valueDescription = "{disable|enable|preserve-class-initialization}",
|
||||
description = "Normalize constructor calls " +
|
||||
"(disable: don't normalize; enable: normalize; " +
|
||||
"preserve-class-initialization: normalize preserving class initialization order), " +
|
||||
"default is disable"
|
||||
valueDescription = "{disable|enable}",
|
||||
description = "Normalize constructor calls (disable: don't normalize; enable: normalize), default is disable"
|
||||
)
|
||||
var constructorCallNormalizationMode: String? by FreezableVar(JVMConstructorCallNormalizationMode.DEFAULT.description)
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Note that this file is also present in idea/src/META-INF/services
|
||||
org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm
|
||||
org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs
|
||||
@@ -204,6 +204,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
||||
extraLanguageFeatures.put(LanguageFeature.Coroutines, coroutinesState);
|
||||
}
|
||||
|
||||
if (arguments.getLegacySmartCastAfterTry()) {
|
||||
extraLanguageFeatures.put(LanguageFeature.SoundSmartCastsAfterTry, LanguageFeature.State.DISABLED);
|
||||
}
|
||||
|
||||
setupPlatformSpecificLanguageFeatureSettings(extraLanguageFeatures, arguments);
|
||||
|
||||
CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(apiVersion),
|
||||
@@ -212,6 +218,13 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
||||
));
|
||||
}
|
||||
|
||||
protected void setupPlatformSpecificLanguageFeatureSettings(
|
||||
@NotNull Map<LanguageFeature, LanguageFeature.State> extraLanguageFeatures,
|
||||
@NotNull A commandLineArguments
|
||||
) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static KotlinPaths computeKotlinPaths(@NotNull MessageCollector messageCollector, @NotNull CommonCompilerArguments arguments) {
|
||||
KotlinPaths paths;
|
||||
|
||||
@@ -228,6 +228,17 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupPlatformSpecificLanguageFeatureSettings(
|
||||
extraLanguageFeatures: MutableMap<LanguageFeature, LanguageFeature.State>,
|
||||
commandLineArguments: K2JVMCompilerArguments
|
||||
) {
|
||||
if (commandLineArguments.strictJavaNullabilityAssertions) {
|
||||
extraLanguageFeatures[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED
|
||||
}
|
||||
|
||||
super.setupPlatformSpecificLanguageFeatureSettings(extraLanguageFeatures, commandLineArguments)
|
||||
}
|
||||
|
||||
private fun registerJavacIfNeeded(environment: KotlinCoreEnvironment,
|
||||
arguments: K2JVMCompilerArguments): Boolean {
|
||||
if (arguments.useJavac) {
|
||||
@@ -374,8 +385,6 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
configuration.put(JVMConfigurationKeys.ADD_BUILT_INS_FROM_COMPILER_TO_DEPENDENCIES, arguments.addCompilerBuiltIns)
|
||||
configuration.put(JVMConfigurationKeys.CREATE_BUILT_INS_FROM_MODULE_DEPENDENCIES, arguments.loadBuiltInsFromDependencies)
|
||||
|
||||
|
||||
|
||||
arguments.declarationsOutputPath?.let { configuration.put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
//import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.light.LightJavaModule
|
||||
//import com.intellij.psi.impl.light.LightJavaModule
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
@@ -91,22 +92,22 @@ class ClasspathRootsResolver(
|
||||
|
||||
for ((root, packagePrefix) in javaSourceRoots) {
|
||||
val modularRoot = modularSourceRoot(root, hasOutputDirectoryInClasspath)
|
||||
if (modularRoot != null) {
|
||||
modules += modularRoot
|
||||
}
|
||||
else {
|
||||
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
|
||||
if (isValidJavaFqName(prefix)) FqName(prefix)
|
||||
else null.also {
|
||||
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
|
||||
if (modularRoot != null) {
|
||||
modules += modularRoot
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
|
||||
if (isValidJavaFqName(prefix)) FqName(prefix)
|
||||
else null.also {
|
||||
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
for (root in jvmClasspathRoots) {
|
||||
result += JavaRoot(root, JavaRoot.RootType.BINARY)
|
||||
}
|
||||
result += JavaRoot(root, JavaRoot.RootType.BINARY)
|
||||
}
|
||||
|
||||
val outputDirectoryAddedAsPartOfModule = modules.any { module -> module.moduleRoots.any { it.file == outputDirectory } }
|
||||
|
||||
@@ -116,17 +117,19 @@ class ClasspathRootsResolver(
|
||||
if (outputDirectoryAddedAsPartOfModule && root == outputDirectory) continue
|
||||
|
||||
val module = modularBinaryRoot(root)
|
||||
if (module != null) {
|
||||
modules += module
|
||||
}
|
||||
}
|
||||
if (module != null) {
|
||||
modules += module
|
||||
}
|
||||
}
|
||||
|
||||
addModularRoots(modules, result)
|
||||
|
||||
return RootsAndModules(result, modules)
|
||||
}
|
||||
|
||||
private fun findSourceModuleInfo(root: VirtualFile): Pair<VirtualFile, PsiJavaModule>? {
|
||||
private fun findSourceModuleInfo(root: VirtualFile): Pair<VirtualFile, *>? {
|
||||
return null
|
||||
/*
|
||||
val moduleInfoFile =
|
||||
when {
|
||||
root.isDirectory -> root.findChild(PsiJavaModule.MODULE_INFO_FILE)
|
||||
@@ -138,9 +141,12 @@ class ClasspathRootsResolver(
|
||||
val psiJavaModule = psiFile.children.singleOrNull { it is PsiJavaModule } as? PsiJavaModule ?: return null
|
||||
|
||||
return moduleInfoFile to psiJavaModule
|
||||
*/
|
||||
}
|
||||
|
||||
private fun modularSourceRoot(root: VirtualFile, hasOutputDirectoryInClasspath: Boolean): JavaModule.Explicit? {
|
||||
return null
|
||||
/*
|
||||
val (moduleInfoFile, psiJavaModule) = findSourceModuleInfo(root) ?: return null
|
||||
val sourceRoot = JavaModule.Root(root, isBinary = false)
|
||||
val roots =
|
||||
@@ -148,19 +154,14 @@ class ClasspathRootsResolver(
|
||||
listOf(sourceRoot, JavaModule.Root(outputDirectory!!, isBinary = true))
|
||||
else listOf(sourceRoot)
|
||||
return JavaModule.Explicit(JavaModuleInfo.create(psiJavaModule), roots, moduleInfoFile)
|
||||
*/
|
||||
}
|
||||
|
||||
private fun modularBinaryRoot(root: VirtualFile): JavaModule? {
|
||||
val isJar = root.fileSystem.protocol == StandardFileSystems.JAR_PROTOCOL
|
||||
val manifest: Attributes? by lazy(NONE) { readManifestAttributes(root) }
|
||||
|
||||
val moduleInfoFile =
|
||||
root.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE)
|
||||
?: root.takeIf { isJar }?.findFileByRelativePath(MULTI_RELEASE_MODULE_INFO_CLS_FILE)?.takeIf {
|
||||
manifest?.getValue(IS_MULTI_RELEASE)?.equals("true", ignoreCase = true) == true
|
||||
}
|
||||
|
||||
if (moduleInfoFile != null) {
|
||||
return null
|
||||
/*
|
||||
val moduleInfoFile = root.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE)
|
||||
return if (moduleInfoFile != null) {
|
||||
val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null
|
||||
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile)
|
||||
}
|
||||
@@ -182,8 +183,6 @@ class ClasspathRootsResolver(
|
||||
}
|
||||
return JavaModule.Automatic(moduleName, moduleRoot)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun readManifestAttributes(jarRoot: VirtualFile): Attributes? {
|
||||
@@ -194,6 +193,7 @@ class ClasspathRootsResolver(
|
||||
catch (e: IOException) {
|
||||
null
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private fun addModularRoots(modules: List<JavaModule>, result: MutableList<JavaRoot>) {
|
||||
@@ -261,9 +261,9 @@ class ClasspathRootsResolver(
|
||||
else {
|
||||
for ((root, isBinary) in module.moduleRoots) {
|
||||
result.add(JavaRoot(root, if (isBinary) JavaRoot.RootType.BINARY else JavaRoot.RootType.SOURCE))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (requireStdlibModule && sourceModule != null && KOTLIN_STDLIB_MODULE_NAME !in allDependencies) {
|
||||
report(
|
||||
@@ -320,7 +320,6 @@ class ClasspathRootsResolver(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val MULTI_RELEASE_MODULE_INFO_CLS_FILE = "META-INF/versions/9/${PsiJavaModule.MODULE_INFO_CLS_FILE}"
|
||||
const val AUTOMATIC_MODULE_NAME = "Automatic-Module-Name"
|
||||
const val IS_MULTI_RELEASE = "Multi-Release"
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
|
||||
private val binaryCache: MutableMap<ClassId, JavaClass?> = THashMap()
|
||||
private val signatureParsingComponent =
|
||||
BinaryClassSignatureParser(ClassifierResolutionContext { findClass(it, allScope) })
|
||||
BinaryClassSignatureParser()
|
||||
|
||||
override fun findClass(classId: ClassId, searchScope: GlobalSearchScope): JavaClass? {
|
||||
val virtualFile = findVirtualFileForTopLevelClass(classId, searchScope) ?: return null
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.core.JavaCoreApplicationEnvironment
|
||||
import com.intellij.core.JavaCoreProjectEnvironment
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.lang.MetaLanguage
|
||||
import com.intellij.lang.java.JavaParserDefinition
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
@@ -144,7 +143,6 @@ class KotlinCoreEnvironment private constructor(
|
||||
super.registerJavaPsiFacade()
|
||||
}
|
||||
}
|
||||
|
||||
private val sourceFiles = mutableListOf<KtFile>()
|
||||
private val rootsIndex: JvmDependenciesDynamicCompoundIndex
|
||||
private val packagePartProviders = mutableListOf<JvmPackagePartProvider>()
|
||||
@@ -224,12 +222,12 @@ class KotlinCoreEnvironment private constructor(
|
||||
this.initialRoots = initialRoots
|
||||
|
||||
if (!configuration.getBoolean(JVMConfigurationKeys.SKIP_RUNTIME_VERSION_CHECK) && messageCollector != null) {
|
||||
JvmRuntimeVersionsConsistencyChecker.checkCompilerClasspathConsistency(
|
||||
messageCollector,
|
||||
configuration,
|
||||
initialRoots.mapNotNull { (file, type) -> if (type == JavaRoot.RootType.BINARY) file else null }
|
||||
)
|
||||
}
|
||||
JvmRuntimeVersionsConsistencyChecker.checkCompilerClasspathConsistency(
|
||||
messageCollector,
|
||||
configuration,
|
||||
initialRoots.mapNotNull { (file, type) -> if (type == JavaRoot.RootType.BINARY) file else null }
|
||||
)
|
||||
}
|
||||
|
||||
val (roots, singleJavaFileRoots) =
|
||||
initialRoots.partition { (file) -> file.isDirectory || file.extension != JavaFileType.DEFAULT_EXTENSION }
|
||||
@@ -318,7 +316,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
|
||||
for (packagePartProvider in packagePartProviders) {
|
||||
packagePartProvider.addRoots(newRoots)
|
||||
}
|
||||
}
|
||||
|
||||
return rootsIndex.addNewIndexForRoots(newRoots)?.let { newIndex ->
|
||||
updateClasspathFromRootsIndex(newIndex)
|
||||
@@ -344,9 +342,9 @@ class KotlinCoreEnvironment private constructor(
|
||||
return findLocalFile(root.file.absolutePath).also {
|
||||
if (it == null) {
|
||||
report(STRONG_WARNING, "Classpath entry points to a non-existent location: ${root.file}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun findJarRoot(file: File): VirtualFile? =
|
||||
applicationEnvironment.jarFileSystem.findFileByPath("$file${URLUtil.JAR_SEPARATOR}")
|
||||
@@ -370,7 +368,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val ideaCompatibleBuildNumber = "172.9999"
|
||||
private val ideaCompatibleBuildNumber = "163.9999"
|
||||
|
||||
init {
|
||||
setCompatibleBuild()
|
||||
@@ -460,6 +458,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
Extensions.cleanRootArea(parentDisposable)
|
||||
registerAppExtensionPoints()
|
||||
val applicationEnvironment = object : JavaCoreApplicationEnvironment(parentDisposable) {
|
||||
@Suppress("NOTHING_TO_OVERRIDE")
|
||||
override fun createJrtFileSystem(): VirtualFileSystem? = CoreJrtFileSystem()
|
||||
}
|
||||
|
||||
@@ -486,7 +485,6 @@ class KotlinCoreEnvironment private constructor(
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler::class.java)
|
||||
//
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier::class.java)
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), MetaLanguage.EP_NAME, MetaLanguage::class.java)
|
||||
}
|
||||
|
||||
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
|
||||
|
||||
@@ -26,5 +26,11 @@ open class KotlinCoreProjectEnvironment(
|
||||
disposable: Disposable,
|
||||
applicationEnvironment: JavaCoreApplicationEnvironment
|
||||
) : JavaCoreProjectEnvironment(disposable, applicationEnvironment) {
|
||||
init {
|
||||
myProject.registerService<ControlFlowFactory>(ControlFlowFactory::class.java,
|
||||
ControlFlowFactory(myPsiManager))
|
||||
|
||||
}
|
||||
|
||||
override fun createCoreFileManager() = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(project))
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
//import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
||||
@@ -191,14 +191,15 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
val isJava9Module = chunk.any { module ->
|
||||
val isJava9Module = false
|
||||
/*chunk.any { module ->
|
||||
module.getJavaSourceRoots().any { (path, packagePrefix) ->
|
||||
val file = File(path)
|
||||
packagePrefix == null &&
|
||||
(file.name == PsiJavaModule.MODULE_INFO_FILE ||
|
||||
(file.isDirectory && file.listFiles().any { it.name == PsiJavaModule.MODULE_INFO_FILE }))
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (module in chunk) {
|
||||
for (classpathRoot in module.getClasspathRoots()) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.*
|
||||
|
||||
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||
@@ -41,8 +40,4 @@ class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||
override fun editExternalAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String, value: Array<out PsiNameValuePair>?): Boolean {
|
||||
throw UnsupportedOperationException("not implemented")
|
||||
}
|
||||
|
||||
override fun hasAnnotationRootsForFile(file: VirtualFile): Boolean {
|
||||
throw UnsupportedOperationException("not implemented")
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.modules
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem
|
||||
//import com.intellij.psi.PsiJavaModule
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleFinder
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
|
||||
@@ -40,8 +41,11 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
|
||||
modulesRoot?.findChild(name)?.let(this::findSystemModule) ?: userModules[name]
|
||||
|
||||
private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? {
|
||||
return null
|
||||
/*
|
||||
val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null
|
||||
val moduleInfo = JavaModuleInfo.read(file) ?: return null
|
||||
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ class ReplCodeAnalyzer(environment: KotlinCoreEnvironment) {
|
||||
return delegateFactory.getPackageMemberDeclarationProvider(packageFqName)
|
||||
}
|
||||
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile) {
|
||||
delegateFactory.diagnoseMissingPackageFragment(file)
|
||||
override fun diagnoseMissingPackageFragment(fqName: FqName, file: KtFile?) {
|
||||
delegateFactory.diagnoseMissingPackageFragment(fqName, file)
|
||||
}
|
||||
|
||||
class AdaptablePackageMemberDeclarationProvider(
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
description = "Compiler runner + daemon client"
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
@@ -13,6 +15,7 @@ dependencies {
|
||||
compileOnly(project(":compiler:daemon-common"))
|
||||
compile(project(":kotlin-daemon-client"))
|
||||
compileOnly(project(":compiler:util"))
|
||||
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -20,10 +23,13 @@ sourceSets {
|
||||
"test" {}
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
val jar: Jar by tasks
|
||||
jar.apply {
|
||||
from(getSourceSetsFrom(":kotlin-daemon-client")["main"].output.classesDirs)
|
||||
from(getSourceSetsFrom(":compiler:daemon-common")["main"].output.classesDirs)
|
||||
}
|
||||
|
||||
runtimeJar(rewriteDepsToShadedCompiler(jar))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
@@ -216,4 +216,9 @@ messages/**)
|
||||
-keep class com.sun.source.** { *; }
|
||||
|
||||
# for coroutines
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
|
||||
# for webdemo
|
||||
-keep class com.intellij.openapi.progress.ProgressManager { *; }
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@file:JvmName("FileClasses")
|
||||
|
||||
package org.jetbrains.kotlin.fileClasses
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
@Deprecated("Use JvmFileClassUtil instead.", level = DeprecationLevel.ERROR)
|
||||
open class JvmFileClassesProvider
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Deprecated("Use JvmFileClassUtil instead.", level = DeprecationLevel.ERROR)
|
||||
object NoResolveFileClassesProvider : JvmFileClassesProvider()
|
||||
|
||||
@Suppress("DEPRECATION_ERROR", "unused")
|
||||
@Deprecated("Use JvmFileClassUtil.getFileClassInternalName instead.", ReplaceWith("JvmFileClassUtil.getFileClassInternalName(file)"), DeprecationLevel.ERROR)
|
||||
fun JvmFileClassesProvider.getFileClassInternalName(file: KtFile): String =
|
||||
JvmFileClassUtil.getFileClassInternalName(file)
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.psiUtil.contains
|
||||
|
||||
class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass), VirtualFileBoundJavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
init {
|
||||
@@ -114,7 +115,7 @@ class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass)
|
||||
override val virtualFile: VirtualFile?
|
||||
get() = psi.containingFile?.virtualFile
|
||||
|
||||
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile.virtualFile in scope
|
||||
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile in scope
|
||||
|
||||
override fun getAnnotationOwnerPsi() = psi.modifierList
|
||||
|
||||
|
||||
@@ -16,14 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.structure.impl.classFiles
|
||||
|
||||
import com.intellij.psi.CommonClassNames
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClassifierType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.flattenTo
|
||||
import org.jetbrains.kotlin.utils.compact
|
||||
@@ -33,14 +30,11 @@ import java.text.StringCharacterIterator
|
||||
|
||||
/**
|
||||
* Take a look at com.intellij.psi.impl.compiled.SignatureParsing
|
||||
* NOTE: currently this class can simply be converted to an object, but there are postponed plans
|
||||
* to introduce cached instance for java.lang.Object type that would require injected class finder.
|
||||
* So please, do not convert it to object
|
||||
*/
|
||||
class BinaryClassSignatureParser(globalContext: ClassifierResolutionContext) {
|
||||
companion object {
|
||||
private val JAVA_LANG_OBJECT = ClassId.topLevel(FqName(CommonClassNames.JAVA_LANG_OBJECT))
|
||||
}
|
||||
|
||||
private val JAVA_LANG_OBJECT_CLASSIFIER_TYPE: JavaClassifierType =
|
||||
PlainJavaClassifierType({ globalContext.resolveClass(JAVA_LANG_OBJECT) }, emptyList())
|
||||
class BinaryClassSignatureParser {
|
||||
|
||||
fun parseTypeParametersDeclaration(signature: CharacterIterator, context: ClassifierResolutionContext): List<JavaTypeParameter> {
|
||||
if (signature.current() != '<') {
|
||||
@@ -68,25 +62,14 @@ class BinaryClassSignatureParser(globalContext: ClassifierResolutionContext) {
|
||||
val parameterName = name.toString()
|
||||
|
||||
// postpone list allocation till a second bound is seen; ignore sole Object bound
|
||||
var bounds: MutableList<JavaClassifierType>? = null
|
||||
var jlo = false
|
||||
val bounds: MutableList<JavaClassifierType> = ContainerUtil.newSmartList()
|
||||
while (signature.current() == ':') {
|
||||
signature.next()
|
||||
val bound = parseClassifierRefSignature(signature, context) ?: continue
|
||||
if (bounds == null) {
|
||||
if (JAVA_LANG_OBJECT_CLASSIFIER_TYPE === bound) {
|
||||
jlo = true
|
||||
continue
|
||||
}
|
||||
bounds = ContainerUtil.newSmartList()
|
||||
if (jlo) {
|
||||
bounds.add(JAVA_LANG_OBJECT_CLASSIFIER_TYPE)
|
||||
}
|
||||
}
|
||||
bounds.add(bound)
|
||||
}
|
||||
|
||||
return BinaryJavaTypeParameter(Name.identifier(parameterName), bounds ?: emptyList())
|
||||
return BinaryJavaTypeParameter(Name.identifier(parameterName), bounds)
|
||||
}
|
||||
|
||||
fun parseClassifierRefSignature(signature: CharacterIterator, context: ClassifierResolutionContext): JavaClassifierType? {
|
||||
@@ -148,8 +131,6 @@ class BinaryClassSignatureParser(globalContext: ClassifierResolutionContext) {
|
||||
}
|
||||
signature.next()
|
||||
|
||||
if (canonicalName.toString() == "java/lang/Object") return JAVA_LANG_OBJECT_CLASSIFIER_TYPE
|
||||
|
||||
return PlainJavaClassifierType(
|
||||
{ context.resolveByInternalName(canonicalName.toString()) },
|
||||
argumentGroups.reversed().flattenTo(arrayListOf()).compact()
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
|
||||
class KotlinBinaryClassCache : Disposable {
|
||||
private class RequestCache {
|
||||
@@ -56,8 +55,6 @@ class KotlinBinaryClassCache : Disposable {
|
||||
fun getKotlinBinaryClass(file: VirtualFile, fileContent: ByteArray? = null): KotlinJvmBinaryClass? {
|
||||
if (file.fileType !== JavaClassFileType.INSTANCE) return null
|
||||
|
||||
if (file.name == PsiJavaModule.MODULE_INFO_CLS_FILE) return null
|
||||
|
||||
val service = ServiceManager.getService(KotlinBinaryClassCache::class.java)
|
||||
val requestCache = service.cache.get()
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ object JvmBindingContextSlices {
|
||||
@JvmField
|
||||
val RECEIVER_RUNTIME_ASSERTION_INFO: WritableSlice<ExpressionReceiver, RuntimeAssertionInfo> = BasicWritableSlice(RewritePolicy.DO_NOTHING)
|
||||
|
||||
@JvmField
|
||||
val BODY_RUNTIME_ASSERTION_INFO: WritableSlice<KtExpression, RuntimeAssertionInfo> = BasicWritableSlice(RewritePolicy.DO_NOTHING)
|
||||
|
||||
@JvmField
|
||||
val LOAD_FROM_JAVA_SIGNATURE_ERRORS: WritableSlice<DeclarationDescriptor, List<String>> = Slices.createCollectiveSlice()
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.jvm
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DeclarationReturnTypeSanitizer
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||
|
||||
object JvmDeclarationReturnTypeSanitizer : DeclarationReturnTypeSanitizer {
|
||||
override fun sanitizeReturnType(
|
||||
inferred: UnwrappedType,
|
||||
wrappedTypeFactory: WrappedTypeFactory,
|
||||
trace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): UnwrappedType =
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
||||
// NB can't check for presence of EnhancedNullability here,
|
||||
// because it will also cause recursion in declaration type resolution.
|
||||
inferred.replaceAnnotations(FilteredAnnotations(inferred.annotations) {
|
||||
it != JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION
|
||||
})
|
||||
}
|
||||
else inferred
|
||||
}
|
||||
@@ -18,9 +18,12 @@ package org.jetbrains.kotlin.resolve.jvm
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.typeEnhancement.hasEnhancedNullability
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
@@ -31,9 +34,9 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.isClassType
|
||||
import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class RuntimeAssertionInfo(val needNotNullAssertion: Boolean, val message: String) {
|
||||
@@ -83,6 +86,9 @@ class RuntimeAssertionInfo(val needNotNullAssertion: Boolean, val message: Strin
|
||||
}
|
||||
}
|
||||
|
||||
private val KtExpression.textForRuntimeAssertionInfo
|
||||
get() = StringUtil.trimMiddle(text, 50)
|
||||
|
||||
class RuntimeAssertionsDataFlowExtras(
|
||||
private val c: ResolutionContext<*>,
|
||||
private val dataFlowValue: DataFlowValue,
|
||||
@@ -93,7 +99,7 @@ class RuntimeAssertionsDataFlowExtras(
|
||||
override val possibleTypes: Set<KotlinType>
|
||||
get() = c.dataFlowInfo.getCollectedTypes(dataFlowValue)
|
||||
override val presentableText: String
|
||||
get() = StringUtil.trimMiddle(expression.text, 50)
|
||||
get() = expression.textForRuntimeAssertionInfo
|
||||
}
|
||||
|
||||
object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
@@ -138,4 +144,101 @@ object RuntimeAssertionsOnExtensionReceiverCallChecker : CallChecker {
|
||||
c.trace.record(JvmBindingContextSlices.RECEIVER_RUNTIME_ASSERTION_INFO, expressionReceiverValue, assertionInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object RuntimeAssertionsOnDeclarationBodyChecker {
|
||||
@JvmStatic
|
||||
fun check(
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
bindingTrace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) return
|
||||
|
||||
when {
|
||||
declaration is KtProperty && descriptor is VariableDescriptor ->
|
||||
checkLocalVariable(declaration, descriptor, bindingTrace)
|
||||
declaration is KtFunction && descriptor is FunctionDescriptor ->
|
||||
checkFunction(declaration, descriptor, bindingTrace)
|
||||
declaration is KtProperty && descriptor is PropertyDescriptor ->
|
||||
checkProperty(declaration, descriptor, bindingTrace)
|
||||
declaration is KtPropertyAccessor && descriptor is PropertyAccessorDescriptor ->
|
||||
checkPropertyAccessor(declaration, descriptor, bindingTrace)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkLocalVariable(
|
||||
declaration: KtProperty,
|
||||
descriptor: VariableDescriptor,
|
||||
bindingTrace: BindingTrace
|
||||
) {
|
||||
if (declaration.typeReference != null) return
|
||||
|
||||
checkNullabilityAssertion(declaration.initializer ?: return, descriptor.type, bindingTrace)
|
||||
}
|
||||
|
||||
private fun checkFunction(
|
||||
declaration: KtFunction,
|
||||
descriptor: FunctionDescriptor,
|
||||
bindingTrace: BindingTrace
|
||||
) {
|
||||
if (declaration.typeReference != null || declaration.hasBlockBody()) return
|
||||
|
||||
checkNullabilityAssertion(declaration.bodyExpression ?: return, descriptor.returnType ?: return,
|
||||
bindingTrace)
|
||||
}
|
||||
|
||||
private fun checkProperty(
|
||||
declaration: KtProperty,
|
||||
descriptor: PropertyDescriptor,
|
||||
bindingTrace: BindingTrace
|
||||
) {
|
||||
if (declaration.typeReference != null) return
|
||||
|
||||
// TODO nullability assertion on delegate initialization expression, see KT-20823
|
||||
if (declaration.hasDelegateExpression()) return
|
||||
|
||||
checkNullabilityAssertion(declaration.initializer ?: return, descriptor.type, bindingTrace)
|
||||
}
|
||||
|
||||
private fun checkPropertyAccessor(
|
||||
declaration: KtPropertyAccessor,
|
||||
descriptor: PropertyAccessorDescriptor,
|
||||
bindingTrace: BindingTrace
|
||||
) {
|
||||
if (declaration.property.typeReference != null || declaration.hasBlockBody()) return
|
||||
|
||||
checkNullabilityAssertion(declaration.bodyExpression ?: return, descriptor.correspondingProperty.type,
|
||||
bindingTrace)
|
||||
}
|
||||
|
||||
|
||||
private fun checkNullabilityAssertion(
|
||||
expression: KtExpression,
|
||||
declarationType: KotlinType,
|
||||
bindingTrace: BindingTrace
|
||||
) {
|
||||
if (declarationType.unwrap().canContainNull()) return
|
||||
|
||||
val expressionType = bindingTrace.getType(expression) ?: return
|
||||
if (expressionType.isError) return
|
||||
|
||||
if (!expressionType.hasEnhancedNullability()) return
|
||||
|
||||
bindingTrace.record(
|
||||
JvmBindingContextSlices.BODY_RUNTIME_ASSERTION_INFO,
|
||||
expression,
|
||||
RuntimeAssertionInfo(true, expression.textForRuntimeAssertionInfo)
|
||||
)
|
||||
}
|
||||
|
||||
private fun UnwrappedType.canContainNull(): Boolean {
|
||||
val upper = upperIfFlexible()
|
||||
return when {
|
||||
upper.isMarkedNullable -> true
|
||||
upper.isClassType -> false
|
||||
else -> upper.immediateSupertypes().all { it.unwrap().canContainNull() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -28,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpressio
|
||||
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.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
|
||||
|
||||
class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker {
|
||||
|
||||
@@ -41,7 +42,8 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
||||
isStaticDeclaration(descriptor) &&
|
||||
isInterface(descriptor.containingDeclaration) &&
|
||||
descriptor is JavaCallableMemberDescriptor) {
|
||||
context.trace.report(ErrorsJvm.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn))
|
||||
val diagnostic = if (isDefaultCallsProhibited(context)) INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET
|
||||
context.trace.report(diagnostic.on(reportOn))
|
||||
}
|
||||
|
||||
if (getSuperCallExpression(resolvedCall.call) == null) return
|
||||
@@ -55,11 +57,15 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
||||
val classifier = DescriptorUtils.getParentOfType(context.scope.ownerDescriptor, ClassifierDescriptor::class.java)
|
||||
//is java interface default method called from trait
|
||||
if (classifier != null && DescriptorUtils.isInterface(classifier)) {
|
||||
context.trace.report(ErrorsJvm.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn))
|
||||
context.trace.report(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn))
|
||||
}
|
||||
else if (!supportDefaults) {
|
||||
context.trace.report(ErrorsJvm.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn))
|
||||
val diagnostic = if (isDefaultCallsProhibited(context)) DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
|
||||
context.trace.report(diagnostic.on(reportOn))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDefaultCallsProhibited(context: CallCheckerContext) =
|
||||
context.languageVersionSettings.supportsFeature(LanguageFeature.DefaultMethodsCallFromJava6TargetError)
|
||||
}
|
||||
|
||||
@@ -115,8 +115,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
"Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}",
|
||||
NAME, NAME, STRING);
|
||||
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET, "Calls to static methods in Java interfaces are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
|
||||
MAP.put(INLINE_FROM_HIGHER_PLATFORM, "Cannot inline bytecode built with {0} into bytecode that is being built with {1}. Please specify proper ''-jvm-target'' option", STRING, STRING);
|
||||
|
||||
|
||||
@@ -96,8 +96,10 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, DeclarationDescriptor, String> TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> INLINE_FROM_HIGHER_PLATFORM = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
package org.jetbrains.kotlin.resolve.jvm.modules
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
//import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiModifier
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
/*
|
||||
import org.jetbrains.kotlin.utils.compact
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.ModuleVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_TRANSITIVE
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
*/
|
||||
import java.io.IOException
|
||||
|
||||
class JavaModuleInfo(
|
||||
@@ -41,6 +43,7 @@ class JavaModuleInfo(
|
||||
"Module $moduleName (${requires.size} requires, ${exports.size} exports)"
|
||||
|
||||
companion object {
|
||||
/*
|
||||
fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
|
||||
return JavaModuleInfo(
|
||||
psiJavaModule.name,
|
||||
@@ -56,7 +59,10 @@ class JavaModuleInfo(
|
||||
}
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
||||
fun read(file: VirtualFile): JavaModuleInfo? = null // unsupported with this version of ASM
|
||||
/*
|
||||
fun read(file: VirtualFile): JavaModuleInfo? {
|
||||
val contents = try { file.contentsToByteArray() } catch (e: IOException) { return null }
|
||||
|
||||
@@ -85,5 +91,6 @@ class JavaModuleInfo(
|
||||
JavaModuleInfo(moduleName!!, requires.compact(), exports.compact())
|
||||
else null
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
|
||||
delegationFilter = JvmDelegationFilter,
|
||||
|
||||
overridesBackwardCompatibilityHelper = JvmOverridesBackwardCompatibilityHelper
|
||||
overridesBackwardCompatibilityHelper = JvmOverridesBackwardCompatibilityHelper,
|
||||
|
||||
declarationReturnTypeSanitizer = JvmDeclarationReturnTypeSanitizer
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useImpl<JvmReflectionAPICallChecker>()
|
||||
|
||||
@@ -190,7 +190,10 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
}
|
||||
|
||||
private fun WriteValueInstruction.isTrivialInitializer() =
|
||||
element is KtVariableDeclaration || element is KtParameter
|
||||
// WriteValueInstruction having KtDeclaration as an element means
|
||||
// it must be a write happened at the same time when
|
||||
// the variable (common variable/parameter/object) has been declared
|
||||
element is KtDeclaration
|
||||
|
||||
private inner class ReadOnlyInitControlFlowInfoImpl(
|
||||
val declaredSet: ImmutableSet<VariableDescriptor>,
|
||||
@@ -291,8 +294,14 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
|
||||
val variableUseStatusData: Map<Instruction, Edges<ReadOnlyUseControlFlowInfo>>
|
||||
get() {
|
||||
val resultForTrivialVals = computeUseInfoForTrivialVals()
|
||||
if (rootVariables.nonTrivialVariables.isEmpty()) return resultForTrivialVals
|
||||
val edgesForTrivialVals = computeUseInfoForTrivialVals()
|
||||
if (rootVariables.nonTrivialVariables.isEmpty()) {
|
||||
return hashMapOf<Instruction, Edges<ReadOnlyUseControlFlowInfo>>().apply {
|
||||
pseudocode.traverse(TraversalOrder.FORWARD) { instruction ->
|
||||
put(instruction, edgesForTrivialVals)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pseudocodeVariableDataCollector.collectData(TraversalOrder.BACKWARD, UseControlFlowInfo()) { instruction: Instruction, incomingEdgesData: Collection<UseControlFlowInfo> ->
|
||||
|
||||
@@ -333,17 +342,16 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
Edges(enterResult, exitResult)
|
||||
}
|
||||
}.mapValues {
|
||||
(instruction, edges) ->
|
||||
val edgeForTrivialVals = resultForTrivialVals[instruction]!!
|
||||
(_, edges) ->
|
||||
|
||||
Edges(
|
||||
edgeForTrivialVals.incoming.replaceDelegate(edges.incoming),
|
||||
edgeForTrivialVals.outgoing.replaceDelegate(edges.outgoing)
|
||||
edgesForTrivialVals.incoming.replaceDelegate(edges.incoming),
|
||||
edgesForTrivialVals.outgoing.replaceDelegate(edges.outgoing)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeUseInfoForTrivialVals(): Map<Instruction, Edges<ReadOnlyUseControlFlowInfoImpl>> {
|
||||
private fun computeUseInfoForTrivialVals(): Edges<ReadOnlyUseControlFlowInfoImpl> {
|
||||
val used = hashSetOf<VariableDescriptor>()
|
||||
|
||||
pseudocode.traverse(TraversalOrder.FORWARD) { instruction ->
|
||||
@@ -355,13 +363,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
}
|
||||
|
||||
val constantUseInfo = ReadOnlyUseControlFlowInfoImpl(used, null)
|
||||
val constantEdges = Edges(constantUseInfo, constantUseInfo)
|
||||
val result = hashMapOf<Instruction, Edges<ReadOnlyUseControlFlowInfoImpl>>()
|
||||
|
||||
pseudocode.traverse(TraversalOrder.FORWARD) { instruction ->
|
||||
result[instruction] = constantEdges
|
||||
}
|
||||
return result
|
||||
return Edges(constantUseInfo, constantUseInfo)
|
||||
}
|
||||
|
||||
private fun extractValWithTrivialInitializer(instruction: Instruction): VariableDescriptor? {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.config.LanguageVersion;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
@@ -982,9 +983,9 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> PLUGIN_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, String, String> PLUGIN_WARNING = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, String, String> PLUGIN_INFO = DiagnosticFactory2.create(INFO);
|
||||
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_WARNING = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_INFO = DiagnosticFactory1.create(INFO);
|
||||
|
||||
// Function contracts
|
||||
DiagnosticFactory1<KtElement, String> ERROR_IN_CONTRACT_DESCRIPTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
@@ -14,12 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.build
|
||||
package org.jetbrains.kotlin.diagnostics
|
||||
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
|
||||
|
||||
fun ModuleChunk.isDummy(context: CompileContext): Boolean {
|
||||
val targetIndex = context.projectDescriptor.buildTargetIndex
|
||||
return targets.all { targetIndex.isDummy(it) }
|
||||
}
|
||||
class RenderedDiagnostic<D : Diagnostic>(
|
||||
val diagnostic: D,
|
||||
val renderer: DiagnosticRenderer<D>
|
||||
) {
|
||||
val text = renderer.render(diagnostic)
|
||||
|
||||
val factory: DiagnosticFactory<*> get() = diagnostic.factory
|
||||
|
||||
override fun toString() = text
|
||||
}
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.diagnostics
|
||||
|
||||
import com.intellij.mock.MockApplication
|
||||
import com.intellij.openapi.application.Application
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
@@ -167,19 +164,15 @@ inline fun <reified T : KtDeclaration> reportOnDeclarationAs(trace: BindingTrace
|
||||
}
|
||||
|
||||
fun <D : Diagnostic> DiagnosticSink.reportFromPlugin(diagnostic: D, ext: DefaultErrorMessages.Extension) {
|
||||
if (ApplicationManager.getApplication() !is MockApplication) {
|
||||
return this.report(diagnostic)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val renderer = ext.map[diagnostic.factory] as? DiagnosticRenderer<D>
|
||||
?: error("Renderer not found for diagnostic ${diagnostic.factory.name}")
|
||||
|
||||
val text = renderer.render(diagnostic)
|
||||
val renderedDiagnostic = RenderedDiagnostic(diagnostic, renderer)
|
||||
|
||||
when (diagnostic.severity) {
|
||||
Severity.ERROR -> report(Errors.PLUGIN_ERROR.on(diagnostic.psiElement, diagnostic.factory.name, text))
|
||||
Severity.WARNING -> report(Errors.PLUGIN_WARNING.on(diagnostic.psiElement, diagnostic.factory.name, text))
|
||||
Severity.INFO -> report(Errors.PLUGIN_INFO.on(diagnostic.psiElement, diagnostic.factory.name, text))
|
||||
Severity.ERROR -> report(Errors.PLUGIN_ERROR.on(diagnostic.psiElement, renderedDiagnostic))
|
||||
Severity.WARNING -> report(Errors.PLUGIN_WARNING.on(diagnostic.psiElement, renderedDiagnostic))
|
||||
Severity.INFO -> report(Errors.PLUGIN_INFO.on(diagnostic.psiElement, renderedDiagnostic))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,26 +16,27 @@
|
||||
|
||||
package org.jetbrains.kotlin.diagnostics.rendering;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import kotlin.Pair;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
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.diagnostics.RenderedDiagnostic;
|
||||
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.*;
|
||||
@@ -44,47 +45,30 @@ import static org.jetbrains.kotlin.diagnostics.rendering.RenderingContext.of;
|
||||
public class DefaultErrorMessages {
|
||||
|
||||
public interface Extension {
|
||||
ExtensionPointName<Extension> EP_NAME = ExtensionPointName.create("org.jetbrains.kotlin.defaultErrorMessages");
|
||||
|
||||
@NotNull
|
||||
DiagnosticFactoryToRendererMap getMap();
|
||||
}
|
||||
|
||||
private static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("Default");
|
||||
private static final MappedExtensionProvider<Extension, List<DiagnosticFactoryToRendererMap>> RENDERER_MAPS = MappedExtensionProvider.create(
|
||||
Extension.EP_NAME,
|
||||
extensions -> {
|
||||
List<DiagnosticFactoryToRendererMap> result = new ArrayList<>(extensions.size() + 1);
|
||||
for (Extension extension : extensions) {
|
||||
result.add(extension.getMap());
|
||||
}
|
||||
result.add(MAP);
|
||||
return result;
|
||||
});
|
||||
private static final List<DiagnosticFactoryToRendererMap> RENDERER_MAPS =
|
||||
CollectionsKt.plus(
|
||||
Collections.singletonList(MAP),
|
||||
CollectionsKt.map(ServiceLoader.load(Extension.class, DefaultErrorMessages.class.getClassLoader()), Extension::getMap)
|
||||
);
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String render(@NotNull Diagnostic diagnostic) {
|
||||
for (DiagnosticFactoryToRendererMap map : RENDERER_MAPS.get()) {
|
||||
DiagnosticRenderer renderer = map.get(diagnostic.getFactory());
|
||||
if (renderer != null) {
|
||||
//noinspection unchecked
|
||||
return renderer.render(diagnostic);
|
||||
}
|
||||
DiagnosticRenderer renderer = getRendererForDiagnostic(diagnostic);
|
||||
if (renderer != null) {
|
||||
return renderer.render(diagnostic);
|
||||
}
|
||||
throw new IllegalArgumentException("Don't know how to render diagnostic of type " + diagnostic.getFactory().getName() +
|
||||
" with the following renderer maps: " + RENDERER_MAPS.get());
|
||||
return diagnostic.toString() + " (error: could not render message)";
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@Nullable
|
||||
public static DiagnosticRenderer getRendererForDiagnostic(@NotNull Diagnostic diagnostic) {
|
||||
for (DiagnosticFactoryToRendererMap map : RENDERER_MAPS.get()) {
|
||||
DiagnosticRenderer renderer = map.get(diagnostic.getFactory());
|
||||
|
||||
if (renderer != null) return renderer;
|
||||
}
|
||||
|
||||
return null;
|
||||
return AddToStdlibKt.firstNotNullResult(RENDERER_MAPS, map -> map.get(diagnostic.getFactory()));
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -888,9 +872,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_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
|
||||
|
||||
MAP.put(PLUGIN_ERROR, "{0}: {1}", TO_STRING, TO_STRING);
|
||||
MAP.put(PLUGIN_WARNING, "{0}: {1}", TO_STRING, TO_STRING);
|
||||
MAP.put(PLUGIN_INFO, "{0}: {1}", TO_STRING, TO_STRING);
|
||||
MAP.put(PLUGIN_ERROR, "{0}", (d, c) -> d.getText());
|
||||
MAP.put(PLUGIN_WARNING, "{0}", (d, c) -> d.getText());
|
||||
MAP.put(PLUGIN_INFO, "{0}", (d, c) -> d.getText());
|
||||
|
||||
MAP.put(ERROR_IN_CONTRACT_DESCRIPTION, "Error in contract description: {0}", TO_STRING);
|
||||
MAP.put(CONTRACT_NOT_ALLOWED, "Contract is not allowed here");
|
||||
|
||||
@@ -28,7 +28,7 @@ object KotlinStubVersions {
|
||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
|
||||
private const val BINARY_STUB_VERSION = 62
|
||||
private const val BINARY_STUB_VERSION = 63
|
||||
|
||||
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
|
||||
// Increasing this version will lead to reindexing of all classfiles.
|
||||
|
||||
@@ -22,10 +22,12 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
|
||||
class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVersionSettings) : DeserializationConfiguration {
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val skipMetadataVersionCheck = languageVersionSettings.getFlag(AnalysisFlag.skipMetadataVersionCheck)
|
||||
|
||||
override val skipPreReleaseCheck = skipMetadataVersionCheck || !languageVersionSettings.languageVersion.isStable
|
||||
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val isJvmPackageNameSupported = languageVersionSettings.supportsFeature(LanguageFeature.JvmPackageName)
|
||||
|
||||
override val returnsEffectAllowed: Boolean = languageVersionSettings.supportsFeature(LanguageFeature.ReturnsEffect)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||
|
||||
interface DeclarationReturnTypeSanitizer {
|
||||
fun sanitizeReturnType(
|
||||
inferred: UnwrappedType,
|
||||
wrappedTypeFactory: WrappedTypeFactory,
|
||||
trace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): UnwrappedType
|
||||
|
||||
object Default : DeclarationReturnTypeSanitizer {
|
||||
override fun sanitizeReturnType(
|
||||
inferred: UnwrappedType,
|
||||
wrappedTypeFactory: WrappedTypeFactory,
|
||||
trace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) = inferred
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ public class DescriptorResolver {
|
||||
private final WrappedTypeFactory wrappedTypeFactory;
|
||||
private final SyntheticResolveExtension syntheticResolveExtension;
|
||||
private final TypeApproximator typeApproximator;
|
||||
private final DeclarationReturnTypeSanitizer declarationReturnTypeSanitizer;
|
||||
|
||||
public DescriptorResolver(
|
||||
@NotNull AnnotationResolver annotationResolver,
|
||||
@@ -103,7 +104,8 @@ public class DescriptorResolver {
|
||||
@NotNull ModifiersChecker modifiersChecker,
|
||||
@NotNull WrappedTypeFactory wrappedTypeFactory,
|
||||
@NotNull Project project,
|
||||
TypeApproximator approximator
|
||||
@NotNull TypeApproximator approximator,
|
||||
@NotNull DeclarationReturnTypeSanitizer declarationReturnTypeSanitizer
|
||||
) {
|
||||
this.annotationResolver = annotationResolver;
|
||||
this.builtIns = builtIns;
|
||||
@@ -120,6 +122,7 @@ public class DescriptorResolver {
|
||||
this.wrappedTypeFactory = wrappedTypeFactory;
|
||||
this.syntheticResolveExtension = SyntheticResolveExtension.Companion.getInstance(project);
|
||||
typeApproximator = approximator;
|
||||
this.declarationReturnTypeSanitizer = declarationReturnTypeSanitizer;
|
||||
}
|
||||
|
||||
public List<KotlinType> resolveSupertypes(
|
||||
@@ -1152,12 +1155,12 @@ public class DescriptorResolver {
|
||||
) {
|
||||
return wrappedTypeFactory.createRecursionIntolerantDeferredType(trace, () -> {
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(function, trace, languageVersionSettings);
|
||||
KotlinType type = expressionTypingServices.getBodyExpressionType(
|
||||
trace, scope, dataFlowInfo, function, functionDescriptor);
|
||||
KotlinType result = transformAnonymousTypeIfNeeded(functionDescriptor, function, type, trace);
|
||||
UnwrappedType approximatedType = typeApproximator.approximateDeclarationType(result, false);
|
||||
functionsTypingVisitor.checkTypesForReturnStatements(function, trace, approximatedType);
|
||||
return approximatedType;
|
||||
KotlinType type = expressionTypingServices.getBodyExpressionType(trace, scope, dataFlowInfo, function, functionDescriptor);
|
||||
KotlinType publicType = transformAnonymousTypeIfNeeded(functionDescriptor, function, type, trace);
|
||||
UnwrappedType approximatedType = typeApproximator.approximateDeclarationType(publicType, false);
|
||||
KotlinType sanitizedType = declarationReturnTypeSanitizer.sanitizeReturnType(approximatedType, wrappedTypeFactory, trace, languageVersionSettings);
|
||||
functionsTypingVisitor.checkTypesForReturnStatements(function, trace, sanitizedType);
|
||||
return sanitizedType;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ class FunctionDescriptorResolver(
|
||||
assert(function.typeReference == null) {
|
||||
"Return type must be initialized early for function: " + function.text + ", at: " + DiagnosticUtils.atLocation(function) }
|
||||
|
||||
val returnType = when {
|
||||
val inferredReturnType = when {
|
||||
function.hasBlockBody() ->
|
||||
builtIns.unitType
|
||||
function.hasBody() ->
|
||||
@@ -142,7 +142,7 @@ class FunctionDescriptorResolver(
|
||||
else ->
|
||||
ErrorUtils.createErrorType("No type, no body")
|
||||
}
|
||||
functionDescriptor.setReturnType(returnType)
|
||||
functionDescriptor.setReturnType(inferredReturnType)
|
||||
}
|
||||
|
||||
fun initializeFunctionDescriptorAndExplicitReturnType(
|
||||
|
||||
@@ -24,7 +24,7 @@ interface IdentifierChecker {
|
||||
fun checkIdentifier(identifier: PsiElement?, diagnosticHolder: DiagnosticSink)
|
||||
fun checkDeclaration(declaration: KtDeclaration, diagnosticHolder: DiagnosticSink)
|
||||
|
||||
object DEFAULT : IdentifierChecker {
|
||||
object Default : IdentifierChecker {
|
||||
override fun checkIdentifier(identifier: PsiElement?, diagnosticHolder: DiagnosticSink) {}
|
||||
override fun checkDeclaration(declaration: KtDeclaration, diagnosticHolder: DiagnosticSink) {}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,16 @@ import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.VariableDescriptorWithInitializerImpl
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.KtVariableDeclaration
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptorNonRoot
|
||||
interface OverloadFilter {
|
||||
fun filterPackageMemberOverloads(overloads: Collection<DeclarationDescriptorNonRoot>): Collection<DeclarationDescriptorNonRoot>
|
||||
|
||||
object DEFAULT : OverloadFilter {
|
||||
object Default : OverloadFilter {
|
||||
override fun filterPackageMemberOverloads(overloads: Collection<DeclarationDescriptorNonRoot>): Collection<DeclarationDescriptorNonRoot> =
|
||||
overloads
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
interface OverridesBackwardCompatibilityHelper {
|
||||
fun overrideCanBeOmitted(overridingDescriptor: CallableMemberDescriptor): Boolean
|
||||
|
||||
object DEFAULT : OverridesBackwardCompatibilityHelper {
|
||||
object Default : OverridesBackwardCompatibilityHelper {
|
||||
override fun overrideCanBeOmitted(overridingDescriptor: CallableMemberDescriptor): Boolean =
|
||||
false
|
||||
}
|
||||
|
||||
@@ -64,8 +64,9 @@ abstract class TargetPlatform(val platformName: String) {
|
||||
override val platformConfigurator =
|
||||
object : PlatformConfigurator(
|
||||
DynamicTypesSettings(), listOf(), listOf(), listOf(), listOf(), listOf(),
|
||||
IdentifierChecker.DEFAULT, OverloadFilter.DEFAULT, PlatformToKotlinClassMap.EMPTY, DelegationFilter.DEFAULT,
|
||||
OverridesBackwardCompatibilityHelper.DEFAULT
|
||||
IdentifierChecker.Default, OverloadFilter.Default, PlatformToKotlinClassMap.EMPTY, DelegationFilter.Default,
|
||||
OverridesBackwardCompatibilityHelper.Default,
|
||||
DeclarationReturnTypeSanitizer.Default
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
@@ -118,7 +119,8 @@ abstract class PlatformConfigurator(
|
||||
private val overloadFilter: OverloadFilter,
|
||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
||||
private val delegationFilter: DelegationFilter,
|
||||
private val overridesBackwardCompatibilityHelper: OverridesBackwardCompatibilityHelper
|
||||
private val overridesBackwardCompatibilityHelper: OverridesBackwardCompatibilityHelper,
|
||||
private val declarationReturnTypeSanitizer: DeclarationReturnTypeSanitizer
|
||||
) {
|
||||
private val declarationCheckers: List<DeclarationChecker> = DEFAULT_DECLARATION_CHECKERS + additionalDeclarationCheckers
|
||||
private val callCheckers: List<CallChecker> = DEFAULT_CALL_CHECKERS + additionalCallCheckers
|
||||
@@ -139,6 +141,7 @@ abstract class PlatformConfigurator(
|
||||
useInstance(platformToKotlinClassMap)
|
||||
useInstance(delegationFilter)
|
||||
useInstance(overridesBackwardCompatibilityHelper)
|
||||
useInstance(declarationReturnTypeSanitizer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||
import org.jetbrains.kotlin.descriptors.impl.VariableDescriptorWithInitializerImpl
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -39,7 +40,9 @@ class VariableTypeAndInitializerResolver(
|
||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||
private val delegatedPropertyResolver: DelegatedPropertyResolver,
|
||||
private val wrappedTypeFactory: WrappedTypeFactory,
|
||||
private val typeApproximator: TypeApproximator
|
||||
private val typeApproximator: TypeApproximator,
|
||||
private val declarationReturnTypeSanitizer: DeclarationReturnTypeSanitizer,
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
companion object {
|
||||
@JvmField
|
||||
@@ -92,6 +95,7 @@ class VariableTypeAndInitializerResolver(
|
||||
|
||||
else -> resolveInitializerType(scopeForInitializer, variable.initializer!!, dataFlowInfo, trace, local)
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -152,7 +156,9 @@ class VariableTypeAndInitializerResolver(
|
||||
trace: BindingTrace,
|
||||
local: Boolean
|
||||
): KotlinType {
|
||||
return approximateType(expressionTypingServices.safeGetType(scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, trace), local)
|
||||
val inferredType = expressionTypingServices.safeGetType(scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, trace)
|
||||
val approximatedType = approximateType(inferredType, local)
|
||||
return declarationReturnTypeSanitizer.sanitizeReturnType(approximatedType, wrappedTypeFactory, trace, languageVersionSettings)
|
||||
}
|
||||
|
||||
private fun approximateType(type: KotlinType, local: Boolean): UnwrappedType = typeApproximator.approximateDeclarationType(type, local)
|
||||
|
||||
@@ -180,12 +180,25 @@ class GenericCandidateResolver(
|
||||
|
||||
private fun getBinaryWithTypeParent(calleeExpression: KtExpression?): KtBinaryExpressionWithTypeRHS? {
|
||||
val callExpression = calleeExpression?.parent.safeAs<KtCallExpression>() ?: return null
|
||||
val parent = callExpression.parent
|
||||
return when (parent) {
|
||||
is KtBinaryExpressionWithTypeRHS -> parent
|
||||
is KtQualifiedExpression -> parent.parent.safeAs<KtBinaryExpressionWithTypeRHS>().takeIf { parent.selectorExpression == callExpression }
|
||||
else -> null
|
||||
val possibleQualifiedExpression = callExpression.parent
|
||||
|
||||
val targetExpression = if (possibleQualifiedExpression is KtQualifiedExpression) {
|
||||
if (possibleQualifiedExpression.selectorExpression != callExpression) return null
|
||||
possibleQualifiedExpression
|
||||
}
|
||||
else {
|
||||
callExpression
|
||||
}
|
||||
|
||||
return targetExpression.topParenthesizedParentOrMe().parent.safeAs<KtBinaryExpressionWithTypeRHS>()
|
||||
}
|
||||
|
||||
private fun KtExpression.topParenthesizedParentOrMe(): KtExpression {
|
||||
var result: KtExpression = this
|
||||
while (KtPsiUtil.deparenthesizeOnce(result.parent.safeAs()) == result) {
|
||||
result = result.parent.safeAs() ?: break
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addValidityConstraintsForConstituentTypes(builder: ConstraintSystem.Builder, type: KotlinType) {
|
||||
|
||||
@@ -96,9 +96,12 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
nullability: Nullability,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
typeInfo: SetMultimap<DataFlowValue, KotlinType>? = null,
|
||||
affectReceiver: Boolean = true
|
||||
affectReceiver: Boolean = true,
|
||||
recordUnstable: Boolean = true
|
||||
): Boolean {
|
||||
map.put(value, nullability)
|
||||
if (value.isStable || recordUnstable) {
|
||||
map.put(value, nullability)
|
||||
}
|
||||
|
||||
val identifierInfo = value.identifierInfo
|
||||
if (affectReceiver && !nullability.canBeNull() &&
|
||||
@@ -108,7 +111,8 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
val receiverType = identifierInfo.receiverType
|
||||
if (identifierInfo.safe && receiverType != null) {
|
||||
val receiverValue = DataFlowValue(identifierInfo.receiverInfo, receiverType)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.SafeCast -> {
|
||||
@@ -118,12 +122,16 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.SafeCastCheckBoundSmartCasts)) {
|
||||
|
||||
val subjectValue = DataFlowValue(identifierInfo.subjectInfo, subjectType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability, languageVersionSettings, typeInfo)
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = false)
|
||||
if (subjectValue.isStable) {
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
}
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.Variable -> identifierInfo.bound?.let {
|
||||
putNullabilityAndTypeInfo(map, it, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, it, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ interface DelegationFilter {
|
||||
|
||||
fun filter(interfaceMember: CallableMemberDescriptor, languageVersionSettings: LanguageVersionSettings): Boolean
|
||||
|
||||
object DEFAULT : DelegationFilter {
|
||||
object Default : DelegationFilter {
|
||||
override fun filter(interfaceMember: CallableMemberDescriptor, languageVersionSettings: LanguageVersionSettings) = true
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,7 @@ class FileScopeFactory(
|
||||
|
||||
fun createScopesForFile(file: KtFile, existingImports: ImportingScope? = null): FileScopes {
|
||||
val packageView = moduleDescriptor.getPackage(file.packageFqName)
|
||||
val packageFragment = topLevelDescriptorProvider.getPackageFragment(file.packageFqName)
|
||||
if (packageFragment == null) {
|
||||
// TODO J2K and change return type of diagnoseMissingPackageFragment() to Nothing
|
||||
(topLevelDescriptorProvider as? LazyClassContext)?.declarationProviderFactory?.diagnoseMissingPackageFragment(file)
|
||||
error("Could not find fragment ${file.packageFqName} for file ${file.name}")
|
||||
}
|
||||
val packageFragment = topLevelDescriptorProvider.getPackageFragmentOrDiagnoseFailure(file.packageFqName, file)
|
||||
|
||||
return FilesScopesBuilder(file, existingImports, packageFragment, packageView).result
|
||||
}
|
||||
@@ -119,7 +114,7 @@ class FileScopeFactory(
|
||||
}
|
||||
}
|
||||
|
||||
val lexicalScope = LexicalScope.Base(lazyImportingScope, topLevelDescriptorProvider.getPackageFragment(file.packageFqName)!!)
|
||||
val lexicalScope = LexicalScope.Base(lazyImportingScope, topLevelDescriptorProvider.getPackageFragmentOrDiagnoseFailure(file.packageFqName, file))
|
||||
|
||||
val importResolver = object : ImportResolver {
|
||||
override fun forceResolveAllImports() {
|
||||
|
||||
@@ -216,16 +216,8 @@ open class LazyDeclarationResolver @Deprecated("") constructor(
|
||||
val ktFile = declaration.containingFile as KtFile
|
||||
val fqName = ktFile.packageFqName
|
||||
topLevelDescriptorProvider.assertValid()
|
||||
val packageDescriptor = topLevelDescriptorProvider.getPackageFragment(fqName)
|
||||
if (packageDescriptor == null) {
|
||||
if (topLevelDescriptorProvider is LazyClassContext) {
|
||||
topLevelDescriptorProvider.declarationProviderFactory.diagnoseMissingPackageFragment(ktFile)
|
||||
}
|
||||
else {
|
||||
throw IllegalStateException("Cannot find package fragment for file " + ktFile.name + " with package " + fqName)
|
||||
}
|
||||
}
|
||||
return packageDescriptor!!.getMemberScope()
|
||||
val packageDescriptor = topLevelDescriptorProvider.getPackageFragmentOrDiagnoseFailure(fqName, ktFile)
|
||||
return packageDescriptor.getMemberScope()
|
||||
}
|
||||
else {
|
||||
return when (parentDeclaration) {
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
|
||||
|
||||
@Inject
|
||||
public void setDelegationFilter(@NotNull DelegationFilter delegationFilter) {
|
||||
public void setDelegationFilter(@NotNull DelegationFilter delegationFilter) {
|
||||
this.delegationFilter = delegationFilter;
|
||||
}
|
||||
|
||||
@@ -213,6 +213,18 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
return packages.invoke(fqName);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LazyPackageDescriptor getPackageFragmentOrDiagnoseFailure(@NotNull FqName fqName, @Nullable KtFile from) {
|
||||
LazyPackageDescriptor packageDescriptor = getPackageFragment(fqName);
|
||||
if (packageDescriptor == null) {
|
||||
declarationProviderFactory.diagnoseMissingPackageFragment(fqName, from);
|
||||
assert false : "diagnoseMissingPackageFragment should throw!";
|
||||
}
|
||||
return packageDescriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private LazyPackageDescriptor createPackage(FqName fqName) {
|
||||
PackageMemberDeclarationProvider provider = declarationProviderFactory.getPackageMemberDeclarationProvider(fqName);
|
||||
@@ -350,8 +362,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
) {
|
||||
result.add(current);
|
||||
for (FqName subPackage : packageFragmentProvider.getSubPackagesOf(current.getFqName(), MemberScope.Companion.getALL_NAME_FILTER())) {
|
||||
LazyPackageDescriptor fragment = getPackageFragment(subPackage);
|
||||
assert fragment != null : "Couldn't find fragment for " + subPackage;
|
||||
LazyPackageDescriptor fragment = getPackageFragmentOrDiagnoseFailure(subPackage, null);
|
||||
collectAllPackages(result, fragment);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -19,11 +19,14 @@ package org.jetbrains.kotlin.resolve.lazy
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor
|
||||
|
||||
interface TopLevelDescriptorProvider {
|
||||
fun getPackageFragment(fqName: FqName): LazyPackageDescriptor?
|
||||
|
||||
fun getPackageFragmentOrDiagnoseFailure(fqName: FqName, from: KtFile?): LazyPackageDescriptor
|
||||
|
||||
fun getTopLevelClassifierDescriptors(fqName: FqName, location: LookupLocation): Collection<ClassifierDescriptor>
|
||||
|
||||
fun assertValid()
|
||||
@@ -36,6 +39,10 @@ object NoTopLevelDescriptorProvider : TopLevelDescriptorProvider {
|
||||
shouldNotBeCalled()
|
||||
}
|
||||
|
||||
override fun getPackageFragmentOrDiagnoseFailure(fqName: FqName, from: KtFile?): LazyPackageDescriptor {
|
||||
shouldNotBeCalled()
|
||||
}
|
||||
|
||||
override fun getTopLevelClassifierDescriptors(fqName: FqName, location: LookupLocation): Collection<ClassifierDescriptor> {
|
||||
shouldNotBeCalled()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,11 @@ public abstract class AbstractDeclarationProviderFactory implements DeclarationP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void diagnoseMissingPackageFragment(KtFile file) {
|
||||
throw new IllegalStateException("Cannot find package fragment for file " + file.getName() + " with package " + file.getPackageFqName());
|
||||
public void diagnoseMissingPackageFragment(@NotNull FqName fqName, @Nullable KtFile file) {
|
||||
String message = "Cannot find package fragment " + fqName;
|
||||
if (file != null) {
|
||||
message += "\nvFile = " + file.getVirtualFilePath() + ", file package = '" + file.getPackageFqName() + "'";
|
||||
}
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,5 @@ public interface DeclarationProviderFactory {
|
||||
@Nullable
|
||||
PackageMemberDeclarationProvider getPackageMemberDeclarationProvider(@NotNull FqName packageFqName);
|
||||
|
||||
void diagnoseMissingPackageFragment(KtFile file);
|
||||
void diagnoseMissingPackageFragment(@NotNull FqName fqName, @Nullable KtFile file);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ class LocalClassDescriptorHolder(
|
||||
throw UnsupportedOperationException("Should not be called for top-level declarations")
|
||||
}
|
||||
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile?) {
|
||||
override fun diagnoseMissingPackageFragment(fqName: FqName, file: KtFile?) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +46,10 @@ protected constructor(
|
||||
cached = WeakReference(newVal)
|
||||
return newVal.second
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic fun <T, R> create(epName: ExtensionPointName<T>, map: (List<T>) -> R): MappedExtensionProvider<T, R>
|
||||
= MappedExtensionProvider(epName, map)
|
||||
}
|
||||
}
|
||||
|
||||
class ExtensionProvider<T>(epName: ExtensionPointName<T>) : MappedExtensionProvider<T, List<T>>(epName, { it }) {
|
||||
companion object {
|
||||
@JvmStatic fun <T> create(epName: ExtensionPointName<T>): ExtensionProvider<T> = ExtensionProvider(epName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.build.GeneratedFile
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
@@ -83,6 +83,16 @@ class IncrementalJsCompilerRunner(
|
||||
override fun calculateSourcesToCompile(caches: IncrementalJsCachesManager, changedFiles: ChangedFiles.Known, args: K2JSCompilerArguments): CompilationMode {
|
||||
if (BuildInfo.read(lastBuildInfoFile) == null) return CompilationMode.Rebuild { "No information on previous build" }
|
||||
|
||||
val libs = (args.libraries ?: "").split(File.pathSeparator).mapTo(HashSet()) { File(it) }
|
||||
val libsDirs = libs.filter { it.isDirectory }
|
||||
|
||||
val changedLib = changedFiles.allAsSequence.find { it in libs }
|
||||
?: changedFiles.allAsSequence.find { changedFile ->
|
||||
libsDirs.any { libDir -> FileUtil.isAncestor(libDir, changedFile, true) }
|
||||
}
|
||||
|
||||
if (changedLib != null) return CompilationMode.Rebuild { "Library has been changed: $changedLib" }
|
||||
|
||||
return CompilationMode.Incremental(getDirtyFiles(changedFiles))
|
||||
}
|
||||
|
||||
@@ -133,4 +143,7 @@ class IncrementalJsCompilerRunner(
|
||||
args.freeArgs = freeArgsBackup
|
||||
}
|
||||
}
|
||||
|
||||
private val ChangedFiles.Known.allAsSequence: Sequence<File>
|
||||
get() = modified.asSequence() + removed.asSequence()
|
||||
}
|
||||
@@ -1315,6 +1315,12 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("allKotlinFilesRemovedThenNewAdded")
|
||||
public void testAllKotlinFilesRemovedThenNewAdded() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/other/allKotlinFilesRemovedThenNewAdded/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classToPackageFacade")
|
||||
public void testClassToPackageFacade() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/other/classToPackageFacade/");
|
||||
|
||||
2
compiler/testData/asJava/lightClasses/compilationErrors/AllInlineOnly.java
vendored
Normal file
2
compiler/testData/asJava/lightClasses/compilationErrors/AllInlineOnly.java
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
public final class AllInlineOnly {
|
||||
}
|
||||
11
compiler/testData/asJava/lightClasses/compilationErrors/AllInlineOnly.kt
vendored
Normal file
11
compiler/testData/asJava/lightClasses/compilationErrors/AllInlineOnly.kt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// p.AllInlineOnly
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("AllInlineOnly")
|
||||
|
||||
package p
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun f(): Int = 3
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun g(p: String): String = "p"
|
||||
2
compiler/testData/asJava/lightClasses/facades/AllPrivate.java
vendored
Normal file
2
compiler/testData/asJava/lightClasses/facades/AllPrivate.java
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
public final class AllPrivate {
|
||||
}
|
||||
9
compiler/testData/asJava/lightClasses/facades/AllPrivate.kt
vendored
Normal file
9
compiler/testData/asJava/lightClasses/facades/AllPrivate.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// p.AllPrivate
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("AllPrivate")
|
||||
|
||||
package p
|
||||
|
||||
private fun f(): Int = 3
|
||||
|
||||
private fun g(p: String): String = "p"
|
||||
1
compiler/testData/cli/js/jsExtraHelp.out
vendored
1
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
|
||||
-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
|
||||
-Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects
|
||||
-Xno-inline Disable method inlining
|
||||
|
||||
7
compiler/testData/cli/jvm/extraHelp.out
vendored
7
compiler/testData/cli/jvm/extraHelp.out
vendored
@@ -5,8 +5,8 @@ where advanced options include:
|
||||
or all modules on the module path if <module> is ALL-MODULE-PATH
|
||||
-Xbuild-file=<path> Path to the .xml build file to compile
|
||||
-Xcompile-java Reuse javac analysis and compile Java source files
|
||||
-Xnormalize-constructor-calls={disable|enable|preserve-class-initialization}
|
||||
Normalize constructor calls (disable: don't normalize; enable: normalize; preserve-class-initialization: normalize preserving class initialization order), default is disable
|
||||
-Xnormalize-constructor-calls={disable|enable}
|
||||
Normalize constructor calls (disable: don't normalize; enable: normalize), default is disable
|
||||
-Xdump-declarations-to=<path> Path to JSON file to dump Java to Kotlin declaration mappings
|
||||
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
|
||||
-Xmodule-path=<path> Paths where to find Java 9+ modules
|
||||
@@ -26,12 +26,15 @@ where advanced options include:
|
||||
Script resolver environment in key-value pairs (the value could be quoted and escaped)
|
||||
-Xsingle-module Combine modules for source files and binary dependencies into a single module
|
||||
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
|
||||
-Xstrict-java-nullability-assertions
|
||||
Generate nullability assertions for non-null Java expressions
|
||||
-Xuse-javac Use javac for Java source and class files analysis
|
||||
-Xuse-old-class-files-reading Use old class files reading implementation (may slow down the build and should be used in case of problems with the new implementation)
|
||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||
-Xcoroutines={enable|warn|error}
|
||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||
-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
|
||||
-Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects
|
||||
-Xno-inline Disable method inlining
|
||||
|
||||
4
compiler/testData/cli/jvm/legacySmartCastsAfterTry.args
vendored
Normal file
4
compiler/testData/cli/jvm/legacySmartCastsAfterTry.args
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/legacySmartCastsAfterTry.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xlegacy-smart-cast-after-try
|
||||
9
compiler/testData/cli/jvm/legacySmartCastsAfterTry.kt
vendored
Normal file
9
compiler/testData/cli/jvm/legacySmartCastsAfterTry.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
fun foo() {
|
||||
var some: String? = null
|
||||
some = "alpha"
|
||||
try {
|
||||
some = "omega"
|
||||
}
|
||||
catch (e: Exception) {}
|
||||
some.length
|
||||
}
|
||||
4
compiler/testData/cli/jvm/legacySmartCastsAfterTry.out
vendored
Normal file
4
compiler/testData/cli/jvm/legacySmartCastsAfterTry.out
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/legacySmartCastsAfterTry.kt:2:25: warning: variable 'some' initializer is redundant
|
||||
var some: String? = null
|
||||
^
|
||||
OK
|
||||
@@ -1,4 +1,5 @@
|
||||
warning: flag is not supported by this version of the compiler: -Xabcdefghijklm
|
||||
warning: flag is not supported by this version of the compiler: -Xnopqrstuvwxyz
|
||||
warning: flag is not supported by this version of the compiler: -XXxxxxxxxxxxxx
|
||||
warning: running the Kotlin compiler under Java 6 or 7 is unsupported and will no longer be possible in a future update.
|
||||
OK
|
||||
|
||||
24
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt
vendored
Normal file
24
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor1.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface IBar {
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
abstract class Base(val x: IFoo)
|
||||
|
||||
enum class Test : IFoo, IBar {
|
||||
FOO {
|
||||
// FOO referenced from inner class constructor with uninitialized 'this'
|
||||
inner class Inner : Base(FOO)
|
||||
|
||||
val z = Inner()
|
||||
|
||||
override fun foo() = "OK"
|
||||
|
||||
override fun bar() = z.x.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test.FOO.bar()
|
||||
24
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt
vendored
Normal file
24
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor2.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface IBar {
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
enum class Test : IFoo, IBar {
|
||||
FOO {
|
||||
// FOO referenced from inner class constructor with initialized 'this'
|
||||
inner class Inner {
|
||||
val fooFoo = FOO.foo()
|
||||
}
|
||||
|
||||
val z = Inner()
|
||||
|
||||
override fun foo() = "OK"
|
||||
|
||||
override fun bar() = z.fooFoo
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test.FOO.bar()
|
||||
23
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt
vendored
Normal file
23
compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface IBar {
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
enum class Test : IFoo, IBar {
|
||||
FOO {
|
||||
// FOO referenced from inner class constructor with initialized 'this',
|
||||
// in delegate initializer
|
||||
inner class Inner : IFoo by FOO
|
||||
|
||||
val z = Inner()
|
||||
|
||||
override fun foo() = "OK"
|
||||
|
||||
override fun bar() = z.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test.FOO.bar()
|
||||
8
compiler/testData/codegen/box/enum/kt20651a.kt
vendored
Normal file
8
compiler/testData/codegen/box/enum/kt20651a.kt
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
enum class Foo(
|
||||
val x: String,
|
||||
val callback: () -> String
|
||||
) {
|
||||
FOO("OK", { FOO.x })
|
||||
}
|
||||
|
||||
fun box() = Foo.FOO.callback()
|
||||
17
compiler/testData/codegen/box/enum/kt20651b.kt
vendored
Normal file
17
compiler/testData/codegen/box/enum/kt20651b.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
interface Callback {
|
||||
fun invoke(): String
|
||||
}
|
||||
|
||||
enum class Foo(
|
||||
val x: String,
|
||||
val callback: Callback
|
||||
) {
|
||||
FOO(
|
||||
"OK",
|
||||
object : Callback {
|
||||
override fun invoke() = FOO.x
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun box() = Foo.FOO.callback.invoke()
|
||||
@@ -2,16 +2,21 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
|
||||
//This front-end problem test added to box ones only cause of FULL_JDK support
|
||||
import org.w3c.dom.Element
|
||||
import org.xml.sax.InputSource
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import java.io.StringReader
|
||||
|
||||
class MyElement(e: Element): Element by e {
|
||||
fun bar() = "OK"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val touch = MyElement::class.java
|
||||
return "OK"
|
||||
val factory = DocumentBuilderFactory.newInstance()!!;
|
||||
val builder = factory.newDocumentBuilder()!!;
|
||||
val source = InputSource(StringReader("<OK></OK>"));
|
||||
val doc = builder.parse(source)!!;
|
||||
val myElement = MyElement(doc.getDocumentElement()!!)
|
||||
return myElement.getTagName()!!
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
J().test()
|
||||
return "Fail: should throw"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun withAssertion(j: J) = j.nullString()
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public @NotNull String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
TestKt.withAssertion(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// See KT-8135
|
||||
// We could generate runtime assertion on call site for 'generic<NOT_NULL_TYPE>()' below.
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
J().test()
|
||||
return "OK"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "Fail: SHOULD NOT throw"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun withAssertion(j: J) = generic<String?>(j)
|
||||
|
||||
fun <T> generic(j: J) = j.nullT<T>()
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public <T> @NotNull T nullT() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
TestKt.withAssertion(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
outer()
|
||||
return "Fail: should throw"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun outer() {
|
||||
fun withAssertion() = J().nullString()
|
||||
withAssertion() // NB not used itself
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public @NotNull String nullString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
J().test()
|
||||
return "Fail: should throw"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun withAssertion(j: J) {
|
||||
val x = j.nullString()
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public @NotNull String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
TestKt.withAssertion(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
J().test()
|
||||
return "Fail: should throw"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
class C {
|
||||
val withAssertion = J().nullString()
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public @NotNull String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object test() {
|
||||
return new C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
||||
|
||||
// FILE: box.kt
|
||||
fun box(): String {
|
||||
try {
|
||||
J().test()
|
||||
return "Fail: should throw"
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
val withAssertion get() = J().nullString()
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class J {
|
||||
public @NotNull String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
TestKt.getWithAssertion();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user