mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-04 00:21:28 +00:00
Compare commits
302 Commits
1.2-Beta2
...
diagnoseMi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6db79146b1 | ||
|
|
03d6595ea4 | ||
|
|
ad20d82334 | ||
|
|
14f2ede057 | ||
|
|
a005f4804e | ||
|
|
9305903e6c | ||
|
|
329322e268 | ||
|
|
6c2eb06351 | ||
|
|
84ab397f25 | ||
|
|
fab8187574 | ||
|
|
9730d50e10 | ||
|
|
132285ea03 | ||
|
|
1be86e05ae | ||
|
|
43302ce00c | ||
|
|
0a31b4ccc1 | ||
|
|
bd7129d0d6 | ||
|
|
9e061d3bbb | ||
|
|
b20ffe76b7 | ||
|
|
b2e5e9dab5 | ||
|
|
d1eaf444a6 | ||
|
|
327caa086b | ||
|
|
3ead2e9cd4 | ||
|
|
dddd1cdba5 | ||
|
|
3049b5d92f | ||
|
|
b43b470b8f | ||
|
|
f52ba44e90 | ||
|
|
8c6ed3e872 | ||
|
|
61b78d7eda | ||
|
|
3cfb1fd6a7 | ||
|
|
339d06d040 | ||
|
|
56a51c1d22 | ||
|
|
8f98f00030 | ||
|
|
6a7cdc01a6 | ||
|
|
64a51fe0d1 | ||
|
|
89c4196c06 | ||
|
|
817f79520a | ||
|
|
0fffb9fb17 | ||
|
|
bcbeab00d5 | ||
|
|
9ea9ea1008 | ||
|
|
204d9e3423 | ||
|
|
ffa9478d0c | ||
|
|
093f796fc7 | ||
|
|
6fe299cd5b | ||
|
|
be63f09f8f | ||
|
|
4d4285824b | ||
|
|
e17610f378 | ||
|
|
d6143e2af6 | ||
|
|
0a4860b4d7 | ||
|
|
f6a7327758 | ||
|
|
50ebcfe09e | ||
|
|
c2b9803933 | ||
|
|
44260cdc7c | ||
|
|
2ed3e88561 | ||
|
|
f93f502ebe | ||
|
|
d59276671f | ||
|
|
0fd4cdb086 | ||
|
|
63ad89eeb0 | ||
|
|
ef71f7707d | ||
|
|
5f4233e4bf | ||
|
|
fbda2a4343 | ||
|
|
a64fc10e94 | ||
|
|
8695c6a1e4 | ||
|
|
d0274c3c53 | ||
|
|
d79b571781 | ||
|
|
8786c951a6 | ||
|
|
33549362cb | ||
|
|
c2276e2ccb | ||
|
|
ef00807a18 | ||
|
|
c009f94eea | ||
|
|
959299eeab | ||
|
|
ccd7bfa337 | ||
|
|
152bcda2c8 | ||
|
|
dfd24d166c | ||
|
|
213ce01152 | ||
|
|
f878fa69c1 | ||
|
|
1af692c957 | ||
|
|
cbef372e69 | ||
|
|
7a156e4407 | ||
|
|
da99a100cc | ||
|
|
149daa173c | ||
|
|
54990e16c1 | ||
|
|
561d7749b1 | ||
|
|
f0da58531e | ||
|
|
cfd432614f | ||
|
|
64dbe07fdb | ||
|
|
1f643ddce8 | ||
|
|
6b43465ed8 | ||
|
|
e9e01b70a8 | ||
|
|
e488cf13ad | ||
|
|
a6e98c30d7 | ||
|
|
a11cf253df | ||
|
|
11f9c055fd | ||
|
|
2c4e023cba | ||
|
|
d75656d571 | ||
|
|
2d7fe98e55 | ||
|
|
1408c4bd44 | ||
|
|
3186c31ba7 | ||
|
|
2df4d9496a | ||
|
|
b3b08514c5 | ||
|
|
b565b00930 | ||
|
|
d6504d82b7 | ||
|
|
5541634187 | ||
|
|
e8e09dbbf8 | ||
|
|
72354559e5 | ||
|
|
97332aaeea | ||
|
|
3319fdba6d | ||
|
|
ef274ad43b | ||
|
|
189e2506d1 | ||
|
|
55996fa43d | ||
|
|
28535a57d8 | ||
|
|
dd9f12d2e5 | ||
|
|
a1949e1d53 | ||
|
|
6420f50f2e | ||
|
|
3fe2298855 | ||
|
|
6c5d78d8d5 | ||
|
|
ace9d0da94 | ||
|
|
bbcf4f7caf | ||
|
|
85945e0a6d | ||
|
|
aae67e154a | ||
|
|
8631e898a7 | ||
|
|
5778ace6b0 | ||
|
|
d12f5c79a1 | ||
|
|
cf160b5a07 | ||
|
|
98310d3bdb | ||
|
|
94e39a4c6c | ||
|
|
fb876e398c | ||
|
|
f21e1c60e0 | ||
|
|
d28e9fd22d | ||
|
|
be630f93dd | ||
|
|
6a43743c98 | ||
|
|
b7b3caedcc | ||
|
|
54d1a85430 | ||
|
|
33c0e16b83 | ||
|
|
e73760d4ff | ||
|
|
42945d33ee | ||
|
|
706a3698ec | ||
|
|
2a7d555be4 | ||
|
|
57602c420d | ||
|
|
2b924f44d8 | ||
|
|
6c47b4a39c | ||
|
|
313cd4f7bc | ||
|
|
caca7c67f4 | ||
|
|
b88d74d29b | ||
|
|
f456fa9697 | ||
|
|
97cf09b45a | ||
|
|
84c0e8dfb4 | ||
|
|
40574949c7 | ||
|
|
b1dcab886b | ||
|
|
25988957f7 | ||
|
|
b27334d2a0 | ||
|
|
1fa5152cb7 | ||
|
|
1a8be635b9 | ||
|
|
1c6dce3674 | ||
|
|
58631053c7 | ||
|
|
e83f1b138b | ||
|
|
be6474593d | ||
|
|
dd24ba6978 | ||
|
|
37300f7486 | ||
|
|
6f5d459e09 | ||
|
|
e151b8f641 | ||
|
|
499cfb5772 | ||
|
|
8a9e28afdc | ||
|
|
840825704a | ||
|
|
4cc1e22a5a | ||
|
|
17abce2811 | ||
|
|
87f3d24f9b | ||
|
|
fa4e4cbb42 | ||
|
|
f23dfdc0ac | ||
|
|
537600b3b3 | ||
|
|
d51fa6d87e | ||
|
|
bafc75ade4 | ||
|
|
73b3efd628 | ||
|
|
7a934d74e5 | ||
|
|
1ed8aa1cc5 | ||
|
|
5a6f22cc95 | ||
|
|
68870a16bb | ||
|
|
75c8b787c2 | ||
|
|
25feb23cfa | ||
|
|
f2be34ca1c | ||
|
|
d0e8f99d60 | ||
|
|
cace6624e6 | ||
|
|
31a1fb916a | ||
|
|
7044e46756 | ||
|
|
6adb62f3a2 | ||
|
|
e0eea15a4c | ||
|
|
e1f8bac4d5 | ||
|
|
2fbecfdd9c | ||
|
|
cb0482f53e | ||
|
|
d9d565d8b0 | ||
|
|
8a34c48d56 | ||
|
|
8e17bab56f | ||
|
|
81615fa551 | ||
|
|
cc85ac44b3 | ||
|
|
f589c9baf0 | ||
|
|
14a30e09c6 | ||
|
|
e76d8bc793 | ||
|
|
299a4b7f69 | ||
|
|
c5fa7fb217 | ||
|
|
f9809d5a73 | ||
|
|
6a659f33b5 | ||
|
|
b2e53644a5 | ||
|
|
739b21f519 | ||
|
|
1b0421d27b | ||
|
|
26c1aec5df | ||
|
|
4b8c04a3d6 | ||
|
|
fa03632197 | ||
|
|
4c4427c280 | ||
|
|
da52716bfd | ||
|
|
3c9ef6d319 | ||
|
|
b921eb5cc9 | ||
|
|
e90c914802 | ||
|
|
5b9b8778b5 | ||
|
|
58b815d842 | ||
|
|
a1778a7da8 | ||
|
|
bd2fd1758f | ||
|
|
dc6c19d7ef | ||
|
|
5284db8088 | ||
|
|
fd12bd904b | ||
|
|
b781661279 | ||
|
|
d4ea4983d8 | ||
|
|
f25a5b5177 | ||
|
|
7a991ddc25 | ||
|
|
e65adeb029 | ||
|
|
b8fb002a8f | ||
|
|
d89a946c5a | ||
|
|
d6ee9c9068 | ||
|
|
83b10403d7 | ||
|
|
997aa12bcc | ||
|
|
2883a92b93 | ||
|
|
6820509f83 | ||
|
|
6e410cb182 | ||
|
|
825aff7ac6 | ||
|
|
320c5f6f3a | ||
|
|
1cdac78b32 | ||
|
|
896dacc835 | ||
|
|
eaa3b3ccf0 | ||
|
|
0a2421d453 | ||
|
|
d453a2fc92 | ||
|
|
a0da37fd41 | ||
|
|
f92c4b7704 | ||
|
|
6d6ce7cbab | ||
|
|
6804409fc5 | ||
|
|
0ce4873312 | ||
|
|
c4e3cc0705 | ||
|
|
339b1a3895 | ||
|
|
3fda173ced | ||
|
|
9fe0681fb6 | ||
|
|
db34bae05b | ||
|
|
a2a8335bab | ||
|
|
0a808528b7 | ||
|
|
e94e62be98 | ||
|
|
431d47a605 | ||
|
|
050403d15b | ||
|
|
fb70227868 | ||
|
|
5babf89245 | ||
|
|
6fb1e269b4 | ||
|
|
43a1162b25 | ||
|
|
fed5bddde2 | ||
|
|
1b5b9f1fbb | ||
|
|
91ed130286 | ||
|
|
58571dcf1d | ||
|
|
8c7f469030 | ||
|
|
cafd99660a | ||
|
|
27d3ed76a0 | ||
|
|
eefad896a0 | ||
|
|
50ab054883 | ||
|
|
d89143e641 | ||
|
|
2034b1f075 | ||
|
|
a63aca08f2 | ||
|
|
7dbefc1613 | ||
|
|
a4f06c9fa8 | ||
|
|
eba2fdfe89 | ||
|
|
fde1ac5575 | ||
|
|
3fb0354676 | ||
|
|
46526db8f0 | ||
|
|
13d6e96c2f | ||
|
|
3bea095618 | ||
|
|
ef3b0e0ff0 | ||
|
|
13086b4347 | ||
|
|
65d9b0edb3 | ||
|
|
341edc3f86 | ||
|
|
93efc51843 | ||
|
|
b9fa8d4d96 | ||
|
|
539e655802 | ||
|
|
e73e4dcc6a | ||
|
|
a55c6f0c95 | ||
|
|
8ae3dbdcfc | ||
|
|
03baa51f82 | ||
|
|
8b0b334601 | ||
|
|
0510c553c3 | ||
|
|
3665255a2b | ||
|
|
8a0dcca957 | ||
|
|
0a861fd4ed | ||
|
|
dc02b2e3ab | ||
|
|
2682837fd7 | ||
|
|
ee9a6ca53e | ||
|
|
25b6dac7b5 | ||
|
|
1c3a3cd651 | ||
|
|
790b615fa1 | ||
|
|
bf3769f37e | ||
|
|
e2fd9a71df | ||
|
|
e68f8d6d45 |
8
.idea/codeStyles/Project.xml
generated
8
.idea/codeStyles/Project.xml
generated
@@ -81,12 +81,10 @@
|
||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_WRAP" value="5" />
|
||||
<option name="ASSIGNMENT_WRAP" value="1" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="CoffeeScript">
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="5" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ECMA Script Level 4">
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
@@ -111,7 +109,6 @@
|
||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="GSP">
|
||||
<indentOptions>
|
||||
@@ -145,7 +142,6 @@
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="FIELD_ANNOTATION_WRAP" value="0" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
@@ -192,7 +188,6 @@
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="FIELD_ANNOTATION_WRAP" value="0" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
<indentOptions>
|
||||
<option name="TAB_SIZE" value="8" />
|
||||
</indentOptions>
|
||||
@@ -217,7 +212,6 @@
|
||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Scala">
|
||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
|
||||
@@ -265,7 +259,6 @@
|
||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
@@ -280,7 +273,6 @@
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -1,10 +1,10 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Generate Tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<configuration default="false" name="Generate All Tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/generators" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="scriptParameters" value="-x :ultimate:generateTests" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
22
.idea/runConfigurations/Generate_Compiler_Tests.xml
generated
Normal file
22
.idea/runConfigurations/Generate_Compiler_Tests.xml
generated
Normal file
@@ -0,0 +1,22 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Generate Compiler Tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/compiler" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value=":compiler:generateTests" />
|
||||
<option value=":compiler:tests-java8:generateTests" />
|
||||
<option value=":js:js.tests:generateTests" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Regenerate standard library generated sources" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<configuration default="false" name="Generate standard library sources" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/tools/kotlin-stdlib-gen" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/libraries/tools/kotlin-stdlib-gen" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
@@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Binary compatibility tests, overwrite results" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<configuration default="false" name="Test: public API binary compatibility validator, overwrite results" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/tools/binary-compatibility-validator" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/libraries/tools/binary-compatibility-validator" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value=" --tests * " />
|
||||
<option name="taskDescriptions">
|
||||
@@ -10,6 +10,7 @@
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value=":kotlin-runtime:clean" />
|
||||
<option value=":kotlin-stdlib:clean" />
|
||||
<option value=":kotlin-reflect:clean" />
|
||||
<option value=":tools:binary-compatibility-validator:cleanTest" />
|
||||
2
.idea/scopes/IDE.xml
generated
2
.idea/scopes/IDE.xml
generated
@@ -1,3 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="IDE" pattern="file[idea]:src/*/||file[idea]:testData/*/||file[ide-common]:src/*/||file[idea-analysis]:src/*/||file[idea-android]:src/*/||file[idea-completion]:src/*/||file[idea-completion]:testData/*/||file[idea-core]:src/*/||file[idea-jps-common]:/*/||file[idea-live-templates]:/*/||file[idea-live-templates]:testData/*/||file[idea-repl]:/*/||src[idea-android-output-parser]:*..*" />
|
||||
<scope name="IDE" pattern="file[idea_main]:*/||file[idea]:testData/*/||file[idea-formatter_main]:*/||file[ide-common_main]:*/||file[idea-android_main]:*/||file[idea-android-output-parser_main]:*/||file[idea]:idea-completion/testData/*/||file[idea-core_main]:*/||file[idea-gradle_main]:*/||file[idea-jps-common_main]:*/||file[idea-jvm_main]:*/||file[idea]:idea-live-templates/src/*/||file[idea]:idea-live-templates/testData/*/||file[idea-maven_main]:*/||file[idea-repl]:*/||file[idea-test-framework_main]:*/||file[kotlin-gradle-tooling_main]:*/" />
|
||||
</component>
|
||||
@@ -73,7 +73,7 @@ on Windows.
|
||||
- `install` - build and install all public artifacts into local maven repository
|
||||
- `runIde` - build IDEA plugin and run IDEA with it
|
||||
- `coreLibsTest` - build and run stdlib, reflect and kotlin-test tests
|
||||
- `gradlePluginsTest` - build and run gradle plugin tests
|
||||
- `gradlePluginTest` - build and run gradle plugin tests
|
||||
- `compilerTest` - build and run all compiler tests
|
||||
- `ideaPluginTest` - build and run all IDEA plugin tests
|
||||
|
||||
|
||||
@@ -75,14 +75,7 @@
|
||||
</macrodef>
|
||||
|
||||
<target name="writeCompilerVersionToTemplateFile">
|
||||
<mkdir dir="${version_substitute_dir}"/>
|
||||
|
||||
<substituteVersionInFile
|
||||
target.file="${compiler.version.java}"
|
||||
target.file.bk="${compiler.version.java.bk}"
|
||||
target.file.versioned="${compiler.version.java.versioned}"
|
||||
test.string="public static final String VERSION = "@snapshot@";"
|
||||
version="${compiler.version.number}"/>
|
||||
<!-- empty, version is written in gradle build -->
|
||||
</target>
|
||||
|
||||
<target name="writePluginVersionToTemplateFile">
|
||||
|
||||
@@ -11,11 +11,14 @@ dependencies {
|
||||
compileOnly(project(":js:js.serializer"))
|
||||
compileOnly(project(":js:js.frontend"))
|
||||
compileOnly(ideaSdkDeps("util"))
|
||||
testCompileOnly(project(":compiler:cli-common"))
|
||||
testCompile(projectTests(":compiler:tests-common"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
testCompile(protobufFull())
|
||||
testRuntime(projectDist(":kotlin-stdlib"))
|
||||
testRuntime(projectDist(":kotlin-reflect"))
|
||||
testCompile(projectDist(":kotlin-stdlib"))
|
||||
testCompile(projectDist(":kotlin-reflect"))
|
||||
testCompileOnly(ideaSdkDeps("openapi"))
|
||||
testRuntime(projectDist(":kotlin-compiler"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -31,4 +34,4 @@ testsJar()
|
||||
|
||||
projectTest()
|
||||
|
||||
publish()
|
||||
publish()
|
||||
|
||||
@@ -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 ?: 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
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
buildscript {
|
||||
extra["defaultSnapshotVersion"] = "1.2-SNAPSHOT"
|
||||
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.0-dev-92", onlySuccessBootstrap = false))
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.0-dev-439", onlySuccessBootstrap = false))
|
||||
|
||||
val repos = listOfNotNull(
|
||||
bootstrapKotlinRepo,
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
|
||||
repositories {
|
||||
for (repo in repos) {
|
||||
maven { setUrl(repo) }
|
||||
maven(url = repo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ val scriptRuntimeCfg = configurations.create("scriptRuntime").extendsFrom(script
|
||||
|
||||
repositories {
|
||||
for (repo in (rootProject.extra["repos"] as List<String>)) {
|
||||
maven { setUrl(repo) }
|
||||
maven(url = repo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +217,7 @@ fun Task.listConfigurationContents(configName: String) {
|
||||
|
||||
val defaultJvmTarget = "1.8"
|
||||
val defaultJavaHome = jdkPath(defaultJvmTarget!!)
|
||||
val ignoreTestFailures by extra(project.findProperty("ignoreTestFailures")?.toString()?.toBoolean() ?: project.hasProperty("teamcity"))
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -236,14 +237,26 @@ allprojects {
|
||||
}
|
||||
configureJvmProject(javaHome!!, jvmTarget!!)
|
||||
|
||||
val commonCompilerArgs = listOf("-Xallow-kotlin-package")
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
languageVersion = kotlinLanguageVersion
|
||||
apiVersion = kotlinLanguageVersion
|
||||
freeCompilerArgs = listOf("-Xallow-kotlin-package", "-Xnormalize-constructor-calls=enable")
|
||||
freeCompilerArgs = commonCompilerArgs
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = commonCompilerArgs + listOf("-Xnormalize-constructor-calls=enable")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(VerificationTask::class.java as Class<Task>) {
|
||||
(this as VerificationTask).ignoreFailures = ignoreTestFailures
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
enabled = false
|
||||
}
|
||||
@@ -289,11 +302,6 @@ task<Copy>("ideaPlugin") {
|
||||
into("$ideaPluginDir/lib")
|
||||
}
|
||||
|
||||
task("dist-plugin") {
|
||||
dependsOn("ideaPlugin")
|
||||
doFirst { logger.warn("'$name' task is deprecated, use '${dependsOn.last()}' instead") }
|
||||
}
|
||||
|
||||
tasks {
|
||||
"clean" {
|
||||
doLast {
|
||||
@@ -319,11 +327,6 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
"gradlePluginsTest" {
|
||||
// deprecated
|
||||
dependsOn("gradlePluginTest")
|
||||
}
|
||||
|
||||
"gradlePluginIntegrationTest" {
|
||||
dependsOn(":kotlin-gradle-plugin-integration-tests:check")
|
||||
}
|
||||
@@ -335,30 +338,15 @@ tasks {
|
||||
":compiler:tests-java8:test")
|
||||
}
|
||||
|
||||
"compiler-tests" {
|
||||
dependsOn("jvmCompilerTest")
|
||||
doFirst { logger.warn("'$name' task is deprecated, use '${dependsOn.last()}' instead") }
|
||||
}
|
||||
|
||||
"jsCompilerTest" {
|
||||
dependsOn(":js:js.tests:test")
|
||||
}
|
||||
|
||||
"js-tests" {
|
||||
dependsOn("jsCompilerTest")
|
||||
doFirst { logger.warn("'$name' task is deprecated, use '${dependsOn.last()}' instead") }
|
||||
}
|
||||
|
||||
"scriptingTest" {
|
||||
dependsOn("dist")
|
||||
dependsOn(":kotlin-script-util:test")
|
||||
}
|
||||
|
||||
"scripting-tests" {
|
||||
dependsOn("scriptingTest")
|
||||
doFirst { logger.warn("'$name' task is deprecated, use '${dependsOn.last()}' instead") }
|
||||
}
|
||||
|
||||
"compilerTest" {
|
||||
dependsOn("jvmCompilerTest")
|
||||
dependsOn("jsCompilerTest")
|
||||
@@ -380,6 +368,9 @@ tasks {
|
||||
dependsOn("examplesTest")
|
||||
}
|
||||
|
||||
"androidCodegenTest" {
|
||||
dependsOn(":compiler:android-tests:test")
|
||||
}
|
||||
|
||||
"jps-tests" {
|
||||
dependsOn("dist")
|
||||
@@ -405,12 +396,11 @@ tasks {
|
||||
"idea-plugin-additional-tests")
|
||||
}
|
||||
|
||||
"android-tests" {
|
||||
"android-ide-tests" {
|
||||
dependsOn("dist")
|
||||
dependsOn(":plugins:android-extensions-ide:test",
|
||||
":idea:idea-android:test",
|
||||
":kotlin-annotation-processing:test",
|
||||
":compiler:android-tests:test")
|
||||
":kotlin-annotation-processing:test")
|
||||
}
|
||||
|
||||
"plugins-tests" {
|
||||
@@ -422,20 +412,13 @@ tasks {
|
||||
":kotlin-annotation-processing-gradle:test")
|
||||
}
|
||||
|
||||
"other-tests" {
|
||||
dependsOn("dist")
|
||||
dependsOn(":kotlin-build-common:test",
|
||||
":generators:test")
|
||||
doFirst { logger.warn("'$name' task is deprecated") }
|
||||
}
|
||||
|
||||
|
||||
"ideaPluginTest" {
|
||||
dependsOn(
|
||||
"idea-plugin-tests",
|
||||
"jps-tests",
|
||||
"plugins-tests",
|
||||
"android-tests",
|
||||
"android-ide-tests",
|
||||
":generators:test"
|
||||
)
|
||||
}
|
||||
@@ -449,7 +432,7 @@ tasks {
|
||||
"check" { dependsOn("test") }
|
||||
}
|
||||
|
||||
the<IdeaModel>().apply {
|
||||
configure<IdeaModel> {
|
||||
module {
|
||||
excludeDirs = files(
|
||||
project.buildDir,
|
||||
@@ -478,7 +461,10 @@ 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")
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
|
||||
buildscript {
|
||||
val buildSrcKotlinVersion: String by extra(findProperty("buildSrc.kotlin.version")?.toString() ?: embeddedKotlinVersion)
|
||||
extra["buildSrcKotlinRepo"] = findProperty("buildSrc.kotlin.repo")
|
||||
val buildSrcKotlinRepo: String? by extra(findProperty("buildSrc.kotlin.repo") as String?)
|
||||
extra["versions.shadow"] = "2.0.1"
|
||||
|
||||
repositories {
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
maven { setUrl(it) }
|
||||
buildSrcKotlinRepo?.let {
|
||||
maven(url = it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +31,11 @@ plugins {
|
||||
|
||||
repositories {
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
maven { setUrl(it) }
|
||||
maven(url = it)
|
||||
}
|
||||
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 {
|
||||
|
||||
@@ -62,3 +62,9 @@ var Project.jvmTarget: String?
|
||||
var Project.javaHome: String?
|
||||
get() = extra.takeIf { it.has("javaHome") }?.get("javaHome") as? String
|
||||
set(v) { extra["javaHome"] = v }
|
||||
|
||||
fun Project.generator(fqName: String) = task<JavaExec> {
|
||||
classpath = the<JavaPluginConvention>().sourceSets["test"].runtimeClasspath
|
||||
main = fqName
|
||||
workingDir = rootDir
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -39,7 +37,7 @@ fun Project.classesDirsArtifact(): FileCollection {
|
||||
}
|
||||
|
||||
fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
|
||||
val testsJarCfg = configurations.getOrCreate("tests-jar").extendsFrom(configurations["testCompile"])
|
||||
val testsJarCfg = configurations.getOrCreate("tests-jar").extendsFrom(configurations["testRuntime"])
|
||||
|
||||
return task<Jar>("testsJar") {
|
||||
dependsOn("testClasses")
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ fun Project.ideaUltimatePluginDeps(vararg artifactBaseNames: String, plugin: Str
|
||||
fun Project.kotlinDep(artifactBaseName: String, version: String): String = "org.jetbrains.kotlin:kotlin-$artifactBaseName:$version"
|
||||
|
||||
fun DependencyHandler.projectDist(name: String): Dependency = project(name, configuration = "distJar").apply { isTransitive = false }
|
||||
fun DependencyHandler.projectTests(name: String): Dependency = project(name, configuration = "tests-jar").apply { isTransitive = false }
|
||||
fun DependencyHandler.projectTests(name: String): Dependency = project(name, configuration = "tests-jar")
|
||||
fun DependencyHandler.projectRuntimeJar(name: String): Dependency = project(name, configuration = "runtimeJar")
|
||||
fun DependencyHandler.projectArchives(name: String): Dependency = project(name, configuration = "archives")
|
||||
fun DependencyHandler.projectClasses(name: String): Dependency = project(name, configuration = "classes-dirs")
|
||||
|
||||
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",
|
||||
"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)
|
||||
@@ -4,7 +4,7 @@ import org.codehaus.groovy.runtime.InvokerHelper
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.maven.MavenDeployer
|
||||
import org.gradle.api.artifacts.maven.MavenDeployment
|
||||
import org.gradle.api.artifacts.maven.MavenResolver
|
||||
|
||||
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
||||
@@ -100,21 +100,16 @@ open class PublishedKotlinModule : Plugin<Project> {
|
||||
|
||||
var repository: MavenRemoteRepository by Delegates.notNull()
|
||||
|
||||
val signPom = rootProject.extra["signPom"] as groovy.lang.Closure<*>
|
||||
|
||||
repositories {
|
||||
withConvention(MavenRepositoryHandlerConvention::class) {
|
||||
|
||||
mavenDeployer {
|
||||
signPom.call(project, this as MavenDeployer)
|
||||
|
||||
withGroovyBuilder {
|
||||
// TODO: Use with kotlin-dsl 0.12+ instead of signPom
|
||||
// "beforeDeployment" {
|
||||
// val signing = project.the<SigningExtension>()
|
||||
// if (signing.isRequired)
|
||||
// signing.signPom(this as MavenDeployment)
|
||||
// }
|
||||
"beforeDeployment" {
|
||||
val signing = project.the<SigningExtension>()
|
||||
if (signing.isRequired)
|
||||
signing.signPom(delegate as MavenDeployment)
|
||||
}
|
||||
|
||||
"repository"("url" to repoUrl)!!.also { repository = it as MavenRemoteRepository }.withGroovyBuilder {
|
||||
if (username != null && password != null) {
|
||||
|
||||
@@ -40,6 +40,16 @@ fun Project.projectTest(taskName: String = "test", body: Test.() -> Unit = {}):
|
||||
}
|
||||
}
|
||||
|
||||
doFirst {
|
||||
val agent = tasks.findByPath(":test-instrumenter:jar")!!.outputs.files.singleFile
|
||||
|
||||
val args = project.findProperty("kotlin.test.instrumentation.args")?.let { "=$it" }.orEmpty()
|
||||
|
||||
jvmArgs("-javaagent:$agent$args")
|
||||
}
|
||||
|
||||
dependsOn(":test-instrumenter:jar")
|
||||
|
||||
jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1100m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true")
|
||||
maxHeapSize = "1100m"
|
||||
systemProperty("idea.is.unit.test", "true")
|
||||
@@ -47,7 +57,6 @@ fun Project.projectTest(taskName: String = "test", body: Test.() -> Unit = {}):
|
||||
environment("PROJECT_CLASSES_DIRS", the<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.asPath)
|
||||
environment("PROJECT_BUILD_DIR", buildDir)
|
||||
systemProperty("jps.kotlin.home", rootProject.extra["distKotlinHomeDir"])
|
||||
ignoreFailures = System.getenv("kotlin_build_ignore_test_failures")?.let { it == "yes" } ?: false
|
||||
body()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
// Have to stay in the separate dir: attempt to move it to the source root dir lead to invalid import into IDEA
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
dependencies {
|
||||
compile(project(":core"))
|
||||
compile(project(":core::util.runtime"))
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:backend"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:frontend.java"))
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:cli-common"))
|
||||
compile(project(":compiler:cli"))
|
||||
compile(project(":compiler:light-classes"))
|
||||
compile(project(":compiler:serialization"))
|
||||
compile(project(":kotlin-preloader"))
|
||||
compile(project(":compiler:daemon-common"))
|
||||
compile(project(":kotlin-daemon-client"))
|
||||
compile(project(":js:js.serializer"))
|
||||
compile(project(":js:js.frontend"))
|
||||
compile(project(":js:js.translator"))
|
||||
compileOnly(project(":plugins:android-extensions-compiler"))
|
||||
compile(project(":kotlin-test:kotlin-test-jvm"))
|
||||
compile(project(":compiler:tests-common-jvm6"))
|
||||
compile(commonDep("junit:junit"))
|
||||
compile(ideaSdkCoreDeps("intellij-core"))
|
||||
compile(ideaSdkDeps("openapi", "idea", "idea_rt"))
|
||||
compile(preloadedDeps("dx", subdir = "android-5.0/lib"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { java.srcDir("../compiler/tests-common") }
|
||||
"test" {}
|
||||
}
|
||||
@@ -6,18 +6,19 @@ jvmTarget = "1.6"
|
||||
dependencies {
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:cli"))
|
||||
compile(project(":compiler.tests-common"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:backend"))
|
||||
compile(projectTests(":compiler:tests-common"))
|
||||
compile(commonDep("junit:junit"))
|
||||
compile(ideaSdkDeps("openapi"))
|
||||
|
||||
testCompile(project(":compiler:incremental-compilation-impl"))
|
||||
testCompile(project(":core"))
|
||||
testCompile(project(":compiler:frontend.java"))
|
||||
testCompile(projectTests(":jps-plugin"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(ideaSdkDeps("jps-model.jar", subdir = "jps"))
|
||||
testCompile(ideaSdkDeps("groovy-all"))
|
||||
testCompile(ideaSdkDeps("openapi", "idea"))
|
||||
testCompile(ideaSdkDeps("idea", "idea_rt"))
|
||||
testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
|
||||
testCompile(ideaSdkDeps("jps-builders"))
|
||||
}
|
||||
|
||||
@@ -1,175 +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.android.tests;
|
||||
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.android.tests.download.SDKDownloader;
|
||||
import org.jetbrains.kotlin.android.tests.emulator.Emulator;
|
||||
import org.jetbrains.kotlin.android.tests.gradle.GradleRunner;
|
||||
import org.jetbrains.kotlin.android.tests.run.PermissionManager;
|
||||
import org.junit.Assert;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodegenTestsOnAndroidRunner {
|
||||
|
||||
private final PathManager pathManager;
|
||||
|
||||
public static TestSuite getTestSuite(PathManager pathManager) {
|
||||
return new CodegenTestsOnAndroidRunner(pathManager).generateTestSuite();
|
||||
}
|
||||
|
||||
private CodegenTestsOnAndroidRunner(PathManager pathManager) {
|
||||
this.pathManager = pathManager;
|
||||
}
|
||||
|
||||
private TestSuite generateTestSuite() {
|
||||
TestSuite suite = new TestSuite("MySuite");
|
||||
|
||||
String resultOutput = runTests();
|
||||
|
||||
String reportFolder = pathManager.getTmpFolder() + "/build/outputs/androidTest-results/connected";
|
||||
try {
|
||||
List<TestCase> testCases = parseSingleReportInFolder(reportFolder);
|
||||
for (TestCase aCase : testCases) {
|
||||
suite.addTest(aCase);
|
||||
}
|
||||
Assert.assertNotEquals("There is no test results in report", 0, testCases.size());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Can't parse test results in " + reportFolder +"\n" + resultOutput);
|
||||
}
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String runTests() {
|
||||
File rootForAndroidDependencies = new File(pathManager.getDependenciesRoot());
|
||||
if (!rootForAndroidDependencies.exists()) {
|
||||
rootForAndroidDependencies.mkdirs();
|
||||
}
|
||||
|
||||
SDKDownloader downloader = new SDKDownloader(pathManager);
|
||||
downloader.downloadAll();
|
||||
downloader.unzipAll();
|
||||
PermissionManager.setPermissions(pathManager);
|
||||
|
||||
Emulator emulator = new Emulator(pathManager, Emulator.ARM);
|
||||
GradleRunner gradleRunner = new GradleRunner(pathManager);
|
||||
gradleRunner.clean();
|
||||
gradleRunner.build();
|
||||
|
||||
emulator.createEmulator();
|
||||
|
||||
String platformPrefixProperty = System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "Idea");
|
||||
try {
|
||||
emulator.startEmulator();
|
||||
|
||||
try {
|
||||
emulator.waitEmulatorStart();
|
||||
//runTestsViaAdb(emulator, gradleRunner);
|
||||
return gradleRunner.connectedDebugAndroidTest();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
emulator.stopEmulator();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if (platformPrefixProperty != null) {
|
||||
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, platformPrefixProperty);
|
||||
}
|
||||
else {
|
||||
System.clearProperty(PlatformUtils.PLATFORM_PREFIX_KEY);
|
||||
}
|
||||
emulator.finishEmulatorProcesses();
|
||||
}
|
||||
}
|
||||
|
||||
private String runTestsViaAdb(Emulator emulator, GradleRunner gradleRunner) {
|
||||
gradleRunner.installDebugAndroidTest();
|
||||
String result = emulator.runTestsViaAdb();
|
||||
System.out.println(result);
|
||||
gradleRunner.uninstallDebugAndroidTest();
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<TestCase> parseSingleReportInFolder(String reportFolder) throws
|
||||
IOException,
|
||||
SAXException,
|
||||
ParserConfigurationException {
|
||||
File folder = new File(reportFolder);
|
||||
File[] files = folder.listFiles();
|
||||
assert files != null;
|
||||
assert files.length == 1;
|
||||
File reportFile = files[0];
|
||||
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(reportFile);
|
||||
Element root = doc.getDocumentElement();
|
||||
NodeList testCases = root.getElementsByTagName("testcase");
|
||||
List<TestCase> result = new ArrayList(testCases.getLength());
|
||||
|
||||
for (int i = 0; i < testCases.getLength(); i++) {
|
||||
Element item = (Element) testCases.item(i);
|
||||
NodeList failure = item.getElementsByTagName("failure");
|
||||
String name = item.getAttribute("name");
|
||||
String clazz = item.getAttribute("classname");
|
||||
|
||||
if (failure.getLength() == 0) {
|
||||
result.add(new TestCase(name) {
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
result.add(new TestCase(name) {
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
Assert.fail(failure.item(0).getTextContent());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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.android.tests
|
||||
|
||||
import com.intellij.util.PlatformUtils
|
||||
import junit.framework.TestCase
|
||||
import junit.framework.TestSuite
|
||||
import org.jetbrains.kotlin.android.tests.download.SDKDownloader
|
||||
import org.jetbrains.kotlin.android.tests.emulator.Emulator
|
||||
import org.jetbrains.kotlin.android.tests.gradle.GradleRunner
|
||||
import org.jetbrains.kotlin.android.tests.run.PermissionManager
|
||||
import org.junit.Assert
|
||||
import org.w3c.dom.Element
|
||||
import org.xml.sax.SAXException
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.parsers.ParserConfigurationException
|
||||
|
||||
class CodegenTestsOnAndroidRunner private constructor(private val pathManager: PathManager) {
|
||||
|
||||
private fun runTestsInEmulator(): TestSuite {
|
||||
val rootSuite = TestSuite("Root")
|
||||
|
||||
downloadDependencies()
|
||||
val emulator = Emulator(pathManager, Emulator.ARM)
|
||||
emulator.createEmulator()
|
||||
|
||||
val gradleRunner = GradleRunner(pathManager)
|
||||
//old dex
|
||||
cleanAndBuildProject(gradleRunner)
|
||||
|
||||
try {
|
||||
emulator.startEmulator()
|
||||
|
||||
try {
|
||||
emulator.waitEmulatorStart()
|
||||
|
||||
runTestsOnEmulator(gradleRunner, TestSuite("Dex")).apply {
|
||||
rootSuite.addTest(this)
|
||||
}
|
||||
|
||||
enableD8(true)
|
||||
runTestsOnEmulator(gradleRunner, TestSuite("D8")).apply {
|
||||
(0 until this.countTestCases()).forEach {
|
||||
val testCase = testAt(it) as TestCase
|
||||
testCase.name += "_D8"
|
||||
}
|
||||
rootSuite.addTest(this)
|
||||
}
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
finally {
|
||||
emulator.stopEmulator()
|
||||
}
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
finally {
|
||||
emulator.finishEmulatorProcesses()
|
||||
}
|
||||
|
||||
return rootSuite
|
||||
}
|
||||
|
||||
private fun enableD8(enable: Boolean) {
|
||||
val file = File(pathManager.androidTmpFolder, "gradle.properties")
|
||||
val lines = file.readLines().map {
|
||||
if (it.startsWith("android.enableD8=")) {
|
||||
"android.enableD8=$enable"
|
||||
}
|
||||
else it
|
||||
}
|
||||
file.writeText(lines.joinToString("\n"))
|
||||
}
|
||||
|
||||
private fun processReport(suite: TestSuite, resultOutput: String) {
|
||||
val reportFolder = pathManager.tmpFolder + "/build/outputs/androidTest-results/connected"
|
||||
try {
|
||||
val testCases = parseSingleReportInFolder(reportFolder)
|
||||
testCases.forEach { aCase -> suite.addTest(aCase) }
|
||||
Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong())
|
||||
}
|
||||
catch (e: Exception) {
|
||||
throw RuntimeException("Can't parse test results in " + reportFolder + "\n" + resultOutput)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun runTestsOnEmulator(gradleRunner: GradleRunner, suite: TestSuite): TestSuite {
|
||||
val platformPrefixProperty = System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "Idea")
|
||||
try {
|
||||
val resultOutput = gradleRunner.connectedDebugAndroidTest()
|
||||
processReport(suite, resultOutput)
|
||||
return suite
|
||||
}
|
||||
finally {
|
||||
if (platformPrefixProperty != null) {
|
||||
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, platformPrefixProperty)
|
||||
}
|
||||
else {
|
||||
System.clearProperty(PlatformUtils.PLATFORM_PREFIX_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun downloadDependencies() {
|
||||
val rootForAndroidDependencies = File(pathManager.dependenciesRoot)
|
||||
if (!rootForAndroidDependencies.exists()) {
|
||||
rootForAndroidDependencies.mkdirs()
|
||||
}
|
||||
|
||||
val downloader = SDKDownloader(pathManager)
|
||||
downloader.downloadAll()
|
||||
downloader.unzipAll()
|
||||
PermissionManager.setPermissions(pathManager)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun runTestsInEmulator(pathManager: PathManager): TestSuite {
|
||||
return CodegenTestsOnAndroidRunner(pathManager).runTestsInEmulator()
|
||||
}
|
||||
|
||||
private fun cleanAndBuildProject(gradleRunner: GradleRunner) {
|
||||
gradleRunner.clean()
|
||||
gradleRunner.build()
|
||||
}
|
||||
|
||||
@Throws(IOException::class, SAXException::class, ParserConfigurationException::class)
|
||||
private fun parseSingleReportInFolder(reportFolder: String): List<TestCase> {
|
||||
val folder = File(reportFolder)
|
||||
val files = folder.listFiles()!!
|
||||
assert(files.size == 1)
|
||||
val reportFile = files[0]
|
||||
|
||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||
val dBuilder = dbFactory.newDocumentBuilder()
|
||||
val doc = dBuilder.parse(reportFile)
|
||||
val root = doc.documentElement
|
||||
val testCases = root.getElementsByTagName("testcase")
|
||||
|
||||
return (0 until testCases.length).map { i ->
|
||||
val item = testCases.item(i) as Element
|
||||
val failure = item.getElementsByTagName("failure")
|
||||
val name = item.getAttribute("name")
|
||||
val clazz = item.getAttribute("classname")
|
||||
|
||||
if (failure.length == 0) {
|
||||
object : TestCase(name) {
|
||||
@Throws(Throwable::class)
|
||||
override fun runTest() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
object : TestCase(name) {
|
||||
@Throws(Throwable::class)
|
||||
override fun runTest() {
|
||||
Assert.fail(failure.item(0).textContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,10 @@ public class PathManager {
|
||||
return tmpFolder + "/src";
|
||||
}
|
||||
|
||||
public String getAndroidTmpFolder() {
|
||||
return tmpFolder;
|
||||
}
|
||||
|
||||
public String getAndroidSdkRoot() {
|
||||
return getDependenciesRoot() + "/android-sdk";
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.jetbrains.kotlin.android.tests;
|
||||
|
||||
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Ignore
|
||||
public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
|
||||
private static final String PROJECT_NAME = "android-module";
|
||||
private static final String SDK_NAME = "Android_SDK";
|
||||
|
||||
@@ -19,13 +19,17 @@ package org.jetbrains.kotlin.android.tests;
|
||||
import com.google.common.io.Files;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import junit.framework.TestSuite;
|
||||
import kotlin.io.FilesKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.AllTests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidRunner extends TestSuite {
|
||||
@RunWith(AllTests.class)
|
||||
public class AndroidRunner {
|
||||
|
||||
private static PathManager pathManager;
|
||||
|
||||
@@ -49,7 +53,7 @@ public class AndroidRunner extends TestSuite {
|
||||
CodegenTestsOnAndroidGenerator.generate(pathManager);
|
||||
|
||||
System.out.println("Run tests on android...");
|
||||
TestSuite suite = CodegenTestsOnAndroidRunner.getTestSuite(pathManager);
|
||||
TestSuite suite = CodegenTestsOnAndroidRunner.runTestsInEmulator(pathManager);
|
||||
//AndroidJpsBuildTestCase indirectly depends on UsefulTestCase which compiled against java 8
|
||||
//TODO: Need add separate run configuration for AndroidJpsBuildTestCase
|
||||
//suite.addTest(new AndroidJpsBuildTestCase());
|
||||
@@ -62,10 +66,11 @@ public class AndroidRunner extends TestSuite {
|
||||
}
|
||||
|
||||
private static void writeAndroidSkdToLocalProperties() throws IOException {
|
||||
System.out.println("Writing android sdk to local.properties: " + pathManager.getAndroidSdkRoot());
|
||||
String sdkRoot = FilesKt.getInvariantSeparatorsPath(new File(pathManager.getAndroidSdkRoot()));
|
||||
System.out.println("Writing android sdk to local.properties: " + sdkRoot);
|
||||
File file = new File(pathManager.getTmpFolder() + "/local.properties");
|
||||
try (FileWriter fw = new FileWriter(file)) {
|
||||
fw.write("sdk.dir=" + pathManager.getAndroidSdkRoot());
|
||||
fw.write("sdk.dir=" + sdkRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,14 @@ import org.jetbrains.kotlin.test.*;
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
|
||||
|
||||
private final PathManager pathManager;
|
||||
|
||||
@@ -123,6 +123,13 @@ public class SpecialFiles {
|
||||
excludedFiles.add("closureOfInnerLocalClass.kt");
|
||||
excludedFiles.add("closureWithSelfInstantiation.kt");
|
||||
excludedFiles.add("quotedClassName.kt");
|
||||
|
||||
//wrong function resolution after package renaming
|
||||
excludedFiles.add("apiVersionAtLeast1.kt");
|
||||
|
||||
//special flags
|
||||
excludedFiles.add("inlineFunInConstructorCallWithEnabledNormalization.kt");
|
||||
excludedFiles.add("kt9532_lv10.kt");
|
||||
}
|
||||
|
||||
private SpecialFiles() {
|
||||
|
||||
@@ -17,16 +17,19 @@
|
||||
package org.jetbrains.kotlin.backend.common
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn")
|
||||
val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")
|
||||
|
||||
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
|
||||
val COROUTINE_CONTEXT_FQ_NAME = COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
|
||||
if (name != SUSPEND_COROUTINE_OR_RETURN_NAME) return false
|
||||
@@ -42,3 +45,7 @@ fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
|
||||
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull()
|
||||
|
||||
fun FunctionDescriptor.isBuiltInCoroutineContext() =
|
||||
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe == COROUTINE_CONTEXT_FQ_NAME
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -1080,11 +1086,15 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
for (Map.Entry<DeclarationDescriptor, EnclosedValueDescriptor> entry : closure.getCaptureVariables().entrySet()) {
|
||||
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
|
||||
DeclarationDescriptor declarationDescriptor = entry.getKey();
|
||||
EnclosedValueDescriptor valueDescriptor = entry.getValue();
|
||||
|
||||
Type sharedVarType = typeMapper.getSharedVarType(declarationDescriptor);
|
||||
boolean asSharedVar = sharedVarType != null;
|
||||
if (sharedVarType == null) {
|
||||
sharedVarType = typeMapper.mapType((VariableDescriptor) entry.getKey());
|
||||
sharedVarType = typeMapper.mapType((VariableDescriptor) declarationDescriptor);
|
||||
}
|
||||
StackValue capturedVar = lookupOuterValue(entry.getValue());
|
||||
StackValue capturedVar = lookupOuterValue(valueDescriptor, asSharedVar);
|
||||
callGenerator.putCapturedValueOnStack(capturedVar, sharedVarType, paramIndex++);
|
||||
}
|
||||
|
||||
@@ -1138,11 +1148,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StackValue lookupOuterValue(EnclosedValueDescriptor d) {
|
||||
private StackValue lookupOuterValue(EnclosedValueDescriptor d, boolean asSharedVar) {
|
||||
DeclarationDescriptor descriptor = d.getDescriptor();
|
||||
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
|
||||
if (aCase.isCase(descriptor)) {
|
||||
return aCase.outerValue(d, this);
|
||||
StackValue outerValue = aCase.outerValue(d, this);
|
||||
if (asSharedVar && outerValue instanceof StackValue.FieldForSharedVar) {
|
||||
StackValue.FieldForSharedVar fieldForSharedVar = (StackValue.FieldForSharedVar) outerValue;
|
||||
return fieldForSharedVar.receiver;
|
||||
}
|
||||
return outerValue;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Can't get outer value in " + this + " for " + d);
|
||||
@@ -1221,7 +1236,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private StackValue genCoroutineInstanceForSuspendLambda(@NotNull FunctionDescriptor suspendFunction) {
|
||||
public StackValue genCoroutineInstanceForSuspendLambda(@NotNull FunctionDescriptor suspendFunction) {
|
||||
if (!(suspendFunction instanceof AnonymousFunctionDescriptor)) return null;
|
||||
|
||||
ClassDescriptor suspendLambdaClassDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, suspendFunction);
|
||||
@@ -1717,12 +1732,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 +1757,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
|
||||
@@ -2169,6 +2209,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
assert enclosingSuspendFunctionJvmView != null : "No JVM view function found for " + enclosingSuspendFunction;
|
||||
|
||||
return getContinuationParameterFromEnclosingSuspendFunctionDescriptor(enclosingSuspendFunctionJvmView);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StackValue getContinuationParameterFromEnclosingSuspendFunctionDescriptor(@NotNull FunctionDescriptor enclosingSuspendFunctionJvmView) {
|
||||
ValueParameterDescriptor continuationParameter =
|
||||
enclosingSuspendFunctionJvmView.getValueParameters()
|
||||
.get(enclosingSuspendFunctionJvmView.getValueParameters().size() - 1);
|
||||
@@ -2784,7 +2829,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;
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isNullableAny;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceWithDefaultsMember;
|
||||
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.METHOD_FOR_FUNCTION;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
@@ -101,7 +100,7 @@ public class FunctionCodegen {
|
||||
private final Function1<DeclarationDescriptor, Boolean> IS_PURE_INTERFACE_CHECKER = new Function1<DeclarationDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(DeclarationDescriptor descriptor) {
|
||||
return JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state);
|
||||
return JvmCodegenUtil.isInterfaceWithoutDefaults(descriptor, state);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -866,7 +865,7 @@ public class FunctionCodegen {
|
||||
public void generateBridges(@NotNull FunctionDescriptor descriptor) {
|
||||
if (descriptor instanceof ConstructorDescriptor) return;
|
||||
if (owner.getContextKind() == OwnerKind.DEFAULT_IMPLS) return;
|
||||
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor.getContainingDeclaration(), state)) return;
|
||||
if (IS_PURE_INTERFACE_CHECKER.invoke(descriptor.getContainingDeclaration())) return;
|
||||
|
||||
// equals(Any?), hashCode(), toString() never need bridges
|
||||
if (isMethodOfAny(descriptor)) return;
|
||||
|
||||
@@ -1338,7 +1338,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateTraitMethods() {
|
||||
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)) return;
|
||||
if (isInterfaceWithoutDefaults(descriptor, state)) return;
|
||||
|
||||
List<FunctionDescriptor> restrictedInheritance = new ArrayList<>();
|
||||
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmConstantsKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor;
|
||||
@@ -63,15 +62,12 @@ public class JvmCodegenUtil {
|
||||
private JvmCodegenUtil() {
|
||||
}
|
||||
|
||||
public static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
|
||||
return isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
|
||||
public static boolean isInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
|
||||
return isInterfaceWithoutDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
|
||||
}
|
||||
|
||||
private static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
|
||||
if (!isJvmInterface(descriptor)) {
|
||||
return false;
|
||||
}
|
||||
if (ANNOTATION_CLASS == ((ClassDescriptor) descriptor).getKind()) return true;
|
||||
private static boolean isInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
|
||||
if (!DescriptorUtils.isInterface(descriptor)) return false;
|
||||
|
||||
if (descriptor instanceof DeserializedClassDescriptor) {
|
||||
SourceElement source = ((DeserializedClassDescriptor) descriptor).getSource();
|
||||
@@ -91,7 +87,7 @@ public class JvmCodegenUtil {
|
||||
}
|
||||
|
||||
public static boolean isJvm8InterfaceWithDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
|
||||
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, isJvm8Target, isJvm8TargetWithDefaults);
|
||||
return DescriptorUtils.isInterface(descriptor) && !isInterfaceWithoutDefaults(descriptor, isJvm8Target, isJvm8TargetWithDefaults);
|
||||
}
|
||||
|
||||
public static boolean isJvm8InterfaceWithDefaultsMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -106,14 +106,21 @@ public interface LocalLookup {
|
||||
BindingContext bindingContext = state.getBindingContext();
|
||||
Type localType = asmTypeForAnonymousClass(bindingContext, vd);
|
||||
|
||||
MutableClosure localFunClosure = bindingContext.get(CLOSURE, bindingContext.get(CLASS_FOR_CALLABLE, vd));
|
||||
ClassDescriptor callableClass = bindingContext.get(CLASS_FOR_CALLABLE, vd);
|
||||
assert callableClass != null : "No CLASS_FOR_CALLABLE:" + vd;
|
||||
|
||||
MutableClosure localFunClosure = bindingContext.get(CLOSURE, callableClass);
|
||||
if (localFunClosure != null && JvmCodegenUtil.isConst(localFunClosure)) {
|
||||
// This is an optimization: we can obtain an instance of a const closure simply by GETSTATIC ...$instance
|
||||
// (instead of passing this instance to the constructor and storing as a field)
|
||||
return StackValue.field(localType, localType, JvmAbi.INSTANCE_FIELD, true, StackValue.LOCAL_0, vd);
|
||||
}
|
||||
|
||||
String fieldName = "$" + vd.getName();
|
||||
String localFunClassName = callableClass.getName().asString();
|
||||
int localClassIndexStart = localFunClassName.lastIndexOf('$');
|
||||
String localFunSuffix = localClassIndexStart >= 0 ? localFunClassName.substring(localClassIndexStart) : "";
|
||||
|
||||
String fieldName = "$" + vd.getName() + localFunSuffix;
|
||||
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(localType, classType, fieldName, false,
|
||||
StackValue.LOCAL_0, vd);
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen.coroutines
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineOrReturn
|
||||
import org.jetbrains.kotlin.backend.common.*
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
||||
@@ -66,6 +64,9 @@ val COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME =
|
||||
@JvmField
|
||||
val CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME.topLevelClassAsmType()
|
||||
|
||||
@JvmField
|
||||
val COROUTINE_CONTEXT_ASM_TYPE = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineContext")).topLevelClassAsmType()
|
||||
|
||||
@JvmField
|
||||
val COROUTINE_IMPL_ASM_TYPE = COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl")).topLevelClassAsmType()
|
||||
|
||||
@@ -76,6 +77,7 @@ private val INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME =
|
||||
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
|
||||
|
||||
private val NORMALIZE_CONTINUATION_METHOD_NAME = "normalizeContinuation"
|
||||
private val GET_CONTEXT_METHOD_NAME = "getContext"
|
||||
|
||||
data class ResolvedCallWithRealDescriptor(val resolvedCall: ResolvedCall<*>, val fakeContinuationExpression: KtExpression)
|
||||
|
||||
@@ -287,6 +289,35 @@ fun createMethodNodeForSuspendCoroutineOrReturn(
|
||||
return node
|
||||
}
|
||||
|
||||
fun createMethodNodeForCoroutineContext(functionDescriptor: FunctionDescriptor): MethodNode {
|
||||
assert(functionDescriptor.isBuiltInCoroutineContext()) {
|
||||
"functionDescriptor must be kotlin.coroutines.intrinsics.coroutineContext property getter"
|
||||
}
|
||||
|
||||
val node =
|
||||
MethodNode(
|
||||
Opcodes.ASM5,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE, CONTINUATION_ASM_TYPE),
|
||||
null, null
|
||||
)
|
||||
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
|
||||
node.visitMethodInsn(
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
CONTINUATION_ASM_TYPE.internalName,
|
||||
GET_CONTEXT_METHOD_NAME,
|
||||
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE),
|
||||
true
|
||||
)
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
node.visitMaxs(1, 1)
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <D : CallableDescriptor?> D.unwrapInitialDescriptorForSuspendFunction(): D =
|
||||
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
|
||||
|
||||
@@ -18,12 +18,13 @@ package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInCoroutineContext
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.getMethodAsmFlags
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForSuspendCoroutineOrReturn
|
||||
import org.jetbrains.kotlin.codegen.coroutines.isBuiltInSuspendCoroutineOrReturnInJvm
|
||||
import org.jetbrains.kotlin.codegen.context.ClosureContext
|
||||
import org.jetbrains.kotlin.codegen.coroutines.*
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.bytecode
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.classId
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -50,8 +51,6 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral
|
||||
import org.jetbrains.kotlin.types.expressions.LabelResolver
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
@@ -225,6 +224,19 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
return true
|
||||
}
|
||||
|
||||
private fun continuationValue(): StackValue {
|
||||
assert(codegen is ExpressionCodegen) { "Expected ExpressionCodegen in coroutineContext inlining" }
|
||||
codegen as ExpressionCodegen
|
||||
|
||||
val parentContext = codegen.context.parentContext
|
||||
return if (parentContext is ClosureContext) {
|
||||
val originalSuspendLambdaDescriptor = parentContext.originalSuspendLambdaDescriptor ?: error("No original lambda descriptor found")
|
||||
codegen.genCoroutineInstanceForSuspendLambda(originalSuspendLambdaDescriptor) ?: error("No stack value for coroutine instance of lambda found")
|
||||
}
|
||||
else
|
||||
codegen.getContinuationParameterFromEnclosingSuspendFunctionDescriptor(codegen.context.functionDescriptor) ?: error("No stack value for continuation parameter of suspend function")
|
||||
}
|
||||
|
||||
protected fun inlineCall(nodeAndSmap: SMAPAndMethodNode, callDefault: Boolean): InlineResult {
|
||||
assert(delayedHiddenWriting == null) { "'putHiddenParamsIntoLocals' should be called after 'processAndPutHiddenParameters(true)'" }
|
||||
defaultSourceMapper.callSiteMarker = CallSiteMarker(codegen.lastLineNumber)
|
||||
@@ -252,6 +264,9 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
addInlineMarker(codegen.v, true)
|
||||
}
|
||||
|
||||
if (functionDescriptor.isBuiltInCoroutineContext())
|
||||
invocationParamBuilder.addNextValueParameter(CONTINUATION_ASM_TYPE, false, continuationValue(), 0)
|
||||
|
||||
val parameters = invocationParamBuilder.buildParameters()
|
||||
|
||||
val info = RootInliningContext(
|
||||
@@ -458,24 +473,28 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
state: GenerationState,
|
||||
sourceCompilerForInline: SourceCompilerForInline
|
||||
): SMAPAndMethodNode {
|
||||
if (isSpecialEnumMethod(functionDescriptor)) {
|
||||
val arguments = resolvedCall!!.typeArguments
|
||||
when {
|
||||
isSpecialEnumMethod(functionDescriptor) -> {
|
||||
val arguments = resolvedCall!!.typeArguments
|
||||
|
||||
val node = createSpecialEnumMethodBody(
|
||||
codegen,
|
||||
functionDescriptor.name.asString(),
|
||||
arguments.keys.single().defaultType,
|
||||
state.typeMapper
|
||||
)
|
||||
return SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1))
|
||||
}
|
||||
else if (functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm()) {
|
||||
return SMAPAndMethodNode(
|
||||
createMethodNodeForSuspendCoroutineOrReturn(
|
||||
functionDescriptor, state.typeMapper
|
||||
),
|
||||
val node = createSpecialEnumMethodBody(
|
||||
codegen,
|
||||
functionDescriptor.name.asString(),
|
||||
arguments.keys.single().defaultType,
|
||||
state.typeMapper
|
||||
)
|
||||
return SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1))
|
||||
}
|
||||
functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm() ->
|
||||
return SMAPAndMethodNode(
|
||||
createMethodNodeForSuspendCoroutineOrReturn(functionDescriptor, state.typeMapper),
|
||||
SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1)
|
||||
)
|
||||
)
|
||||
functionDescriptor.isBuiltInCoroutineContext() ->
|
||||
return SMAPAndMethodNode(
|
||||
createMethodNodeForCoroutineContext(functionDescriptor),
|
||||
SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1)
|
||||
)
|
||||
}
|
||||
|
||||
val asmMethod = if (callDefault)
|
||||
|
||||
@@ -69,7 +69,7 @@ internal const val THIS = "this"
|
||||
internal const val THIS_0 = "this$0"
|
||||
internal const val FIRST_FUN_LABEL = "$$$$\$ROOT$$$$$"
|
||||
internal const val SPECIAL_TRANSFORMATION_NAME = "\$special"
|
||||
internal const val INLINE_TRANSFORMATION_SUFFIX = "\$inlined"
|
||||
const val INLINE_TRANSFORMATION_SUFFIX = "\$inlined"
|
||||
internal const val INLINE_CALL_TRANSFORMATION_SUFFIX = "$" + INLINE_TRANSFORMATION_SUFFIX
|
||||
internal const val INLINE_FUN_THIS_0_SUFFIX = "\$inline_fun"
|
||||
internal const val DEFAULT_LAMBDA_FAKE_CALL = "$$\$DEFAULT_LAMBDA_FAKE_CALL$$$"
|
||||
|
||||
@@ -36,10 +36,8 @@ object LateinitIsInitialized : IntrinsicPropertyGetter() {
|
||||
private fun getStackValue(resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): StackValue? {
|
||||
val expression =
|
||||
(resolvedCall.extensionReceiver as? ExpressionReceiver)?.expression as? KtCallableReferenceExpression ?: return null
|
||||
|
||||
// TODO: support properties imported from objects as soon as KT-18982 is fixed
|
||||
val receiver = expression.receiverExpression?.let(codegen::gen) ?: StackValue.none()
|
||||
|
||||
val target = expression.callableReference.getResolvedCallWithAssert(codegen.bindingContext).resultingDescriptor
|
||||
return codegen.intermediateValueForProperty(target as PropertyDescriptor, true, false, null, false, receiver, null, true)
|
||||
val referenceResolvedCall = expression.callableReference.getResolvedCallWithAssert(codegen.bindingContext)
|
||||
val receiver = codegen.generateCallableReferenceReceiver(referenceResolvedCall) ?: StackValue.none()
|
||||
val target = referenceResolvedCall.resultingDescriptor as PropertyDescriptor
|
||||
return codegen.intermediateValueForProperty(target, 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,14 @@ val testDistProjects = listOf(
|
||||
":kotlin-test:kotlin-test-jvm",
|
||||
":kotlin-test:kotlin-test-junit",
|
||||
":kotlin-test:kotlin-test-js",
|
||||
":kotlin-daemon-client",
|
||||
":kotlin-preloader",
|
||||
":plugins:android-extensions-compiler",
|
||||
":kotlin-ant",
|
||||
":kotlin-annotations-jvm",
|
||||
":kotlin-annotations-android")
|
||||
|
||||
val testJvm6ServerRuntime by configurations.creating
|
||||
|
||||
dependencies {
|
||||
depDistProjects.forEach {
|
||||
testCompile(projectDist(it))
|
||||
@@ -43,16 +44,24 @@ dependencies {
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompileOnly(projectDist(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompileOnly(projectDist(":kotlin-test:kotlin-test-junit"))
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
testCompile(project(":compiler:tests-common-jvm6"))
|
||||
testCompile(projectTests(":compiler:tests-common"))
|
||||
testCompile(projectTests(":generators:test-generator"))
|
||||
testCompile(project(":compiler:ir.ir2cfg"))
|
||||
testCompile(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward
|
||||
testCompileOnly(project(":kotlin-daemon-client"))
|
||||
otherCompilerModules.forEach {
|
||||
testCompileOnly(project(it))
|
||||
}
|
||||
testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all", "commons-httpclient-3.1-patched"))
|
||||
|
||||
testRuntime(projectDist(":kotlin-compiler"))
|
||||
testRuntime(projectDist(":kotlin-daemon-client"))
|
||||
testRuntime(preloadedDeps("dx", subdir = "android-5.0/lib"))
|
||||
testRuntime(ideaSdkCoreDeps("*.jar"))
|
||||
testRuntime(ideaSdkDeps("*.jar"))
|
||||
testRuntime(files("${System.getProperty("java.home")}/../lib/tools.jar"))
|
||||
|
||||
testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -82,9 +91,9 @@ projectTest {
|
||||
systemProperty("kotlin.test.script.classpath", the<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator))
|
||||
}
|
||||
|
||||
evaluationDependsOn(":compiler:tests-common-jvm6")
|
||||
|
||||
fun Project.codegenTest(taskName: String, jdk: String, body: Test.() -> Unit): Test = projectTest(taskName) {
|
||||
fun Project.codegenTest(target: Int, jvm: Int,
|
||||
jdk: String = "JDK_${if (jvm <= 8) "1" else ""}$jvm",
|
||||
body: Test.() -> Unit): Test = projectTest("codegenTarget${target}Jvm${jvm}Test") {
|
||||
dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray())
|
||||
workingDir = rootDir
|
||||
|
||||
@@ -99,34 +108,25 @@ fun Project.codegenTest(taskName: String, jdk: String, body: Test.() -> Unit): T
|
||||
}
|
||||
body()
|
||||
doFirst {
|
||||
val jdkPath = project.property(jdk) ?: error("$jdk is not optional to run this test")
|
||||
val jdkPath = project.findProperty(jdk) ?: error("$jdk is not optional to run this test")
|
||||
executable = "$jdkPath/bin/java"
|
||||
println("Running test with $executable")
|
||||
}
|
||||
}.also {
|
||||
task(taskName.replace(Regex("-[a-z]"), { it.value.takeLast(1).toUpperCase() })) {
|
||||
dependsOn(it)
|
||||
group = "verification"
|
||||
}
|
||||
group = "verification"
|
||||
}
|
||||
|
||||
codegenTest("codegen-target6-jvm6-test", "JDK_18") {
|
||||
dependsOn(":compiler:tests-common-jvm6:build")
|
||||
codegenTest(target = 6, jvm = 6, jdk = "JDK_18") {
|
||||
dependsOn(testJvm6ServerRuntime)
|
||||
|
||||
//TODO make port flexible
|
||||
val port = "5100"
|
||||
val port = project.findProperty("kotlin.compiler.codegen.tests.port")?.toString() ?: "5100"
|
||||
var jdkProcess: Process? = null
|
||||
|
||||
doFirst {
|
||||
logger.info("Configuring JDK 6 server...")
|
||||
val jdkPath = project.property("JDK_16") ?: error("JDK_16 is not optional to run this test")
|
||||
val jdkPath = project.findProperty("JDK_16") ?: error("JDK_16 is not optional to run this test")
|
||||
val executable = "$jdkPath/bin/java"
|
||||
val main = "org.jetbrains.kotlin.test.clientserver.TestProcessServer"
|
||||
|
||||
val classpath = getSourceSetsFrom(":compiler:tests-common-jvm6")["main"].output.asPath + ":" +
|
||||
getSourceSetsFrom(":kotlin-stdlib")["main"].output.asPath + ":" +
|
||||
getSourceSetsFrom(":kotlin-stdlib")["builtins"].output.asPath + ":" +
|
||||
getSourceSetsFrom(":kotlin-test:kotlin-test-jvm")["main"].output.asPath
|
||||
val classpath = testJvm6ServerRuntime.asPath
|
||||
|
||||
logger.debug("Server classpath: $classpath")
|
||||
|
||||
@@ -150,19 +150,21 @@ codegenTest("codegen-target6-jvm6-test", "JDK_18") {
|
||||
}
|
||||
}
|
||||
|
||||
codegenTest("codegen-target6-jvm9-test", "JDK_9") {
|
||||
codegenTest(target = 6, jvm = 9) {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.6")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target8-jvm8-test", "JDK_18") {
|
||||
codegenTest(target = 8, jvm = 8) {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target8-jvm9-test", "JDK_9") {
|
||||
codegenTest(target = 8, jvm = 9) {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target9-jvm9-test", "JDK_9") {
|
||||
codegenTest(target = 9, jvm = 9) {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
systemProperty("kotlin.test.substitute.bytecode.1.8.to.1.9", "true")
|
||||
}
|
||||
|
||||
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestsKt")
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.arguments
|
||||
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import java.io.Serializable
|
||||
|
||||
abstract class CommonToolArguments : Freezable(), Serializable {
|
||||
@@ -24,7 +23,7 @@ abstract class CommonToolArguments : Freezable(), Serializable {
|
||||
@JvmStatic private val serialVersionUID = 0L
|
||||
}
|
||||
|
||||
var freeArgs: MutableList<String> = SmartList()
|
||||
var freeArgs: List<String> by FreezableVar(emptyList())
|
||||
|
||||
@Transient var errors: ArgumentParseErrors = ArgumentParseErrors()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.arguments
|
||||
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
@@ -100,12 +100,14 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: List<String>, resu
|
||||
return argument.value == arg
|
||||
}
|
||||
|
||||
val freeArgs = ArrayList<String>()
|
||||
|
||||
var i = 0
|
||||
loop@ while (i < args.size) {
|
||||
val arg = args[i++]
|
||||
|
||||
if (freeArgsStarted) {
|
||||
result.freeArgs.add(arg)
|
||||
freeArgs.add(arg)
|
||||
continue
|
||||
}
|
||||
if (arg == FREE_ARGS_DELIMITER) {
|
||||
@@ -118,7 +120,7 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: List<String>, resu
|
||||
when {
|
||||
arg.startsWith(ADVANCED_ARGUMENT_PREFIX) -> errors.unknownExtraFlags.add(arg)
|
||||
arg.startsWith("-") -> errors.unknownArgs.add(arg)
|
||||
else -> result.freeArgs.add(arg)
|
||||
else -> freeArgs.add(arg)
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -148,6 +150,8 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: List<String>, resu
|
||||
|
||||
updateField(property, result, value, argument.delimiter)
|
||||
}
|
||||
|
||||
result.freeArgs += freeArgs
|
||||
}
|
||||
|
||||
private fun <A : CommonToolArguments> updateField(property: KMutableProperty1<A, Any?>, result: A, value: Any, delimiter: String) {
|
||||
|
||||
@@ -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,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
||||
extraLanguageFeatures.put(LanguageFeature.Coroutines, coroutinesState);
|
||||
}
|
||||
|
||||
setupPlatformSpecificLanguageFeatureSettings(extraLanguageFeatures, arguments);
|
||||
|
||||
CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(apiVersion),
|
||||
@@ -212,6 +214,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) }
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.mock.MockProject
|
||||
import com.sun.tools.javac.util.Context
|
||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.STRONG_WARNING
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
@@ -48,7 +48,7 @@ object JavacWrapperRegistrar {
|
||||
Class.forName(JAVAC_CONTEXT_CLASS)
|
||||
}
|
||||
catch (e: ClassNotFoundException) {
|
||||
messageCollector.report(STRONG_WARNING, "'$JAVAC_CONTEXT_CLASS' class can't be found ('tools.jar' is not found)")
|
||||
messageCollector.report(ERROR, "'$JAVAC_CONTEXT_CLASS' class can't be found ('tools.jar' is not found)")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -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 { *; }
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,9 @@ object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
|
||||
delegationFilter = JvmDelegationFilter,
|
||||
|
||||
overridesBackwardCompatibilityHelper = JvmOverridesBackwardCompatibilityHelper
|
||||
overridesBackwardCompatibilityHelper = JvmOverridesBackwardCompatibilityHelper,
|
||||
|
||||
declarationReturnTypeSanitizer = JvmDeclarationReturnTypeSanitizer
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useImpl<JvmReflectionAPICallChecker>()
|
||||
|
||||
@@ -57,6 +57,7 @@ abstract class ResolverForProject<M : ModuleInfo> {
|
||||
abstract fun tryGetResolverForModule(moduleInfo: M): ResolverForModule?
|
||||
abstract fun descriptorForModule(moduleInfo: M): ModuleDescriptor
|
||||
abstract fun resolverForModuleDescriptor(descriptor: ModuleDescriptor): ResolverForModule
|
||||
abstract fun diagnoseUnknownModuleInfo(infos: List<ModuleInfo>): Nothing
|
||||
|
||||
abstract val name: String
|
||||
abstract val allModules: Collection<M>
|
||||
@@ -70,8 +71,9 @@ class EmptyResolverForProject<M : ModuleInfo> : ResolverForProject<M>() {
|
||||
|
||||
override fun tryGetResolverForModule(moduleInfo: M): ResolverForModule? = null
|
||||
override fun resolverForModuleDescriptor(descriptor: ModuleDescriptor): ResolverForModule = throw IllegalStateException("$descriptor is not contained in this resolver")
|
||||
override fun descriptorForModule(moduleInfo: M) = throw IllegalStateException("Should not be called for $moduleInfo")
|
||||
override fun descriptorForModule(moduleInfo: M) = diagnoseUnknownModuleInfo(listOf(moduleInfo))
|
||||
override val allModules: Collection<M> = listOf()
|
||||
override fun diagnoseUnknownModuleInfo(infos: List<ModuleInfo>) = throw IllegalStateException("Should not be called for $infos")
|
||||
}
|
||||
|
||||
class ResolverForProjectImpl<M : ModuleInfo>(
|
||||
@@ -164,11 +166,14 @@ class ResolverForProjectImpl<M : ModuleInfo>(
|
||||
|
||||
override fun descriptorForModule(moduleInfo: M): ModuleDescriptorImpl {
|
||||
if (!isCorrectModuleInfo(moduleInfo)) {
|
||||
throw AssertionError("$name does not know how to resolve $moduleInfo")
|
||||
diagnoseUnknownModuleInfo(listOf(moduleInfo))
|
||||
}
|
||||
return doGetDescriptorForModule(moduleInfo)
|
||||
}
|
||||
|
||||
override fun diagnoseUnknownModuleInfo(infos: List<ModuleInfo>) =
|
||||
throw AssertionError("$name does not know how to resolve $infos")
|
||||
|
||||
private fun doGetDescriptorForModule(module: M): ModuleDescriptorImpl {
|
||||
if (module in modules) {
|
||||
return projectContext.storageManager.compute {
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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;
|
||||
@@ -980,11 +981,12 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_LOCAL_SUSPENSION_POINT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_PROPERTY_ACCESS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
|
||||
|
||||
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,12 +16,11 @@
|
||||
|
||||
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;
|
||||
@@ -29,13 +28,14 @@ import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
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 +44,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 {
|
||||
@@ -886,11 +869,12 @@ public class DefaultErrorMessages {
|
||||
MAP.put(NON_LOCAL_RETURN_IN_DISABLED_INLINE, "Non-local returns are not allowed with inlining disabled");
|
||||
MAP.put(NON_LOCAL_SUSPENSION_POINT, "Suspension functions can be called only within coroutine body");
|
||||
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend function ''{0}'' should be called only from a coroutine or another suspend function", NAME);
|
||||
MAP.put(ILLEGAL_SUSPEND_PROPERTY_ACCESS, "Suspend property ''{0}'' should be accessed only from a coroutine or suspend function", NAME);
|
||||
MAP.put(ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
|
||||
|
||||
MAP.put(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");
|
||||
|
||||
@@ -1263,11 +1263,11 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
LOCAL(true, false),
|
||||
SCRIPT_TOPLEVEL(true, true);
|
||||
|
||||
public final boolean desctructuringAllowed;
|
||||
public final boolean destructuringAllowed;
|
||||
public final boolean accessorsAllowed;
|
||||
|
||||
PropertyParsingMode(boolean desctructuringAllowed, boolean accessorsAllowed) {
|
||||
this.desctructuringAllowed = desctructuringAllowed;
|
||||
PropertyParsingMode(boolean destructuringAllowed, boolean accessorsAllowed) {
|
||||
this.destructuringAllowed = destructuringAllowed;
|
||||
this.accessorsAllowed = accessorsAllowed;
|
||||
}
|
||||
}
|
||||
@@ -1295,7 +1295,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
if (multiDeclaration) {
|
||||
PsiBuilder.Marker multiDecl = mark();
|
||||
parseMultiDeclarationName(propertyNameFollow);
|
||||
errorIf(multiDecl, !mode.desctructuringAllowed, "Destructuring declarations are only allowed for local variables/values");
|
||||
errorIf(multiDecl, !mode.destructuringAllowed, "Destructuring declarations are only allowed for local variables/values");
|
||||
}
|
||||
else {
|
||||
parseFunctionOrPropertyName(receiverTypeDeclared, "property", propertyNameFollow, /*nameRequired = */ true);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -114,9 +114,8 @@ class SyntheticClassOrObjectDescriptor(
|
||||
|
||||
private inner class SyntheticTypeConstructor(storageManager: StorageManager) : AbstractClassTypeConstructor(storageManager) {
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
override fun isFinal(): Boolean = true
|
||||
override fun isDenotable(): Boolean = true
|
||||
override fun getDeclarationDescriptor(): ClassifierDescriptor = thisDescriptor
|
||||
override fun getDeclarationDescriptor(): ClassDescriptor = thisDescriptor
|
||||
override fun computeSupertypes(): Collection<KotlinType> = syntheticSupertypes
|
||||
override val supertypeLoopChecker: SupertypeLoopChecker = SupertypeLoopChecker.EMPTY
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZE
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import java.util.*
|
||||
|
||||
@@ -51,7 +53,20 @@ object DescriptorToSourceUtils {
|
||||
return result
|
||||
}
|
||||
|
||||
// TODO Fix in descriptor
|
||||
@JvmStatic private fun getSourceForExtensionReceiverParameterDescriptor(descriptor: ReceiverParameterDescriptor): PsiElement? {
|
||||
// Only for extension receivers
|
||||
if (descriptor.source != SourceElement.NO_SOURCE || descriptor.value !is ExtensionReceiver) return null
|
||||
val containingDeclaration = descriptor.containingDeclaration as? CallableDescriptor ?: return null
|
||||
val psi = containingDeclaration.source.getPsi() as? KtCallableDeclaration ?: return null
|
||||
return psi.receiverTypeReference
|
||||
}
|
||||
|
||||
@JvmStatic fun getSourceFromDescriptor(descriptor: DeclarationDescriptor): PsiElement? {
|
||||
if (descriptor is ReceiverParameterDescriptor) {
|
||||
getSourceForExtensionReceiverParameterDescriptor(descriptor)?.let { return it }
|
||||
}
|
||||
|
||||
return (descriptor as? DeclarationDescriptorWithSource)?.source?.getPsi()
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -706,15 +706,15 @@ class CandidateResolver(
|
||||
candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.status.possibleTransformToSuccess()
|
||||
|
||||
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.check(
|
||||
checker: CallCandidateResolutionContext<D>.() -> Unit
|
||||
crossinline checker: CallCandidateResolutionContext<D>.() -> Unit
|
||||
) {
|
||||
if (shouldContinue()) checker()
|
||||
if (shouldContinue()) checker() else candidateCall.addRemainingTasks { checker() }
|
||||
}
|
||||
|
||||
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.checkAndReport(
|
||||
checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus
|
||||
crossinline checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus
|
||||
) {
|
||||
if (shouldContinue()) {
|
||||
check {
|
||||
candidateCall.addStatus(checker())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -22,12 +22,15 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspensionAnnotation
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||
@@ -42,17 +45,21 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object CoroutineSuspendCallChecker : CallChecker {
|
||||
private val ALLOWED_SCOPE_KINDS = setOf(LexicalScopeKind.FUNCTION_INNER_SCOPE, LexicalScopeKind.FUNCTION_HEADER_FOR_DESTRUCTURING)
|
||||
private val COROUTINE_CONTEXT_FQ_NAME = FqName("kotlin.coroutines.experimental.intrinsics.coroutineContext")
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor as? FunctionDescriptor ?: return
|
||||
if (!descriptor.isSuspend) return
|
||||
val descriptor = resolvedCall.candidateDescriptor
|
||||
when (descriptor) {
|
||||
is FunctionDescriptor -> if (!descriptor.isSuspend) return
|
||||
is PropertyDescriptor -> if (descriptor.fqNameSafe != COROUTINE_CONTEXT_FQ_NAME) return
|
||||
else -> return
|
||||
}
|
||||
|
||||
val enclosingSuspendFunction =
|
||||
context.scope
|
||||
.parentsWithSelf.firstOrNull {
|
||||
it is LexicalScope && it.kind in ALLOWED_SCOPE_KINDS &&
|
||||
it.ownerDescriptor.safeAs<FunctionDescriptor>()?.isSuspend == true
|
||||
}?.cast<LexicalScope>()?.ownerDescriptor?.cast<FunctionDescriptor>()
|
||||
val enclosingSuspendFunction = context.scope
|
||||
.parentsWithSelf.firstOrNull {
|
||||
it is LexicalScope && it.kind in ALLOWED_SCOPE_KINDS &&
|
||||
it.ownerDescriptor.safeAs<FunctionDescriptor>()?.isSuspend == true
|
||||
}?.cast<LexicalScope>()?.ownerDescriptor?.cast<FunctionDescriptor>()
|
||||
|
||||
when {
|
||||
enclosingSuspendFunction != null -> {
|
||||
@@ -70,7 +77,10 @@ object CoroutineSuspendCallChecker : CallChecker {
|
||||
checkRestrictsSuspension(enclosingSuspendFunction, resolvedCall, reportOn, context)
|
||||
}
|
||||
else -> {
|
||||
context.trace.report(Errors.ILLEGAL_SUSPEND_FUNCTION_CALL.on(reportOn, resolvedCall.candidateDescriptor))
|
||||
when (descriptor) {
|
||||
is FunctionDescriptor -> context.trace.report(Errors.ILLEGAL_SUSPEND_FUNCTION_CALL.on(reportOn, resolvedCall.candidateDescriptor))
|
||||
is PropertyDescriptor -> context.trace.report(Errors.ILLEGAL_SUSPEND_PROPERTY_ACCESS.on(reportOn, resolvedCall.candidateDescriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.model;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
@@ -42,6 +44,10 @@ public interface MutableResolvedCall<D extends CallableDescriptor> extends Resol
|
||||
|
||||
void markCallAsCompleted();
|
||||
|
||||
void addRemainingTasks(Function0<Unit> task);
|
||||
|
||||
void performRemainingTasks();
|
||||
|
||||
boolean isCompleted();
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.resolve.calls.model;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.SmartList;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
@@ -81,6 +83,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
private Boolean hasInferredReturnType = null;
|
||||
private boolean completed = false;
|
||||
private KotlinType smartCastDispatchReceiverType = null;
|
||||
private Queue<Function0<Unit>> remainingTasks = null;
|
||||
|
||||
private ResolvedCallImpl(
|
||||
@NotNull ResolutionCandidate<D> candidate,
|
||||
@@ -283,7 +286,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
for (int i = 0; i < candidateDescriptor.getValueParameters().size(); ++i) {
|
||||
arguments.add(null);
|
||||
}
|
||||
|
||||
|
||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : valueArguments.entrySet()) {
|
||||
ValueParameterDescriptor parameterDescriptor = entry.getKey();
|
||||
ResolvedValueArgument value = entry.getValue();
|
||||
@@ -299,7 +302,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@@ -353,6 +356,23 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
constraintSystem = null;
|
||||
tracing = null;
|
||||
completed = true;
|
||||
remainingTasks = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRemainingTasks(Function0<Unit> task) {
|
||||
if (remainingTasks == null) {
|
||||
remainingTasks = new ArrayDeque<>();
|
||||
}
|
||||
remainingTasks.add(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRemainingTasks() {
|
||||
if (remainingTasks == null) return;
|
||||
while (!remainingTasks.isEmpty()) {
|
||||
remainingTasks.poll().invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,9 +96,14 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
nullability: Nullability,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
typeInfo: SetMultimap<DataFlowValue, KotlinType>? = null,
|
||||
affectReceiver: Boolean = true
|
||||
affectReceiver: Boolean = true,
|
||||
// TODO: remove me in version 1.3! I'm very dirty hack!
|
||||
// In normal circumstances this should be always 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 +113,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 +124,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation
|
||||
import org.jetbrains.kotlin.resolve.calls.context.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceSupport
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallKind
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionResultsHandler
|
||||
@@ -56,6 +55,7 @@ import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.lang.IllegalStateException
|
||||
import java.util.*
|
||||
@@ -208,12 +208,15 @@ class NewResolutionOldInference(
|
||||
|
||||
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
|
||||
resolvedCall, basicCallContext, candidateTrace, tracing, basicCallContext.call,
|
||||
CandidateResolveMode.FULLY // todo
|
||||
CandidateResolveMode.EXIT_ON_FIRST_ERROR
|
||||
)
|
||||
candidateResolver.performResolutionForCandidateCall(callCandidateResolutionContext, basicCallContext.checkArguments) // todo
|
||||
|
||||
val diagnostics = listOfNotNull(createPreviousResolveError(resolvedCall.status))
|
||||
MyCandidate(diagnostics, resolvedCall)
|
||||
MyCandidate(diagnostics, resolvedCall) {
|
||||
resolvedCall.performRemainingTasks()
|
||||
listOfNotNull(createPreviousResolveError(resolvedCall.status))
|
||||
}
|
||||
}
|
||||
if (basicCallContext.collectAllCandidates) {
|
||||
val allCandidates = towerResolver.runWithEmptyTowerData(KnownResultProcessor(resolvedCandidates),
|
||||
@@ -315,12 +318,26 @@ class NewResolutionOldInference(
|
||||
override val isDebuggerContext: Boolean get() = resolutionContext.isDebuggerContext
|
||||
}
|
||||
|
||||
internal data class MyCandidate(
|
||||
val diagnostics: List<KotlinCallDiagnostic>,
|
||||
val resolvedCall: MutableResolvedCall<*>
|
||||
internal class MyCandidate(
|
||||
// Diagnostics that are already computed
|
||||
// if resultingApplicability is successful they must be the same as `diagnostics`,
|
||||
// otherwise they might be a bit different but result remains unsuccessful
|
||||
val eagerDiagnostics: List<KotlinCallDiagnostic>,
|
||||
val resolvedCall: MutableResolvedCall<*>,
|
||||
finalDiagnosticsComputation: (() -> List<KotlinCallDiagnostic>)? = null
|
||||
) : Candidate {
|
||||
override val resultingApplicability: ResolutionCandidateApplicability = getResultApplicability(diagnostics)
|
||||
override val isSuccessful get() = resultingApplicability.isSuccess
|
||||
val diagnostics: List<KotlinCallDiagnostic> by lazy(LazyThreadSafetyMode.NONE) {
|
||||
finalDiagnosticsComputation?.invoke() ?: eagerDiagnostics
|
||||
}
|
||||
|
||||
operator fun component1() = diagnostics
|
||||
operator fun component2() = resolvedCall
|
||||
|
||||
override val resultingApplicability: ResolutionCandidateApplicability by lazy(LazyThreadSafetyMode.NONE) {
|
||||
getResultApplicability(diagnostics)
|
||||
}
|
||||
|
||||
override val isSuccessful = getResultApplicability(eagerDiagnostics).isSuccess
|
||||
}
|
||||
|
||||
private inner class CandidateFactoryImpl(
|
||||
@@ -366,16 +383,27 @@ class NewResolutionOldInference(
|
||||
|
||||
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
|
||||
candidateCall, basicCallContext, candidateTrace, tracing, basicCallContext.call,
|
||||
CandidateResolveMode.FULLY // todo
|
||||
CandidateResolveMode.EXIT_ON_FIRST_ERROR
|
||||
)
|
||||
candidateResolver.performResolutionForCandidateCall(callCandidateResolutionContext, basicCallContext.checkArguments) // todo
|
||||
|
||||
val diagnostics = (towerCandidate.diagnostics +
|
||||
checkInfixAndOperator(basicCallContext.call, towerCandidate.descriptor) +
|
||||
createPreviousResolveError(candidateCall.status)).filterNotNull() // todo
|
||||
return MyCandidate(diagnostics, candidateCall)
|
||||
val diagnostics = createDiagnosticsForCandidate(towerCandidate, candidateCall)
|
||||
return MyCandidate(diagnostics, candidateCall) {
|
||||
candidateCall.performRemainingTasks()
|
||||
createDiagnosticsForCandidate(towerCandidate, candidateCall)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createDiagnosticsForCandidate(
|
||||
towerCandidate: CandidateWithBoundDispatchReceiver,
|
||||
candidateCall: ResolvedCallImpl<CallableDescriptor>
|
||||
): List<ResolutionDiagnostic> =
|
||||
mutableListOf<ResolutionDiagnostic>().apply {
|
||||
addAll(towerCandidate.diagnostics)
|
||||
addAll(checkInfixAndOperator(basicCallContext.call, towerCandidate.descriptor))
|
||||
addIfNotNull(createPreviousResolveError(candidateCall.status))
|
||||
}
|
||||
|
||||
private fun checkInfixAndOperator(call: Call, descriptor: CallableDescriptor): List<ResolutionDiagnostic> {
|
||||
if (descriptor !is FunctionDescriptor || ErrorUtils.isError(descriptor)) return emptyList()
|
||||
if (descriptor.name != name && (name == OperatorNameConventions.UNARY_PLUS || name == OperatorNameConventions.UNARY_MINUS)) {
|
||||
@@ -405,7 +433,9 @@ class NewResolutionOldInference(
|
||||
"Variable call must be success: $variable"
|
||||
}
|
||||
|
||||
return MyCandidate(variable.diagnostics + invoke.diagnostics, resolvedCallImpl)
|
||||
return MyCandidate(variable.eagerDiagnostics + invoke.eagerDiagnostics, resolvedCallImpl) {
|
||||
variable.diagnostics + invoke.diagnostics
|
||||
}
|
||||
}
|
||||
|
||||
override fun factoryForVariable(stripExplicitReceiver: Boolean): CandidateFactory<MyCandidate> {
|
||||
|
||||
@@ -397,7 +397,7 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
||||
if (b.hasStableParameterNames() && !equalsBy(aParams, bParams, ValueParameterDescriptor::getName)) return Incompatible.ParameterNames
|
||||
if (!equalsBy(aTypeParams, bTypeParams, TypeParameterDescriptor::getName)) return Incompatible.TypeParameterNames
|
||||
|
||||
if (a.modality != b.modality) return Incompatible.Modality
|
||||
if (!areCompatibleModalities(a.modality, b.modality)) return Incompatible.Modality
|
||||
if (a.visibility != b.visibility) return Incompatible.Visibility
|
||||
|
||||
areCompatibleTypeParameters(aTypeParams, bTypeParams, platformModule, substitutor).let { if (it != Compatible) return it }
|
||||
@@ -535,7 +535,7 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
||||
val bTypeParams = b.declaredTypeParameters
|
||||
if (aTypeParams.size != bTypeParams.size) return Incompatible.TypeParameterCount
|
||||
|
||||
if (a.modality != b.modality && !(a.modality == Modality.FINAL && b.modality == Modality.OPEN)) return Incompatible.Modality
|
||||
if (!areCompatibleModalities(a.modality, b.modality)) return Incompatible.Modality
|
||||
|
||||
if (a.visibility != b.visibility) return Incompatible.Visibility
|
||||
|
||||
@@ -556,6 +556,11 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
||||
return Compatible
|
||||
}
|
||||
|
||||
private fun areCompatibleModalities(a: Modality, b: Modality): Boolean {
|
||||
return a == Modality.FINAL && b == Modality.OPEN ||
|
||||
a == b
|
||||
}
|
||||
|
||||
|
||||
private fun areCompatibleClassScopes(
|
||||
a: ClassDescriptor,
|
||||
|
||||
@@ -741,7 +741,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val type = trace.getType(expression)!!
|
||||
if (type.isError) return null
|
||||
return KClassValue(type).wrap()
|
||||
return factory.createKClassValue(type).wrap()
|
||||
}
|
||||
|
||||
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>?> {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.resolve.diagnostics
|
||||
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
@@ -53,8 +52,6 @@ interface DiagnosticSuppressor {
|
||||
}
|
||||
|
||||
abstract class KotlinSuppressCache {
|
||||
private val LOG = Logger.getInstance(DiagnosticsWithSuppression::class.java)
|
||||
|
||||
private val ADDITIONAL_SUPPRESS_STRING_PROVIDERS = ExtensionProvider.create(SuppressStringProvider.EP_NAME)
|
||||
private val DIAGNOSTIC_SUPPRESSORS = ExtensionProvider.create(DiagnosticSuppressor.EP_NAME)
|
||||
|
||||
@@ -121,12 +118,6 @@ abstract class KotlinSuppressCache {
|
||||
This way we need no more lookups than the number of suppress() annotations from here to the root.
|
||||
*/
|
||||
protected fun isSuppressedByAnnotated(suppressionKey: String, severity: Severity, annotated: KtAnnotated, debugDepth: Int): Boolean {
|
||||
if (LOG.isDebugEnabled) {
|
||||
LOG.debug("Annotated: ", annotated.name)
|
||||
LOG.debug("Depth: ", debugDepth)
|
||||
LOG.debug("Cache size: ", suppressors.size, "\n")
|
||||
}
|
||||
|
||||
val suppressor = getOrCreateSuppressor(annotated)
|
||||
if (suppressor.isSuppressed(suppressionKey, severity)) return true
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class ClassResolutionScopesSupport(
|
||||
createInheritanceScope(inheritanceScopeWithoutMe(), classDescriptor, classDescriptor, withCompanionObject = false)
|
||||
}
|
||||
|
||||
val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
|
||||
val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue(onRecursion = createThrowingLexicalScope) {
|
||||
val scopeWithGenerics = scopeWithGenerics(inheritanceScopeWithMe())
|
||||
LexicalScopeImpl(scopeWithGenerics, classDescriptor, true, classDescriptor.thisAsReceiverParameter, LexicalScopeKind.CLASS_MEMBER_SCOPE)
|
||||
}
|
||||
@@ -116,7 +116,9 @@ class ClassResolutionScopesSupport(
|
||||
createLazyValueWithPostCompute(compute, onRecursion, {})
|
||||
|
||||
companion object {
|
||||
private val createThrowingLexicalScope: (Boolean) -> LexicalScope = { ThrowingLexicalScope() }
|
||||
private val createThrowingLexicalScope: (Boolean) -> LexicalScope = {
|
||||
ThrowingLexicalScope()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -650,11 +650,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return parameters.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return getModality() == Modality.FINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDenotable() {
|
||||
return true;
|
||||
@@ -662,7 +657,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ClassifierDescriptor getDeclarationDescriptor() {
|
||||
public ClassDescriptor getDeclarationDescriptor() {
|
||||
return LazyClassDescriptor.this;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user