mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-11 00:21:31 +00:00
Compare commits
435 Commits
rr/mitropo
...
1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adfe706504 | ||
|
|
f6c1ff038c | ||
|
|
0747a6f1d0 | ||
|
|
c3bd24349c | ||
|
|
8be1335a54 | ||
|
|
cf033d0f20 | ||
|
|
98b28996b0 | ||
|
|
c6e328aa0f | ||
|
|
61e8e01608 | ||
|
|
c3d01ec9ed | ||
|
|
723df5fdc3 | ||
|
|
ddbf7906e1 | ||
|
|
ad811531bd | ||
|
|
a54c04ab04 | ||
|
|
e44f5ce624 | ||
|
|
bb470f3e58 | ||
|
|
f16f364ea4 | ||
|
|
384c651dee | ||
|
|
edeaff2023 | ||
|
|
4a646faac8 | ||
|
|
95d4efdbd7 | ||
|
|
6251e8c461 | ||
|
|
923f9fb7c2 | ||
|
|
9998841a60 | ||
|
|
e5fd456075 | ||
|
|
ddadef7331 | ||
|
|
4ff79ae2bc | ||
|
|
62d16d88c7 | ||
|
|
05c62b0459 | ||
|
|
c451a47a63 | ||
|
|
9f634e4fab | ||
|
|
99cd039edc | ||
|
|
7521b762fe | ||
|
|
5fa0eecdee | ||
|
|
6ccb123d58 | ||
|
|
6e746d85c5 | ||
|
|
8755dec1b1 | ||
|
|
b0eb7a8484 | ||
|
|
d310564f8c | ||
|
|
037b0a2b7b | ||
|
|
3c80d0f86f | ||
|
|
fde3e8f374 | ||
|
|
beeb92d864 | ||
|
|
73ad5eb472 | ||
|
|
1bdb55b3fc | ||
|
|
b39bd00309 | ||
|
|
7625ea7ca1 | ||
|
|
994cbe7468 | ||
|
|
da8b5d1678 | ||
|
|
df71ce42e5 | ||
|
|
31f1027491 | ||
|
|
a43734b663 | ||
|
|
f65acea46a | ||
|
|
78b89f67fb | ||
|
|
e6de277729 | ||
|
|
9cb9397747 | ||
|
|
d60566984f | ||
|
|
cae827ace1 | ||
|
|
ece8d847a7 | ||
|
|
8bc8a1a1e9 | ||
|
|
c02d8ba872 | ||
|
|
944f812cdf | ||
|
|
eb4bd5290b | ||
|
|
19a2f6ad1d | ||
|
|
c8f332fdcb | ||
|
|
d09c26ac44 | ||
|
|
d0f0d3c9dc | ||
|
|
8c4a24f42e | ||
|
|
42a58ae6a8 | ||
|
|
f2a3ed4ac6 | ||
|
|
fa78bbfded | ||
|
|
41096ea6b8 | ||
|
|
f355d4b4e0 | ||
|
|
c577450a87 | ||
|
|
abfaf29fff | ||
|
|
e4e975db7d | ||
|
|
1adefff577 | ||
|
|
d262b0e602 | ||
|
|
32fff210fb | ||
|
|
3033341fa4 | ||
|
|
4e68be6132 | ||
|
|
7d1d8985b2 | ||
|
|
719465d58c | ||
|
|
965698eeb5 | ||
|
|
503a96c469 | ||
|
|
7e88a2eb13 | ||
|
|
0e8710c6c2 | ||
|
|
cc4ed6603f | ||
|
|
7a96ab04bd | ||
|
|
2059cebc01 | ||
|
|
8dae11b358 | ||
|
|
8d8b92af59 | ||
|
|
ba1e5c39ba | ||
|
|
66a2d20dc1 | ||
|
|
e14c092140 | ||
|
|
a622dcaedd | ||
|
|
b504057ffe | ||
|
|
01b77f357f | ||
|
|
58e3e01013 | ||
|
|
a0eeb63196 | ||
|
|
16f8d9805b | ||
|
|
89eda710ab | ||
|
|
ffaebc3415 | ||
|
|
6d3389df38 | ||
|
|
92fd99622b | ||
|
|
c40c04bdce | ||
|
|
862d5a13d0 | ||
|
|
96626e693d | ||
|
|
a72dc1887a | ||
|
|
40f9d7680c | ||
|
|
2c0bf5a12d | ||
|
|
61295a6003 | ||
|
|
316e8ae504 | ||
|
|
b6d132751b | ||
|
|
0c05245f2f | ||
|
|
37ecd149b2 | ||
|
|
ea915cd538 | ||
|
|
54b7c4a09e | ||
|
|
75e8aa23eb | ||
|
|
91c7fe40ce | ||
|
|
8223ed5b6e | ||
|
|
36ccbf6b83 | ||
|
|
7eeaecc4a7 | ||
|
|
0d4e3ed0f6 | ||
|
|
096c77ee9e | ||
|
|
5a6ab876be | ||
|
|
5110ac2666 | ||
|
|
1ffd998207 | ||
|
|
5be10b34c2 | ||
|
|
c17fd0b0d0 | ||
|
|
0eadae9535 | ||
|
|
f7ee7eabdc | ||
|
|
cd8e30f1f5 | ||
|
|
1dd1f15b95 | ||
|
|
ac0a9c476c | ||
|
|
7f412a47a0 | ||
|
|
65f9aef779 | ||
|
|
32a037df22 | ||
|
|
bda218c50b | ||
|
|
e0eece53c4 | ||
|
|
6b2435e0b7 | ||
|
|
8407757a7c | ||
|
|
53e6fde7f1 | ||
|
|
1b29496b9d | ||
|
|
c3941599e9 | ||
|
|
58f5628165 | ||
|
|
1c1001cd82 | ||
|
|
7338cb0d0b | ||
|
|
ded40b5529 | ||
|
|
2771a91dfb | ||
|
|
277965f940 | ||
|
|
d80c049c13 | ||
|
|
15e70e3c21 | ||
|
|
c4ba543578 | ||
|
|
57978ad42a | ||
|
|
6bdbf23bdb | ||
|
|
534817b7a6 | ||
|
|
6360c51ac2 | ||
|
|
61ca6bfb8f | ||
|
|
a3f25fc823 | ||
|
|
d6ae45ff67 | ||
|
|
3c919b17b3 | ||
|
|
b244590c52 | ||
|
|
a5be0ceaec | ||
|
|
3cb37a7257 | ||
|
|
3786c23249 | ||
|
|
bf0cd8919a | ||
|
|
acf51ab6e8 | ||
|
|
78dd3488f8 | ||
|
|
ce747884c1 | ||
|
|
f53529fad2 | ||
|
|
c4ea34a084 | ||
|
|
86fc06d24f | ||
|
|
8d3d54af1e | ||
|
|
133bf20698 | ||
|
|
8fa610a463 | ||
|
|
64c1a16b36 | ||
|
|
e0aee0acc2 | ||
|
|
6649588dff | ||
|
|
e1fca178e9 | ||
|
|
7ba8f1f74d | ||
|
|
21cfff6ab3 | ||
|
|
4fa49ed28e | ||
|
|
8ef8af8675 | ||
|
|
700c6cd2d7 | ||
|
|
41102693a5 | ||
|
|
97e2c67a18 | ||
|
|
4a20e1db83 | ||
|
|
c30e7f4307 | ||
|
|
8fb1e2e08f | ||
|
|
0618e8e223 | ||
|
|
a4f2da6606 | ||
|
|
198536dc0a | ||
|
|
80c8e3b731 | ||
|
|
3d3f3ef859 | ||
|
|
fadde6f8d5 | ||
|
|
2d6ed6b001 | ||
|
|
6d09caeb8f | ||
|
|
6e0ea9ae9f | ||
|
|
653ba5bceb | ||
|
|
d24c96fc6f | ||
|
|
3f3d6b3320 | ||
|
|
c37c5d2087 | ||
|
|
7b398e9e78 | ||
|
|
5101c98d18 | ||
|
|
d2f765370f | ||
|
|
76e72380a7 | ||
|
|
30bfdeccbf | ||
|
|
5731945e76 | ||
|
|
2ce436bb36 | ||
|
|
a26fbcd5d4 | ||
|
|
157079fdc3 | ||
|
|
9e5ab273f8 | ||
|
|
1fdf01b8a9 | ||
|
|
84692927bc | ||
|
|
bff3fc7d24 | ||
|
|
e8e6862154 | ||
|
|
298ea58539 | ||
|
|
11a382f5d5 | ||
|
|
5dd25e2896 | ||
|
|
0427d20ebf | ||
|
|
d160f63dad | ||
|
|
9c06c9b6ad | ||
|
|
9b5787c829 | ||
|
|
df65bb1476 | ||
|
|
e58a2d5a9e | ||
|
|
541d87c6c0 | ||
|
|
c805765b79 | ||
|
|
1360974e11 | ||
|
|
cd52a5cb09 | ||
|
|
039c2911ec | ||
|
|
f4f62f27c1 | ||
|
|
42ff05d2fd | ||
|
|
225fdbfac6 | ||
|
|
c640bc3f14 | ||
|
|
393b1c6b24 | ||
|
|
f1a7ccb3a9 | ||
|
|
52bc09ca7e | ||
|
|
61e1f68735 | ||
|
|
6253676195 | ||
|
|
f4e4893cb8 | ||
|
|
6dc94ef89f | ||
|
|
a1edf43b48 | ||
|
|
b64c8cb829 | ||
|
|
8002f8e28d | ||
|
|
1454e85cab | ||
|
|
5124f69b0d | ||
|
|
ca6a19b1ac | ||
|
|
95076bd68c | ||
|
|
eafe7848d4 | ||
|
|
118014ddb9 | ||
|
|
439866b5f7 | ||
|
|
79800e721c | ||
|
|
064b95da81 | ||
|
|
b71d5c7d6c | ||
|
|
e8f4d89351 | ||
|
|
2d2659dcfe | ||
|
|
812deadcd3 | ||
|
|
9b915d656a | ||
|
|
bab722cf68 | ||
|
|
533794b440 | ||
|
|
06cafe0d13 | ||
|
|
9bc815745a | ||
|
|
6b6fd50331 | ||
|
|
ee53f34465 | ||
|
|
d16a7264f4 | ||
|
|
820d8cb9c2 | ||
|
|
8e10298618 | ||
|
|
e65497b67c | ||
|
|
088f9c2edf | ||
|
|
6823c358bf | ||
|
|
edc0459af1 | ||
|
|
9c71780d36 | ||
|
|
ee481be188 | ||
|
|
fc8d972ac8 | ||
|
|
2ec3d94dc0 | ||
|
|
0490e3ba58 | ||
|
|
9d34f91e50 | ||
|
|
043db50c44 | ||
|
|
4f07a94fb7 | ||
|
|
e310a58251 | ||
|
|
1ca9d358b1 | ||
|
|
2a1db9efb3 | ||
|
|
ecbf20151b | ||
|
|
5a14678a8f | ||
|
|
ac6cab266f | ||
|
|
4d4012853c | ||
|
|
33a83ebf4a | ||
|
|
603fdff499 | ||
|
|
4b4ed61783 | ||
|
|
6527c25b3e | ||
|
|
c5e5a50908 | ||
|
|
4178a2f999 | ||
|
|
b8ab3bc503 | ||
|
|
eda798fa8a | ||
|
|
a815927234 | ||
|
|
15dae23695 | ||
|
|
077acfe2b4 | ||
|
|
9da010c163 | ||
|
|
72bdbdb838 | ||
|
|
6fa75444fd | ||
|
|
934eaa61fa | ||
|
|
bbd15ac27c | ||
|
|
60e3f31c2b | ||
|
|
90f5cd9057 | ||
|
|
f954fa26f5 | ||
|
|
287ba05618 | ||
|
|
a633a7b797 | ||
|
|
8c935188b3 | ||
|
|
4f0379728a | ||
|
|
be000176aa | ||
|
|
a79ca8620f | ||
|
|
690d0cd5d9 | ||
|
|
346b47e00a | ||
|
|
63b33eebb0 | ||
|
|
7dafdef7a1 | ||
|
|
bc6286bb9c | ||
|
|
f966647e14 | ||
|
|
3e8ccc567b | ||
|
|
b1023bfeb1 | ||
|
|
449f270aea | ||
|
|
00f63a0dab | ||
|
|
8e8542e984 | ||
|
|
f94c470607 | ||
|
|
180d8dfb02 | ||
|
|
9848f65d4c | ||
|
|
cfb8e27a51 | ||
|
|
a686816728 | ||
|
|
305b93d79c | ||
|
|
8c723b4251 | ||
|
|
82e3126f39 | ||
|
|
8f2711147f | ||
|
|
621687c75d | ||
|
|
9316cca89a | ||
|
|
2209b38307 | ||
|
|
70aec3914d | ||
|
|
0f6f4496a3 | ||
|
|
7eccbb0f0d | ||
|
|
735b50aa95 | ||
|
|
b548e38773 | ||
|
|
e287af71d3 | ||
|
|
3a1cde2fe7 | ||
|
|
3dc09ad788 | ||
|
|
18bda4646f | ||
|
|
53c97ecb22 | ||
|
|
ce43732715 | ||
|
|
85c7882833 | ||
|
|
420559a7d2 | ||
|
|
057848d7a9 | ||
|
|
081a2cc7cd | ||
|
|
30e447648c | ||
|
|
aa8c12e814 | ||
|
|
2ac27c8bdf | ||
|
|
8418313b39 | ||
|
|
ec03bfc64a | ||
|
|
6ff8c4a051 | ||
|
|
8649762b2a | ||
|
|
5a70f32250 | ||
|
|
8608127c23 | ||
|
|
8600540b9d | ||
|
|
79de5b962f | ||
|
|
fc602179db | ||
|
|
97e753bb30 | ||
|
|
70349e4f78 | ||
|
|
3c9fdda679 | ||
|
|
f7dc3d4ce8 | ||
|
|
de54a61594 | ||
|
|
8b764ad8c9 | ||
|
|
6354600db1 | ||
|
|
812e9716be | ||
|
|
c5c2eedddb | ||
|
|
aed6c9367d | ||
|
|
52123a976d | ||
|
|
9bf6b40eb9 | ||
|
|
c8dffd6fcb | ||
|
|
158ddb010b | ||
|
|
728faf4df0 | ||
|
|
7e13a314a1 | ||
|
|
c87a6b6c92 | ||
|
|
126dad7d3f | ||
|
|
bd1b4cf629 | ||
|
|
898056429d | ||
|
|
fd12c661f7 | ||
|
|
cf788372d3 | ||
|
|
c14ac2f48c | ||
|
|
bf0e8daff3 | ||
|
|
5c329e7487 | ||
|
|
3e2765e357 | ||
|
|
ddf9568cf8 | ||
|
|
d3b96efdbf | ||
|
|
2ce79db5ca | ||
|
|
852e236896 | ||
|
|
667f7ddc72 | ||
|
|
13d4be6f74 | ||
|
|
a78a7eb6fb | ||
|
|
a39aeb5288 | ||
|
|
bc2a563b61 | ||
|
|
bd44cd9a3c | ||
|
|
cbb36d8f3d | ||
|
|
3e832fcf34 | ||
|
|
8517bfff23 | ||
|
|
ff567b4a21 | ||
|
|
369d64b489 | ||
|
|
276daa6d83 | ||
|
|
96ebda5548 | ||
|
|
7433683011 | ||
|
|
9342de43d2 | ||
|
|
ac1f19d6ef | ||
|
|
2f1a1c570d | ||
|
|
a2e194dd18 | ||
|
|
01a083efbf | ||
|
|
89b99b7952 | ||
|
|
a3d83ce268 | ||
|
|
6d3f06cd09 | ||
|
|
2bd7132f3e | ||
|
|
91146aa07a | ||
|
|
26dd9bd035 | ||
|
|
9107e18f8d | ||
|
|
04fd2dd0c8 | ||
|
|
07f6da5919 | ||
|
|
7ba05d71e6 | ||
|
|
045eddab71 | ||
|
|
0ef2e036a3 | ||
|
|
06fe23f773 | ||
|
|
a16510b2fe | ||
|
|
4edb43000d | ||
|
|
5983635cfa | ||
|
|
bac921f661 | ||
|
|
3960112397 | ||
|
|
0999aab6fb | ||
|
|
fa142c273e | ||
|
|
ee3a4eefdf | ||
|
|
64c5164201 | ||
|
|
97bee57321 | ||
|
|
0710b5b459 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -13,3 +13,11 @@ workspace.xml
|
||||
*.versionsBackup
|
||||
/idea/testData/debugger/tinyApp/classes*
|
||||
/jps-plugin/testData/kannotator
|
||||
ultimate/.DS_Store
|
||||
ultimate/.idea/shelf
|
||||
ultimate/dependencies
|
||||
ultimate/ideaSDK
|
||||
ultimate/out
|
||||
ultimate/tmp
|
||||
ultimate/workspace.xml
|
||||
ultimate/*.versionsBackup
|
||||
|
||||
9
.idea/artifacts/KotlinFormatter.xml
generated
Normal file
9
.idea/artifacts/KotlinFormatter.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="KotlinFormatter">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/internal</output-path>
|
||||
<root id="archive" name="kotlin-formatter.jar">
|
||||
<element id="module-output" name="formatter" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/idea/formatter" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
2
.idea/artifacts/KotlinJpsPlugin.xml
generated
2
.idea/artifacts/KotlinJpsPlugin.xml
generated
@@ -11,7 +11,7 @@
|
||||
<element id="directory" name="META-INF">
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps-plugin/src/META-INF" />
|
||||
</element>
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="cli-common" />
|
||||
<element id="module-output" name="idea-jps-common" />
|
||||
<element id="module-output" name="jps-plugin" />
|
||||
|
||||
13
.idea/artifacts/KotlinPlugin.xml
generated
13
.idea/artifacts/KotlinPlugin.xml
generated
@@ -47,6 +47,9 @@
|
||||
<element id="module-output" name="idea-repl" />
|
||||
<element id="module-output" name="idea-live-templates" />
|
||||
<element id="module-output" name="resolution" />
|
||||
<element id="module-output" name="plugin-api" />
|
||||
<element id="module-output" name="idea-ultimate" />
|
||||
<element id="module-output" name="formatter" />
|
||||
</element>
|
||||
<element id="library" level="project" name="javax.inject" />
|
||||
<element id="directory" name="jps">
|
||||
@@ -59,6 +62,16 @@
|
||||
<element id="archive" name="kotlin-android-extensions-compiler-plugin.jar">
|
||||
<element id="module-output" name="android-extensions-compiler" />
|
||||
</element>
|
||||
<element id="archive" name="android-lint.jar">
|
||||
<element id="module-output" name="uast-kotlin" />
|
||||
<element id="module-output" name="lint-idea" />
|
||||
<element id="module-output" name="uast-java" />
|
||||
<element id="module-output" name="uast-common" />
|
||||
<element id="module-output" name="lint-checks" />
|
||||
<element id="library" level="project" name="guava" />
|
||||
<element id="module-output" name="lint-api" />
|
||||
<element id="module-output" name="uast-android" />
|
||||
</element>
|
||||
</element>
|
||||
<element id="directory" name="kotlinc">
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/dist/kotlinc" />
|
||||
|
||||
4
.idea/libraries/cli_parser.xml
generated
4
.idea/libraries/cli_parser.xml
generated
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="cli-parser">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
1
.idea/libraries/idea_full.xml
generated
1
.idea/libraries/idea_full.xml
generated
@@ -11,7 +11,6 @@
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
|
||||
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/lib" recursive="false" />
|
||||
|
||||
9
.idea/modules.xml
generated
9
.idea/modules.xml
generated
@@ -3,6 +3,7 @@
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Kotlin.iml" filepath="$PROJECT_DIR$/Kotlin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/lint/android-annotations/android-annotations.iml" filepath="$PROJECT_DIR$/plugins/lint/android-annotations/android-annotations.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" group="plugins/android-extensions" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" group="plugins/android-extensions" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" group="plugins/android-extensions" />
|
||||
@@ -31,6 +32,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/core/descriptors.runtime/descriptors.runtime.iml" filepath="$PROJECT_DIR$/core/descriptors.runtime/descriptors.runtime.iml" group="core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/core/deserialization/deserialization.iml" filepath="$PROJECT_DIR$/core/deserialization/deserialization.iml" group="core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/eval4j/eval4j.iml" filepath="$PROJECT_DIR$/eval4j/eval4j.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/formatter/formatter.iml" filepath="$PROJECT_DIR$/idea/formatter/formatter.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/compiler/frontend/frontend.iml" group="compiler" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" group="compiler/java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/generators/generators.iml" filepath="$PROJECT_DIR$/generators/generators.iml" group="infrastructure" />
|
||||
@@ -58,6 +60,9 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/js/js.translator/js.translator.iml" filepath="$PROJECT_DIR$/js/js.translator/js.translator.iml" group="compiler/js" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" filepath="$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" group="ide/jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/light-classes/light-classes.iml" filepath="$PROJECT_DIR$/compiler/light-classes/light-classes.iml" group="compiler/java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" filepath="$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" group="compiler" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/preloader/preloader.iml" filepath="$PROJECT_DIR$/compiler/preloader/preloader.iml" group="compiler/cli" />
|
||||
<module fileurl="file://$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" filepath="$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" group="core" />
|
||||
@@ -65,6 +70,10 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/serialization/serialization.iml" filepath="$PROJECT_DIR$/compiler/serialization/serialization.iml" group="compiler" />
|
||||
<module fileurl="file://$PROJECT_DIR$/temp-jdk8/temp-jdk8.iml" filepath="$PROJECT_DIR$/temp-jdk8/temp-jdk8.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/lint/uast-android/uast-android.iml" filepath="$PROJECT_DIR$/plugins/lint/uast-android/uast-android.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/uast-common/uast-common.iml" filepath="$PROJECT_DIR$/plugins/uast-common/uast-common.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/uast-java/uast-java.iml" filepath="$PROJECT_DIR$/plugins/uast-java/uast-java.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" filepath="$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" group="plugins/lint" />
|
||||
<module fileurl="file://$PROJECT_DIR$/compiler/util/util.iml" filepath="$PROJECT_DIR$/compiler/util/util.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/core/util.runtime/util.runtime.iml" filepath="$PROJECT_DIR$/core/util.runtime/util.runtime.iml" group="core" />
|
||||
</modules>
|
||||
|
||||
2
.idea/runConfigurations/All_Tests.xml
generated
2
.idea/runConfigurations/All_Tests.xml
generated
@@ -13,7 +13,7 @@
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="package" />
|
||||
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:MaxPermSize=400m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m" />
|
||||
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:MaxPermSize=500m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="Application" factoryName="Application" singleton="true">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
|
||||
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=250m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
|
||||
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=400m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
|
||||
370
ChangeLog.md
Normal file
370
ChangeLog.md
Normal file
@@ -0,0 +1,370 @@
|
||||
# CHANGELOG
|
||||
|
||||
<!-- Find: ([^\[/])(KT-\d+) -->
|
||||
<!-- Replace: $1[$2](https://youtrack.jetbrains.com/issue/$2) -->
|
||||
|
||||
## 1.0.2-1
|
||||
|
||||
- [KT-12159](https://youtrack.jetbrains.com/issue/KT-12159), [KT-12406](https://youtrack.jetbrains.com/issue/KT-12406), [KT-12431](https://youtrack.jetbrains.com/issue/KT-12431), [KT-12478](https://youtrack.jetbrains.com/issue/KT-12478) Support Android Studio 2.2
|
||||
- [KT-11770](https://youtrack.jetbrains.com/issue/KT-11770) Fix warning "RuntimeException: Could not find installation home path" when using incremental compilation in Gradle
|
||||
- [KT-12436](https://youtrack.jetbrains.com/issue/KT-12436), [KT-12440](https://youtrack.jetbrains.com/issue/KT-12440) Fix multiple exceptions during refactorings in IDEA 2016.2 EAP
|
||||
- [KT-12015](https://youtrack.jetbrains.com/issue/KT-12015), [KT-12047](https://youtrack.jetbrains.com/issue/KT-12047), [KT-12387](https://youtrack.jetbrains.com/issue/KT-12387) Fix multiple issues in Kotlin Lint checks
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Compiler
|
||||
|
||||
#### Analysis & diagnostics
|
||||
|
||||
- [KT-7437](https://youtrack.jetbrains.com/issue/KT-7437), [KT-7971](https://youtrack.jetbrains.com/issue/KT-7971), [KT-7051](https://youtrack.jetbrains.com/issue/KT-7051), [KT-6125](https://youtrack.jetbrains.com/issue/KT-6125), [KT-6186](https://youtrack.jetbrains.com/issue/KT-6186), [KT-11649](https://youtrack.jetbrains.com/issue/KT-11649) Implement missing checks for protected visibility
|
||||
- [KT-11666](https://youtrack.jetbrains.com/issue/KT-11666) Report "Implicit nothing return type" on non-override member functions
|
||||
- [KT-4328](https://youtrack.jetbrains.com/issue/KT-4328), [KT-11497](https://youtrack.jetbrains.com/issue/KT-11497), [KT-10493](https://youtrack.jetbrains.com/issue/KT-10493), [KT-10820](https://youtrack.jetbrains.com/issue/KT-10820), [KT-11368](https://youtrack.jetbrains.com/issue/KT-11368) Report error if some classes were not found due to missing or conflicting dependencies
|
||||
- [KT-11280](https://youtrack.jetbrains.com/issue/KT-11280) Do not perform smart casts for values with custom `equals` compared with `==`
|
||||
- [KT-3856](https://youtrack.jetbrains.com/issue/KT-3856) Fix wrong "inner class inaccessible" diagnostic for extension to outer class
|
||||
- [KT-3896](https://youtrack.jetbrains.com/issue/KT-3896), [KT-3883](https://youtrack.jetbrains.com/issue/KT-3883), [KT-4986](https://youtrack.jetbrains.com/issue/KT-4986) `do...while (true)` is now considered an infinite loop
|
||||
- [KT-10445](https://youtrack.jetbrains.com/issue/KT-10445) Prohibit initialization of captured `val` in lambda or in local function
|
||||
- [KT-10042](https://youtrack.jetbrains.com/issue/KT-10042) Correctly handle local classes and anonymous objects in control flow analysis
|
||||
- [KT-11043](https://youtrack.jetbrains.com/issue/KT-11043) Prohibit complex expressions with class literals in annotation arguments
|
||||
- [KT-10992](https://youtrack.jetbrains.com/issue/KT-10992), [KT-11007](https://youtrack.jetbrains.com/issue/KT-11007) Fix multiple problems related to smart casts
|
||||
- [KT-11490](https://youtrack.jetbrains.com/issue/KT-11490) Prohibit nested intersection types in return position
|
||||
- [KT-11411](https://youtrack.jetbrains.com/issue/KT-11411) Report "illegal noinline/crossinline" on parameter of subtype of function type
|
||||
- [KT-3083](https://youtrack.jetbrains.com/issue/KT-3083) Report "conflicting overloads" for functions with parameter of type parameter type
|
||||
- [KT-7265](https://youtrack.jetbrains.com/issue/KT-7265) Parse anonymous functions in blocks as expressions
|
||||
- [KT-8246](https://youtrack.jetbrains.com/issue/KT-8246) Handle break/continue for outer loop correctly in case of try/finally in between
|
||||
- [KT-11300](https://youtrack.jetbrains.com/issue/KT-11300) Report error on increment or augmented assignment when `get` is an operator but `set` is not
|
||||
- Report warning about unused anonymous functions
|
||||
- Improve callable reference type in some ambiguous cases
|
||||
- Improve multiple diagnostic messages: [KT-10761](https://youtrack.jetbrains.com/issue/KT-10761), [KT-9760](https://youtrack.jetbrains.com/issue/KT-9760), [KT-10949](https://youtrack.jetbrains.com/issue/KT-10949), [KT-9887](https://youtrack.jetbrains.com/issue/KT-9887), [KT-9550](https://youtrack.jetbrains.com/issue/KT-9550), [KT-11239](https://youtrack.jetbrains.com/issue/KT-11239), [KT-11819](https://youtrack.jetbrains.com/issue/KT-11819)
|
||||
- Fix several compiler bugs leading to exceptions: [KT-9820](https://youtrack.jetbrains.com/issue/KT-9820), [KT-11597](https://youtrack.jetbrains.com/issue/KT-11597), [KT-10983](https://youtrack.jetbrains.com/issue/KT-10983), [KT-10972](https://youtrack.jetbrains.com/issue/KT-10972), [KT-11287](https://youtrack.jetbrains.com/issue/KT-11287), [KT-11492](https://youtrack.jetbrains.com/issue/KT-11492), [KT-11765](https://youtrack.jetbrains.com/issue/KT-11765), [KT-11869](https://youtrack.jetbrains.com/issue/KT-11869)
|
||||
|
||||
#### JVM code generation
|
||||
|
||||
- [KT-8269](https://youtrack.jetbrains.com/issue/KT-8269), [KT-9246](https://youtrack.jetbrains.com/issue/KT-9246), [KT-10143](https://youtrack.jetbrains.com/issue/KT-10143) Fix visibility of protected classes in bytecode
|
||||
- [KT-11363](https://youtrack.jetbrains.com/issue/KT-11363) Fix potential binary compatibility breakage on using `when` over enums in inline functions
|
||||
- [KT-11762](https://youtrack.jetbrains.com/issue/KT-11762) Fix VerifyError caused by explicit loop variable type
|
||||
- [KT-11645](https://youtrack.jetbrains.com/issue/KT-11645) Fix NoSuchFieldError on private const property in multi-file class
|
||||
- [KT-9670](https://youtrack.jetbrains.com/issue/KT-9670) Optimize Class <-> KClass wrapping/unwrapping when getting values from annotation
|
||||
- [KT-6842](https://youtrack.jetbrains.com/issue/KT-6842) Optimize unnecessary boxing and interface calls on iterating over ranges
|
||||
- [KT-11025](https://youtrack.jetbrains.com/issue/KT-11025) Don't inline const val properties in non-annotation contexts
|
||||
- [KT-5429](https://youtrack.jetbrains.com/issue/KT-5429) Write nullability annotations on extension receiver parameters
|
||||
- [KT-11347](https://youtrack.jetbrains.com/issue/KT-11347) Preserve source file and line number of call site when inlining certain standard library functions
|
||||
- [KT-11677](https://youtrack.jetbrains.com/issue/KT-11677) Write correct generic signatures for local classes in inlined lambdas
|
||||
- [KT-12127](https://youtrack.jetbrains.com/issue/KT-12127) Do not write unnecessary generic signature for property delegate backing field
|
||||
- Fix multiple issues leading to exceptions or bad bytecode being generated: [KT-11034](https://youtrack.jetbrains.com/issue/KT-11034), [KT-11519](https://youtrack.jetbrains.com/issue/KT-11519), [KT-11117](https://youtrack.jetbrains.com/issue/KT-11117), [KT-11479](https://youtrack.jetbrains.com/issue/KT-11479)
|
||||
|
||||
#### Java interoperability
|
||||
|
||||
- [KT-3068](https://youtrack.jetbrains.com/issue/KT-3068) Load contravariantly projected collections in Java (`List<? super T>`) as mutable collections in Kotlin (`MutableList<in T>`)
|
||||
- [KT-11322](https://youtrack.jetbrains.com/issue/KT-11322) Do not lose type nullability information in SAM constructors
|
||||
- [KT-11721](https://youtrack.jetbrains.com/issue/KT-11721) Fix wrong "Typechecker has run into recursive problem" error on calling Kotlin get function as synthetic Java property
|
||||
- [KT-10691](https://youtrack.jetbrains.com/issue/KT-10691) Fix wrong "Inherited platform declarations clash" error on inheritance from generic Java class with overloaded methods
|
||||
|
||||
#### Command line compiler
|
||||
|
||||
- [KT-9546](https://youtrack.jetbrains.com/issue/KT-9546) Flush stdout and stderr before shutdown when executing scripts
|
||||
- [KT-10605](https://youtrack.jetbrains.com/issue/KT-10605) Disable colored output on certain platforms to prevent crashes
|
||||
- Report warning instead of error on unknown "-X" flags
|
||||
- Remove the compiler option "Xmultifile-facades-open"
|
||||
|
||||
#### Compiler daemon
|
||||
|
||||
- Reduce read disk activity
|
||||
- Fix compiler daemon JAR cache clearing on IDEA Ultimate
|
||||
|
||||
### Standard library
|
||||
|
||||
- [KT-11410](https://youtrack.jetbrains.com/issue/KT-11410) Reduce method count of the standard library by ~2k
|
||||
- [KT-9990](https://youtrack.jetbrains.com/issue/KT-9990) Optimize snapshot operations to return special collection implementations when result is empty or has single element
|
||||
- [KT-10794](https://youtrack.jetbrains.com/issue/KT-10794) EmptyList now implements RandomAccess
|
||||
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Create at most one wrapper sequence for adjacent drop/take operations on sequences
|
||||
- [KT-11301](https://youtrack.jetbrains.com/issue/KT-11301) Make Map.plus accept Map out-projected by key type as either operand (receiver or parameter)
|
||||
- [KT-11485](https://youtrack.jetbrains.com/issue/KT-11485) Remove implementations of some internal intrinsic functions
|
||||
- [KT-11648](https://youtrack.jetbrains.com/issue/KT-11648) Add deprecated extension MutableList.remove to redirect to valid function removeAt
|
||||
- [KT-11348](https://youtrack.jetbrains.com/issue/KT-11348) kotlin.test: Make inline methods `todo` and `currentStackTrace` `@InlineOnly` not to lose stack trace
|
||||
- [KT-11745](https://youtrack.jetbrains.com/issue/KT-11745) Rename parameters of `String.subSequence` to match those of `CharSequence.subSequence`
|
||||
- [KT-10953](https://youtrack.jetbrains.com/issue/KT-10953) Clarify parameter order of lambda function parameter of `*Indexed` functions
|
||||
- [KT-10198](https://youtrack.jetbrains.com/issue/KT-10198) Improve docs for `binarySearch` functions
|
||||
- [KT-9786](https://youtrack.jetbrains.com/issue/KT-9786) Improve docs for `trimIndent`/`trimMargin`
|
||||
|
||||
### Reflection
|
||||
|
||||
- [KT-9952](https://youtrack.jetbrains.com/issue/KT-9952) Improve `toString()` for lambdas and function expressions when kotlin-reflect.jar is available
|
||||
- [KT-11433](https://youtrack.jetbrains.com/issue/KT-11433) Fix multiple resource leaks by closing InputStream instances
|
||||
- [KT-8131](https://youtrack.jetbrains.com/issue/KT-8131) Fix exception from calling `KProperty.javaField` on a subclass
|
||||
- [KT-10690](https://youtrack.jetbrains.com/issue/KT-10690) Support `javaMethod` and `kotlinFunction` for top level functions in a different file
|
||||
- [KT-11447](https://youtrack.jetbrains.com/issue/KT-11447) Support reflection calls to multifile class members
|
||||
- [KT-10892](https://youtrack.jetbrains.com/issue/KT-10892) Load annotations of const properties from multifile classes
|
||||
- [KT-11258](https://youtrack.jetbrains.com/issue/KT-11258) Don't crash on requesting members of Java collection classes
|
||||
- [KT-11502](https://youtrack.jetbrains.com/issue/KT-11502) Clarify KClass equality
|
||||
|
||||
### JS
|
||||
|
||||
- [KT-4124](https://youtrack.jetbrains.com/issue/KT-4124) Support nested classes
|
||||
- [KT-11030](https://youtrack.jetbrains.com/issue/KT-11030) Support local classes
|
||||
- [KT-7819](https://youtrack.jetbrains.com/issue/KT-7819) Support non-local returns in local lambdas
|
||||
- [KT-6912](https://youtrack.jetbrains.com/issue/KT-6912) Safe calls (`x?.let { it }`) are now inlined
|
||||
- [KT-2670](https://youtrack.jetbrains.com/issue/KT-2670) Support unsafe casts (`as`)
|
||||
- [KT-7016](https://youtrack.jetbrains.com/issue/KT-7016), [KT-8012](https://youtrack.jetbrains.com/issue/KT-8012) Fix `is`-checks for reified type parameters
|
||||
- [KT-7038](https://youtrack.jetbrains.com/issue/KT-7038) Avoid unwanted side effects on `is`-checks for nullable types
|
||||
- [KT-10614](https://youtrack.jetbrains.com/issue/KT-10614) Copy array on vararg call with spread operator
|
||||
- [KT-10785](https://youtrack.jetbrains.com/issue/KT-10785) Correctly translate property names and receiver instances in assignment operations
|
||||
- [KT-11611](https://youtrack.jetbrains.com/issue/KT-11611) Fix translation of default value of secondary constructor's functional parameter
|
||||
- [KT-11100](https://youtrack.jetbrains.com/issue/KT-11100) Fix generation of `invoke` on objects and companion objects
|
||||
- [KT-11823](https://youtrack.jetbrains.com/issue/KT-11823) Fix capturing of outer class' `this` in inner's lambdas
|
||||
- [KT-11996](https://youtrack.jetbrains.com/issue/KT-11996) Fix translation of a call to a private member of an outer class from an inner class which is a subtype of the outer class
|
||||
- [KT-10667](https://youtrack.jetbrains.com/issue/KT-10667) Support inheritance from nested built-in types such as Map.Entry
|
||||
- [KT-7480](https://youtrack.jetbrains.com/issue/KT-7480) Remove declarations of LinkedList, SortedSet, TreeSet, Enumeration
|
||||
- [KT-3064](https://youtrack.jetbrains.com/issue/KT-3064) Implement `CharSequence.repeat`
|
||||
|
||||
### IDE
|
||||
|
||||
New features:
|
||||
|
||||
- Spring Support
|
||||
- [KT-11098](https://youtrack.jetbrains.com/issue/KT-11098) Inspection on final classes/functions annotated with Spring `@Configuration`/`@Component`/`@Bean`
|
||||
- [KT-11405](https://youtrack.jetbrains.com/issue/KT-11405) Navigation and Find Usages for Spring beans referenced in annotation arguments and BeanFactory method calls
|
||||
- [KT-3741](https://youtrack.jetbrains.com/issue/KT-3741) Show Spring-specific line markers on Kotlin classes
|
||||
- [KT-11406](https://youtrack.jetbrains.com/issue/KT-11406) Support Spring EL injections inside of Kotlin string literals
|
||||
- [KT-11604](https://youtrack.jetbrains.com/issue/KT-11604) Support "Configure Spring facet" inspection on Kotlin classes
|
||||
- [KT-11407](https://youtrack.jetbrains.com/issue/KT-11407) Implement "Generate Spring Dependency..." actions
|
||||
- [KT-11408](https://youtrack.jetbrains.com/issue/KT-11408) Implement "Generate `@Autowired` Dependency..." action
|
||||
- [KT-11652](https://youtrack.jetbrains.com/issue/KT-11652) Rename bean attributes mentioned in Spring XML config together with corresponding Kotlin declarations
|
||||
- Enable precise incremental compilation by default in non-Maven/Gradle projects
|
||||
- [KT-11612](https://youtrack.jetbrains.com/issue/KT-11612) Highlight named arguments
|
||||
- [KT-7715](https://youtrack.jetbrains.com/issue/KT-7715) Highlight `var`s that can be replaced by `val`s
|
||||
- [KT-5208](https://youtrack.jetbrains.com/issue/KT-5208) Intention action to convert string to raw string and back
|
||||
- [KT-11078](https://youtrack.jetbrains.com/issue/KT-11078) Quick fix to remove `.java` when KClass is expected
|
||||
- [KT-1494](https://youtrack.jetbrains.com/issue/KT-1494) Inspection to highlight public members with no documentation
|
||||
- [KT-8473](https://youtrack.jetbrains.com/issue/KT-8473) Intention action to implement interface or abstract class
|
||||
- [KT-10299](https://youtrack.jetbrains.com/issue/KT-10299) Inspection to warn on array properties in data classes
|
||||
- [KT-6674](https://youtrack.jetbrains.com/issue/KT-6674) Inspection to warn on protected symbols in effectively final classes
|
||||
- [KT-11576](https://youtrack.jetbrains.com/issue/KT-11576) Quick fix to suppress "Unused symbol" warning based on annotations on the declaration
|
||||
- [KT-10063](https://youtrack.jetbrains.com/issue/KT-10063) Quick fix for adding `arrayOf` wrapper for annotation parameters
|
||||
- [KT-10476](https://youtrack.jetbrains.com/issue/KT-10476) Quick fix for converting primitive types
|
||||
- [KT-10859](https://youtrack.jetbrains.com/issue/KT-10859) Quick fix to make `var` with private setter final
|
||||
- [KT-9498](https://youtrack.jetbrains.com/issue/KT-9498) Quick fix to specify property type
|
||||
- [KT-10509](https://youtrack.jetbrains.com/issue/KT-10509) Quick fix to simplify condition with senseless comparison
|
||||
- [KT-11404](https://youtrack.jetbrains.com/issue/KT-11404) Quick fix to let type implement missing interface
|
||||
- [KT-6785](https://youtrack.jetbrains.com/issue/KT-6785), [KT-10013](https://youtrack.jetbrains.com/issue/KT-10013), [KT-9996](https://youtrack.jetbrains.com/issue/KT-9996), [KT-11675](https://youtrack.jetbrains.com/issue/KT-11675) Support Smart Enter for trailing lambda argument, try/catch/finally, property setter, init block
|
||||
- Add `kotlinClassName()` and `kotlinFunctionName()` macros for use in live templates
|
||||
- Auto-configure EAP-repository during Kotlin Maven and Gradle project set up
|
||||
|
||||
Issues fixed:
|
||||
|
||||
- [KT-11678](https://youtrack.jetbrains.com/issue/KT-11678), [KT-4768](https://youtrack.jetbrains.com/issue/KT-4768) Support navigation to Kotlin libraries from Java sources
|
||||
- [KT-9401](https://youtrack.jetbrains.com/issue/KT-9401) Support Change Signature quick fix for Java -> Kotlin case
|
||||
- [KT-8592](https://youtrack.jetbrains.com/issue/KT-8592) Fix "Choose sources" for Kotlin files
|
||||
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Fix Navigate to declaration for Java constructor with `@NotNull` parameter
|
||||
- [KT-11018](https://youtrack.jetbrains.com/issue/KT-11018) Fix `var`s shown in Ctrl + Mouse Hover as `val`s
|
||||
- [KT-5105](https://youtrack.jetbrains.com/issue/KT-5105), [KT-11024](https://youtrack.jetbrains.com/issue/KT-11024) Improve incompatible ABI versions editor strap, show the hint on how to resolve the problem
|
||||
- [KT-11638](https://youtrack.jetbrains.com/issue/KT-11638) Fixed `hashCode()` implementation in "Generate equals/hashCode" action
|
||||
- [KT-10971](https://youtrack.jetbrains.com/issue/KT-10971) Pull Members Up: Always insert spaces between keywords
|
||||
- [KT-11476](https://youtrack.jetbrains.com/issue/KT-11476), [KT-4175](https://youtrack.jetbrains.com/issue/KT-4175), [KT-10965](https://youtrack.jetbrains.com/issue/KT-10965), [KT-11076](https://youtrack.jetbrains.com/issue/KT-11076) Formatter: fix multiple issues regarding space handling
|
||||
- [KT-9025](https://youtrack.jetbrains.com/issue/KT-9025) Improve "Create Kotlin Java runtime library" dialog usability
|
||||
- [KT-11481](https://youtrack.jetbrains.com/issue/KT-11481) Fix "Add import" intention not being available for `is` branches in when
|
||||
- [KT-10619](https://youtrack.jetbrains.com/issue/KT-10619) Fix completion after package name in annotation
|
||||
- [KT-10621](https://youtrack.jetbrains.com/issue/KT-10621) Do not show non-top level packages after `@` in completion
|
||||
- [KT-11295](https://youtrack.jetbrains.com/issue/KT-11295) "Convert string to template" intention: fix exception on certain code
|
||||
- [KT-10750](https://youtrack.jetbrains.com/issue/KT-10750), [KT-11424](https://youtrack.jetbrains.com/issue/KT-11424) "Convert if to when" intention now detects effectively else branches in subsequent code and performs more accurate comment handling
|
||||
- Configure Kotlin: show only changed files in the notification "Kotlin not configured", restore all changed files in undo action
|
||||
- [KT-11556](https://youtrack.jetbrains.com/issue/KT-11556) Do not show "Kotlin not configured" for Kotlin JS projects
|
||||
- [KT-11593](https://youtrack.jetbrains.com/issue/KT-11593) Fix "Configure Kotlin" action for Gradle projects in IDEA 2016
|
||||
- [KT-11077](https://youtrack.jetbrains.com/issue/KT-11077) Use new built-in definition file format (`.kotlin_builtins` files)
|
||||
- [KT-5728](https://youtrack.jetbrains.com/issue/KT-5728) Remove closing curly brace in a string template when opening one is deleted
|
||||
- [KT-10883](https://youtrack.jetbrains.com/issue/KT-10883) "Explicit get or set call" quick fix: do not move caret too far away
|
||||
- [KT-5717](https://youtrack.jetbrains.com/issue/KT-5717) "Replace 'when' with 'if'": do not lose comments
|
||||
- [KT-10797](https://youtrack.jetbrains.com/issue/KT-10797) "Replace with operator" intention is not available anymore for non-`operator` functions
|
||||
- [KT-11529](https://youtrack.jetbrains.com/issue/KT-11529) Highlighting range for unresolved annotation name does not include `@` now
|
||||
- [KT-11178](https://youtrack.jetbrains.com/issue/KT-11178) Don't show "Change type arguments" fix when there's nothing to change
|
||||
- [KT-11789](https://youtrack.jetbrains.com/issue/KT-11789) Don't interpret annotations inside Markdown code blocks as KDoc tags
|
||||
- [KT-11702](https://youtrack.jetbrains.com/issue/KT-11702) Fixed resolution of Kotlin beans with custom name
|
||||
- [KT-11689](https://youtrack.jetbrains.com/issue/KT-11689) Fixed exception on attempt to navigate to Kotlin file from Spring notification balloon
|
||||
- [KT-11725](https://youtrack.jetbrains.com/issue/KT-11725) Fixed renaming of injected SpEL references
|
||||
- [KT-11720](https://youtrack.jetbrains.com/issue/KT-11720) Fixed renaming of Kotlin beans through SpEL references
|
||||
- [KT-11719](https://youtrack.jetbrains.com/issue/KT-11719) Fixed renaming of Kotlin parameters references in XML files
|
||||
- [KT-11736](https://youtrack.jetbrains.com/issue/KT-11736) Fixed searching of Java usages for @JvmStatic properties and @JvmStatic @JvmOverloads functions
|
||||
- [KT-11862](https://youtrack.jetbrains.com/issue/KT-11862) Fixed bogus warnings about unresolved types in the Change Signature dialog
|
||||
- Fix several issues leading to exceptions: [KT-11579](https://youtrack.jetbrains.com/issue/KT-11579), [KT-11580](https://youtrack.jetbrains.com/issue/KT-11580), [KT-11777](https://youtrack.jetbrains.com/issue/KT-11777), [KT-11868](https://youtrack.jetbrains.com/issue/KT-11868), [KT-11845](https://youtrack.jetbrains.com/issue/KT-11845), [KT-11486](https://youtrack.jetbrains.com/issue/KT-11486)
|
||||
- Fixed NoSuchFieldException in Kotlin module settings on IDEA Ultimate
|
||||
|
||||
#### Debugger
|
||||
|
||||
- [KT-11705](https://youtrack.jetbrains.com/issue/KT-11705) "Smart step into" no longer skips methods from subclasses
|
||||
- Debugger can now distinguish nested inline arguments
|
||||
- [KT-11326](https://youtrack.jetbrains.com/issue/KT-11326) Support private classes in Evaluate Expression
|
||||
- [KT-11455](https://youtrack.jetbrains.com/issue/KT-11455) Fix Evaluate Expression behavior for files with errors in sources
|
||||
- [KT-10670](https://youtrack.jetbrains.com/issue/KT-10670) Fix Evaluate Expression behavior for inline functions with default parameters
|
||||
- [KT-11380](https://youtrack.jetbrains.com/issue/KT-11380) Evaluate Expression now handles smart casts correctly
|
||||
- [KT-10148](https://youtrack.jetbrains.com/issue/KT-10148) Do not suggest methods from outer context in "Smart step into"
|
||||
- Fix Evaluate Expression for expression created for array element
|
||||
- Complete private members from libraries in Evaluate Expression
|
||||
- [KT-11578](https://youtrack.jetbrains.com/issue/KT-11578) Evaluate Expression: do not highlight completion variants from nullable receiver with grey
|
||||
- [KT-6805](https://youtrack.jetbrains.com/issue/KT-6805) Convert Java expression to Kotlin when opening Evaluate Expression from Variables view
|
||||
- [KT-11927](https://youtrack.jetbrains.com/issue/KT-11927) Fix "ambiguous import" error when invoking Evaluate Expression from Variables view for some field
|
||||
- [KT-11831](https://youtrack.jetbrains.com/issue/KT-11831) Fix Evaluate Expression for values of raw types
|
||||
- Show error message when debug info for some local variable is corrupted
|
||||
- Avoid 1s delay in completion in debugger fields if session is not stopped on a breakpoint
|
||||
- Avoid cast to runtime type unavailable in current scope
|
||||
- Fix text with line breaks in popup with line breakpoint variants
|
||||
- Fix breakpoints inside inline functions in libraries sources
|
||||
- Allow breakpoints at catch clause declaration
|
||||
- [KT-11848](https://youtrack.jetbrains.com/issue/KT-11848) Fix breakpoints inside generic crossinline lambda argument body
|
||||
- [KT-11932](https://youtrack.jetbrains.com/issue/KT-11932) Fix Step Over for `while` loop condition
|
||||
|
||||
### Java to Kotlin converter
|
||||
|
||||
- Protected members used outside of inheritors are converted as public
|
||||
- Support conversion for annotation constructor calls
|
||||
- Place comments from the middle of the call to the end
|
||||
- Drop line breaks between operator arguments (except `+`, `-`, `&&` and `||`)
|
||||
- Add non-null assertions on call site for non-null parameters
|
||||
- Specify type for variables with anonymous type if they have write accesses
|
||||
- [KT-11587](https://youtrack.jetbrains.com/issue/KT-11587) Fix conversion of static field accesses from other Java class
|
||||
- [KT-6800](https://youtrack.jetbrains.com/issue/KT-6800) Quote `$` symbols in converted strings
|
||||
- [KT-11126](https://youtrack.jetbrains.com/issue/KT-11126) Convert annotations in annotations parameters correctly
|
||||
- [KT-11600](https://youtrack.jetbrains.com/issue/KT-11600) Do not produce unresolved `toArray` calls for Java `Collection#toArray(T[])`
|
||||
- [KT-11544](https://youtrack.jetbrains.com/issue/KT-11544) Fix conversion of uninitialized non-final field
|
||||
- [KT-10604](https://youtrack.jetbrains.com/issue/KT-10604) Fix conversion of scratch files
|
||||
- [KT-11543](https://youtrack.jetbrains.com/issue/KT-11543) Do not produce unnecessary casts of non-nullable expression to nullable type
|
||||
- [KT-11160](https://youtrack.jetbrains.com/issue/KT-11160) Fix IDE freeze
|
||||
|
||||
### Android
|
||||
|
||||
- [KT-7729](https://youtrack.jetbrains.com/issue/KT-7729) Add Android Lint checks for Kotlin (from Android Studio 1.5)
|
||||
- [KT-11487](https://youtrack.jetbrains.com/issue/KT-11487) Fixed sequential build with kapt and stubs enabled when Kotlin source file was modified and no Java source files were modified
|
||||
- [KT-11264](https://youtrack.jetbrains.com/issue/KT-11264) Action to create new activity in Kotlin
|
||||
- [KT-11201](https://youtrack.jetbrains.com/issue/KT-11201) Do not ignore items with similar names in kapt
|
||||
- [KT-11944](https://youtrack.jetbrains.com/issue/KT-11944) Rename Android Extensions imports when the layout file is renamed/deleted/added
|
||||
- [KT-10321](https://youtrack.jetbrains.com/issue/KT-10321) Do not upcast ViewStub to View
|
||||
- [KT-10841](https://youtrack.jetbrains.com/issue/KT-10841) Support `@android:id/*` IDs in Android Extensions
|
||||
|
||||
### Maven
|
||||
|
||||
- [KT-2917](https://youtrack.jetbrains.com/issue/KT-2917), [KT-11261](https://youtrack.jetbrains.com/issue/KT-11261) Maven archetype for new Kotlin projects
|
||||
|
||||
### Gradle
|
||||
|
||||
- [KT-8487](https://youtrack.jetbrains.com/issue/KT-8487) Experimental support for incremental compilation with project property `kotlin.incremental`
|
||||
- [KT-11350](https://youtrack.jetbrains.com/issue/KT-11350) Fixed a bug causing Java rebuild when both Java and Kotlin are up-to-date
|
||||
- [KT-10507](https://youtrack.jetbrains.com/issue/KT-10507) Fix IllegalArgumentException "Missing extension point" on parallel builds
|
||||
- [KT-10932](https://youtrack.jetbrains.com/issue/KT-10932) Prevent compile tasks from running when nothing changes
|
||||
- [KT-11993](https://youtrack.jetbrains.com/issue/KT-11993) Fix NoSuchMethodError on access to internal members in production from tests (IDEA 2016+)
|
||||
|
||||
## 1.0.1-2
|
||||
|
||||
### Compiler
|
||||
|
||||
- [KT-11584](https://youtrack.jetbrains.com/issue/KT-11584), [KT-11514](https://youtrack.jetbrains.com/issue/KT-11514) Correct comparison of Long! / Double! with integer constant
|
||||
- [KT-11590](https://youtrack.jetbrains.com/issue/KT-11590) SAM adapter for inline function corrected
|
||||
|
||||
## 1.0.1-1
|
||||
|
||||
### Compiler
|
||||
|
||||
- [KT-11468](https://youtrack.jetbrains.com/issue/KT-11468) More correct use-site / declaration-site variance combination handling
|
||||
- [KT-11478](https://youtrack.jetbrains.com/issue/KT-11478) "Couldn't inline method call" internal compiler error fixed
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Compiler
|
||||
|
||||
Analysis & diagnostics issues fixed:
|
||||
|
||||
- [KT-2277](https://youtrack.jetbrains.com/issue/KT-2277) Local function declarations are now checked for overload conflicts
|
||||
- [KT-3602](https://youtrack.jetbrains.com/issue/KT-3602) Special diagnostic is reported now on nullable ‘for’ range
|
||||
- [KT-10775](https://youtrack.jetbrains.com/issue/KT-10775) No compilation exception for empty when
|
||||
- [KT-10952](https://youtrack.jetbrains.com/issue/KT-10952) False deprecation warnings removed
|
||||
- [KT-10934](https://youtrack.jetbrains.com/issue/KT-10934) Type inference improved for whens
|
||||
- [KT-10902](https://youtrack.jetbrains.com/issue/KT-10902) Redeclaration is reported for top-level property vs classifier conflict
|
||||
- [KT-9985](https://youtrack.jetbrains.com/issue/KT-9985) Correct handling of safe call arguments in generic functions
|
||||
- [KT-10856](https://youtrack.jetbrains.com/issue/KT-10856) Diagnostic about projected out member is reported correctly on calls with smart cast receiver
|
||||
- [KT-5190](https://youtrack.jetbrains.com/issue/KT-5190) Calls of Java 8 Stream.collect
|
||||
- [KT-11109](https://youtrack.jetbrains.com/issue/KT-11109) Warning is reported on Strictfp annotation on a class because it's not supported yet
|
||||
- [KT-10686](https://youtrack.jetbrains.com/issue/KT-10686) Support generic constructors defined in Java
|
||||
- [KT-6958](https://youtrack.jetbrains.com/issue/KT-6958) Fixed resolution for overloaded functions with extension lambdas
|
||||
- [KT-10765](https://youtrack.jetbrains.com/issue/KT-10765) Correct handling of overload conflict between constructor and function in JPS
|
||||
- [KT-10752](https://youtrack.jetbrains.com/issue/KT-10752) If inferred type for an expression refers to a non-accessible Java class, it's a compiler error to prevent IAE in runtime
|
||||
- [KT-7415](https://youtrack.jetbrains.com/issue/KT-7415) Approximation of captured types in signatures
|
||||
- [KT-10913](https://youtrack.jetbrains.com/issue/KT-10913), [KT-10186](https://youtrack.jetbrains.com/issue/KT-10186), [KT-5198](https://youtrack.jetbrains.com/issue/KT-5198) False “unreachable code” fixed for various situations
|
||||
- Minor: [KT-3680](https://youtrack.jetbrains.com/issue/KT-3680), [KT-9702](https://youtrack.jetbrains.com/issue/KT-9702), [KT-8776](https://youtrack.jetbrains.com/issue/KT-8776), [KT-6745](https://youtrack.jetbrains.com/issue/KT-6745), [KT-10919](https://youtrack.jetbrains.com/issue/KT-10919), [KT-9548](https://youtrack.jetbrains.com/issue/KT-9548)
|
||||
|
||||
JVM code generation issues fixed:
|
||||
|
||||
- [KT-11153](https://youtrack.jetbrains.com/issue/KT-11153) NoClassDefFoundError is fixed on primitive iterators during boxing optimization
|
||||
- [KT-7319](https://youtrack.jetbrains.com/issue/KT-7319) Correct parameter names for @JvmOverloads-generated methods
|
||||
- [KT-10425](https://youtrack.jetbrains.com/issue/KT-10425) Non-const values of member properties are not inlined now
|
||||
- [KT-11163](https://youtrack.jetbrains.com/issue/KT-11163) Correct calls of custom compareTo on primitives
|
||||
- [KT-11081](https://youtrack.jetbrains.com/issue/KT-11081) Reified type parameters are correctly stored in anonymous objects
|
||||
- [KT-11121](https://youtrack.jetbrains.com/issue/KT-11121) Generic properties generation is fixed for interfaces
|
||||
- [KT-11285](https://youtrack.jetbrains.com/issue/KT-11285), [KT-10958](https://youtrack.jetbrains.com/issue/KT-10958) Special bridge generation refined
|
||||
- [KT-10313](https://youtrack.jetbrains.com/issue/KT-10313), [KT-11190](https://youtrack.jetbrains.com/issue/KT-11190), [KT-11192](https://youtrack.jetbrains.com/issue/KT-11192), [KT-11130](https://youtrack.jetbrains.com/issue/KT-11130) Diagnostics and bytecode fixed for various operations with Long
|
||||
- [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203), [KT-11191](https://youtrack.jetbrains.com/issue/KT-11191), [KT-11206](https://youtrack.jetbrains.com/issue/KT-11206), [KT-8505](https://youtrack.jetbrains.com/issue/KT-8505), [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203) Handling of increment / decrement for collection elements with user-defined get / set fixed
|
||||
- [KT-9739](https://youtrack.jetbrains.com/issue/KT-9739) Backticked names with spaces are generated correctly
|
||||
|
||||
JS translator issues fixed:
|
||||
|
||||
- [KT-7683](https://youtrack.jetbrains.com/issue/KT-7683), [KT-11027](https://youtrack.jetbrains.com/issue/KT-11027) correct handling of in / !in inside when expressions
|
||||
|
||||
### Standard library
|
||||
|
||||
- [KT-10579](https://youtrack.jetbrains.com/issue/KT-10579) Improved performance of sum() and average() for arrays
|
||||
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Improved performance of drop() / take() for sequences
|
||||
|
||||
### Reflection
|
||||
|
||||
- [KT-10840](https://youtrack.jetbrains.com/issue/KT-10840) Fix annotations on Java elements in reflection
|
||||
|
||||
### IDE
|
||||
|
||||
New features:
|
||||
|
||||
- Compatibility with IDEA 2016
|
||||
- Kotlin Education Plugin (for IDEA 2016)
|
||||
- [KT-9752](https://youtrack.jetbrains.com/issue/KT-9752) More usable file chooser for "Move declaration to another file"
|
||||
- [KT-9697](https://youtrack.jetbrains.com/issue/KT-9697) Move method to companion object and back
|
||||
- [KT-7443](https://youtrack.jetbrains.com/issue/KT-7443) Inspection + intention to replace assert (x != null) with "!!" or elvis
|
||||
|
||||
General issues fixed:
|
||||
|
||||
- [KT-11277](https://youtrack.jetbrains.com/issue/KT-11277) Correct moving of Java classes from project view
|
||||
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Navigate Declaration fixed for Java classes with @NotNull parameter in constructor
|
||||
- [KT-10553](https://youtrack.jetbrains.com/issue/KT-10553) A warning provided when Refactor / Move result is not compilable due to visibility problems
|
||||
- [KT-11039](https://youtrack.jetbrains.com/issue/KT-11039) Parameter names are now not missing in parameter info and completion for compiled java code used from kotlin
|
||||
- [KT-10204](https://youtrack.jetbrains.com/issue/KT-10204) Highlight usages in file is working now for function parameter
|
||||
- [KT-10954](https://youtrack.jetbrains.com/issue/KT-10954) Introduce Parameter (Ctrl+Alt+P) fixed when default value is a simple name reference
|
||||
- [KT-10776](https://youtrack.jetbrains.com/issue/KT-10776) Intentions: "Convert to lambda expression" works now for empty function body
|
||||
- [KT-10815](https://youtrack.jetbrains.com/issue/KT-10815) Generate equals() and hashCode() is no more suggested for interfaces
|
||||
- [KT-10818](https://youtrack.jetbrains.com/issue/KT-10818) "Initialize with constructor parameter" fixed
|
||||
- [KT-8876](https://youtrack.jetbrains.com/issue/KT-8876) "Convert member to extension" now removes modality modifiers (open / final)
|
||||
- [KT-10800](https://youtrack.jetbrains.com/issue/KT-10800) Create enum entry now adds comma after a new entry
|
||||
- [KT-10552](https://youtrack.jetbrains.com/issue/KT-10552) Pull Members Up now takes visibility conflicts into account
|
||||
- [KT-10978](https://youtrack.jetbrains.com/issue/KT-10978) Partially fixed, completion for JOOQ became ~ 10 times faster
|
||||
- [KT-10940](https://youtrack.jetbrains.com/issue/KT-10940) Reference search optimized for convention functions
|
||||
- [KT-9026](https://youtrack.jetbrains.com/issue/KT-9026) Editor no more locks up during scala file viewing
|
||||
- [KT-11142](https://youtrack.jetbrains.com/issue/KT-11142), [KT-11276](https://youtrack.jetbrains.com/issue/KT-11276) Darkula scheme appearance corrected for Kotlin
|
||||
- Minor: [KT-10778](https://youtrack.jetbrains.com/issue/KT-10778), [KT-10763](https://youtrack.jetbrains.com/issue/KT-10763), [KT-10908](https://youtrack.jetbrains.com/issue/KT-10908), [KT-10345](https://youtrack.jetbrains.com/issue/KT-10345), [KT-10696](https://youtrack.jetbrains.com/issue/KT-10696), [KT-11041](https://youtrack.jetbrains.com/issue/KT-11041), [KT-9434](https://youtrack.jetbrains.com/issue/KT-9434), [KT-8744](https://youtrack.jetbrains.com/issue/KT-8744), [KT-9738](https://youtrack.jetbrains.com/issue/KT-9738), [KT-10912](https://youtrack.jetbrains.com/issue/KT-10912)
|
||||
|
||||
Configuration issues fixed:
|
||||
|
||||
- [KT-11213](https://youtrack.jetbrains.com/issue/KT-11213) Kotlin plugin version corrected in build.gradle
|
||||
- [KT-10918](https://youtrack.jetbrains.com/issue/KT-10918) "Update Kotlin runtime" action does not try to update the runtime coming in from Gradle
|
||||
- [KT-11072](https://youtrack.jetbrains.com/issue/KT-11072) Libraries in maven, gradle and ide systems are never more detected as runtime libraries
|
||||
- [KT-10489](https://youtrack.jetbrains.com/issue/KT-10489) Configuration messages are aggregated into one notification
|
||||
- [KT-10831](https://youtrack.jetbrains.com/issue/KT-10831) Configure Kotlin in Project: "All modules containing Kotlin files" does not list modules not containing Kotlin files
|
||||
- [KT-10366](https://youtrack.jetbrains.com/issue/KT-10366) Gradle import: no fake "Configure Kotlin" notification on project creating
|
||||
|
||||
Debugger issues fixed:
|
||||
|
||||
- [KT-10827](https://youtrack.jetbrains.com/issue/KT-10827) Fixed debugger stepping for inline calls
|
||||
- [KT-10780](https://youtrack.jetbrains.com/issue/KT-10780) Breakpoints in a lazy property work correctly
|
||||
- [KT-10634](https://youtrack.jetbrains.com/issue/KT-10634) Watches can now use private overloaded functions
|
||||
- [KT-10611](https://youtrack.jetbrains.com/issue/KT-10611) Line breakpoints now can be created inside lambda in init block
|
||||
- [KT-10673](https://youtrack.jetbrains.com/issue/KT-10673) Breakpoints inside lambda are no more ignored in presence of crossinline function parameter
|
||||
- [KT-11318](https://youtrack.jetbrains.com/issue/KT-11318) Stepping inside for each is optimized
|
||||
- [KT-3873](https://youtrack.jetbrains.com/issue/KT-3873) Editing code while standing on breakpoint is optimized
|
||||
- [KT-7261](https://youtrack.jetbrains.com/issue/KT-7261), [KT-7266](https://youtrack.jetbrains.com/issue/KT-7266), [KT-10672](https://youtrack.jetbrains.com/issue/KT-10672) Evaluate expression applicability corrected
|
||||
|
||||
### Tools
|
||||
|
||||
- [KT-7943](https://youtrack.jetbrains.com/issue/KT-7943), [KT-10127](https://youtrack.jetbrains.com/issue/KT-10127) Overhead removed in Kotlin Gradle Plugin
|
||||
- [KT-11351](https://youtrack.jetbrains.com/issue/KT-11351) Fixed NoSuchMethodError with Gradle 2.12
|
||||
154
Changelog.md
154
Changelog.md
@@ -1,154 +0,0 @@
|
||||
# CHANGELOG
|
||||
|
||||
<!-- Find: ([^\[/])(KT-\d+) -->
|
||||
<!-- Replace: $1[$2](https://youtrack.jetbrains.com/issue/$2) -->
|
||||
|
||||
## 1.1
|
||||
|
||||
## 1.0.2
|
||||
- Show only changed files in notification "Kotlin not configured"
|
||||
- Configure Kotlin: restore all changed files in undo action
|
||||
- Enable precise incremental compilation by default
|
||||
- Report warning about unused anonymous functions
|
||||
|
||||
### JVM
|
||||
- Remove the compiler option "Xmultifile-facades-open"
|
||||
|
||||
### JS
|
||||
- Safe calls (`x?.let { it }`) are now inlined
|
||||
|
||||
### Tools. J2K
|
||||
- Protected members used outside of inheritors are converted as public
|
||||
- Support conversion for annotation constructor calls
|
||||
- Place comments from the middle of the call to the end
|
||||
- Drop line breaks between operator arguments (except '+', "-", "&&" and "||")
|
||||
- Add non-null assertions on call site for non-null parameters
|
||||
- Specify type for variables with anonymous type if they have write accesses
|
||||
|
||||
### Tools. Android
|
||||
- Fixed sequential build with kapt and stubs enabled when Kotlin source file was modified and no Java source files were modified
|
||||
|
||||
### IDE
|
||||
- Debugger can distinguish nested inline arguments
|
||||
- Add kotlinClassName() and kotlinFunctionName() macros for use in live templates
|
||||
- Complete private members from libraries in Evaluate Expression dialog
|
||||
- Show error message when debug info for some local variable is corrupted
|
||||
- [KT-11638](https://youtrack.jetbrains.com/issue/KT-11638) Fixed hashCode() implementation in "Generate equals/hashCode" action
|
||||
|
||||
### Tools.Gradle
|
||||
- Added project property 'kotlin.incremental'
|
||||
- Fixed a bug causing Java rebuild when both Java and Kotlin are up-to-date
|
||||
|
||||
## 1.0.1-2
|
||||
|
||||
### Compiler
|
||||
|
||||
- [KT-11584](https://youtrack.jetbrains.com/issue/KT-11584), [KT-11514](https://youtrack.jetbrains.com/issue/KT-11514) Correct comparison of Long! / Double! with integer constant
|
||||
- [KT-11590](https://youtrack.jetbrains.com/issue/KT-11590) SAM adapter for inline function corrected
|
||||
|
||||
## 1.0.1-1
|
||||
|
||||
### Compiler
|
||||
|
||||
- [KT-11468](https://youtrack.jetbrains.com/issue/KT-11468) More correct use-site / declaration-site variance combination handling
|
||||
- [KT-11478](https://youtrack.jetbrains.com/issue/KT-11478) "Couldn't inline method call" internal compiler error fixed
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Compiler
|
||||
|
||||
Analysis & diagnostics issues fixed:
|
||||
|
||||
- [KT-2277](https://youtrack.jetbrains.com/issue/KT-2277) Local function declarations are now checked for overload conflicts
|
||||
- [KT-3602](https://youtrack.jetbrains.com/issue/KT-3602) Special diagnostic is reported now on nullable ‘for’ range
|
||||
- [KT-10775](https://youtrack.jetbrains.com/issue/KT-10775) No compilation exception for empty when
|
||||
- [KT-10952](https://youtrack.jetbrains.com/issue/KT-10952) False deprecation warnings removed
|
||||
- [KT-10934](https://youtrack.jetbrains.com/issue/KT-10934) Type inference improved for whens
|
||||
- [KT-10902](https://youtrack.jetbrains.com/issue/KT-10902) Redeclaration is reported for top-level property vs classifier conflict
|
||||
- [KT-9985](https://youtrack.jetbrains.com/issue/KT-9985) Correct handling of safe call arguments in generic functions
|
||||
- [KT-10856](https://youtrack.jetbrains.com/issue/KT-10856) Diagnostic about projected out member is reported correctly on calls with smart cast receiver
|
||||
- [KT-5190](https://youtrack.jetbrains.com/issue/KT-5190) Calls of Java 8 Stream.collect
|
||||
- [KT-11109](https://youtrack.jetbrains.com/issue/KT-11109) Warning is reported on Strictfp annotation on a class because it's not supported yet
|
||||
- [KT-10686](https://youtrack.jetbrains.com/issue/KT-10686) Support generic constructors defined in Java
|
||||
- [KT-6958](https://youtrack.jetbrains.com/issue/KT-6958) Fixed resolution for overloaded functions with extension lambdas
|
||||
- [KT-10765](https://youtrack.jetbrains.com/issue/KT-10765) Correct handling of overload conflict between constructor and function in JPS
|
||||
- [KT-10752](https://youtrack.jetbrains.com/issue/KT-10752) If inferred type for an expression refers to a non-accessible Java class, it's a compiler error to prevent IAE in runtime
|
||||
- [KT-7415](https://youtrack.jetbrains.com/issue/KT-7415) Approximation of captured types in signatures
|
||||
- [KT-10913](https://youtrack.jetbrains.com/issue/KT-10913), [KT-10186](https://youtrack.jetbrains.com/issue/KT-10186), [KT-5198](https://youtrack.jetbrains.com/issue/KT-5198) False “unreachable code” fixed for various situations
|
||||
- Minor: [KT-3680](https://youtrack.jetbrains.com/issue/KT-3680), [KT-9702](https://youtrack.jetbrains.com/issue/KT-9702), [KT-8776](https://youtrack.jetbrains.com/issue/KT-8776), [KT-6745](https://youtrack.jetbrains.com/issue/KT-6745), [KT-10919](https://youtrack.jetbrains.com/issue/KT-10919), [KT-9548](https://youtrack.jetbrains.com/issue/KT-9548)
|
||||
|
||||
JVM code generation issues fixed:
|
||||
|
||||
- [KT-11153](https://youtrack.jetbrains.com/issue/KT-11153) NoClassDefFoundError is fixed on primitive iterators during boxing optimization
|
||||
- [KT-7319](https://youtrack.jetbrains.com/issue/KT-7319) Correct parameter names for @JvmOverloads-generated methods
|
||||
- [KT-10425](https://youtrack.jetbrains.com/issue/KT-10425) Non-const values of member properties are not inlined now
|
||||
- [KT-11163](https://youtrack.jetbrains.com/issue/KT-11163) Correct calls of custom compareTo on primitives
|
||||
- [KT-11081](https://youtrack.jetbrains.com/issue/KT-11081) Reified type parameters are correctly stored in anonymous objects
|
||||
- [KT-11121](https://youtrack.jetbrains.com/issue/KT-11121) Generic properties generation is fixed for interfaces
|
||||
- [KT-11285](https://youtrack.jetbrains.com/issue/KT-11285), [KT-10958](https://youtrack.jetbrains.com/issue/KT-10958) Special bridge generation refined
|
||||
- [KT-10313](https://youtrack.jetbrains.com/issue/KT-10313), [KT-11190](https://youtrack.jetbrains.com/issue/KT-11190), [KT-11192](https://youtrack.jetbrains.com/issue/KT-11192), [KT-11130](https://youtrack.jetbrains.com/issue/KT-11130) Diagnostics and bytecode fixed for various operations with Long
|
||||
- [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203), [KT-11191](https://youtrack.jetbrains.com/issue/KT-11191), [KT-11206](https://youtrack.jetbrains.com/issue/KT-11206), [KT-8505](https://youtrack.jetbrains.com/issue/KT-8505), [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203) Handling of increment / decrement for collection elements with user-defined get / set fixed
|
||||
- [KT-9739](https://youtrack.jetbrains.com/issue/KT-9739) Backticked names with spaces are generated correctly
|
||||
|
||||
JS translator issues fixed:
|
||||
|
||||
- [KT-7683](https://youtrack.jetbrains.com/issue/KT-7683), [KT-11027](https://youtrack.jetbrains.com/issue/KT-11027) correct handling of in / !in inside when expressions
|
||||
|
||||
### Standard library
|
||||
|
||||
- [KT-10579](https://youtrack.jetbrains.com/issue/KT-10579) Improved performance of sum() and average() for arrays
|
||||
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Improved performance of drop() / take() for sequences
|
||||
|
||||
### IDE
|
||||
|
||||
New features:
|
||||
|
||||
- Compatibility with IDEA 2016
|
||||
- Kotlin Education Plugin (for IDEA 2016)
|
||||
- [KT-9752](https://youtrack.jetbrains.com/issue/KT-9752) More usable file chooser for "Move declaration to another file"
|
||||
- [KT-9697](https://youtrack.jetbrains.com/issue/KT-9697) Move method to companion object and back
|
||||
|
||||
General issues fixed:
|
||||
|
||||
- [KT-11277](https://youtrack.jetbrains.com/issue/KT-11277) Correct moving of Java classes from project view
|
||||
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Navigate Declaration fixed for Java classes with @NotNull parameter in constructor
|
||||
- [KT-10553](https://youtrack.jetbrains.com/issue/KT-10553) A warning provided when Refactor / Move result is not compilable due to visibility problems
|
||||
- [KT-11039](https://youtrack.jetbrains.com/issue/KT-11039) Parameter names are now not missing in parameter info and completion for compiled java code used from kotlin
|
||||
- [KT-10204](https://youtrack.jetbrains.com/issue/KT-10204) Highlight usages in file is working now for function parameter
|
||||
- [KT-10954](https://youtrack.jetbrains.com/issue/KT-10954) Introduce Parameter (Ctrl+Alt+P) fixed when default value is a simple name reference
|
||||
- [KT-10776](https://youtrack.jetbrains.com/issue/KT-10776) Intentions: "Convert to lambda expression" works now for empty function body
|
||||
- [KT-10815](https://youtrack.jetbrains.com/issue/KT-10815) Generate equals() and hashCode() is no more suggested for interfaces
|
||||
- [KT-10818](https://youtrack.jetbrains.com/issue/KT-10818) "Initialize with constructor parameter" fixed
|
||||
- [KT-8876](https://youtrack.jetbrains.com/issue/KT-8876) "Convert member to extension" now removes modality modifiers (open / final)
|
||||
- [KT-10800](https://youtrack.jetbrains.com/issue/KT-10800) Create enum entry now adds comma after a new entry
|
||||
- [KT-10552](https://youtrack.jetbrains.com/issue/KT-10552) Pull Members Up now takes visibility conflicts into account
|
||||
- [KT-10978](https://youtrack.jetbrains.com/issue/KT-10978) Partially fixed, completion for JOOQ became ~ 10 times faster
|
||||
- [KT-10940](https://youtrack.jetbrains.com/issue/KT-10940) Reference search optimized for convention functions
|
||||
- [KT-9026](https://youtrack.jetbrains.com/issue/KT-9026) Editor no more locks up during scala file viewing
|
||||
- [KT-11142](https://youtrack.jetbrains.com/issue/KT-11142), [KT-11276](https://youtrack.jetbrains.com/issue/KT-11276) Darkula scheme appearance corrected for Kotlin
|
||||
- Minor: [KT-10778](https://youtrack.jetbrains.com/issue/KT-10778), [KT-10763](https://youtrack.jetbrains.com/issue/KT-10763), [KT-10908](https://youtrack.jetbrains.com/issue/KT-10908), [KT-10345](https://youtrack.jetbrains.com/issue/KT-10345), [KT-10696](https://youtrack.jetbrains.com/issue/KT-10696), [KT-11041](https://youtrack.jetbrains.com/issue/KT-11041), [KT-9434](https://youtrack.jetbrains.com/issue/KT-9434)
|
||||
|
||||
Configuration issues fixed:
|
||||
|
||||
- [KT-11213](https://youtrack.jetbrains.com/issue/KT-11213) Kotlin plugin version corrected in build.gradle
|
||||
- [KT-10918](https://youtrack.jetbrains.com/issue/KT-10918) "Update Kotlin runtime" action does not try to update the runtime coming in from Gradle
|
||||
- [KT-11072](https://youtrack.jetbrains.com/issue/KT-11072) Libraries in maven, gradle and ide systems are never more detected as runtime libraries
|
||||
- [KT-10489](https://youtrack.jetbrains.com/issue/KT-10489) Configuration messages are aggregated into one notification
|
||||
- [KT-10831](https://youtrack.jetbrains.com/issue/KT-10831) Configure Kotlin in Project: "All modules containing Kotlin files" does not list modules not containing Kotlin files
|
||||
- [KT-10366](https://youtrack.jetbrains.com/issue/KT-10366) Gradle import: no fake "Configure Kotlin" notification on project creating
|
||||
|
||||
Debugger issues fixed:
|
||||
|
||||
- [KT-10827](https://youtrack.jetbrains.com/issue/KT-10827) Fixed debugger stepping for inline calls
|
||||
- [KT-10780](https://youtrack.jetbrains.com/issue/KT-10780) Breakpoints in a lazy property work correctly
|
||||
- [KT-10634](https://youtrack.jetbrains.com/issue/KT-10634) Watches can now use private overloaded functions
|
||||
- [KT-10611](https://youtrack.jetbrains.com/issue/KT-10611) Line breakpoints now can be created inside lambda in init block
|
||||
- [KT-10673](https://youtrack.jetbrains.com/issue/KT-10673) Breakpoints inside lambda are no more ignored in presence of crossinline function parameter
|
||||
- [KT-11318](https://youtrack.jetbrains.com/issue/KT-11318) Stepping inside for each is optimized
|
||||
- [KT-3873](https://youtrack.jetbrains.com/issue/KT-3873) Editing code while standing on breakpoint is optimized
|
||||
- [KT-7261](https://youtrack.jetbrains.com/issue/KT-7261), [KT-7266](https://youtrack.jetbrains.com/issue/KT-7266), [KT-10672](https://youtrack.jetbrains.com/issue/KT-10672) Evaluate expression applicability corrected
|
||||
|
||||
### Tools
|
||||
|
||||
- [KT-7943](https://youtrack.jetbrains.com/issue/KT-7943), [KT-10127](https://youtrack.jetbrains.com/issue/KT-10127) Overhead removed in Kotlin Gradle Plugin
|
||||
- [KT-11351](https://youtrack.jetbrains.com/issue/KT-11351) Fixed NoSuchMethodError with Gradle 2.12
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -24,6 +24,8 @@ import com.intellij.util.io.EnumeratorStringDescriptor
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.incremental.ChangeInfo.MembersChanged
|
||||
import org.jetbrains.kotlin.incremental.ChangeInfo.Removed
|
||||
import org.jetbrains.kotlin.incremental.storage.*
|
||||
import org.jetbrains.kotlin.inline.inlineFunctionsJvmNames
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
@@ -32,12 +34,14 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.supertypes
|
||||
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
@@ -118,6 +122,11 @@ open class IncrementalCacheImpl<Target>(
|
||||
}
|
||||
}
|
||||
|
||||
// used in gradle
|
||||
@Suppress("unused")
|
||||
fun classesBySources(sources: Iterable<File>): Iterable<JvmClassName> =
|
||||
sources.flatMap { sourceToClassesMap[it] }
|
||||
|
||||
fun getSubtypesOf(className: FqName): Sequence<FqName> =
|
||||
subtypesMap[className].asSequence()
|
||||
|
||||
@@ -207,32 +216,34 @@ open class IncrementalCacheImpl<Target>(
|
||||
debugLog("$className is changed: $this")
|
||||
}
|
||||
|
||||
fun clearCacheForRemovedClasses(): CompilationResult {
|
||||
|
||||
private fun computeChanges(className: JvmClassName, createChangeInfo: (FqName, Collection<String>) -> ChangeInfo): List<ChangeInfo> {
|
||||
fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> =
|
||||
members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet()
|
||||
|
||||
fun createChangeInfo(className: JvmClassName): ChangeInfo? {
|
||||
if (className.internalName == MODULE_MAPPING_FILE_NAME) return null
|
||||
if (className.internalName == MODULE_MAPPING_FILE_NAME) return emptyList()
|
||||
|
||||
val mapValue = protoMap.get(className) ?: return null
|
||||
val mapValue = protoMap[className] ?: return emptyList()
|
||||
|
||||
return when {
|
||||
mapValue.isPackageFacade -> {
|
||||
val packageData = JvmProtoBufUtil.readPackageDataFrom(mapValue.bytes, mapValue.strings)
|
||||
return when {
|
||||
mapValue.isPackageFacade -> {
|
||||
val packageData = JvmProtoBufUtil.readPackageDataFrom(mapValue.bytes, mapValue.strings)
|
||||
|
||||
val memberNames =
|
||||
packageData.packageProto.getNonPrivateNames(
|
||||
packageData.nameResolver,
|
||||
ProtoBuf.Package::getFunctionList,
|
||||
ProtoBuf.Package::getPropertyList
|
||||
)
|
||||
val memberNames =
|
||||
packageData.packageProto.getNonPrivateNames(
|
||||
packageData.nameResolver,
|
||||
ProtoBuf.Package::getFunctionList,
|
||||
ProtoBuf.Package::getPropertyList
|
||||
)
|
||||
|
||||
ChangeInfo.Removed(className.packageFqName, memberNames)
|
||||
}
|
||||
else -> {
|
||||
val classData = JvmProtoBufUtil.readClassDataFrom(mapValue.bytes, mapValue.strings)
|
||||
listOf(createChangeInfo(className.packageFqName, memberNames))
|
||||
}
|
||||
else -> {
|
||||
val classData = JvmProtoBufUtil.readClassDataFrom(mapValue.bytes, mapValue.strings)
|
||||
|
||||
val classFqName = className.fqNameForClassNameWithoutDollars
|
||||
val kind = Flags.CLASS_KIND.get(classData.classProto.flags)
|
||||
|
||||
if (kind == ProtoBuf.Class.Kind.COMPANION_OBJECT) {
|
||||
val memberNames =
|
||||
classData.classProto.getNonPrivateNames(
|
||||
classData.nameResolver,
|
||||
@@ -241,11 +252,19 @@ open class IncrementalCacheImpl<Target>(
|
||||
ProtoBuf.Class::getPropertyList
|
||||
) + classData.classProto.enumEntryList.map { classData.nameResolver.getString(it.name) }
|
||||
|
||||
ChangeInfo.Removed(className.fqNameForClassNameWithoutDollars, memberNames)
|
||||
val companionObjectChanged = createChangeInfo(classFqName.parent(), classFqName.shortName().asString().singletonOrEmptyList())
|
||||
val companionObjectMembersChanged = createChangeInfo(classFqName, memberNames)
|
||||
|
||||
listOf(companionObjectMembersChanged, companionObjectChanged)
|
||||
}
|
||||
else {
|
||||
listOf(ChangeInfo.SignatureChanged(classFqName, areSubclassesAffected = true))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearCacheForRemovedClasses(): CompilationResult {
|
||||
val dirtyClasses = dirtyOutputClassesMap
|
||||
.getDirtyOutputClasses()
|
||||
.map(JvmClassName::byInternalName)
|
||||
@@ -253,7 +272,7 @@ open class IncrementalCacheImpl<Target>(
|
||||
|
||||
val changes =
|
||||
if (IncrementalCompilation.isExperimental())
|
||||
dirtyClasses.mapNotNull { createChangeInfo(it) }.asSequence()
|
||||
dirtyClasses.flatMap { computeChanges(it, ::Removed) }.asSequence()
|
||||
else
|
||||
emptySequence<ChangeInfo>()
|
||||
|
||||
@@ -346,9 +365,6 @@ open class IncrementalCacheImpl<Target>(
|
||||
experimentalMaps.forEach { it.clean() }
|
||||
}
|
||||
|
||||
fun classesBySources(sources: Iterable<File>): Iterable<JvmClassName> =
|
||||
sources.flatMap { sourceToClassesMap[it] }
|
||||
|
||||
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
|
||||
|
||||
fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult {
|
||||
@@ -376,7 +392,17 @@ open class IncrementalCacheImpl<Target>(
|
||||
storage[key] = data
|
||||
}
|
||||
|
||||
if (oldData == null || !checkChangesIsOpenPart) return CompilationResult(protoChanged = true)
|
||||
if (!checkChangesIsOpenPart) return CompilationResult(protoChanged = true)
|
||||
|
||||
if (oldData == null) {
|
||||
val changes =
|
||||
if (IncrementalCompilation.isExperimental())
|
||||
computeChanges(className, ::MembersChanged).asSequence()
|
||||
else
|
||||
emptySequence<ChangeInfo>()
|
||||
|
||||
return CompilationResult(protoChanged = true, changes = changes)
|
||||
}
|
||||
|
||||
val difference = difference(oldData, data)
|
||||
val fqName = if (isPackage) className.packageFqName else className.fqNameForClassNameWithoutDollars
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.incremental.testingUtils
|
||||
|
||||
import com.google.common.collect.Sets
|
||||
import com.google.common.hash.Hashing
|
||||
import com.google.common.io.Files
|
||||
import com.google.protobuf.ExtensionRegistry
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.incremental.LocalFileKotlinClass
|
||||
@@ -36,6 +33,7 @@ import java.io.File
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import java.util.*
|
||||
import java.util.zip.CRC32
|
||||
import kotlin.comparisons.compareBy
|
||||
|
||||
// Set this to true if you want to dump all bytecode (test will fail in this case)
|
||||
@@ -45,7 +43,7 @@ fun assertEqualDirectories(expected: File, actual: File, forgiveExtraFiles: Bool
|
||||
val pathsInExpected = getAllRelativePaths(expected)
|
||||
val pathsInActual = getAllRelativePaths(actual)
|
||||
|
||||
val commonPaths = Sets.intersection(pathsInExpected, pathsInActual)
|
||||
val commonPaths = pathsInExpected.intersect(pathsInActual)
|
||||
val changedPaths = commonPaths
|
||||
.filter { DUMP_ALL || !Arrays.equals(File(expected, it).readBytes(), File(actual, it).readBytes()) }
|
||||
.sorted()
|
||||
@@ -71,7 +69,11 @@ fun assertEqualDirectories(expected: File, actual: File, forgiveExtraFiles: Bool
|
||||
Assert.assertEquals(expectedString, actualString)
|
||||
}
|
||||
|
||||
private fun File.hash() = Files.hash(this, Hashing.crc32())
|
||||
private fun File.checksumString(): String {
|
||||
val crc32 = CRC32()
|
||||
crc32.update(this.readBytes())
|
||||
return java.lang.Long.toHexString(crc32.value)
|
||||
}
|
||||
|
||||
private fun getDirectoryString(dir: File, interestingPaths: List<String>): String {
|
||||
val buf = StringBuilder()
|
||||
@@ -93,7 +95,7 @@ private fun getDirectoryString(dir: File, interestingPaths: List<String>): Strin
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.println(child.name, " ", child.hash())
|
||||
p.println(child.name, " ", child.checksumString())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
21
build.xml
21
build.xml
@@ -68,7 +68,7 @@
|
||||
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="jansi.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="jline.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.2.jar"/>
|
||||
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
|
||||
</path>
|
||||
|
||||
@@ -512,7 +512,7 @@
|
||||
<zipfileset src="${idea.sdk}/lib/oromatcher.jar"/>
|
||||
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
|
||||
<zipfileset src="${dependencies.dir}/jline.jar"/>
|
||||
<zipfileset src="${dependencies.dir}/cli-parser-1.1.1.jar"/>
|
||||
<zipfileset src="${dependencies.dir}/cli-parser-1.1.2.jar"/>
|
||||
<zipfileset src="${protobuf.jar}"/>
|
||||
|
||||
<manifest>
|
||||
@@ -668,25 +668,28 @@
|
||||
<pathelement path="${bootstrap.reflect}"/>
|
||||
<pathelement path="${bootstrap.kotlin.test}"/>
|
||||
<pathelement path="${idea.sdk}/lib/junit-4.12.jar"/>
|
||||
<pathelement path="${idea.sdk}/lib/guava-17.0.jar"/>
|
||||
<pathelement path="${kotlin-home}/lib/kotlin-build-common.jar"/>
|
||||
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||
<pathelement path="${protobuf.jar}"/>
|
||||
</classpath>
|
||||
</javac2>
|
||||
|
||||
<jar destfile="${kotlin-home}/lib/kotlin-build-common-test.jar">
|
||||
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/>
|
||||
|
||||
<jarjar jarfile="${kotlin-home}/lib/kotlin-build-common-test.jar">
|
||||
<fileset dir="${output}/classes/kotlin-build-common-test"/>
|
||||
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
|
||||
<zipfileset src="${protobuf.jar}"/>
|
||||
<rule pattern="com.google.**" result="org.jetbrains.kotlin.com.google.@1"/>
|
||||
<rule pattern="com.intellij.**" result="org.jetbrains.kotlin.com.intellij.@1"/>
|
||||
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
|
||||
|
||||
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
|
||||
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.build.common}"/>
|
||||
<attribute name="Implementation-Version" value="${build.number}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</jarjar>
|
||||
</target>
|
||||
|
||||
<target name="daemon-client">
|
||||
@@ -877,7 +880,7 @@
|
||||
</target>
|
||||
|
||||
<target name="stdlib">
|
||||
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xdump-declarations-to ${output}/declarations/stdlib-declarations.json">
|
||||
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xmultifile-parts-inherit -Xdump-declarations-to ${output}/declarations/stdlib-declarations.json">
|
||||
<src>
|
||||
<include name="libraries/stdlib/src"/>
|
||||
</src>
|
||||
@@ -902,7 +905,7 @@
|
||||
|
||||
<pack-runtime-jar jar-name="kotlin-test.jar" implementation-title="${manifest.impl.title.kotlin.test}">
|
||||
<jar-content>
|
||||
<fileset dir="${output}/classes/kotlin-test" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal"/>
|
||||
<fileset dir="${output}/classes/kotlin-test" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal/InlineOnly*,kotlin/internal"/>
|
||||
</jar-content>
|
||||
</pack-runtime-jar>
|
||||
</target>
|
||||
@@ -926,7 +929,7 @@
|
||||
</target>
|
||||
|
||||
<target name="reflection">
|
||||
<new-kotlinc output="${output}/classes/reflection" moduleName="kotlin-reflection" additionalOptions="-Xdump-declarations-to ${output}/declarations/reflect-declarations.json">
|
||||
<new-kotlinc output="${output}/classes/reflection" moduleName="kotlin-reflection">
|
||||
<src>
|
||||
<include name="core/reflection.jvm/src"/>
|
||||
</src>
|
||||
|
||||
@@ -279,7 +279,7 @@ public abstract class AnnotationCodegen {
|
||||
ClassifierDescriptor classifierDescriptor = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor();
|
||||
assert classifierDescriptor != null : "Annotation descriptor has no class: " + annotationDescriptor;
|
||||
RetentionPolicy rp = getRetentionPolicy(classifierDescriptor);
|
||||
if (rp == RetentionPolicy.SOURCE && typeMapper.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES) {
|
||||
if (rp == RetentionPolicy.SOURCE && typeMapper.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -404,6 +404,7 @@ public abstract class AnnotationCodegen {
|
||||
case FULL:
|
||||
throw new IllegalStateException("Don't know how to compile annotation value " + value);
|
||||
case LIGHT_CLASSES:
|
||||
case KAPT:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown builder mode: " + mode);
|
||||
|
||||
@@ -25,4 +25,8 @@ public enum ClassBuilderMode {
|
||||
* Generating light classes: Only function signatures
|
||||
*/
|
||||
LIGHT_CLASSES,
|
||||
/**
|
||||
* Function signatures + metadata (to support incremental compilation with kapt)
|
||||
*/
|
||||
KAPT;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
||||
annotationCodegen.genAnnotations(it.value, signature.valueParameters[it.index].asmType)
|
||||
}
|
||||
|
||||
if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) {
|
||||
if (state.classBuilderMode != ClassBuilderMode.FULL) {
|
||||
FunctionCodegen.generateLocalVariablesForParameters(mv, signature, null, Label(), Label(), remainingParameters, isStatic)
|
||||
mv.visitEnd()
|
||||
return
|
||||
|
||||
@@ -627,7 +627,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
// for (e : E in c) {...}
|
||||
protected final KtForExpression forExpression;
|
||||
private final Label bodyStart = new Label();
|
||||
private final Label loopParameterStartLabel = new Label();
|
||||
private final Label bodyEnd = new Label();
|
||||
private final List<Runnable> leaveVariableTasks = Lists.newArrayList();
|
||||
|
||||
@@ -635,6 +635,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
protected final Type asmElementType;
|
||||
|
||||
protected int loopParameterVar;
|
||||
protected Type loopParameterType;
|
||||
|
||||
private AbstractForLoopGenerator(@NotNull KtForExpression forExpression) {
|
||||
this.forExpression = forExpression;
|
||||
@@ -658,15 +659,15 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
if (loopParameter != null) {
|
||||
// E e = tmp<iterator>.next()
|
||||
final VariableDescriptor parameterDescriptor = bindingContext.get(VALUE_PARAMETER, loopParameter);
|
||||
@SuppressWarnings("ConstantConditions") final Type asmTypeForParameter = asmType(parameterDescriptor.getType());
|
||||
loopParameterVar = myFrameMap.enter(parameterDescriptor, asmTypeForParameter);
|
||||
loopParameterType = asmType(parameterDescriptor.getType());
|
||||
loopParameterVar = myFrameMap.enter(parameterDescriptor, loopParameterType);
|
||||
scheduleLeaveVariable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myFrameMap.leave(parameterDescriptor);
|
||||
v.visitLocalVariable(parameterDescriptor.getName().asString(),
|
||||
asmTypeForParameter.getDescriptor(), null,
|
||||
bodyStart, bodyEnd,
|
||||
loopParameterType.getDescriptor(), null,
|
||||
loopParameterStartLabel, bodyEnd,
|
||||
loopParameterVar);
|
||||
}
|
||||
});
|
||||
@@ -676,6 +677,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
assert multiParameter != null;
|
||||
|
||||
// E tmp<e> = tmp<iterator>.next()
|
||||
loopParameterType = asmElementType;
|
||||
loopParameterVar = createLoopTempVariable(asmElementType);
|
||||
}
|
||||
}
|
||||
@@ -685,9 +687,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
public abstract void checkPreCondition(@NotNull Label loopExit);
|
||||
|
||||
public void beforeBody() {
|
||||
v.mark(bodyStart);
|
||||
|
||||
assignToLoopParameter();
|
||||
v.mark(loopParameterStartLabel);
|
||||
|
||||
if (forExpression.getLoopParameter() == null) {
|
||||
KtDestructuringDeclaration multiParameter = forExpression.getDestructuringParameter();
|
||||
@@ -843,7 +844,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
makeFakeCall(new TransientReceiver(iteratorCall.getResultingDescriptor().getReturnType()));
|
||||
StackValue value = invokeFunction(fakeCall, nextCall, StackValue.local(iteratorVarIndex, asmTypeForIterator));
|
||||
//noinspection ConstantConditions
|
||||
StackValue.local(loopParameterVar, asmType(nextCall.getResultingDescriptor().getReturnType())).store(value, v);
|
||||
StackValue.local(loopParameterVar, loopParameterType).store(value, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3666,6 +3667,11 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
Label clauseStart = new Label();
|
||||
v.mark(clauseStart);
|
||||
|
||||
KtExpression catchBody = clause.getCatchBody();
|
||||
if (catchBody != null) {
|
||||
markLineNumber(catchBody, false);
|
||||
}
|
||||
|
||||
VariableDescriptor descriptor = bindingContext.get(VALUE_PARAMETER, clause.getCatchParameter());
|
||||
assert descriptor != null;
|
||||
Type descriptorType = asmType(descriptor.getType());
|
||||
@@ -3673,7 +3679,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
int index = lookupLocalIndex(descriptor);
|
||||
v.store(index, descriptorType);
|
||||
|
||||
gen(clause.getCatchBody(), expectedAsmType);
|
||||
gen(catchBody, expectedAsmType);
|
||||
|
||||
if (!isStatement) {
|
||||
v.store(savedValue, expectedAsmType);
|
||||
|
||||
@@ -198,7 +198,7 @@ public class FunctionCodegen {
|
||||
parentBodyCodegen.addAdditionalTask(new JvmStaticGenerator(functionDescriptor, origin, state, parentBodyCodegen));
|
||||
}
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, contextKind)) {
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL || isAbstractMethod(functionDescriptor, contextKind)) {
|
||||
generateLocalVariableTable(
|
||||
mv,
|
||||
jvmSignature,
|
||||
@@ -294,7 +294,7 @@ public class FunctionCodegen {
|
||||
|
||||
private void markEnumOrInnerConstructorParameterAsSynthetic(MethodVisitor mv, int i) {
|
||||
// IDEA's ClsPsi builder fails to annotate synthetic parameters
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
||||
|
||||
// This is needed to avoid RuntimeInvisibleParameterAnnotations error in javac:
|
||||
// see MethodWriter.visitParameterAnnotation()
|
||||
@@ -374,6 +374,9 @@ public class FunctionCodegen {
|
||||
if (!KotlinTypeMapper.isAccessor(functionDescriptor)) {
|
||||
genNotNullAssertionsForParameters(new InstructionAdapter(mv), parentCodegen.state, functionDescriptor, frameMap);
|
||||
}
|
||||
|
||||
parentCodegen.beforeMethodBody(mv);
|
||||
|
||||
methodEnd = new Label();
|
||||
context.setMethodEndLabel(methodEnd);
|
||||
strategy.generateBody(mv, frameMap, signature, context, parentCodegen);
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (!ktClass.hasModifier(KtTokens.OPEN_KEYWORD) && !isAbstract) {
|
||||
// Light-class mode: Do not make enum classes final since PsiClass corresponding to enum is expected to be inheritable from
|
||||
isFinal = !(ktClass.isEnum() && state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES);
|
||||
isFinal = !(ktClass.isEnum() && state.getClassBuilderMode() != ClassBuilderMode.FULL);
|
||||
}
|
||||
isStatic = !ktClass.isInner();
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
int access = 0;
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
// ClassBuilderMode.LIGHT_CLASSES means we are generating light classes & looking at a nested or inner class
|
||||
// Light class generation is implemented so that Cls-classes only read bare code of classes,
|
||||
// without knowing whether these classes are inner or not (see ClassStubBuilder.EMPTY_STRATEGY)
|
||||
@@ -265,7 +265,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private void writeEnclosingMethod() {
|
||||
// Do not emit enclosing method in "light-classes mode" since currently we generate local light classes as if they're top level
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) {
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.calculateInnerClassAccessFlags;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive;
|
||||
import static org.jetbrains.kotlin.codegen.ClassBuilderModeUtilKt.shouldGenerateMetadata;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.VARIABLE;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
@@ -118,7 +119,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
|
||||
generateSyntheticParts();
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
if (shouldGenerateMetadata(state.getClassBuilderMode())) {
|
||||
generateKotlinMetadataAnnotation();
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
}
|
||||
|
||||
private static void badDescriptor(ClassDescriptor descriptor, ClassBuilderMode mode) {
|
||||
if (mode != ClassBuilderMode.LIGHT_CLASSES) {
|
||||
if (mode == ClassBuilderMode.FULL) {
|
||||
throw new IllegalStateException("Generating bad descriptor in ClassBuilderMode = " + mode + ": " + descriptor);
|
||||
}
|
||||
}
|
||||
@@ -336,23 +337,32 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ExpressionCodegen createOrGetClInitCodegen() {
|
||||
DeclarationDescriptor descriptor = context.getContextDescriptor();
|
||||
protected final ExpressionCodegen createOrGetClInitCodegen() {
|
||||
if (clInit == null) {
|
||||
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
SimpleFunctionDescriptorImpl clInit =
|
||||
SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(), Name.special("<clinit>"), SYNTHESIZED,
|
||||
KotlinSourceElementKt.toSourceElement(element));
|
||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
|
||||
null, Visibilities.PRIVATE);
|
||||
|
||||
this.clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInit), state, this);
|
||||
DeclarationDescriptor contextDescriptor = context.getContextDescriptor();
|
||||
SimpleFunctionDescriptorImpl clInitDescriptor = createClInitFunctionDescriptor(contextDescriptor);
|
||||
MethodVisitor mv = createClInitMethodVisitor(contextDescriptor);
|
||||
clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInitDescriptor), state, this);
|
||||
}
|
||||
return clInit;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected MethodVisitor createClInitMethodVisitor(@NotNull DeclarationDescriptor contextDescriptor) {
|
||||
return v.newMethod(JvmDeclarationOriginKt.OtherOrigin(contextDescriptor), ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected SimpleFunctionDescriptorImpl createClInitFunctionDescriptor(@NotNull DeclarationDescriptor descriptor) {
|
||||
SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(),
|
||||
Name.special("<clinit>"), SYNTHESIZED, KotlinSourceElementKt.toSourceElement(element));
|
||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
|
||||
null, Visibilities.PRIVATE);
|
||||
return clInit;
|
||||
}
|
||||
|
||||
protected void generateInitializers(@NotNull Function0<ExpressionCodegen> createCodegen) {
|
||||
NotNullLazyValue<ExpressionCodegen> codegen = LockBasedStorageManager.NO_LOCKS.createLazyValue(createCodegen);
|
||||
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
|
||||
@@ -370,6 +380,9 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeMethodBody(@NotNull MethodVisitor mv) {
|
||||
}
|
||||
|
||||
private void initializeProperty(@NotNull ExpressionCodegen codegen, @NotNull KtProperty property) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
|
||||
assert propertyDescriptor != null;
|
||||
@@ -382,7 +395,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
propValue.store(codegen.gen(initializer), codegen.v);
|
||||
}
|
||||
|
||||
private boolean shouldInitializeProperty(@NotNull KtProperty property) {
|
||||
protected boolean shouldInitializeProperty(@NotNull KtProperty property) {
|
||||
if (!property.hasDelegateExpressionOrInitializer()) return false;
|
||||
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
|
||||
@@ -398,7 +411,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
ConstantValue<?> initializerValue = computeInitializerValue(property, propertyDescriptor, initializer);
|
||||
// we must write constant values for fields in light classes,
|
||||
// because Java's completion for annotation arguments uses this information
|
||||
if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES;
|
||||
if (initializerValue == null) return state.getClassBuilderMode() == ClassBuilderMode.FULL;
|
||||
|
||||
//TODO: OPTIMIZATION: don't initialize static final fields
|
||||
KotlinType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||
@@ -482,7 +495,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
v.newField(NO_ORIGIN, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
|
||||
"[" + K_PROPERTY_TYPE, null, null);
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
||||
|
||||
InstructionAdapter iv = createOrGetClInitCodegen().v;
|
||||
iv.iconst(delegatedProperties.size());
|
||||
|
||||
@@ -26,18 +26,21 @@ import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentProvider
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClassPart
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
|
||||
@@ -50,11 +53,10 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import java.util.*
|
||||
|
||||
class MultifileClassCodegen(
|
||||
private val state: GenerationState,
|
||||
val files: Collection<KtFile>,
|
||||
private val files: Collection<KtFile>,
|
||||
private val facadeFqName: FqName,
|
||||
private val packagePartRegistry: PackagePartRegistry
|
||||
) {
|
||||
@@ -71,55 +73,105 @@ class MultifileClassCodegen(
|
||||
getDeserializedCallables(compiledPackageFragment)
|
||||
|
||||
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
|
||||
compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
|
||||
compiledPackageFragment.getMemberScope()
|
||||
.getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER)
|
||||
.filterIsInstance<DeserializedCallableMemberDescriptor>()
|
||||
|
||||
private fun KtFile.getFileClassFqName() =
|
||||
state.fileClassesProvider.getFileClassInfo(this).fileClassFqName
|
||||
|
||||
private val shouldGeneratePartHierarchy =
|
||||
state.inheritMultifileParts // TODO support incremental compilation
|
||||
|
||||
private val partInternalNamesSorted = run {
|
||||
val partInternalNamesSet = hashSetOf<String>()
|
||||
for (file in files) {
|
||||
if (file.hasDeclarationsForPartClass()) {
|
||||
partInternalNamesSet.add(file.getFileClassFqName().toInternalName())
|
||||
}
|
||||
}
|
||||
compiledPackageFragment?.let {
|
||||
partInternalNamesSet.addAll(it.partsNames)
|
||||
}
|
||||
partInternalNamesSet.sorted()
|
||||
}
|
||||
|
||||
private val superClassForInheritedPart = run {
|
||||
val result = hashMapOf<String, String>()
|
||||
for (i in 1 ..partInternalNamesSorted.size - 1) {
|
||||
result[partInternalNamesSorted[i]] = partInternalNamesSorted[i - 1]
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
private val delegateGenerationTasks = hashMapOf<CallableMemberDescriptor, () -> Unit>()
|
||||
|
||||
private fun getSuperClassForPart(partInternalName: String) =
|
||||
if (shouldGeneratePartHierarchy)
|
||||
superClassForInheritedPart[partInternalName] ?: J_L_OBJECT
|
||||
else
|
||||
J_L_OBJECT
|
||||
|
||||
private val classBuilder = ClassBuilderOnDemand {
|
||||
val originFile = files.firstOrNull()
|
||||
val actualPackageFragment = packageFragment ?:
|
||||
compiledPackageFragment ?:
|
||||
throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
|
||||
val declarationOrigin = MultifileClass(originFile, actualPackageFragment, facadeFqName)
|
||||
val classBuilder = state.factory.newVisitor(declarationOrigin, facadeClassType, files)
|
||||
|
||||
val filesWithCallables = files.filter { it.declarations.any { it is KtNamedFunction || it is KtProperty } }
|
||||
val actualPackageFragment = packageFragment
|
||||
?: compiledPackageFragment
|
||||
?: throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
|
||||
|
||||
val singleSourceFile = if (previouslyCompiledCallables.isNotEmpty()) null else filesWithCallables.singleOrNull()
|
||||
val declarationOrigin = MultifileClass(originFile, actualPackageFragment)
|
||||
|
||||
classBuilder.defineClass(singleSourceFile, Opcodes.V1_6,
|
||||
FACADE_CLASS_ATTRIBUTES,
|
||||
facadeClassType.internalName,
|
||||
null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
if (singleSourceFile != null) {
|
||||
classBuilder.visitSource(singleSourceFile.name, null)
|
||||
val singleSourceFile =
|
||||
if (previouslyCompiledCallables.isEmpty())
|
||||
files.singleOrNull { it.hasDeclarationsForPartClass() }
|
||||
else
|
||||
null
|
||||
|
||||
val superClassForFacade =
|
||||
if (shouldGeneratePartHierarchy)
|
||||
partInternalNamesSorted.last()
|
||||
else
|
||||
J_L_OBJECT
|
||||
|
||||
state.factory.newVisitor(declarationOrigin, facadeClassType, files).apply {
|
||||
defineClass(singleSourceFile, Opcodes.V1_6, FACADE_CLASS_ATTRIBUTES,
|
||||
facadeClassType.internalName, null, superClassForFacade, ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
if (singleSourceFile != null) {
|
||||
visitSource(singleSourceFile.name, null)
|
||||
}
|
||||
|
||||
if (shouldGeneratePartHierarchy) {
|
||||
newMethod(OtherOrigin(actualPackageFragment), Opcodes.ACC_PRIVATE, "<init>", "()V", null, null).apply {
|
||||
visitCode()
|
||||
visitVarInsn(Opcodes.ALOAD, 0)
|
||||
visitMethodInsn(Opcodes.INVOKESPECIAL, superClassForFacade, "<init>", "()V", false)
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 1)
|
||||
visitEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classBuilder
|
||||
}
|
||||
|
||||
fun generate(errorHandler: CompilationErrorHandler) {
|
||||
val generateCallableMemberTasks = HashMap<CallableMemberDescriptor, () -> Unit>()
|
||||
val partFqNames = arrayListOf<FqName>()
|
||||
assert(delegateGenerationTasks.isEmpty()) { "generate() is called twice for facade class $facadeFqName" }
|
||||
|
||||
generateCodeForSourceFiles(errorHandler, generateCallableMemberTasks, partFqNames)
|
||||
generateCodeForSourceFiles(errorHandler)
|
||||
|
||||
generateDelegatesToPreviouslyCompiledParts(generateCallableMemberTasks, partFqNames)
|
||||
generateDelegatesToPreviouslyCompiledParts()
|
||||
|
||||
if (!partFqNames.isEmpty()) {
|
||||
generateMultifileFacadeClass(generateCallableMemberTasks, partFqNames)
|
||||
if (!partInternalNamesSorted.isEmpty()) {
|
||||
generateMultifileFacadeClass()
|
||||
}
|
||||
|
||||
done()
|
||||
}
|
||||
|
||||
private fun generateCodeForSourceFiles(
|
||||
errorHandler: CompilationErrorHandler,
|
||||
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
|
||||
partFqNames: MutableList<FqName>
|
||||
) {
|
||||
private fun generateCodeForSourceFiles(errorHandler: CompilationErrorHandler) {
|
||||
for (file in files) {
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
try {
|
||||
generatePart(file, generateCallableMemberTasks, partFqNames)
|
||||
generatePart(file)
|
||||
state.afterIndependentPart()
|
||||
}
|
||||
catch (e: ProcessCanceledException) {
|
||||
@@ -137,87 +189,103 @@ class MultifileClassCodegen(
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateMultifileFacadeClass(
|
||||
tasks: Map<CallableMemberDescriptor, () -> Unit>,
|
||||
partFqNames: List<FqName>
|
||||
) {
|
||||
for (member in tasks.keys.sortedWith(MemberComparator.INSTANCE)) {
|
||||
tasks[member]!!()
|
||||
private fun generateMultifileFacadeClass() {
|
||||
for (member in delegateGenerationTasks.keys.sortedWith(MemberComparator.INSTANCE)) {
|
||||
delegateGenerationTasks[member]!!()
|
||||
}
|
||||
|
||||
writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames)
|
||||
writeKotlinMultifileFacadeAnnotationIfNeeded()
|
||||
}
|
||||
|
||||
fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: FieldOwnerContext<PackageFragmentDescriptor>) {
|
||||
MemberCodegen.genClassOrObject(packagePartContext, classOrObject, state, null)
|
||||
}
|
||||
|
||||
private fun generatePart(
|
||||
file: KtFile,
|
||||
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
|
||||
partFqNames: MutableList<FqName>
|
||||
) {
|
||||
val packageFragment = this.packageFragment ?:
|
||||
throw AssertionError("File part $file of $facadeFqName: no package fragment")
|
||||
private fun generatePart(file: KtFile) {
|
||||
val packageFragment = this.packageFragment
|
||||
?: throw AssertionError("File part $file of $facadeFqName: no package fragment")
|
||||
|
||||
var generatePart = false
|
||||
val partClassInfo = state.fileClassesProvider.getFileClassInfo(file)
|
||||
val partType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(partClassInfo.fileClassFqName)
|
||||
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
|
||||
val partClassFqName = file.getFileClassFqName()
|
||||
val partInitializerClassFqName = FqName(partClassFqName.asString() + "__Init")
|
||||
val partType = partClassFqName.toAsmType()
|
||||
val partInitializerType = partInitializerClassFqName.toAsmType()
|
||||
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, partInitializerType, file)
|
||||
|
||||
generateNonPartClassDeclarations(file, partContext)
|
||||
|
||||
if (!state.generateDeclaredClassFilter.shouldGeneratePackagePart(file) || !file.hasDeclarationsForPartClass()) return
|
||||
|
||||
val partInternalName = partType.internalName
|
||||
packagePartRegistry.addPart(partInternalName.substring(partInternalName.lastIndexOf('/') + 1))
|
||||
|
||||
val builder = state.factory.newVisitor(MultifileClassPart(file, packageFragment), partType, file)
|
||||
|
||||
MultifileClassPartCodegen(
|
||||
builder, file, packageFragment,
|
||||
getSuperClassForPart(partInternalName),
|
||||
shouldGeneratePartHierarchy,
|
||||
partContext, state
|
||||
).generate()
|
||||
|
||||
addDelegateGenerationTasksForDeclarationsInFile(file, packageFragment, partType)
|
||||
}
|
||||
|
||||
private fun generateNonPartClassDeclarations(file: KtFile, partContext: FieldOwnerContext<PackageFragmentDescriptor>) {
|
||||
for (declaration in file.declarations) {
|
||||
when (declaration) {
|
||||
is KtProperty, is KtNamedFunction -> {
|
||||
generatePart = true
|
||||
}
|
||||
is KtClassOrObject -> if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
generateClassOrObject(declaration, partContext)
|
||||
}
|
||||
is KtScript -> if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!generatePart || !state.generateDeclaredClassFilter.shouldGeneratePackagePart(file)) return
|
||||
|
||||
partFqNames.add(partClassInfo.fileClassFqName)
|
||||
|
||||
val name = partType.internalName
|
||||
packagePartRegistry.addPart(name.substring(name.lastIndexOf('/') + 1))
|
||||
|
||||
val builder = state.factory.newVisitor(MultifileClassPart(file, packageFragment, facadeFqName), partType, file)
|
||||
|
||||
MultifileClassPartCodegen(builder, file, partType, facadeClassType, partContext, state).generate()
|
||||
|
||||
val facadeContext = state.rootContext.intoMultifileClass(packageFragment, facadeClassType, partType)
|
||||
val memberCodegen = createCodegenForPartOfMultifileFacade(facadeContext)
|
||||
for (declaration in file.declarations) {
|
||||
if (declaration is KtNamedFunction || declaration is KtProperty) {
|
||||
val descriptor = state.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
||||
assert(descriptor is CallableMemberDescriptor) { "Expected callable member, was " + descriptor + " for " + declaration.text }
|
||||
if (!Visibilities.isPrivate((descriptor as CallableMemberDescriptor).visibility)
|
||||
&& AsmUtil.getVisibilityAccessFlag(descriptor) != Opcodes.ACC_PRIVATE) {
|
||||
generateCallableMemberTasks.put(descriptor, { memberCodegen.genFunctionOrProperty(declaration) })
|
||||
}
|
||||
is KtClassOrObject ->
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
generateClassOrObject(declaration, partContext)
|
||||
}
|
||||
is KtScript ->
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateDelegatesToPreviouslyCompiledParts(
|
||||
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
|
||||
partFqNames: MutableList<FqName>
|
||||
) {
|
||||
if (compiledPackageFragment == null) return
|
||||
private fun addDelegateGenerationTasksForDeclarationsInFile(file: KtFile, packageFragment: PackageFragmentDescriptor, partType: Type) {
|
||||
val facadeContext = state.rootContext.intoMultifileClass(packageFragment, facadeClassType, partType)
|
||||
val memberCodegen = createCodegenForDelegatesInMultifileFacade(facadeContext)
|
||||
for (declaration in file.declarations) {
|
||||
if (declaration is KtNamedFunction || declaration is KtProperty) {
|
||||
val descriptor = state.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
||||
if (descriptor !is CallableMemberDescriptor) {
|
||||
throw AssertionError("Expected callable member, was " + descriptor + " for " + declaration.text)
|
||||
}
|
||||
addDelegateGenerationTaskIfNeeded(descriptor, { memberCodegen.genFunctionOrProperty(declaration) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partFqNames.addAll(compiledPackageFragment.partsNames.map { JvmClassName.byInternalName(it).fqNameForClassNameWithoutDollars })
|
||||
private fun shouldGenerateInFacade(descriptor: CallableMemberDescriptor): Boolean {
|
||||
if (Visibilities.isPrivate(descriptor.visibility)) return false
|
||||
if (AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE) return false
|
||||
|
||||
if (state.classBuilderMode != ClassBuilderMode.FULL) return true
|
||||
|
||||
if (shouldGeneratePartHierarchy) {
|
||||
if (descriptor !is PropertyDescriptor || !descriptor.isConst) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun addDelegateGenerationTaskIfNeeded(callable: CallableMemberDescriptor, task: () -> Unit) {
|
||||
if (shouldGenerateInFacade(callable)) {
|
||||
delegateGenerationTasks[callable] = task
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateDelegatesToPreviouslyCompiledParts() {
|
||||
if (compiledPackageFragment == null) return
|
||||
|
||||
for (callable in previouslyCompiledCallables) {
|
||||
val partFqName = JvmFileClassUtil.getPartFqNameForDeserializedCallable(callable)
|
||||
val partType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(partFqName)
|
||||
|
||||
generateCallableMemberTasks[callable] = { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) }
|
||||
addDelegateGenerationTaskIfNeeded(callable, { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +296,7 @@ class MultifileClassCodegen(
|
||||
) {
|
||||
val context = state.rootContext.intoMultifileClass(compiledPackageFragment, facadeClassType, partType)
|
||||
|
||||
val memberCodegen = createCodegenForPartOfMultifileFacade(context)
|
||||
val memberCodegen = createCodegenForDelegatesInMultifileFacade(context)
|
||||
|
||||
when (member) {
|
||||
is DeserializedSimpleFunctionDescriptor -> {
|
||||
@@ -254,20 +322,22 @@ class MultifileClassCodegen(
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames: List<FqName>) {
|
||||
if (state.classBuilderMode != ClassBuilderMode.FULL) return
|
||||
private fun writeKotlinMultifileFacadeAnnotationIfNeeded() {
|
||||
if (!state.classBuilderMode.shouldGenerateMetadata()) return
|
||||
if (files.any { it.isScript }) return
|
||||
|
||||
writeKotlinMetadata(classBuilder, KotlinClassHeader.Kind.MULTIFILE_CLASS) { av ->
|
||||
val arv = av.visitArray(JvmAnnotationNames.METADATA_DATA_FIELD_NAME)
|
||||
for (internalName in partFqNames.map(AsmUtil::internalNameByFqNameWithoutInnerClasses).sorted()) {
|
||||
for (internalName in partInternalNamesSorted) {
|
||||
arv.visit(null, internalName)
|
||||
}
|
||||
arv.visitEnd()
|
||||
val multifileClassKind = if (shouldGeneratePartHierarchy) INHERITING else DELEGATING
|
||||
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_KIND_FIELD_NAME, multifileClassKind.id)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createCodegenForPartOfMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
|
||||
private fun createCodegenForDelegatesInMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
|
||||
object : MemberCodegen<KtFile>(state, null, facadeContext, null, classBuilder) {
|
||||
override fun generateDeclaration() = throw UnsupportedOperationException()
|
||||
override fun generateBody() = throw UnsupportedOperationException()
|
||||
@@ -282,15 +352,16 @@ class MultifileClassCodegen(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val J_L_OBJECT = AsmTypes.OBJECT_TYPE.internalName
|
||||
private val FACADE_CLASS_ATTRIBUTES = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL or Opcodes.ACC_SUPER
|
||||
|
||||
private fun getOnlyPackageFragment(packageFqName: FqName, files: Collection<KtFile>, bindingContext: BindingContext): PackageFragmentDescriptor? {
|
||||
val fragments = SmartList<PackageFragmentDescriptor>()
|
||||
for (file in files) {
|
||||
val fragment = bindingContext.get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
|
||||
assert(fragment != null) { "package fragment is null for " + file + "\n" + file.text }
|
||||
?: throw AssertionError("package fragment is null for " + file + "\n" + file.text)
|
||||
|
||||
assert(packageFqName == fragment!!.fqName) { "expected package fq name: " + packageFqName + ", actual: " + fragment.fqName }
|
||||
assert(packageFqName == fragment.fqName) { "expected package fq name: " + packageFqName + ", actual: " + fragment.fqName }
|
||||
|
||||
if (!fragments.contains(fragment)) {
|
||||
fragments.add(fragment)
|
||||
@@ -302,6 +373,15 @@ class MultifileClassCodegen(
|
||||
return fragments.firstOrNull()
|
||||
}
|
||||
|
||||
private fun KtFile.hasDeclarationsForPartClass() =
|
||||
declarations.any { it is KtProperty || it is KtFunction }
|
||||
|
||||
private fun FqName.toInternalName() =
|
||||
AsmUtil.internalNameByFqNameWithoutInnerClasses(this)
|
||||
|
||||
private fun FqName.toAsmType() =
|
||||
AsmUtil.asmTypeByFqNameWithoutInnerClasses(this)
|
||||
|
||||
private fun getCompiledPackageFragment(facadeFqName: FqName, state: GenerationState):
|
||||
IncrementalPackageFragmentProvider.IncrementalPackageFragment.IncrementalMultifileClassPackageFragment? {
|
||||
if (!IncrementalCompilation.isEnabled()) return null
|
||||
|
||||
@@ -17,44 +17,112 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext
|
||||
import org.jetbrains.kotlin.codegen.context.MultifileClassPartContext
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
|
||||
import java.util.*
|
||||
|
||||
class MultifileClassPartCodegen(
|
||||
v: ClassBuilder,
|
||||
file: KtFile,
|
||||
private val filePartType: Type,
|
||||
private val multifileClassType: Type,
|
||||
partContext: FieldOwnerContext<*>,
|
||||
private val packageFragment: PackageFragmentDescriptor,
|
||||
private val superClassInternalName: String,
|
||||
private val shouldGeneratePartHierarchy: Boolean,
|
||||
private val partContext: MultifileClassPartContext,
|
||||
state: GenerationState
|
||||
) : MemberCodegen<KtFile>(state, null, partContext, file, v) {
|
||||
private val partType = partContext.filePartType
|
||||
private val facadeClassType = partContext.multifileClassType
|
||||
private val staticInitClassType = Type.getObjectType(partType.internalName + STATIC_INIT_CLASS_SUFFIX)
|
||||
|
||||
private val partClassAttributes =
|
||||
if (shouldGeneratePartHierarchy)
|
||||
OPEN_PART_CLASS_ATTRIBUTES
|
||||
else
|
||||
FINAL_PART_CLASS_ATTRIBUTES
|
||||
|
||||
private fun ClassBuilder.newSpecialMethod(originDescriptor: DeclarationDescriptor, name: String) =
|
||||
newMethod(OtherOrigin(originDescriptor), Opcodes.ACC_STATIC, name, "()V", null, null)
|
||||
|
||||
private val staticInitClassBuilder = ClassBuilderOnDemand {
|
||||
state.factory.newVisitor(MultifileClass(file, packageFragment), staticInitClassType, file).apply {
|
||||
defineClass(file, Opcodes.V1_6, STATE_INITIALIZER_CLASS_ATTRIBUTES,
|
||||
staticInitClassType.internalName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
|
||||
visitSource(file.name, null)
|
||||
}
|
||||
}
|
||||
|
||||
private val requiresDeferredStaticInitialization =
|
||||
shouldGeneratePartHierarchy && file.declarations.any {
|
||||
it is KtProperty && shouldInitializeProperty(it)
|
||||
}
|
||||
|
||||
override fun generate() {
|
||||
if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) return
|
||||
if (state.classBuilderMode != ClassBuilderMode.FULL) return
|
||||
|
||||
super.generate()
|
||||
|
||||
if (shouldGeneratePartHierarchy) {
|
||||
v.newMethod(OtherOrigin(packageFragment), Opcodes.ACC_PUBLIC, "<init>", "()V", null, null).apply {
|
||||
visitCode()
|
||||
visitVarInsn(Opcodes.ALOAD, 0)
|
||||
visitMethodInsn(Opcodes.INVOKESPECIAL, superClassInternalName, "<init>", "()V", false)
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 1)
|
||||
visitEnd()
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresDeferredStaticInitialization) {
|
||||
staticInitClassBuilder.apply {
|
||||
newField(OtherOrigin(packageFragment), Opcodes.ACC_STATIC or Opcodes.ACC_PRIVATE or Opcodes.ACC_VOLATILE,
|
||||
CLINIT_SYNC_NAME, "I", null, null)
|
||||
|
||||
newSpecialMethod(packageFragment, CLINIT_TRIGGER_NAME).apply {
|
||||
visitCode()
|
||||
visitFieldInsn(Opcodes.GETSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 0)
|
||||
visitEnd()
|
||||
}
|
||||
|
||||
newSpecialMethod(packageFragment, "<clinit>").apply {
|
||||
visitCode()
|
||||
visitMethodInsn(Opcodes.INVOKESTATIC, partType.internalName, DEFERRED_PART_CLINIT_NAME, "()V", false)
|
||||
visitInsn(Opcodes.ICONST_0)
|
||||
visitFieldInsn(Opcodes.PUTSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 0)
|
||||
visitEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateDeclaration() {
|
||||
v.defineClass(element, Opcodes.V1_6,
|
||||
Opcodes.ACC_FINAL or Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER,
|
||||
filePartType.internalName,
|
||||
null,
|
||||
"java/lang/Object",
|
||||
ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
v.defineClass(element, Opcodes.V1_6, partClassAttributes, partType.internalName, null, superClassInternalName, ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
v.visitSource(element.name, null)
|
||||
|
||||
generatePropertyMetadataArrayFieldIfNeeded(filePartType)
|
||||
generatePropertyMetadataArrayFieldIfNeeded(partType)
|
||||
}
|
||||
|
||||
override fun generateBody() {
|
||||
@@ -69,6 +137,20 @@ class MultifileClassPartCodegen(
|
||||
}
|
||||
}
|
||||
|
||||
override fun createClInitMethodVisitor(contextDescriptor: DeclarationDescriptor): MethodVisitor =
|
||||
if (requiresDeferredStaticInitialization)
|
||||
v.newSpecialMethod(contextDescriptor, DEFERRED_PART_CLINIT_NAME)
|
||||
else
|
||||
super.createClInitMethodVisitor(contextDescriptor)
|
||||
|
||||
override fun done() {
|
||||
super.done()
|
||||
|
||||
if (staticInitClassBuilder.isComputed) {
|
||||
staticInitClassBuilder.done()
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateKotlinMetadataAnnotation() {
|
||||
val members = ArrayList<DeclarationDescriptor>()
|
||||
for (declaration in element.declarations) {
|
||||
@@ -89,11 +171,37 @@ class MultifileClassPartCodegen(
|
||||
|
||||
writeKotlinMetadata(v, KotlinClassHeader.Kind.MULTIFILE_CLASS_PART) { av ->
|
||||
AsmUtil.writeAnnotationData(av, serializer, packageProto)
|
||||
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, multifileClassType.internalName)
|
||||
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, facadeClassType.internalName)
|
||||
val multifileClassKind = if (shouldGeneratePartHierarchy) INHERITING else DELEGATING
|
||||
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_KIND_FIELD_NAME, multifileClassKind.id)
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateSyntheticParts() {
|
||||
generateSyntheticAccessors()
|
||||
}
|
||||
|
||||
override fun beforeMethodBody(mv: MethodVisitor) {
|
||||
if (requiresDeferredStaticInitialization) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, staticInitClassType.internalName, CLINIT_TRIGGER_NAME, "()V", false)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val OPEN_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SUPER
|
||||
private val FINAL_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
|
||||
private val STATE_INITIALIZER_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
|
||||
|
||||
private val STATIC_INIT_CLASS_SUFFIX = "__Clinit"
|
||||
private val CLINIT_TRIGGER_NAME = "\$\$clinitTrigger"
|
||||
private val CLINIT_SYNC_NAME = "\$\$clinitSync"
|
||||
private val DEFERRED_PART_CLINIT_NAME = "\$\$clinit"
|
||||
|
||||
@JvmStatic fun isStaticInitTrigger(insn: AbstractInsnNode) =
|
||||
insn.opcode == Opcodes.INVOKESTATIC
|
||||
&& insn is MethodInsnNode
|
||||
&& insn.owner.endsWith(STATIC_INIT_CLASS_SUFFIX)
|
||||
&& insn.name == CLINIT_TRIGGER_NAME
|
||||
&& insn.desc == "()V"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationSplitter;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtilKt;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
|
||||
@@ -141,9 +142,10 @@ public class PropertyCodegen {
|
||||
|
||||
Annotations propertyAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.PROPERTY);
|
||||
|
||||
// Fields and '$annotations' methods for const properties are generated in the multi-file facade
|
||||
boolean isBackingFieldOwner =
|
||||
descriptor.isConst() ? !(context instanceof MultifileClassPartContext) : CodegenContextUtil.isImplClassOwner(context);
|
||||
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
|
||||
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
|
||||
? !(context instanceof MultifileClassPartContext)
|
||||
: CodegenContextUtil.isImplClassOwner(context);
|
||||
|
||||
if (isBackingFieldOwner) {
|
||||
Annotations fieldAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.FIELD);
|
||||
@@ -184,6 +186,9 @@ public class PropertyCodegen {
|
||||
// Companion object properties always should have accessors, because their backing fields are moved/copied to the outer class
|
||||
if (isCompanionObject(descriptor.getContainingDeclaration())) return true;
|
||||
|
||||
// Non-const properties from multifile classes have accessors regardless of visibility
|
||||
if (!descriptor.isConst() && JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration)) return true;
|
||||
|
||||
// Private class properties have accessors only in cases when those accessors are non-trivial
|
||||
if (Visibilities.isPrivate(descriptor.getVisibility())) {
|
||||
return !isDefaultAccessor;
|
||||
@@ -343,7 +348,7 @@ public class PropertyCodegen {
|
||||
|
||||
FieldVisitor fv = builder.newField(
|
||||
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
|
||||
typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
|
||||
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
|
||||
);
|
||||
|
||||
Annotated fieldAnnotated = new AnnotatedWithFakeAnnotations(propertyDescriptor, annotations);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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
|
||||
|
||||
fun ClassBuilderMode.shouldGenerateMetadata() =
|
||||
this == ClassBuilderMode.FULL || this == ClassBuilderMode.KAPT
|
||||
@@ -250,13 +250,14 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FieldOwnerContext<PackageFragmentDescriptor> intoMultifileClassPart(
|
||||
public MultifileClassPartContext intoMultifileClassPart(
|
||||
@NotNull PackageFragmentDescriptor descriptor,
|
||||
@NotNull Type multifileClassType,
|
||||
@NotNull Type filePartType,
|
||||
@NotNull Type filePartInitializerType,
|
||||
@NotNull KtFile sourceFile
|
||||
) {
|
||||
return new MultifileClassPartContext(descriptor, this, multifileClassType, filePartType, sourceFile);
|
||||
return new MultifileClassPartContext(descriptor, this, multifileClassType, filePartType, filePartInitializerType, sourceFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,16 +24,19 @@ import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
public class MultifileClassPartContext extends MultifileClassContextBase implements DelegatingToPartContext, FacadePartWithSourceFile {
|
||||
private final KtFile sourceFile;
|
||||
private final Type partInitializerType;
|
||||
|
||||
public MultifileClassPartContext(
|
||||
PackageFragmentDescriptor descriptor,
|
||||
CodegenContext parent,
|
||||
Type multifileClassType,
|
||||
Type filePartType,
|
||||
Type partInitializerType,
|
||||
@NotNull KtFile sourceFile
|
||||
) {
|
||||
super(descriptor, parent, multifileClassType, filePartType);
|
||||
this.sourceFile = sourceFile;
|
||||
this.partInitializerType = partInitializerType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -42,6 +45,11 @@ public class MultifileClassPartContext extends MultifileClassContextBase impleme
|
||||
return getFilePartType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getPartInitializerType() {
|
||||
return partInitializerType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtFile getSourceFile() {
|
||||
|
||||
@@ -285,6 +285,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
"<init>", constructorDescriptor,
|
||||
null, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
|
||||
final Label newBodyStartLabel = new Label();
|
||||
constructorVisitor.visitLabel(newBodyStartLabel);
|
||||
//initialize captured fields
|
||||
List<NewJavaField> newFieldsWithSkipped = TransformationUtilsKt.getNewFieldsToGenerate(allCapturedBuilder.listCaptured());
|
||||
List<FieldInfo> fieldInfoWithSkipped = TransformationUtilsKt.transformToFieldInfo(
|
||||
@@ -318,7 +320,20 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
}
|
||||
}
|
||||
|
||||
inlineMethodAndUpdateGlobalResult(parentRemapper, capturedFieldInitializer, constructor, constructorInlineBuilder, true);
|
||||
MethodNode intermediateMethodNode = new MethodNode(AsmUtil.NO_FLAG_PACKAGE_PRIVATE, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
inlineMethodAndUpdateGlobalResult(parentRemapper, intermediateMethodNode, constructor, constructorInlineBuilder, true);
|
||||
|
||||
AbstractInsnNode first = intermediateMethodNode.instructions.getFirst();
|
||||
final Label oldStartLabel = first instanceof LabelNode ? ((LabelNode) first).getLabel() : null;
|
||||
intermediateMethodNode.accept(new MethodBodyVisitor(capturedFieldInitializer) {
|
||||
@Override
|
||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||
if (oldStartLabel == start) {
|
||||
start = newBodyStartLabel;//patch for jack&jill
|
||||
}
|
||||
super.visitLocalVariable(name, desc, signature, start, end, index);
|
||||
}
|
||||
});
|
||||
constructorVisitor.visitEnd();
|
||||
AsmUtil.genClosureFields(TransformationUtilsKt.toNameTypePair(TransformationUtilsKt.filterSkipped(newFieldsWithSkipped)), classBuilder);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.getMethodAsmFlags;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive;
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.API;
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.addInlineMarker;
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.getConstant;
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.*;
|
||||
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral;
|
||||
|
||||
public class InlineCodegen extends CallGenerator {
|
||||
@@ -395,6 +393,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
|
||||
generateAndInsertFinallyBlocks(adapter, infos, ((StackValue.Local)remapper.remap(parameters.getArgsSizeOnStack() + 1).value).index);
|
||||
removeStaticInitializationTrigger(adapter);
|
||||
removeFinallyMarkers(adapter);
|
||||
|
||||
adapter.accept(new MethodBodyVisitor(codegen.v));
|
||||
@@ -404,6 +403,21 @@ public class InlineCodegen extends CallGenerator {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void removeStaticInitializationTrigger(MethodNode methodNode) {
|
||||
InsnList insnList = methodNode.instructions;
|
||||
AbstractInsnNode insn = insnList.getFirst();
|
||||
while (insn != null) {
|
||||
if (MultifileClassPartCodegen.isStaticInitTrigger(insn)) {
|
||||
AbstractInsnNode clinitTriggerCall = insn;
|
||||
insn = insn.getNext();
|
||||
insnList.remove(clinitTriggerCall);
|
||||
}
|
||||
else {
|
||||
insn = insn.getNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private InlineCallSiteInfo getInlineCallSiteInfo() {
|
||||
MethodContext context = codegen.getContext();
|
||||
MemberCodegen<?> parentCodegen = codegen.getParentCodegen();
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
|
||||
@@ -51,11 +52,16 @@ class InlineCodegenForDefaultBody(
|
||||
|
||||
private val jvmSignature = state.typeMapper.mapSignatureWithGeneric(functionDescriptor, context.contextKind)
|
||||
|
||||
private val methodStartLabel = Label()
|
||||
|
||||
init {
|
||||
assert(InlineUtil.isInline(function)) {
|
||||
"InlineCodegen can inline only inline functions and array constructors: " + function
|
||||
}
|
||||
InlineCodegen.reportIncrementalInfo(functionDescriptor, codegen.context.functionDescriptor.original, jvmSignature, state)
|
||||
|
||||
//InlineCodegenForDefaultBody created just after visitCode call
|
||||
codegen.v.visitLabel(methodStartLabel)
|
||||
}
|
||||
|
||||
override fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen) {
|
||||
@@ -70,7 +76,13 @@ class InlineCodegenForDefaultBody(
|
||||
node.signature,
|
||||
node.exceptions.toTypedArray())
|
||||
|
||||
node.accept(InlineAdapter(transformedMethod, 0, childSourceMapper))
|
||||
val argsSize = (Type.getArgumentsAndReturnSizes(jvmSignature.asmMethod.descriptor) ushr 2) - if (callableMethod.isStaticCall()) 1 else 0
|
||||
node.accept(object : InlineAdapter(transformedMethod, 0, childSourceMapper) {
|
||||
override fun visitLocalVariable(name: String, desc: String, signature: String?, start: Label, end: Label, index: Int) {
|
||||
val startLabel = if (index < argsSize) methodStartLabel else start
|
||||
super.visitLocalVariable(name, desc, signature, startLabel, end, index)
|
||||
}
|
||||
})
|
||||
|
||||
transformedMethod.accept(MethodBodyVisitor(codegen.v))
|
||||
}
|
||||
|
||||
@@ -292,8 +292,8 @@ public class MethodInliner {
|
||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||
}
|
||||
}
|
||||
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||
// we will put it if needed in anew processing
|
||||
else if (!inliningContext.isInliningLambda && ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||
//we shouldn't process here content of inlining lambda it should be reified at external level
|
||||
}
|
||||
else {
|
||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.serialization;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
@@ -43,6 +44,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
private final AnnotationSerializer annotationSerializer;
|
||||
private final boolean useTypeTable;
|
||||
private final String moduleName;
|
||||
private final ClassBuilderMode classBuilderMode;
|
||||
|
||||
public JvmSerializerExtension(@NotNull JvmSerializationBindings bindings, @NotNull GenerationState state) {
|
||||
this.bindings = bindings;
|
||||
@@ -50,6 +52,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
this.annotationSerializer = new AnnotationSerializer(stringTable);
|
||||
this.useTypeTable = state.getUseTypeTableInSerializer();
|
||||
this.moduleName = state.getModuleName();
|
||||
this.classBuilderMode = state.getClassBuilderMode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -144,6 +147,16 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
proto.setExtension(JvmProtoBuf.propertySignature, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeErrorType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder builder) {
|
||||
if (classBuilderMode == ClassBuilderMode.KAPT) {
|
||||
builder.setClassName(stringTable.getStringIndex("error.NonExistingClass"));
|
||||
return;
|
||||
}
|
||||
|
||||
super.serializeErrorType(type, builder);
|
||||
}
|
||||
|
||||
private class SignatureSerializer {
|
||||
@Nullable
|
||||
public JvmProtoBuf.JvmMethodSignature methodSignature(@Nullable FunctionDescriptor descriptor, @NotNull Method method) {
|
||||
|
||||
@@ -183,7 +183,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
descriptor.getParentJavaStaticClassScope()?.run {
|
||||
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||
.filter {
|
||||
it is FunctionDescriptor && Visibilities.isVisibleWithIrrelevantReceiver(it, descriptor)
|
||||
it is FunctionDescriptor && Visibilities.isVisibleIgnoringReceiver(it, descriptor)
|
||||
}
|
||||
.forEach(::processMember)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -57,6 +57,7 @@ class GenerationState @JvmOverloads constructor(
|
||||
disableInline: Boolean = false,
|
||||
disableOptimization: Boolean = false,
|
||||
val useTypeTableInSerializer: Boolean = false,
|
||||
val inheritMultifileParts: Boolean = false,
|
||||
val packagesWithObsoleteParts: Collection<FqName> = emptySet(),
|
||||
val obsoleteMultifileClasses: Collection<FqName> = emptySet(),
|
||||
// for PackageCodegen in incremental compilation mode
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.fileClasses.FileClasses;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature;
|
||||
@@ -448,7 +449,7 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
if (classBuilderMode != ClassBuilderMode.LIGHT_CLASSES) {
|
||||
if (classBuilderMode == ClassBuilderMode.FULL) {
|
||||
throw new IllegalStateException(generateErrorMessageForErrorType(jetType, descriptor));
|
||||
}
|
||||
Type asmType = Type.getObjectType("error/NonExistentClass");
|
||||
@@ -924,7 +925,7 @@ public class KotlinTypeMapper {
|
||||
? JvmAbi.getterName(propertyName)
|
||||
: JvmAbi.setterName(propertyName);
|
||||
|
||||
return updateMemberNameIfInternal(isAccessor ? "access$" + accessorName : accessorName, descriptor);
|
||||
return mangleMemberNameIfRequired(isAccessor ? "access$" + accessorName : accessorName, descriptor);
|
||||
}
|
||||
else if (isFunctionLiteral(descriptor)) {
|
||||
PsiElement element = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor);
|
||||
@@ -944,7 +945,7 @@ public class KotlinTypeMapper {
|
||||
return OperatorNameConventions.INVOKE.asString();
|
||||
}
|
||||
else {
|
||||
return updateMemberNameIfInternal(descriptor.getName().asString(), descriptor);
|
||||
return mangleMemberNameIfRequired(descriptor.getName().asString(), descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,13 +974,21 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String updateMemberNameIfInternal(@NotNull String name, @NotNull CallableMemberDescriptor descriptor) {
|
||||
private String mangleMemberNameIfRequired(@NotNull String name, @NotNull CallableMemberDescriptor descriptor) {
|
||||
if (descriptor.getContainingDeclaration() instanceof ScriptDescriptor) {
|
||||
//script properties should be public
|
||||
return name;
|
||||
}
|
||||
|
||||
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"<clinit>".equals(name)) {
|
||||
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
|
||||
assert containingFile != null : "Private descriptor accessed outside of corresponding file scope: " + descriptor;
|
||||
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile);
|
||||
if (fileClassInfo.getWithJvmMultifileClass()) {
|
||||
return name + "$" + fileClassInfo.getFileClassFqName().shortName().asString();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -1248,7 +1257,7 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
|
||||
private void writeFormalTypeParameter(@NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull JvmSignatureWriter sw) {
|
||||
if (classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && typeParameterDescriptor.getName().isSpecial()) {
|
||||
if (classBuilderMode != ClassBuilderMode.FULL && typeParameterDescriptor.getName().isSpecial()) {
|
||||
// If a type parameter has no name, the code below fails, but it should recover in case of light classes
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ public abstract class CommonCompilerArguments {
|
||||
|
||||
public List<String> freeArgs = new SmartList<String>();
|
||||
|
||||
public List<String> unknownExtraFlags = new SmartList<String>();
|
||||
|
||||
@NotNull
|
||||
public String executableScriptFileName() {
|
||||
return "kotlinc";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -64,6 +64,9 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "Xreport-perf", description = "Report detailed performance statistics")
|
||||
public boolean reportPerf;
|
||||
|
||||
@Argument(value = "Xmultifile-parts-inherit", description = "Compile multifile classes as a hierarchy of parts and facade")
|
||||
public boolean inheritMultifileParts;
|
||||
|
||||
@Argument(value = "Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin'")
|
||||
public boolean allowKotlinPackage;
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.sampullara.cli.Args;
|
||||
import kotlin.Pair;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -42,7 +45,7 @@ import java.util.Properties;
|
||||
import static org.jetbrains.kotlin.cli.common.ExitCode.*;
|
||||
|
||||
public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
static {
|
||||
static private void setIdeaIoUseFallback() {
|
||||
if (SystemInfo.isWindows) {
|
||||
Properties properties = System.getProperties();
|
||||
|
||||
@@ -87,7 +90,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
private A parseArguments(@NotNull PrintStream errStream, @NotNull MessageRenderer messageRenderer, @NotNull String[] args) {
|
||||
try {
|
||||
A arguments = createArguments();
|
||||
arguments.freeArgs = Args.parse(arguments, args);
|
||||
parseArguments(args, arguments);
|
||||
return arguments;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
@@ -104,6 +107,26 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess") // Used in maven (see KotlinCompileMojoBase.java)
|
||||
public void parseArguments(@NotNull String[] args, @NotNull A arguments) {
|
||||
Pair<List<String>, List<String>> unparsedArgs =
|
||||
CollectionsKt.partition(Args.parse(arguments, args, false), new Function1<String, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(String s) {
|
||||
return s.startsWith("-X");
|
||||
}
|
||||
});
|
||||
|
||||
arguments.unknownExtraFlags = unparsedArgs.getFirst();
|
||||
arguments.freeArgs = unparsedArgs.getSecond();
|
||||
|
||||
for (String argument : arguments.freeArgs) {
|
||||
if (argument.startsWith("-")) {
|
||||
throw new IllegalArgumentException("Invalid argument: " + argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow derived classes to add additional command line arguments
|
||||
*/
|
||||
@@ -169,6 +192,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
messageCollector = new FilteringMessageCollector(messageCollector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||
}
|
||||
|
||||
reportUnknownExtraFlags(messageCollector, arguments);
|
||||
|
||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||
try {
|
||||
ExitCode exitCode = OK;
|
||||
@@ -192,6 +217,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
try {
|
||||
MessageSeverityCollector severityCollector = new MessageSeverityCollector(groupingCollector);
|
||||
setIdeaIoUseFallback();
|
||||
ExitCode code = doExecute(arguments, services, severityCollector, rootDisposable);
|
||||
exitCode = severityCollector.anyReported(CompilerMessageSeverity.ERROR) ? COMPILATION_ERROR : code;
|
||||
}
|
||||
@@ -226,6 +252,16 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
}
|
||||
}
|
||||
|
||||
private void reportUnknownExtraFlags(@NotNull MessageCollector collector, @NotNull A arguments) {
|
||||
for (String flag : arguments.unknownExtraFlags) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.WARNING,
|
||||
"Flag is not supported by this version of the compiler: " + flag,
|
||||
CompilerMessageLocation.NO_LOCATION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract ExitCode doExecute(
|
||||
@NotNull A arguments,
|
||||
|
||||
@@ -280,6 +280,7 @@ open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize)
|
||||
configuration.put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, arguments.declarationsOutputPath)
|
||||
configuration.put(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, arguments.inheritMultifileParts);
|
||||
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage);
|
||||
configuration.put(CLIConfigurationKeys.REPORT_PERF, arguments.reportPerf);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
|
||||
@@ -141,6 +138,8 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
|
||||
return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
||||
}
|
||||
|
||||
override fun analyze(element: KtElement) = bindingContext
|
||||
|
||||
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
val filesForFacade = findFilesForFacade(facadeFqName, scope)
|
||||
if (filesForFacade.isEmpty()) return emptyList()
|
||||
@@ -149,6 +148,11 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope, filesForFacade))
|
||||
}
|
||||
|
||||
override fun getMultifilePartClasses(partFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
//
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun findFilesForFacade(facadeFqName: FqName, scope: GlobalSearchScope): Collection<KtFile> {
|
||||
if (facadeFqName.isRoot) return emptyList()
|
||||
|
||||
|
||||
@@ -109,10 +109,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
private val sourceFiles = ArrayList<KtFile>()
|
||||
private val javaRoots = ArrayList<JavaRoot>()
|
||||
|
||||
val configuration: CompilerConfiguration = configuration.copy().let {
|
||||
it.setReadOnly(true)
|
||||
it
|
||||
}
|
||||
val configuration: CompilerConfiguration = configuration.copy().apply { setReadOnly(true) }
|
||||
|
||||
init {
|
||||
PersistentFSConstants.setMaxIntellisenseFileSize(FileUtilRt.LARGE_FOR_CONTENT_LOADING)
|
||||
|
||||
@@ -399,6 +399,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_INLINE, false),
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_OPTIMIZATION, false),
|
||||
/* useTypeTableInSerializer = */ false,
|
||||
configuration.get(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, false),
|
||||
packagesWithObsoleteParts,
|
||||
obsoleteMultifileClasses,
|
||||
targetId,
|
||||
|
||||
@@ -35,6 +35,8 @@ public class JVMConfigurationKeys {
|
||||
CompilerConfigurationKey.create("disable inline");
|
||||
public static final CompilerConfigurationKey<Boolean> DISABLE_OPTIMIZATION =
|
||||
CompilerConfigurationKey.create("disable optimization");
|
||||
public static final CompilerConfigurationKey<Boolean> INHERIT_MULTIFILE_PARTS =
|
||||
CompilerConfigurationKey.create("compile multifile classes to a hierarchy of parts and facade");
|
||||
|
||||
public static final CompilerConfigurationKey<IncrementalCompilationComponents> INCREMENTAL_COMPILATION_COMPONENTS =
|
||||
CompilerConfigurationKey.create("incremental cache provider");
|
||||
|
||||
@@ -149,3 +149,6 @@ messages/**)
|
||||
*** SKIP_DEBUG;
|
||||
*** SKIP_FRAMES;
|
||||
}
|
||||
|
||||
# for kotlin-android-extensions in maven
|
||||
-keep class com.intellij.openapi.module.ModuleServiceManager { public *; }
|
||||
@@ -64,7 +64,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
|
||||
.flatMap { it.walk().filter(::isClasspathFile) }
|
||||
.map { FileId(it, it.lastModified(), it.md5Digest()) }
|
||||
.toList()
|
||||
val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime())
|
||||
val nowMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime())
|
||||
lastUpdate.set(nowMs)
|
||||
lastDigestUpdate.set(nowMs)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
|
||||
|
||||
val isChanged: Boolean get() {
|
||||
if (lastChangedStatus.get()) return true
|
||||
val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime())
|
||||
val nowMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime())
|
||||
if (nowMs - lastUpdate.get() < checkPeriod) return false
|
||||
|
||||
val checkDigest = nowMs - lastDigestUpdate.get() > digestCheckPeriod
|
||||
@@ -106,7 +106,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
|
||||
true // io error considered as change
|
||||
}
|
||||
} != null
|
||||
lastUpdate.set(TimeUnit.MILLISECONDS.toMillis(System.nanoTime()))
|
||||
lastUpdate.set(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()))
|
||||
if (checkDigest) lastDigestUpdate.set(lastUpdate.get())
|
||||
|
||||
return changed
|
||||
|
||||
@@ -18,12 +18,15 @@ package org.jetbrains.kotlin.fileClasses
|
||||
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.getImplClassNameForDeserialized
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
|
||||
object JvmFileClassUtil {
|
||||
@@ -84,14 +87,21 @@ object JvmFileClassUtil {
|
||||
it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == shortName
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
private fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
|
||||
@JvmStatic private fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
|
||||
val stringTemplate = argumentExpression as? KtStringTemplateExpression ?: return null
|
||||
val stringTemplateEntries = stringTemplate.entries
|
||||
if (stringTemplateEntries.size != 1) return null
|
||||
val singleEntry = stringTemplateEntries[0] as? KtLiteralStringTemplateEntry ?: return null
|
||||
return singleEntry.text
|
||||
}
|
||||
|
||||
@JvmStatic fun isFromMultifileClass(declarationElement: KtElement, descriptor: DeclarationDescriptor): Boolean {
|
||||
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
val fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(declarationElement.getContainingKtFile())
|
||||
return fileClassInfo.withJvmMultifileClass
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
internal class ParsedJvmFileClassAnnotations(val name: String, val multipleFiles: Boolean)
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
// then use this upper bound instead of star projection
|
||||
// - Otherwise no non-projection parametrization exists for such 'samType'
|
||||
//
|
||||
// See Non-wildcard parametrization in §9.9 of JLS 8 for clarification
|
||||
// See Non-wildcard parametrization in JLS 8 p.9.9 for clarification
|
||||
internal fun nonProjectionParametrization(samType: KotlinType): KotlinType? {
|
||||
if (samType.arguments.none { it.projectionKind != Variance.INVARIANT }) return samType
|
||||
val parameters = samType.constructor.parameters
|
||||
|
||||
@@ -74,7 +74,7 @@ class JavaTypeAccessibilityChecker : AdditionalTypeChecker {
|
||||
if (visitedTypeConstructors.contains(typeConstructor)) return
|
||||
visitedTypeConstructors.add(typeConstructor)
|
||||
|
||||
if (typeConstructor is JavaClassDescriptor && !Visibilities.isVisibleWithIrrelevantReceiver(typeConstructor, scopeOwner)) {
|
||||
if (typeConstructor is JavaClassDescriptor && !Visibilities.isVisibleIgnoringReceiver(typeConstructor, scopeOwner)) {
|
||||
inaccessibleTypes.add(type)
|
||||
}
|
||||
for (typeProjection in type.arguments) {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.checkers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
|
||||
object ProtectedSyntheticExtensionCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
|
||||
val descriptor = resolvedCall.resultingDescriptor
|
||||
|
||||
val sourceFunction = when (descriptor) {
|
||||
is SyntheticJavaPropertyDescriptor -> descriptor.getMethod
|
||||
is SamAdapterExtensionFunctionDescriptor -> descriptor.sourceFunction
|
||||
else -> return
|
||||
}
|
||||
|
||||
val from = context.scope.ownerDescriptor
|
||||
|
||||
// Already reported
|
||||
if (!Visibilities.isVisibleIgnoringReceiver(descriptor, from)) return
|
||||
|
||||
if (resolvedCall.dispatchReceiver != null && resolvedCall.extensionReceiver !is ReceiverValue) return
|
||||
|
||||
val receiverValue = resolvedCall.extensionReceiver as ReceiverValue
|
||||
val receiverTypes = listOf(receiverValue.type) + context.dataFlowInfo.getPredictableTypes(
|
||||
DataFlowValueFactory.createDataFlowValue(receiverValue, context))
|
||||
|
||||
if (receiverTypes.none { Visibilities.isVisible(getReceiverValueWithSmartCast(null, it), sourceFunction, from) }) {
|
||||
context.trace.report(Errors.INVISIBLE_MEMBER.on(resolvedCall.call.callElement, descriptor, descriptor.visibility, from))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
}
|
||||
};
|
||||
|
||||
public static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("JVM");
|
||||
private static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("JVM");
|
||||
static {
|
||||
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
||||
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
||||
@@ -57,17 +57,17 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
|
||||
MAP.put(ErrorsJvm.MISSING_DEPENDENCY_CLASS, "Cannot access class ''{0}''. Check your module classpath for missing or conflicting dependencies", Renderers.TO_STRING);
|
||||
|
||||
MAP.put(ErrorsJvm.JVM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with ''@JvmStatic''");
|
||||
MAP.put(ErrorsJvm.JVM_STATIC_ON_CONST_OR_JVM_FIELD, "''@JvmStatic'' annotation is useless for const or ''@JvmField'' properties");
|
||||
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be ''@JvmStatic'' in object");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "''@JvmOverloads'' annotation has no effect for methods without default arguments");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''@JvmOverloads'' annotation cannot be used on abstract methods");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''@JvmOverloads'' annotation has no effect on private and local declarations");
|
||||
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "''@JvmName'' annotation is not applicable to this declaration");
|
||||
MAP.put(ErrorsJvm.JVM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with '@JvmStatic'");
|
||||
MAP.put(ErrorsJvm.JVM_STATIC_ON_CONST_OR_JVM_FIELD, "'@JvmStatic' annotation is useless for const or '@JvmField' properties");
|
||||
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be '@JvmStatic' in object");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "'@JvmOverloads' annotation has no effect for methods without default arguments");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "'@JvmOverloads' annotation cannot be used on abstract methods");
|
||||
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "'@JvmOverloads' annotation has no effect on private and local declarations");
|
||||
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration");
|
||||
MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name");
|
||||
MAP.put(ErrorsJvm.VOLATILE_ON_VALUE, "''@Volatile'' annotation cannot be used on immutable properties");
|
||||
MAP.put(ErrorsJvm.VOLATILE_ON_DELEGATE, "''@Volatile'' annotation cannot be used on delegated properties");
|
||||
MAP.put(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT, "''@Synchronized'' annotation cannot be used on abstract functions");
|
||||
MAP.put(ErrorsJvm.VOLATILE_ON_VALUE, "'@Volatile' annotation cannot be used on immutable properties");
|
||||
MAP.put(ErrorsJvm.VOLATILE_ON_DELEGATE, "'@Volatile' annotation cannot be used on delegated properties");
|
||||
MAP.put(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external");
|
||||
@@ -101,9 +101,9 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
|
||||
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_FIELD, "{0}", Renderers.TO_STRING);
|
||||
|
||||
MAP.put(ErrorsJvm.JVM_SYNTHETIC_ON_DELEGATE, "''@JvmSynthetic'' annotation cannot be used on delegated properties");
|
||||
MAP.put(ErrorsJvm.JVM_SYNTHETIC_ON_DELEGATE, "'@JvmSynthetic' annotation cannot be used on delegated properties");
|
||||
|
||||
MAP.put(ErrorsJvm.STRICTFP_ON_CLASS, "''@Strictfp'' annotation on classes is unsupported yet");
|
||||
MAP.put(ErrorsJvm.STRICTFP_ON_CLASS, "'@Strictfp' annotation on classes is unsupported yet");
|
||||
|
||||
MAP.put(ErrorsJvm.SUPER_CALL_WITH_DEFAULT_PARAMETERS, "Super-calls with default arguments are not allowed. Please specify all arguments of ''super.{0}'' explicitly", Renderers.TO_STRING);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
@@ -68,9 +67,9 @@ fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclara
|
||||
/**
|
||||
* @param representativeFile one of the files representing this multifile class (will be used for diagnostics)
|
||||
*/
|
||||
fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(MULTIFILE_CLASS, representativeFile, descriptor)
|
||||
fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor)
|
||||
|
||||
fun TraitImpl(element: KtClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor)
|
||||
|
||||
@@ -51,7 +51,8 @@ object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
ProtectedInSuperClassCompanionCallChecker(),
|
||||
UnsupportedSyntheticCallableReferenceChecker(),
|
||||
SuperCallWithDefaultArgumentsChecker(),
|
||||
MissingDependencyClassChecker()
|
||||
MissingDependencyClassChecker(),
|
||||
ProtectedSyntheticExtensionCallChecker
|
||||
),
|
||||
|
||||
additionalTypeCheckers = listOf(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -120,7 +120,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
val getMethod = possibleGetMethodNames
|
||||
.flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
|
||||
.singleOrNull {
|
||||
isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
|
||||
it.hasJavaOriginInHierarchy() && isGoodGetMethod(it)
|
||||
} ?: return result(null, possibleGetMethodNames)
|
||||
|
||||
|
||||
|
||||
@@ -169,7 +169,10 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : SyntheticScope
|
||||
|
||||
}
|
||||
|
||||
val sourceFunctionSubstitutor = TypeSubstitutor.create(substitutionMap)
|
||||
val sourceFunctionSubstitutor =
|
||||
TypeConstructorSubstitution.createByConstructorsMap(
|
||||
substitutionMap, configuration.originalSubstitutor.substitution.approximateCapturedTypes()).buildSubstitutor()
|
||||
|
||||
descriptor.sourceFunction = original.sourceFunction.substitute(sourceFunctionSubstitutor)
|
||||
|
||||
return descriptor
|
||||
|
||||
@@ -36,7 +36,7 @@ fun syntheticExtensionVisibility(originalDescriptor: DeclarationDescriptorWithVi
|
||||
|
||||
else -> object : Visibility(originalVisibility.name, originalVisibility.isPublicAPI) {
|
||||
override fun isVisible(receiver: ReceiverValue?, what: DeclarationDescriptorWithVisibility, from: DeclarationDescriptor)
|
||||
= originalVisibility.isVisible(receiver, originalDescriptor, from)
|
||||
= originalVisibility.isVisible(Visibilities.ALWAYS_SUITABLE_RECEIVER, originalDescriptor, from)
|
||||
|
||||
override fun mustCheckInImports()
|
||||
= throw UnsupportedOperationException("Should never be called for this visibility")
|
||||
|
||||
@@ -466,7 +466,7 @@ public class ControlFlowInformationProvider {
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = CallUtilKt.getResolvedCall(expression, trace.getBindingContext());
|
||||
ReceiverValue receiverValue = null;
|
||||
if (resolvedCall != null) {
|
||||
receiverValue = resolvedCall.getDispatchReceiver();
|
||||
receiverValue = ResolvedCallUtilKt.getDispatchReceiverWithSmartCast(resolvedCall);
|
||||
}
|
||||
|
||||
if (Visibilities.isVisible(receiverValue, variableDescriptor, descriptor) && setterDescriptor != null
|
||||
|
||||
@@ -793,16 +793,31 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
override fun visitBreakExpression(expression: KtBreakExpression) {
|
||||
val loop = getCorrespondingLoop(expression)
|
||||
if (loop != null) {
|
||||
checkJumpDoesNotCrossFunctionBoundary(expression, loop)
|
||||
builder.getExitPoint(loop)?.let { builder.jump(it, expression) }
|
||||
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
|
||||
builder.getExitPoint(loop)?.let { builder.jump(it, expression) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitContinueExpression(expression: KtContinueExpression) {
|
||||
val loop = getCorrespondingLoop(expression)
|
||||
if (loop != null) {
|
||||
checkJumpDoesNotCrossFunctionBoundary(expression, loop)
|
||||
builder.jump(builder.getConditionEntryPoint(loop), expression)
|
||||
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
|
||||
builder.jump(builder.getConditionEntryPoint(loop), expression)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNearestLoopExpression(expression: KtExpression) = expression.getStrictParentOfType<KtLoopExpression>()
|
||||
|
||||
private fun getCorrespondingLoopWithoutLabel(expression: KtExpression): KtLoopExpression? {
|
||||
val parentLoop = getNearestLoopExpression(expression) ?: return null
|
||||
val parentBody = parentLoop.body
|
||||
return if (parentBody != null && parentBody.textRange.contains(expression.textRange)) {
|
||||
parentLoop
|
||||
}
|
||||
else {
|
||||
getNearestLoopExpression(parentLoop)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,7 +836,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
loop = builder.currentLoop
|
||||
loop = getCorrespondingLoopWithoutLabel(expression)
|
||||
if (loop == null) {
|
||||
trace.report(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP.on(expression))
|
||||
}
|
||||
@@ -842,13 +857,24 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
return loop
|
||||
}
|
||||
|
||||
private fun checkJumpDoesNotCrossFunctionBoundary(jumpExpression: KtExpressionWithLabel, jumpTarget: KtElement) {
|
||||
private fun jumpDoesNotCrossFunctionBoundary(jumpExpression: KtExpressionWithLabel, jumpTarget: KtElement): Boolean {
|
||||
val bindingContext = trace.bindingContext
|
||||
|
||||
val labelExprEnclosingFunc = BindingContextUtils.getEnclosingFunctionDescriptor(bindingContext, jumpExpression)
|
||||
val labelTargetEnclosingFunc = BindingContextUtils.getEnclosingFunctionDescriptor(bindingContext, jumpTarget)
|
||||
if (labelExprEnclosingFunc !== labelTargetEnclosingFunc) {
|
||||
trace.report(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY.on(jumpExpression))
|
||||
return if (labelExprEnclosingFunc !== labelTargetEnclosingFunc) {
|
||||
// Check to report only once
|
||||
if (builder.getExitPoint(jumpTarget) != null ||
|
||||
// Local class secondary constructors are handled differently
|
||||
// They are the only local class element NOT included in owner pseudocode
|
||||
// See generateInitializersForScriptClassOrObject && generateDeclarationForLocalClassOrObjectIfNeeded
|
||||
labelExprEnclosingFunc is ConstructorDescriptor && !labelExprEnclosingFunc.isPrimary) {
|
||||
trace.report(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY.on(jumpExpression))
|
||||
}
|
||||
false
|
||||
}
|
||||
else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -73,6 +73,8 @@ public interface Errors {
|
||||
DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
|
||||
|
||||
DiagnosticFactory1<KtExpression, ConstructorDescriptor> PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Exposed visibility group
|
||||
DiagnosticFactory3<PsiElement, EffectiveVisibility, DescriptorWithRelation, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, EffectiveVisibility, DescriptorWithRelation, EffectiveVisibility> EXPOSED_FUNCTION_RETURN_TYPE = DiagnosticFactory3.create(ERROR);
|
||||
@@ -96,7 +98,8 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, Integer, DeclarationDescriptor> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, String> TYPE_ARGUMENTS_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> REDUNDANT_PROJECTION = DiagnosticFactory1.create(WARNING, VARIANCE_IN_PROJECTION);
|
||||
|
||||
@@ -51,7 +51,7 @@ object PositioningStrategies {
|
||||
when (element) {
|
||||
is KtObjectLiteralExpression -> {
|
||||
val objectDeclaration = element.objectDeclaration
|
||||
val objectKeyword = objectDeclaration.getObjectKeyword()
|
||||
val objectKeyword = objectDeclaration.getObjectKeyword()!!
|
||||
val delegationSpecifierList = objectDeclaration.getSuperTypeList()
|
||||
if (delegationSpecifierList == null) {
|
||||
return markElement(objectKeyword)
|
||||
@@ -60,8 +60,8 @@ object PositioningStrategies {
|
||||
}
|
||||
is KtObjectDeclaration -> {
|
||||
return markRange(
|
||||
element.getObjectKeyword(),
|
||||
element.getNameIdentifier() ?: element.getObjectKeyword()
|
||||
element.getObjectKeyword()!!,
|
||||
element.getNameIdentifier() ?: element.getObjectKeyword()!!
|
||||
)
|
||||
}
|
||||
is KtConstructorDelegationCall -> {
|
||||
@@ -265,7 +265,7 @@ object PositioningStrategies {
|
||||
}
|
||||
|
||||
val elementToMark = when (element) {
|
||||
is KtObjectDeclaration -> element.getObjectKeyword()
|
||||
is KtObjectDeclaration -> element.getObjectKeyword()!!
|
||||
is KtPropertyAccessor -> element.getNamePlaceholder()
|
||||
is KtAnonymousInitializer -> element
|
||||
else -> throw IllegalArgumentException(
|
||||
|
||||
@@ -30,7 +30,7 @@ open class PositioningStrategy<E : PsiElement> {
|
||||
return mark(diagnostic.psiElement)
|
||||
}
|
||||
|
||||
protected open fun mark(element: E): List<TextRange> {
|
||||
open fun mark(element: E): List<TextRange> {
|
||||
return markElement(element)
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(INVISIBLE_REFERENCE, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
|
||||
MAP.put(INVISIBLE_MEMBER, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
|
||||
|
||||
MAP.put(PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL, "Protected constructor ''{0}'' from other classes can only be used in super-call", Renderers.SHORT_NAMES_IN_TYPES);
|
||||
|
||||
MAP.put(EXPOSED_PROPERTY_TYPE, "''{0}'' property exposes its ''{2}'' type{1}", TO_STRING, TO_STRING, TO_STRING);
|
||||
MAP.put(EXPOSED_FUNCTION_RETURN_TYPE, "''{0}'' function exposes its ''{2}'' return type{1}", TO_STRING, TO_STRING, TO_STRING);
|
||||
MAP.put(EXPOSED_PARAMETER_TYPE, "''{0}'' function exposes its ''{2}'' parameter type{1}", TO_STRING, TO_STRING, TO_STRING);
|
||||
@@ -146,14 +148,14 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(INAPPLICABLE_TARGET_ON_PROPERTY, "''@{0}:'' annotations could be applied only to property declarations", TO_STRING);
|
||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE, "''@{0}:'' annotations could be applied only to mutable properties", TO_STRING);
|
||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE, "''@delegate:'' annotations could be applied only to delegated properties");
|
||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD, "''@field:'' annotations could be applied only to properties with backing fields");
|
||||
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "''@receiver:'' annotations could be applied only to extension function or extension property declarations");
|
||||
MAP.put(INAPPLICABLE_PARAM_TARGET, "''@param:'' annotations could be applied only to primary constructor parameters");
|
||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE, "'@delegate:' annotations could be applied only to delegated properties");
|
||||
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD, "'@field:' annotations could be applied only to properties with backing fields");
|
||||
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "'@receiver:' annotations could be applied only to extension function or extension property declarations");
|
||||
MAP.put(INAPPLICABLE_PARAM_TARGET, "'@param:' annotations could be applied only to primary constructor parameters");
|
||||
MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING);
|
||||
|
||||
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
|
||||
MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier ''abstract'' is redundant in interface");
|
||||
MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier 'abstract' is redundant in interface");
|
||||
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
|
||||
MAP.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters");
|
||||
MAP.put(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM,
|
||||
@@ -236,8 +238,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(NON_MEMBER_FUNCTION_NO_BODY, "Function ''{0}'' must have a body", NAME);
|
||||
MAP.put(FUNCTION_DECLARATION_WITH_NO_NAME, "Function declaration must have a name");
|
||||
MAP.put(ANONYMOUS_FUNCTION_WITH_NAME, "Anonymous functions with names are prohibited");
|
||||
MAP.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, "\"open\" has no effect in a final class");
|
||||
MAP.put(NON_FINAL_MEMBER_IN_OBJECT, "\"open\" has no effect in an object");
|
||||
MAP.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, "'open' has no effect in a final class");
|
||||
MAP.put(NON_FINAL_MEMBER_IN_OBJECT, "'open' has no effect in an object");
|
||||
|
||||
MAP.put(ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE, "An anonymous function is not allowed to specify default values for its parameters");
|
||||
MAP.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless");
|
||||
@@ -270,7 +272,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(VAL_REASSIGNMENT, "Val cannot be reassigned", NAME);
|
||||
MAP.put(CAPTURED_VAL_INITIALIZATION, "Captured values initialization is forbidden due to possible reassignment", NAME);
|
||||
MAP.put(SETTER_PROJECTED_OUT, "Setter for ''{0}'' is removed by type projection", NAME);
|
||||
MAP.put(INVISIBLE_SETTER, "Cannot assign to ''{0}'': the setter is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
|
||||
MAP.put(INVISIBLE_SETTER, "Cannot assign to ''{0}'': the setter is {1} in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
|
||||
MAP.put(INITIALIZATION_BEFORE_DECLARATION, "Variable cannot be initialized before declaration", NAME);
|
||||
MAP.put(VARIABLE_EXPECTED, "Variable expected");
|
||||
|
||||
@@ -315,7 +317,7 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(EQUALS_MISSING, "No method 'equals(Any?): Boolean' available");
|
||||
MAP.put(ASSIGNMENT_IN_EXPRESSION_CONTEXT, "Assignments are not expressions, and only expressions are allowed in this context");
|
||||
MAP.put(SUPER_IS_NOT_AN_EXPRESSION, "''{0}'' is not an expression, it can only be used on the left-hand side of a dot ('.')", STRING);
|
||||
MAP.put(SUPER_IS_NOT_AN_EXPRESSION, "''{0}'' is not an expression, it can only be used on the left-hand side of a dot (''.'')", STRING);
|
||||
MAP.put(SUPER_CANT_BE_EXTENSION_RECEIVER, "''{0}'' is not an expression, it can not be used as a receiver for extension functions", STRING);
|
||||
MAP.put(DECLARATION_IN_ILLEGAL_CONTEXT, "Declarations are not allowed in this position");
|
||||
MAP.put(SETTER_PARAMETER_WITH_DEFAULT_VALUE, "Setter parameters cannot have default values");
|
||||
@@ -350,12 +352,12 @@ public class DefaultErrorMessages {
|
||||
MAP.put(HAS_NEXT_FUNCTION_NONE_APPLICABLE, "None of the hasNext() functions is applicable for iterator() of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(HAS_NEXT_FUNCTION_TYPE_MISMATCH, "The ''iterator().hasNext()'' function of the loop range must return Boolean, but returns {0}", RENDER_TYPE);
|
||||
|
||||
MAP.put(NEXT_MISSING, "next() cannot be called on iterator() of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(NEXT_AMBIGUITY, "next() is ambiguous for iterator() of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(NEXT_NONE_APPLICABLE, "None of the next() functions is applicable for iterator() of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(NEXT_MISSING, "''next()'' cannot be called on ''iterator()'' of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(NEXT_AMBIGUITY, "''next()'' is ambiguous for ''iterator()'' of type ''{0}''", RENDER_TYPE);
|
||||
MAP.put(NEXT_NONE_APPLICABLE, "None of the ''next()'' functions is applicable for ''iterator()'' of type ''{0}''", RENDER_TYPE);
|
||||
|
||||
MAP.put(ITERATOR_MISSING, "For-loop range must have an iterator() method");
|
||||
MAP.put(ITERATOR_ON_NULLABLE, "Not nullable value required to call an iterator() method on for-loop range");
|
||||
MAP.put(ITERATOR_MISSING, "For-loop range must have an 'iterator()' method");
|
||||
MAP.put(ITERATOR_ON_NULLABLE, "Not nullable value required to call an 'iterator()' method on for-loop range");
|
||||
MAP.put(ITERATOR_AMBIGUITY, "Method ''iterator()'' is ambiguous for this expression: {0}", AMBIGUOUS_CALLS);
|
||||
|
||||
MAP.put(DELEGATE_SPECIAL_FUNCTION_MISSING, "Missing ''{0}'' method on delegate of type ''{1}''", STRING, RENDER_TYPE);
|
||||
@@ -372,11 +374,11 @@ public class DefaultErrorMessages {
|
||||
MAP.put(UNDERSCORE_IS_RESERVED, "Names _, __, ___, ..., are reserved in Kotlin");
|
||||
MAP.put(INVALID_CHARACTERS, "Name {0}", STRING);
|
||||
|
||||
MAP.put(INAPPLICABLE_OPERATOR_MODIFIER, "'operator' modifier is inapplicable on this function: {0}", STRING);
|
||||
MAP.put(INAPPLICABLE_OPERATOR_MODIFIER, "''operator'' modifier is inapplicable on this function: {0}", STRING);
|
||||
MAP.put(INAPPLICABLE_INFIX_MODIFIER, "'infix' modifier is inapplicable on this function");
|
||||
|
||||
MAP.put(OPERATOR_MODIFIER_REQUIRED, "'operator' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
|
||||
MAP.put(INFIX_MODIFIER_REQUIRED, "'infix' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
|
||||
MAP.put(OPERATOR_MODIFIER_REQUIRED, "''operator'' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
|
||||
MAP.put(INFIX_MODIFIER_REQUIRED, "''infix'' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
|
||||
|
||||
MAP.put(RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY,
|
||||
"Returns are not allowed for functions with expression body. Use block body in '{...}'");
|
||||
@@ -429,8 +431,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ELSE_MISPLACED_IN_WHEN, "'else' entry must be the last one in a when-expression");
|
||||
MAP.put(COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT, "Deprecated syntax. Use '||' instead of commas in when-condition for 'when' without argument");
|
||||
|
||||
MAP.put(NO_ELSE_IN_WHEN, "'when' expression must be exhaustive, add necessary {0}", RENDER_WHEN_MISSING_CASES);
|
||||
MAP.put(NON_EXHAUSTIVE_WHEN, "'when' expression on enum is recommended to be exhaustive, add {0}", RENDER_WHEN_MISSING_CASES);
|
||||
MAP.put(NO_ELSE_IN_WHEN, "''when'' expression must be exhaustive, add necessary {0}", RENDER_WHEN_MISSING_CASES);
|
||||
MAP.put(NON_EXHAUSTIVE_WHEN, "''when'' expression on enum is recommended to be exhaustive, add {0}", RENDER_WHEN_MISSING_CASES);
|
||||
|
||||
MAP.put(TYPE_MISMATCH_IN_RANGE, "Type mismatch: incompatible types of range and element checked in it");
|
||||
MAP.put(CYCLIC_INHERITANCE_HIERARCHY, "There's a cycle in the inheritance hierarchy for this type");
|
||||
@@ -470,7 +472,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
|
||||
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
|
||||
MAP.put(BREAK_OR_CONTINUE_IN_WHEN, "'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop");
|
||||
MAP.put(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY, "'break' or 'continue' jumps across a function boundary");
|
||||
MAP.put(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY, "'break' or 'continue' jumps across a function or a class boundary");
|
||||
MAP.put(NOT_A_LOOP_LABEL, "The label ''{0}'' does not denote a loop", STRING);
|
||||
MAP.put(NOT_A_RETURN_LABEL, "The label ''{0}'' does not reference to a context from which we can return", STRING);
|
||||
|
||||
@@ -479,7 +481,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(DYNAMIC_SUPERTYPE, "A supertype cannot be dynamic");
|
||||
MAP.put(REDUNDANT_NULLABLE, "Redundant '?'");
|
||||
MAP.put(UNSAFE_CALL, "Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type {0}", RENDER_TYPE);
|
||||
MAP.put(UNSAFE_IMPLICIT_INVOKE_CALL, "Reference has a nullable type {0}, use explicit '?.invoke()' to make function-like call instead", RENDER_TYPE);
|
||||
MAP.put(UNSAFE_IMPLICIT_INVOKE_CALL, "Reference has a nullable type ''{0}'', use explicit ''?.invoke()'' to make a function-like call instead", RENDER_TYPE);
|
||||
MAP.put(AMBIGUOUS_LABEL, "Ambiguous label");
|
||||
MAP.put(UNSUPPORTED, "Unsupported [{0}]", STRING);
|
||||
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
||||
@@ -539,8 +541,8 @@ public class DefaultErrorMessages {
|
||||
RENDER_TYPE);
|
||||
MAP.put(TYPE_MISMATCH_IN_CONDITION, "Condition must be of type Boolean, but is of type {0}", RENDER_TYPE);
|
||||
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
|
||||
MAP.put(IMPLICIT_NOTHING_RETURN_TYPE, "''Nothing'' return type needs to be specified explicitly");
|
||||
MAP.put(IMPLICIT_NOTHING_PROPERTY_TYPE, "''Nothing'' property type needs to be specified explicitly");
|
||||
MAP.put(IMPLICIT_NOTHING_RETURN_TYPE, "'Nothing' return type needs to be specified explicitly");
|
||||
MAP.put(IMPLICIT_NOTHING_PROPERTY_TYPE, "'Nothing' property type needs to be specified explicitly");
|
||||
MAP.put(IMPLICIT_INTERSECTION_TYPE, "Inferred type {0} is an intersection, please specify the required type explicitly", RENDER_TYPE);
|
||||
MAP.put(EXPECTED_CONDITION, "Expected condition of type Boolean");
|
||||
|
||||
@@ -584,7 +586,7 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(OVERRIDING_FINAL_MEMBER_BY_DELEGATION, "''{0}'' implicitly overrides a final member ''{1}'' by delegation",
|
||||
SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, "val-property ''{0}'' implicitly overrides a var-property ''{1}'' by delegation",
|
||||
MAP.put(VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, "Val-property ''{0}'' implicitly overrides a var-property ''{1}'' by delegation",
|
||||
SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
|
||||
MAP.put(VAR_OVERRIDDEN_BY_VAL, "Var-property {0} cannot be overridden by val-property {1}", FQ_NAMES_IN_TYPES, FQ_NAMES_IN_TYPES);
|
||||
@@ -604,7 +606,7 @@ public class DefaultErrorMessages {
|
||||
DECLARATION_NAME_WITH_KIND);
|
||||
|
||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||
"The function ''" + OperatorNameConventions.INVOKE.asString() + "()'' is not found",
|
||||
ELEMENT_TEXT, new DiagnosticParameterRenderer<KotlinType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -626,7 +628,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(RESULT_TYPE_MISMATCH, "{0} must return {1} but returns {2}", STRING, RENDER_TYPE, RENDER_TYPE);
|
||||
MAP.put(UNSAFE_INFIX_CALL,
|
||||
"Infix call corresponds to a dot-qualified call ''{0}.{1}({2})'' which is not allowed on a nullable receiver ''{0}''. " +
|
||||
"Use '?.'-qualified call instead",
|
||||
"Use ''?.''-qualified call instead",
|
||||
STRING, STRING, STRING);
|
||||
|
||||
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity: {0}", AMBIGUOUS_CALLS);
|
||||
@@ -654,9 +656,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT, "Type inference for control flow expression failed. Please specify its type explicitly.");
|
||||
|
||||
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected", (DiagnosticParameterRenderer) null);
|
||||
MAP.put(NO_TYPE_ARGUMENTS_ON_RHS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected. " +
|
||||
"Use ''{1}'' if you don''t want to pass type arguments", null, STRING);
|
||||
String wrongNumberOfTypeArguments = "{0,choice,0#No type arguments|1#One type argument|1<{0,number,integer} type arguments} expected";
|
||||
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, wrongNumberOfTypeArguments + " for {1}", null, WITHOUT_MODIFIERS);
|
||||
MAP.put(NO_TYPE_ARGUMENTS_ON_RHS, wrongNumberOfTypeArguments + ". Use ''{1}'' if you don''t want to pass type arguments", null, STRING);
|
||||
MAP.put(TYPE_ARGUMENTS_NOT_ALLOWED, "Type arguments are not allowed {0}", STRING);
|
||||
|
||||
MAP.put(TYPE_PARAMETER_AS_REIFIED, "Cannot use ''{0}'' as reified type parameter. Use a class instead.", NAME);
|
||||
MAP.put(REIFIED_TYPE_PARAMETER_NO_INLINE, "Only type parameters of inline functions can be reified");
|
||||
@@ -681,7 +684,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT, "Const 'val' are only allowed on top level or in objects");
|
||||
MAP.put(CONST_VAL_WITH_DELEGATE, "Const 'val' should not have a delegate");
|
||||
MAP.put(CONST_VAL_WITH_GETTER, "Const 'val' should not have a getter");
|
||||
MAP.put(TYPE_CANT_BE_USED_FOR_CONST_VAL, "Const 'val' has type ''{0}''. Only primitives and String are allowed", RENDER_TYPE);
|
||||
MAP.put(TYPE_CANT_BE_USED_FOR_CONST_VAL, "Const ''val'' has type ''{0}''. Only primitives and String are allowed", RENDER_TYPE);
|
||||
MAP.put(CONST_VAL_WITHOUT_INITIALIZER, "Const 'val' should have an initializer");
|
||||
MAP.put(CONST_VAL_WITH_NON_CONST_INITIALIZER, "Const 'val' initializer should be a constant value");
|
||||
MAP.put(NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION, "Only 'const val' can be used in constant expressions");
|
||||
@@ -725,7 +728,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(NON_PUBLIC_CALL_FROM_PUBLIC_INLINE, "Public-API inline function cannot access non-public-API ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(PRIVATE_CLASS_MEMBER_FROM_INLINE, "Non-private inline function cannot access members of private classes: ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(NOT_YET_SUPPORTED_IN_INLINE, "''{0}'' construction is not yet supported in inline functions", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(DECLARATION_CANT_BE_INLINED, "''inline'' modifier is not allowed on virtual members. Only private or final members can be inlined");
|
||||
MAP.put(DECLARATION_CANT_BE_INLINED, "'inline' modifier is not allowed on virtual members. Only private or final members can be inlined");
|
||||
MAP.put(NOTHING_TO_INLINE, "Expected performance impact of inlining ''{0}'' can be insignificant. Inlining works best for functions with lambda parameters", SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(USAGE_IS_NOT_INLINABLE, "Illegal usage of inline-parameter ''{0}'' in ''{1}''. Add ''noinline'' modifier to the parameter declaration", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(NULLABLE_INLINE_PARAMETER, "Inline-parameter ''{0}'' of ''{1}'' must not be nullable. Add ''noinline'' modifier to the parameter declaration or make its type not nullable", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
|
||||
@@ -433,6 +433,9 @@ object Renderers {
|
||||
|
||||
@JvmField val FQ_NAMES_IN_TYPES = DescriptorRenderer.FQ_NAMES_IN_TYPES.asRenderer()
|
||||
@JvmField val COMPACT = DescriptorRenderer.COMPACT.asRenderer()
|
||||
@JvmField val WITHOUT_MODIFIERS = DescriptorRenderer.withOptions {
|
||||
modifiers = emptySet()
|
||||
}.asRenderer()
|
||||
@JvmField val SHORT_NAMES_IN_TYPES = DescriptorRenderer.SHORT_NAMES_IN_TYPES.asRenderer()
|
||||
@JvmField val COMPACT_WITH_MODIFIERS = DescriptorRenderer.COMPACT_WITH_MODIFIERS.asRenderer()
|
||||
@JvmField val DEPRECATION_RENDERER = DescriptorRenderer.ONLY_NAMES_WITH_SHORT_TYPES.withOptions {
|
||||
|
||||
@@ -46,9 +46,12 @@ import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
|
||||
%state TAG_BEGINNING
|
||||
%state TAG_TEXT_BEGINNING
|
||||
%state CONTENTS
|
||||
%state CODE_BLOCK
|
||||
%state CODE_BLOCK_LINE_BEGINNING
|
||||
%state CODE_BLOCK_CONTENTS_BEGINNING
|
||||
|
||||
WHITE_SPACE_CHAR =[\ \t\f\n\r]
|
||||
NOT_WHITE_SPACE_CHAR=[^\ \t\f\n\r]
|
||||
WHITE_SPACE_CHAR =[\ \t\f\n]
|
||||
NOT_WHITE_SPACE_CHAR=[^\ \t\f\n]
|
||||
|
||||
DIGIT=[0-9]
|
||||
ALPHA=[:jletter:]
|
||||
@@ -58,6 +61,8 @@ QUALIFIED_NAME_START={ALPHA}
|
||||
QUALIFIED_NAME_CHAR={ALPHA}|{DIGIT}|[\.]
|
||||
QUALIFIED_NAME={QUALIFIED_NAME_START}{QUALIFIED_NAME_CHAR}*
|
||||
CODE_LINK=\[{QUALIFIED_NAME}\]
|
||||
CODE_FENCE_START=("```" | "~~~").*
|
||||
CODE_FENCE_END=("```" | "~~~")
|
||||
|
||||
%%
|
||||
|
||||
@@ -143,6 +148,11 @@ CODE_LINK=\[{QUALIFIED_NAME}\]
|
||||
return KDocTokens.MARKDOWN_INLINE_LINK;
|
||||
}
|
||||
|
||||
{CODE_FENCE_START} {
|
||||
yybegin(CODE_BLOCK_LINE_BEGINNING);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
|
||||
/* We're only interested in parsing links that can become code references,
|
||||
meaning they contain only identifier characters and characters that can be
|
||||
used in type declarations. No brackets, backticks, asterisks or anything like that.
|
||||
@@ -155,4 +165,47 @@ CODE_LINK=\[{QUALIFIED_NAME}\]
|
||||
return KDocTokens.TEXT; }
|
||||
}
|
||||
|
||||
<CODE_BLOCK_LINE_BEGINNING> {
|
||||
"*"+ {
|
||||
yybegin(CODE_BLOCK_CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
}
|
||||
|
||||
<CODE_BLOCK_LINE_BEGINNING, CODE_BLOCK_CONTENTS_BEGINNING> {
|
||||
{CODE_FENCE_END} / [ \t\f]* [\n] [ \t\f]* {
|
||||
// Code fence end
|
||||
yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
|
||||
{WHITE_SPACE_CHAR}+ {
|
||||
if (yytextContainLineBreaks()) {
|
||||
yybegin(CODE_BLOCK_LINE_BEGINNING);
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
|
||||
. {
|
||||
yybegin(CODE_BLOCK);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
<CODE_BLOCK_LINE_BEGINNING, CODE_BLOCK_CONTENTS_BEGINNING, CODE_BLOCK> {
|
||||
|
||||
{WHITE_SPACE_CHAR}+ {
|
||||
if (yytextContainLineBreaks()) {
|
||||
yybegin(CODE_BLOCK_LINE_BEGINNING);
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
. {
|
||||
yybegin(CODE_BLOCK);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
. { return TokenType.BAD_CHARACTER; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* The following code was generated by JFlex 1.4.3 on 12/9/15 7:45 PM */
|
||||
/* The following code was generated by JFlex 1.4.3 on 4/5/16 7:39 PM */
|
||||
|
||||
package org.jetbrains.kotlin.kdoc.lexer;
|
||||
|
||||
@@ -6,25 +6,29 @@ import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import java.lang.Character;
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 12/9/15 7:45 PM from the specification file
|
||||
* <tt>/home/user/projects/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
|
||||
* on 4/5/16 7:39 PM from the specification file
|
||||
* <tt>/Users/yole/jetbrains/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
|
||||
*/
|
||||
class _KDocLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
private static final int ZZ_BUFFERSIZE = 16384;
|
||||
|
||||
/** lexical states */
|
||||
public static final int CODE_BLOCK_CONTENTS_BEGINNING = 16;
|
||||
public static final int TAG_TEXT_BEGINNING = 8;
|
||||
public static final int CODE_BLOCK = 12;
|
||||
public static final int CODE_BLOCK_LINE_BEGINNING = 14;
|
||||
public static final int CONTENTS_BEGINNING = 4;
|
||||
public static final int LINE_BEGINNING = 2;
|
||||
public static final int CONTENTS = 10;
|
||||
public static final int YYINITIAL = 0;
|
||||
public static final int TAG_TEXT_BEGINNING = 8;
|
||||
public static final int LINE_BEGINNING = 2;
|
||||
public static final int TAG_BEGINNING = 6;
|
||||
|
||||
/**
|
||||
@@ -34,92 +38,75 @@ class _KDocLexer implements FlexLexer {
|
||||
* l is of the form l = 2*k, k a non negative integer
|
||||
*/
|
||||
private static final int ZZ_LEXSTATE[] = {
|
||||
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5
|
||||
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
|
||||
8, 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
"\11\0\1\1\1\12\1\0\2\1\22\0\1\1\3\0\1\3\3\0"+
|
||||
"\1\14\1\15\1\10\3\0\1\4\1\7\12\2\6\0\1\11\32\3"+
|
||||
"\1\5\1\13\1\6\1\0\1\3\1\0\32\3\47\0\4\3\4\0"+
|
||||
"\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0\37\3\1\0"+
|
||||
"\u01ca\3\4\0\14\3\16\0\5\3\7\0\1\3\1\0\1\3\201\0"+
|
||||
"\5\3\1\0\2\3\2\0\4\3\10\0\1\3\1\0\3\3\1\0"+
|
||||
"\1\3\1\0\24\3\1\0\123\3\1\0\213\3\10\0\236\3\11\0"+
|
||||
"\46\3\2\0\1\3\7\0\47\3\110\0\33\3\5\0\3\3\30\0"+
|
||||
"\1\3\24\0\53\3\43\0\2\3\1\0\143\3\1\0\1\3\17\0"+
|
||||
"\2\3\7\0\2\3\12\0\3\3\2\0\1\3\20\0\1\3\1\0"+
|
||||
"\36\3\35\0\131\3\13\0\1\3\30\0\41\3\11\0\2\3\4\0"+
|
||||
"\1\3\5\0\26\3\4\0\1\3\11\0\1\3\3\0\1\3\27\0"+
|
||||
"\31\3\253\0\66\3\3\0\1\3\22\0\1\3\7\0\12\3\17\0"+
|
||||
"\7\3\1\0\7\3\5\0\10\3\2\0\2\3\2\0\26\3\1\0"+
|
||||
"\7\3\1\0\1\3\3\0\4\3\3\0\1\3\20\0\1\3\15\0"+
|
||||
"\2\3\1\0\3\3\16\0\4\3\7\0\1\3\11\0\6\3\4\0"+
|
||||
"\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\2\3\1\0"+
|
||||
"\2\3\37\0\4\3\1\0\1\3\23\0\3\3\20\0\11\3\1\0"+
|
||||
"\3\3\1\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3\3\0"+
|
||||
"\1\3\22\0\1\3\17\0\2\3\17\0\1\3\23\0\10\3\2\0"+
|
||||
"\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3\3\0"+
|
||||
"\1\3\36\0\2\3\1\0\3\3\17\0\1\3\21\0\1\3\1\0"+
|
||||
"\6\3\3\0\3\3\1\0\4\3\3\0\2\3\1\0\1\3\1\0"+
|
||||
"\2\3\3\0\2\3\3\0\3\3\3\0\14\3\26\0\1\3\50\0"+
|
||||
"\1\3\13\0\10\3\1\0\3\3\1\0\27\3\1\0\12\3\1\0"+
|
||||
"\5\3\3\0\1\3\32\0\2\3\6\0\2\3\43\0\10\3\1\0"+
|
||||
"\3\3\1\0\27\3\1\0\12\3\1\0\5\3\3\0\1\3\40\0"+
|
||||
"\1\3\1\0\2\3\17\0\2\3\22\0\10\3\1\0\3\3\1\0"+
|
||||
"\51\3\2\0\1\3\20\0\1\3\21\0\2\3\30\0\6\3\5\0"+
|
||||
"\22\3\3\0\30\3\1\0\11\3\1\0\1\3\2\0\7\3\72\0"+
|
||||
"\60\3\1\0\2\3\13\0\10\3\72\0\2\3\1\0\1\3\2\0"+
|
||||
"\2\3\1\0\1\3\2\0\1\3\6\0\4\3\1\0\7\3\1\0"+
|
||||
"\3\3\1\0\1\3\1\0\1\3\2\0\2\3\1\0\4\3\1\0"+
|
||||
"\2\3\11\0\1\3\2\0\5\3\1\0\1\3\25\0\2\3\42\0"+
|
||||
"\1\3\77\0\10\3\1\0\44\3\33\0\5\3\163\0\53\3\24\0"+
|
||||
"\1\3\20\0\6\3\4\0\4\3\3\0\1\3\3\0\2\3\7\0"+
|
||||
"\3\3\4\0\15\3\14\0\1\3\21\0\46\3\12\0\53\3\1\0"+
|
||||
"\1\3\3\0\u0149\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0"+
|
||||
"\4\3\2\0\51\3\1\0\4\3\2\0\41\3\1\0\4\3\2\0"+
|
||||
"\7\3\1\0\1\3\1\0\4\3\2\0\17\3\1\0\71\3\1\0"+
|
||||
"\4\3\2\0\103\3\45\0\20\3\20\0\125\3\14\0\u026c\3\2\0"+
|
||||
"\21\3\1\0\32\3\5\0\113\3\3\0\3\3\17\0\15\3\1\0"+
|
||||
"\4\3\16\0\22\3\16\0\22\3\16\0\15\3\1\0\3\3\17\0"+
|
||||
"\64\3\43\0\1\3\3\0\2\3\103\0\130\3\10\0\51\3\1\0"+
|
||||
"\1\3\5\0\106\3\12\0\35\3\63\0\36\3\2\0\5\3\13\0"+
|
||||
"\54\3\25\0\7\3\70\0\27\3\11\0\65\3\122\0\1\3\135\0"+
|
||||
"\57\3\21\0\7\3\67\0\36\3\15\0\2\3\20\0\46\3\32\0"+
|
||||
"\44\3\51\0\3\3\12\0\44\3\153\0\4\3\1\0\4\3\16\0"+
|
||||
"\300\3\100\0\u0116\3\2\0\6\3\2\0\46\3\2\0\6\3\2\0"+
|
||||
"\10\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\37\3\2\0"+
|
||||
"\65\3\1\0\7\3\1\0\1\3\3\0\3\3\1\0\7\3\3\0"+
|
||||
"\4\3\2\0\6\3\4\0\15\3\5\0\3\3\1\0\7\3\102\0"+
|
||||
"\2\3\23\0\1\3\34\0\1\3\15\0\1\3\20\0\15\3\3\0"+
|
||||
"\32\3\110\0\1\3\4\0\1\3\2\0\12\3\1\0\1\3\3\0"+
|
||||
"\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1\0\4\3\1\0"+
|
||||
"\13\3\2\0\4\3\5\0\5\3\4\0\1\3\21\0\51\3\u0a77\0"+
|
||||
"\57\3\1\0\57\3\1\0\205\3\6\0\4\3\21\0\46\3\12\0"+
|
||||
"\66\3\11\0\1\3\20\0\27\3\11\0\7\3\1\0\7\3\1\0"+
|
||||
"\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0"+
|
||||
"\7\3\120\0\1\3\u01d5\0\3\3\31\0\11\3\7\0\5\3\2\0"+
|
||||
"\5\3\4\0\126\3\6\0\3\3\1\0\132\3\1\0\4\3\5\0"+
|
||||
"\51\3\3\0\136\3\21\0\33\3\65\0\20\3\u0200\0\u19b6\3\112\0"+
|
||||
"\u51cc\3\64\0\u048d\3\103\0\56\3\2\0\u010d\3\3\0\20\3\12\0"+
|
||||
"\2\3\24\0\57\3\20\0\31\3\10\0\120\3\47\0\11\3\2\0"+
|
||||
"\147\3\2\0\4\3\1\0\2\3\16\0\12\3\120\0\10\3\1\0"+
|
||||
"\3\3\1\0\4\3\1\0\27\3\25\0\1\3\7\0\64\3\16\0"+
|
||||
"\62\3\76\0\6\3\3\0\1\3\16\0\34\3\12\0\27\3\31\0"+
|
||||
"\35\3\7\0\57\3\34\0\1\3\60\0\51\3\27\0\3\3\1\0"+
|
||||
"\10\3\24\0\27\3\3\0\1\3\5\0\60\3\1\0\1\3\3\0"+
|
||||
"\2\3\2\0\5\3\2\0\1\3\1\0\1\3\30\0\3\3\43\0"+
|
||||
"\6\3\2\0\6\3\2\0\6\3\11\0\7\3\1\0\7\3\221\0"+
|
||||
"\43\3\35\0\u2ba4\3\14\0\27\3\4\0\61\3\u2104\0\u012e\3\2\0"+
|
||||
"\76\3\2\0\152\3\46\0\7\3\14\0\5\3\5\0\1\3\1\0"+
|
||||
"\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0"+
|
||||
"\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0\66\3\50\0"+
|
||||
"\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0\5\3\1\0"+
|
||||
"\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0\32\3\13\0"+
|
||||
"\131\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0"+
|
||||
"\2\3\3\0\2\3\31\0";
|
||||
"\11\0\1\1\1\11\1\0\1\1\23\0\1\1\3\0\1\3\3\0"+
|
||||
"\1\16\1\17\1\13\3\0\1\4\1\12\12\2\6\0\1\14\32\3"+
|
||||
"\1\5\1\15\1\6\1\0\1\3\1\7\32\3\3\0\1\10\43\0"+
|
||||
"\4\3\4\0\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0"+
|
||||
"\37\3\1\0\u013f\3\31\0\162\3\4\0\14\3\16\0\5\3\11\0"+
|
||||
"\1\3\213\0\1\3\13\0\1\3\1\0\3\3\1\0\1\3\1\0"+
|
||||
"\24\3\1\0\54\3\1\0\46\3\1\0\5\3\4\0\202\3\10\0"+
|
||||
"\105\3\1\0\46\3\2\0\2\3\6\0\20\3\41\0\46\3\2\0"+
|
||||
"\1\3\7\0\47\3\110\0\33\3\5\0\3\3\56\0\32\3\5\0"+
|
||||
"\13\3\43\0\2\3\1\0\143\3\1\0\1\3\17\0\2\3\7\0"+
|
||||
"\2\3\12\0\3\3\2\0\1\3\20\0\1\3\1\0\36\3\35\0"+
|
||||
"\3\3\60\0\46\3\13\0\1\3\u0152\0\66\3\3\0\1\3\22\0"+
|
||||
"\1\3\7\0\12\3\43\0\10\3\2\0\2\3\2\0\26\3\1\0"+
|
||||
"\7\3\1\0\1\3\3\0\4\3\3\0\1\3\36\0\2\3\1\0"+
|
||||
"\3\3\16\0\4\3\21\0\6\3\4\0\2\3\2\0\26\3\1\0"+
|
||||
"\7\3\1\0\2\3\1\0\2\3\1\0\2\3\37\0\4\3\1\0"+
|
||||
"\1\3\23\0\3\3\20\0\11\3\1\0\3\3\1\0\26\3\1\0"+
|
||||
"\7\3\1\0\2\3\1\0\5\3\3\0\1\3\22\0\1\3\17\0"+
|
||||
"\2\3\17\0\1\3\23\0\10\3\2\0\2\3\2\0\26\3\1\0"+
|
||||
"\7\3\1\0\2\3\1\0\5\3\3\0\1\3\36\0\2\3\1\0"+
|
||||
"\3\3\17\0\1\3\21\0\1\3\1\0\6\3\3\0\3\3\1\0"+
|
||||
"\4\3\3\0\2\3\1\0\1\3\1\0\2\3\3\0\2\3\3\0"+
|
||||
"\3\3\3\0\10\3\1\0\3\3\77\0\1\3\13\0\10\3\1\0"+
|
||||
"\3\3\1\0\27\3\1\0\12\3\1\0\5\3\46\0\2\3\43\0"+
|
||||
"\10\3\1\0\3\3\1\0\27\3\1\0\12\3\1\0\5\3\3\0"+
|
||||
"\1\3\40\0\1\3\1\0\2\3\43\0\10\3\1\0\3\3\1\0"+
|
||||
"\27\3\1\0\20\3\46\0\2\3\43\0\22\3\3\0\30\3\1\0"+
|
||||
"\11\3\1\0\1\3\2\0\7\3\72\0\60\3\1\0\2\3\13\0"+
|
||||
"\10\3\72\0\2\3\1\0\1\3\2\0\2\3\1\0\1\3\2\0"+
|
||||
"\1\3\6\0\4\3\1\0\7\3\1\0\3\3\1\0\1\3\1\0"+
|
||||
"\1\3\2\0\2\3\1\0\4\3\1\0\2\3\11\0\1\3\2\0"+
|
||||
"\5\3\1\0\1\3\25\0\2\3\42\0\1\3\77\0\10\3\1\0"+
|
||||
"\42\3\35\0\4\3\164\0\42\3\1\0\5\3\1\0\2\3\45\0"+
|
||||
"\6\3\112\0\46\3\12\0\51\3\7\0\132\3\5\0\104\3\5\0"+
|
||||
"\122\3\6\0\7\3\1\0\77\3\1\0\1\3\1\0\4\3\2\0"+
|
||||
"\7\3\1\0\1\3\1\0\4\3\2\0\47\3\1\0\1\3\1\0"+
|
||||
"\4\3\2\0\37\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0"+
|
||||
"\1\3\1\0\4\3\2\0\7\3\1\0\7\3\1\0\27\3\1\0"+
|
||||
"\37\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0\47\3\1\0"+
|
||||
"\23\3\105\0\125\3\14\0\u026c\3\2\0\10\3\12\0\32\3\5\0"+
|
||||
"\113\3\3\0\3\3\17\0\15\3\1\0\4\3\16\0\22\3\16\0"+
|
||||
"\22\3\16\0\15\3\1\0\3\3\17\0\64\3\43\0\1\3\3\0"+
|
||||
"\2\3\103\0\130\3\10\0\51\3\127\0\35\3\63\0\36\3\2\0"+
|
||||
"\5\3\u038b\0\154\3\224\0\234\3\4\0\132\3\6\0\26\3\2\0"+
|
||||
"\6\3\2\0\46\3\2\0\6\3\2\0\10\3\1\0\1\3\1\0"+
|
||||
"\1\3\1\0\1\3\1\0\37\3\2\0\65\3\1\0\7\3\1\0"+
|
||||
"\1\3\3\0\3\3\1\0\7\3\3\0\4\3\2\0\6\3\4\0"+
|
||||
"\15\3\5\0\3\3\1\0\7\3\102\0\2\3\23\0\1\3\34\0"+
|
||||
"\1\3\15\0\1\3\40\0\22\3\120\0\1\3\4\0\1\3\2\0"+
|
||||
"\12\3\1\0\1\3\3\0\5\3\6\0\1\3\1\0\1\3\1\0"+
|
||||
"\1\3\1\0\4\3\1\0\3\3\1\0\7\3\3\0\3\3\5\0"+
|
||||
"\5\3\26\0\44\3\u0e81\0\3\3\31\0\11\3\7\0\5\3\2\0"+
|
||||
"\5\3\4\0\126\3\6\0\3\3\1\0\137\3\5\0\50\3\4\0"+
|
||||
"\136\3\21\0\30\3\70\0\20\3\u0200\0\u19b6\3\112\0\u51a6\3\132\0"+
|
||||
"\u048d\3\u0773\0\u2ba4\3\u215c\0\u012e\3\2\0\73\3\225\0\7\3\14\0"+
|
||||
"\5\3\5\0\1\3\1\0\12\3\1\0\15\3\1\0\5\3\1\0"+
|
||||
"\1\3\1\0\2\3\1\0\2\3\1\0\154\3\41\0\u016b\3\22\0"+
|
||||
"\100\3\2\0\66\3\50\0\15\3\66\0\2\3\30\0\3\3\31\0"+
|
||||
"\1\3\6\0\5\3\1\0\207\3\7\0\1\3\34\0\32\3\4\0"+
|
||||
"\1\3\1\0\32\3\12\0\132\3\3\0\6\3\2\0\6\3\2\0"+
|
||||
"\6\3\2\0\3\3\3\0\2\3\3\0\2\3\31\0";
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
@@ -132,12 +119,13 @@ class _KDocLexer implements FlexLexer {
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
|
||||
private static final String ZZ_ACTION_PACKED_0 =
|
||||
"\6\0\3\1\1\2\1\3\1\2\1\4\3\2\1\5"+
|
||||
"\1\6\1\7\3\5\1\0\1\10\4\0\1\11\1\12"+
|
||||
"\2\0\1\13\2\0\1\14\1\15\2\16\1\0\2\17";
|
||||
"\11\0\3\1\1\2\1\3\3\2\1\4\3\2\1\5"+
|
||||
"\1\6\1\7\3\5\1\10\1\11\3\10\1\12\1\0"+
|
||||
"\1\13\6\0\1\14\1\15\4\0\1\16\2\0\1\17"+
|
||||
"\1\20\1\21\1\0\2\22\1\0\1\23\1\24\1\23";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[42];
|
||||
int [] result = new int[60];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -162,15 +150,17 @@ class _KDocLexer implements FlexLexer {
|
||||
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
|
||||
|
||||
private static final String ZZ_ROWMAP_PACKED_0 =
|
||||
"\0\0\0\16\0\34\0\52\0\70\0\106\0\124\0\142"+
|
||||
"\0\160\0\124\0\176\0\214\0\232\0\250\0\160\0\266"+
|
||||
"\0\124\0\304\0\322\0\340\0\160\0\356\0\374\0\124"+
|
||||
"\0\160\0\u010a\0\u0118\0\u0126\0\124\0\u0134\0\u0142\0\u0150"+
|
||||
"\0\124\0\u015e\0\u016c\0\124\0\124\0\u010a\0\u0126\0\u017a"+
|
||||
"\0\u010a\0\124";
|
||||
"\0\0\0\20\0\40\0\60\0\100\0\120\0\140\0\160"+
|
||||
"\0\200\0\220\0\240\0\260\0\220\0\300\0\320\0\340"+
|
||||
"\0\360\0\u0100\0\u0110\0\260\0\u0120\0\220\0\u0130\0\u0140"+
|
||||
"\0\u0150\0\260\0\u0160\0\220\0\u0170\0\260\0\u0180\0\u0190"+
|
||||
"\0\u01a0\0\u01b0\0\220\0\260\0\u01c0\0\u01d0\0\u01e0\0\u01f0"+
|
||||
"\0\u0200\0\220\0\u0210\0\u0220\0\u0230\0\u0240\0\u0250\0\220"+
|
||||
"\0\u0260\0\u0270\0\u0280\0\220\0\220\0\u0290\0\u01c0\0\u01e0"+
|
||||
"\0\u02a0\0\u01c0\0\u02b0\0\220";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[42];
|
||||
int [] result = new int[60];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -193,25 +183,33 @@ class _KDocLexer implements FlexLexer {
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\7\7\1\10\1\11\1\7\1\0\3\7\1\12\1\13"+
|
||||
"\3\12\1\14\2\12\1\15\1\12\1\13\1\16\3\12"+
|
||||
"\1\13\3\12\1\14\2\12\1\17\1\20\1\13\1\16"+
|
||||
"\2\12\1\21\1\22\1\21\1\23\1\21\1\24\2\21"+
|
||||
"\1\25\1\21\1\22\4\21\1\22\3\21\1\26\2\21"+
|
||||
"\1\25\1\21\1\22\3\21\1\12\1\13\3\12\1\14"+
|
||||
"\2\12\1\17\1\12\1\13\1\16\2\12\26\0\1\27"+
|
||||
"\14\0\1\30\1\31\6\0\1\13\10\0\1\13\3\0"+
|
||||
"\3\32\1\33\1\32\1\0\1\34\7\32\7\0\1\30"+
|
||||
"\1\15\12\0\2\35\12\0\1\36\13\0\1\22\10\0"+
|
||||
"\1\22\5\0\3\23\14\0\1\37\15\0\1\40\22\0"+
|
||||
"\1\41\5\0\5\32\1\0\1\34\11\32\3\33\1\0"+
|
||||
"\1\42\14\32\1\0\1\34\5\32\1\43\1\32\2\0"+
|
||||
"\2\36\14\0\3\37\1\0\1\44\11\0\3\40\1\0"+
|
||||
"\1\45\7\0\5\46\1\0\1\47\5\46\1\43\1\46"+
|
||||
"\5\43\1\50\7\43\1\51\15\50\1\52";
|
||||
"\11\12\1\0\1\13\1\14\4\12\1\15\1\16\3\15"+
|
||||
"\1\17\1\15\1\20\1\21\1\16\1\15\1\22\1\15"+
|
||||
"\1\23\3\15\1\16\3\15\1\17\1\15\1\20\1\21"+
|
||||
"\1\16\1\15\1\24\1\25\1\23\2\15\1\26\1\27"+
|
||||
"\1\26\1\30\1\26\1\31\3\26\1\27\1\26\1\32"+
|
||||
"\5\26\1\27\3\26\1\33\3\26\1\27\1\26\1\32"+
|
||||
"\4\26\1\15\1\16\3\15\1\17\1\15\1\20\1\21"+
|
||||
"\1\16\1\15\1\24\1\15\1\23\2\15\1\34\1\35"+
|
||||
"\7\34\1\35\1\34\1\36\5\34\1\35\5\34\1\37"+
|
||||
"\1\40\1\35\1\34\1\41\5\34\1\35\5\34\1\37"+
|
||||
"\1\40\1\35\1\34\1\36\4\34\33\0\1\42\16\0"+
|
||||
"\1\43\1\44\5\0\1\16\7\0\1\16\6\0\3\45"+
|
||||
"\1\46\1\45\1\0\1\47\11\45\7\0\1\50\20\0"+
|
||||
"\1\51\21\0\1\43\1\22\11\0\2\52\14\0\1\53"+
|
||||
"\15\0\1\27\7\0\1\27\10\0\3\30\16\0\1\54"+
|
||||
"\17\0\1\55\15\0\1\35\7\0\1\35\15\0\1\56"+
|
||||
"\20\0\1\57\21\0\1\43\1\41\17\0\1\60\4\0"+
|
||||
"\5\45\1\0\1\47\13\45\3\46\1\0\1\61\16\45"+
|
||||
"\1\0\1\47\7\45\1\62\1\45\7\0\1\63\20\0"+
|
||||
"\1\63\11\0\2\53\16\0\3\54\1\0\1\64\13\0"+
|
||||
"\3\55\1\0\1\65\20\0\1\66\20\0\1\66\7\0"+
|
||||
"\5\67\1\0\1\70\7\67\1\62\1\67\5\62\1\71"+
|
||||
"\11\62\1\72\11\63\1\0\6\63\1\0\1\66\7\0"+
|
||||
"\1\73\6\0\17\71\1\74\1\0\1\73\16\0";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[392];
|
||||
int [] result = new int[704];
|
||||
int offset = 0;
|
||||
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -252,12 +250,12 @@ class _KDocLexer implements FlexLexer {
|
||||
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
|
||||
|
||||
private static final String ZZ_ATTRIBUTE_PACKED_0 =
|
||||
"\6\0\1\11\2\1\1\11\6\1\1\11\5\1\1\0"+
|
||||
"\1\11\4\0\1\11\1\1\2\0\1\11\2\0\2\11"+
|
||||
"\2\1\1\0\1\1\1\11";
|
||||
"\11\0\1\11\2\1\1\11\10\1\1\11\5\1\1\11"+
|
||||
"\5\1\1\0\1\11\6\0\1\11\1\1\4\0\1\11"+
|
||||
"\2\0\1\1\2\11\1\0\2\1\1\0\2\1\1\11";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[42];
|
||||
int [] result = new int[60];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -357,7 +355,7 @@ class _KDocLexer implements FlexLexer {
|
||||
char [] map = new char[0x10000];
|
||||
int i = 0; /* index in packed string */
|
||||
int j = 0; /* index in unpacked array */
|
||||
while (i < 1568) {
|
||||
while (i < 1216) {
|
||||
int count = packed.charAt(i++);
|
||||
char value = packed.charAt(i++);
|
||||
do map[j++] = value; while (--count > 0);
|
||||
@@ -580,12 +578,82 @@ class _KDocLexer implements FlexLexer {
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 10:
|
||||
case 15:
|
||||
{ yybegin(CODE_BLOCK_LINE_BEGINNING);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 21: break;
|
||||
case 13:
|
||||
{ KDocKnownTag tag = KDocKnownTag.findByTagName(zzBuffer.subSequence(zzStartRead, zzMarkedPos));
|
||||
yybegin(tag != null && tag.isReferenceRequired() ? TAG_BEGINNING : TAG_TEXT_BEGINNING);
|
||||
return KDocTokens.TAG_NAME;
|
||||
}
|
||||
case 16: break;
|
||||
case 22: break;
|
||||
case 10:
|
||||
{ yybegin(CODE_BLOCK_CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
case 23: break;
|
||||
case 1:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 24: break;
|
||||
case 14:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.START;
|
||||
}
|
||||
case 25: break;
|
||||
case 2:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 26: break;
|
||||
case 9:
|
||||
{ if (yytextContainLineBreaks()) {
|
||||
yybegin(CODE_BLOCK_LINE_BEGINNING);
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 27: break;
|
||||
case 20:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 3;
|
||||
{ // Code fence end
|
||||
yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 28: break;
|
||||
case 19:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_INLINE_LINK;
|
||||
}
|
||||
case 29: break;
|
||||
case 5:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 30: break;
|
||||
case 12:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
|
||||
}
|
||||
case 31: break;
|
||||
case 16:
|
||||
{ yybegin(TAG_TEXT_BEGINNING);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 32: break;
|
||||
case 4:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
case 33: break;
|
||||
case 8:
|
||||
{ yybegin(CODE_BLOCK);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 34: break;
|
||||
case 3:
|
||||
{ if (yytextContainLineBreaks()) {
|
||||
yybegin(LINE_BEGINNING);
|
||||
@@ -595,75 +663,36 @@ class _KDocLexer implements FlexLexer {
|
||||
return KDocTokens.TEXT; // internal white space
|
||||
}
|
||||
}
|
||||
case 17: break;
|
||||
case 11:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.START;
|
||||
}
|
||||
case 18: break;
|
||||
case 15:
|
||||
case 35: break;
|
||||
case 18:
|
||||
// lookahead expression with fixed lookahead length
|
||||
yypushback(1);
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_INLINE_LINK;
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 19: break;
|
||||
case 8:
|
||||
case 36: break;
|
||||
case 17:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 37: break;
|
||||
case 11:
|
||||
{ if (isLastToken()) return KDocTokens.END;
|
||||
else return KDocTokens.TEXT;
|
||||
}
|
||||
case 20: break;
|
||||
case 5:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 21: break;
|
||||
case 12:
|
||||
{ yybegin(TAG_TEXT_BEGINNING);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 22: break;
|
||||
case 38: break;
|
||||
case 7:
|
||||
{ yybegin(TAG_TEXT_BEGINNING);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 23: break;
|
||||
case 39: break;
|
||||
case 6:
|
||||
{ if (yytextContainLineBreaks()) {
|
||||
yybegin(LINE_BEGINNING);
|
||||
}
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
case 24: break;
|
||||
case 14:
|
||||
// lookahead expression with fixed lookahead length
|
||||
yypushback(1);
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 25: break;
|
||||
case 13:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_LINK;
|
||||
}
|
||||
case 26: break;
|
||||
case 1:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 27: break;
|
||||
case 9:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
|
||||
}
|
||||
case 28: break;
|
||||
case 2:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 29: break;
|
||||
case 4:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
case 30: break;
|
||||
case 40: break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.intellij.util.containers.Stack;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 12/9/15 7:45 PM from the specification file
|
||||
* <tt>/home/user/projects/kotlin/compiler/frontend/src/org/jetbrains/kotlin/lexer/Kotlin.flex</tt>
|
||||
@@ -33,14 +33,14 @@ class _JetLexer implements FlexLexer {
|
||||
* at the beginning of a line
|
||||
* l is of the form l = 2*k, k a non negative integer
|
||||
*/
|
||||
private static final int ZZ_LEXSTATE[] = {
|
||||
private static final int ZZ_LEXSTATE[] = {
|
||||
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
"\11\0\1\3\1\7\1\0\1\3\23\0\1\3\1\13\1\27\1\12"+
|
||||
"\1\10\1\67\1\65\1\24\1\73\1\74\1\36\1\62\1\76\1\23"+
|
||||
"\1\20\1\11\1\14\11\1\1\70\1\75\1\63\1\60\1\64\1\61"+
|
||||
@@ -128,12 +128,12 @@ class _JetLexer implements FlexLexer {
|
||||
"\32\4\13\0\131\4\3\0\6\4\2\0\6\4\2\0\6\4\2\0"+
|
||||
"\3\4\43\0";
|
||||
|
||||
/**
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Translates DFA states to action switch labels.
|
||||
*/
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
@@ -181,7 +181,7 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Translates a state to a row index in the transition table
|
||||
*/
|
||||
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
|
||||
@@ -236,7 +236,7 @@ class _JetLexer implements FlexLexer {
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* The transition table of the DFA
|
||||
*/
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
@@ -618,7 +618,7 @@ class _JetLexer implements FlexLexer {
|
||||
|
||||
private final Stack<State> states = new Stack<State>();
|
||||
private int lBraceCount;
|
||||
|
||||
|
||||
private int commentStart;
|
||||
private int commentDepth;
|
||||
|
||||
@@ -656,7 +656,7 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Unpacks the compressed character translation table.
|
||||
*
|
||||
* @param packed the packed character translation table
|
||||
|
||||
@@ -564,7 +564,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
* : "get"
|
||||
* : "set"
|
||||
* : "param"
|
||||
* : "sparam"
|
||||
* : "setparam"
|
||||
* ;
|
||||
*/
|
||||
private boolean parseAnnotationOrList(AnnotationParsingMode mode) {
|
||||
|
||||
@@ -62,7 +62,7 @@ open class KtClass : KtClassOrObject {
|
||||
}
|
||||
|
||||
protected fun getQualifiedName(): String? {
|
||||
val stub = getStub()
|
||||
val stub = stub
|
||||
if (stub != null) {
|
||||
val fqName = stub.getFqName()
|
||||
return fqName?.asString()
|
||||
@@ -71,12 +71,12 @@ open class KtClass : KtClassOrObject {
|
||||
val parts = ArrayList<String>()
|
||||
var current: KtClassOrObject? = this
|
||||
while (current != null) {
|
||||
parts.add(current.getName()!!)
|
||||
parts.add(current.name!!)
|
||||
current = PsiTreeUtil.getParentOfType<KtClassOrObject>(current, KtClassOrObject::class.java)
|
||||
}
|
||||
val file = getContainingFile()
|
||||
val file = containingFile
|
||||
if (file !is KtFile) return null
|
||||
val fileQualifiedName = file.getPackageFqName().asString()
|
||||
val fileQualifiedName = file.packageFqName.asString()
|
||||
if (!fileQualifiedName.isEmpty()) {
|
||||
parts.add(fileQualifiedName)
|
||||
}
|
||||
|
||||
@@ -34,24 +34,28 @@ abstract class KtClassOrObject :
|
||||
constructor(stub: KotlinClassOrObjectStub<out KtClassOrObject>, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
|
||||
|
||||
fun getSuperTypeList(): KtSuperTypeList? = getStubOrPsiChild(KtStubElementTypes.SUPER_TYPE_LIST)
|
||||
open fun getSuperTypeListEntries(): List<KtSuperTypeListEntry> = getSuperTypeList()?.getEntries().orEmpty()
|
||||
open fun getSuperTypeListEntries(): List<KtSuperTypeListEntry> = getSuperTypeList()?.entries.orEmpty()
|
||||
|
||||
fun addSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry): KtSuperTypeListEntry {
|
||||
getSuperTypeList()?.let {
|
||||
val single = it.entries.singleOrNull()
|
||||
if (single != null && single.typeReference?.typeElement == null) {
|
||||
return single.replace(superTypeListEntry) as KtSuperTypeListEntry
|
||||
}
|
||||
return EditCommaSeparatedListHelper.addItem(it, getSuperTypeListEntries(), superTypeListEntry)
|
||||
}
|
||||
|
||||
val psiFactory = KtPsiFactory(this)
|
||||
val specifierListToAdd = psiFactory.createSuperTypeCallEntry("A()").replace(superTypeListEntry).getParent()
|
||||
val specifierListToAdd = psiFactory.createSuperTypeCallEntry("A()").replace(superTypeListEntry).parent
|
||||
val colon = addBefore(psiFactory.createColon(), getBody())
|
||||
return (addAfter(specifierListToAdd, colon) as KtSuperTypeList).getEntries().first()
|
||||
return (addAfter(specifierListToAdd, colon) as KtSuperTypeList).entries.first()
|
||||
}
|
||||
|
||||
fun removeSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry) {
|
||||
val specifierList = getSuperTypeList() ?: return
|
||||
assert(superTypeListEntry.getParent() === specifierList)
|
||||
assert(superTypeListEntry.parent === specifierList)
|
||||
|
||||
if (specifierList.getEntries().size > 1) {
|
||||
if (specifierList.entries.size > 1) {
|
||||
EditCommaSeparatedListHelper.removeItem<KtElement>(superTypeListEntry)
|
||||
}
|
||||
else {
|
||||
@@ -63,35 +67,35 @@ abstract class KtClassOrObject :
|
||||
|
||||
fun getBody(): KtClassBody? = getStubOrPsiChild(KtStubElementTypes.CLASS_BODY)
|
||||
|
||||
fun addDeclaration(declaration: KtDeclaration): KtDeclaration {
|
||||
inline fun <reified T: KtDeclaration> addDeclaration(declaration: T): T {
|
||||
val body = getOrCreateBody()
|
||||
val anchor = PsiTreeUtil.skipSiblingsBackward(body.rBrace ?: body.getLastChild()!!, PsiWhiteSpace::class.java)
|
||||
return body.addAfter(declaration, anchor) as KtDeclaration
|
||||
val anchor = PsiTreeUtil.skipSiblingsBackward(body.rBrace ?: body.lastChild!!, PsiWhiteSpace::class.java)
|
||||
return body.addAfter(declaration, anchor) as T
|
||||
}
|
||||
|
||||
fun addDeclarationAfter(declaration: KtDeclaration, anchor: PsiElement?): KtDeclaration {
|
||||
val anchorBefore = anchor ?: getDeclarations().lastOrNull() ?: return addDeclaration(declaration)
|
||||
return getOrCreateBody().addAfter(declaration, anchorBefore) as KtDeclaration
|
||||
inline fun <reified T: KtDeclaration> addDeclarationAfter(declaration: T, anchor: PsiElement?): T {
|
||||
val anchorBefore = anchor ?: declarations.lastOrNull() ?: return addDeclaration(declaration)
|
||||
return getOrCreateBody().addAfter(declaration, anchorBefore) as T
|
||||
}
|
||||
|
||||
fun addDeclarationBefore(declaration: KtDeclaration, anchor: PsiElement?): KtDeclaration {
|
||||
val anchorAfter = anchor ?: getDeclarations().firstOrNull() ?: return addDeclaration(declaration)
|
||||
return getOrCreateBody().addBefore(declaration, anchorAfter) as KtDeclaration
|
||||
inline fun <reified T: KtDeclaration> addDeclarationBefore(declaration: T, anchor: PsiElement?): T {
|
||||
val anchorAfter = anchor ?: declarations.firstOrNull() ?: return addDeclaration(declaration)
|
||||
return getOrCreateBody().addBefore(declaration, anchorAfter) as T
|
||||
}
|
||||
|
||||
fun isTopLevel(): Boolean = getStub()?.isTopLevel() ?: (getParent() is KtFile)
|
||||
fun isTopLevel(): Boolean = stub?.isTopLevel() ?: (parent is KtFile)
|
||||
|
||||
fun isLocal(): Boolean = getStub()?.isLocal() ?: KtPsiUtil.isLocal(this)
|
||||
fun isLocal(): Boolean = stub?.isLocal() ?: KtPsiUtil.isLocal(this)
|
||||
|
||||
override fun getDeclarations() = getBody()?.getDeclarations().orEmpty()
|
||||
override fun getDeclarations() = getBody()?.declarations.orEmpty()
|
||||
|
||||
override fun getPresentation(): ItemPresentation? = ItemPresentationProviders.getItemPresentation(this)
|
||||
|
||||
fun getPrimaryConstructor(): KtPrimaryConstructor? = getStubOrPsiChild(KtStubElementTypes.PRIMARY_CONSTRUCTOR)
|
||||
|
||||
fun getPrimaryConstructorModifierList(): KtModifierList? = getPrimaryConstructor()?.getModifierList()
|
||||
fun getPrimaryConstructorParameterList(): KtParameterList? = getPrimaryConstructor()?.getValueParameterList()
|
||||
fun getPrimaryConstructorParameters(): List<KtParameter> = getPrimaryConstructorParameterList()?.getParameters().orEmpty()
|
||||
fun getPrimaryConstructorModifierList(): KtModifierList? = getPrimaryConstructor()?.modifierList
|
||||
fun getPrimaryConstructorParameterList(): KtParameterList? = getPrimaryConstructor()?.valueParameterList
|
||||
fun getPrimaryConstructorParameters(): List<KtParameter> = getPrimaryConstructorParameterList()?.parameters.orEmpty()
|
||||
|
||||
fun hasExplicitPrimaryConstructor(): Boolean = getPrimaryConstructor() != null
|
||||
|
||||
@@ -106,7 +110,7 @@ abstract class KtClassOrObject :
|
||||
CheckUtil.checkWritable(this);
|
||||
|
||||
val file = getContainingKtFile();
|
||||
if (!isTopLevel() || file.getDeclarations().size > 1) {
|
||||
if (!isTopLevel() || file.declarations.size > 1) {
|
||||
super.delete()
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -99,13 +99,25 @@ abstract class KtCodeFragment(
|
||||
|
||||
override fun addImportsFromString(imports: String?) {
|
||||
if (imports == null || imports.isEmpty()) return
|
||||
this.imports.addAll(imports.split(IMPORT_SEPARATOR))
|
||||
|
||||
imports.split(IMPORT_SEPARATOR).forEach {
|
||||
addImport(it)
|
||||
}
|
||||
|
||||
// we need this code to force re-highlighting, otherwise it does not work by some reason
|
||||
val tempElement = KtPsiFactory(project).createColon()
|
||||
add(tempElement).delete()
|
||||
}
|
||||
|
||||
fun addImport(import: String) {
|
||||
val contextFile = getContextContainingFile()
|
||||
if (contextFile != null) {
|
||||
if (contextFile.importDirectives.find { it.text == import } == null) {
|
||||
imports.add(import)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun importsAsImportList(): KtImportList? {
|
||||
if (!imports.isEmpty() && context != null) {
|
||||
return KtPsiFactory(this).createAnalyzableFile("imports_for_codeFragment.kt", imports.joinToString("\n"), context).importList
|
||||
@@ -146,7 +158,11 @@ abstract class KtCodeFragment(
|
||||
|
||||
private fun initImports(imports: String?) {
|
||||
if (imports != null && !imports.isEmpty()) {
|
||||
this.imports.addAll(imports.split(IMPORT_SEPARATOR).map { it.check { it.startsWith("import ") } ?: "import $it" })
|
||||
|
||||
val importsWithPrefix = imports.split(IMPORT_SEPARATOR).map { it.check { it.startsWith("import ") } ?: "import ${it.trim()}" }
|
||||
importsWithPrefix.forEach {
|
||||
addImport(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ class KtObjectDeclaration : KtClassOrObject {
|
||||
override fun setName(@NonNls name: String): PsiElement {
|
||||
if (nameIdentifier == null) {
|
||||
val psiFactory = KtPsiFactory(project)
|
||||
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword())
|
||||
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword())
|
||||
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword()!!)
|
||||
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword()!!)
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class KtObjectDeclaration : KtClassOrObject {
|
||||
fun isCompanion(): Boolean = _stub?.isCompanion() ?: hasModifier(KtTokens.COMPANION_KEYWORD)
|
||||
|
||||
override fun getTextOffset(): Int = nameIdentifier?.textRange?.startOffset
|
||||
?: getObjectKeyword().textRange.startOffset
|
||||
?: getObjectKeyword()!!.textRange.startOffset
|
||||
|
||||
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D): R {
|
||||
return visitor.visitObjectDeclaration(this, data)
|
||||
@@ -66,5 +66,5 @@ class KtObjectDeclaration : KtClassOrObject {
|
||||
|
||||
fun isObjectLiteral(): Boolean = _stub?.isObjectLiteral() ?: (parent is KtObjectLiteralExpression)
|
||||
|
||||
fun getObjectKeyword(): PsiElement = findChildByType(KtTokens.OBJECT_KEYWORD)!!
|
||||
fun getObjectKeyword(): PsiElement? = findChildByType(KtTokens.OBJECT_KEYWORD)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public class KtStringTemplateExpression extends KtExpressionImpl implements PsiL
|
||||
|
||||
@Override
|
||||
public PsiLanguageInjectionHost updateText(@NotNull String text) {
|
||||
KtExpression newExpression = new KtPsiFactory(getProject()).createExpressionIfPossible(text);
|
||||
if (newExpression instanceof KtStringTemplateExpression) return (KtStringTemplateExpression) replace(newExpression);
|
||||
return ElementManipulators.handleContentChange(this, text);
|
||||
}
|
||||
|
||||
|
||||
@@ -367,6 +367,9 @@ fun KtStringTemplateExpression.getContentRange(): TextRange {
|
||||
return TextRange(start, if (lastChild.elementType == KtTokens.CLOSING_QUOTE) length - lastChild.textLength else length)
|
||||
}
|
||||
|
||||
val KtStringTemplateExpression.plainContent: String
|
||||
get() = getContentRange().substring(text)
|
||||
|
||||
fun KtStringTemplateExpression.isSingleQuoted(): Boolean
|
||||
= node.firstChildNode.textLength == 1
|
||||
|
||||
@@ -403,6 +406,7 @@ fun KtDeclaration.visibilityModifierType(): KtModifierKeywordToken?
|
||||
= visibilityModifier()?.node?.elementType as KtModifierKeywordToken?
|
||||
|
||||
fun KtStringTemplateExpression.isPlain() = entries.all { it is KtLiteralStringTemplateEntry }
|
||||
fun KtStringTemplateExpression.isPlainWithEscapes() = entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
|
||||
|
||||
val KtDeclaration.containingClassOrObject: KtClassOrObject?
|
||||
get() = (parent as? KtClassBody)?.parent as? KtClassOrObject
|
||||
|
||||
@@ -101,6 +101,9 @@ public interface BindingContext {
|
||||
*/
|
||||
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<KtExpression, Qualifier>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION =
|
||||
new BasicWritableSlice<KtSuperExpression, KotlinType>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
|
||||
new BasicWritableSlice<KtReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
||||
// if 'A' really means 'A.Companion' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Companion in this case
|
||||
|
||||
@@ -125,9 +125,18 @@ public class BindingContextUtils {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FunctionDescriptor getEnclosingFunctionDescriptor(@NotNull BindingContext context, @NotNull KtElement element) {
|
||||
KtFunction function = PsiTreeUtil.getParentOfType(element, KtFunction.class);
|
||||
return (FunctionDescriptor)context.get(DECLARATION_TO_DESCRIPTOR, function);
|
||||
KtElement functionOrClass = PsiTreeUtil.getParentOfType(element, KtFunction.class, KtClassOrObject.class);
|
||||
DeclarationDescriptor descriptor = context.get(DECLARATION_TO_DESCRIPTOR, functionOrClass);
|
||||
if (functionOrClass instanceof KtFunction) {
|
||||
if (descriptor instanceof FunctionDescriptor) return (FunctionDescriptor) descriptor;
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
if (descriptor instanceof ClassDescriptor) return ((ClassDescriptor) descriptor).getUnsubstitutedPrimaryConstructor();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportAmbiguousLabel(
|
||||
|
||||
@@ -525,20 +525,17 @@ public class BodyResolver {
|
||||
@NotNull ClassDescriptorWithResolutionScopes classDescriptor
|
||||
) {
|
||||
LexicalScope scopeForInitializers = classDescriptor.getScopeForInitializerResolution();
|
||||
if (!classDescriptor.getConstructors().isEmpty()) {
|
||||
KtExpression body = anonymousInitializer.getBody();
|
||||
if (body != null) {
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(
|
||||
(KtDeclaration) anonymousInitializer.getParent().getParent(), trace);
|
||||
expressionTypingServices.getTypeInfo(
|
||||
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace, /*isStatement = */true
|
||||
);
|
||||
}
|
||||
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
|
||||
KtExpression body = anonymousInitializer.getBody();
|
||||
if (body != null) {
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(
|
||||
(KtDeclaration) anonymousInitializer.getParent().getParent(), trace);
|
||||
expressionTypingServices.getTypeInfo(
|
||||
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace, /*isStatement = */true
|
||||
);
|
||||
}
|
||||
else {
|
||||
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
|
||||
if (classDescriptor.getConstructors().isEmpty()) {
|
||||
trace.report(ANONYMOUS_INITIALIZER_IN_INTERFACE.on(anonymousInitializer));
|
||||
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ class DeclarationsChecker(
|
||||
for ((classOrObject, classDescriptor) in bodiesResolveContext.declaredClasses.entries) {
|
||||
checkSupertypesForConsistency(classDescriptor, classOrObject)
|
||||
checkTypesInClassHeader(classOrObject)
|
||||
checkClassOrObjectMembers(classDescriptor)
|
||||
|
||||
when (classOrObject) {
|
||||
is KtClass -> {
|
||||
@@ -344,17 +343,6 @@ class DeclarationsChecker(
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkClassOrObjectMembers(classDescriptor: ClassDescriptorWithResolutionScopes) {
|
||||
for (memberDescriptor in classDescriptor.declaredCallableMembers) {
|
||||
if (memberDescriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) continue
|
||||
val member = DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor) as? KtFunction
|
||||
if (member != null && memberDescriptor is FunctionDescriptor) {
|
||||
checkFunctionExposedType(member, memberDescriptor)
|
||||
checkVarargParameters(trace, memberDescriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPrimaryConstructor(classOrObject: KtClassOrObject, classDescriptor: ClassDescriptor) {
|
||||
val primaryConstructor = classDescriptor.unsubstitutedPrimaryConstructor ?: return
|
||||
val declaration = classOrObject.getPrimaryConstructor() ?: return
|
||||
@@ -664,6 +652,9 @@ class DeclarationsChecker(
|
||||
trace.report(DEPRECATED_TYPE_PARAMETER_SYNTAX.on(typeParameterList))
|
||||
}
|
||||
checkTypeParameterConstraints(function)
|
||||
checkImplicitCallableType(function, functionDescriptor)
|
||||
checkFunctionExposedType(function, functionDescriptor)
|
||||
checkVarargParameters(trace, functionDescriptor)
|
||||
|
||||
val containingDescriptor = functionDescriptor.containingDeclaration
|
||||
val hasAbstractModifier = function.hasModifier(KtTokens.ABSTRACT_KEYWORD)
|
||||
@@ -689,21 +680,19 @@ class DeclarationsChecker(
|
||||
if (!hasBody && !hasAbstractModifier && !hasExternalModifier && !inTrait) {
|
||||
trace.report(NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(function, functionDescriptor))
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier) {
|
||||
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
|
||||
else /* top-level only */ {
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier) {
|
||||
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
|
||||
}
|
||||
}
|
||||
checkImplicitCallableType(function, functionDescriptor)
|
||||
checkFunctionExposedType(function, functionDescriptor)
|
||||
checkVarargParameters(trace, functionDescriptor)
|
||||
}
|
||||
|
||||
private fun checkImplicitCallableType(declaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
|
||||
descriptor.returnType?.let {
|
||||
if (declaration.typeReference == null) {
|
||||
val target = declaration.nameIdentifier ?: declaration
|
||||
if (it.isNothing()) {
|
||||
if (it.isNothing() && !declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
trace.report(
|
||||
(if (declaration is KtProperty) IMPLICIT_NOTHING_PROPERTY_TYPE else IMPLICIT_NOTHING_RETURN_TYPE).on(target)
|
||||
)
|
||||
|
||||
@@ -897,16 +897,6 @@ public class DescriptorResolver {
|
||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scopeWithTypeParameters, getter.getModifierList(), trace)));
|
||||
|
||||
KotlinType outType = propertyDescriptor.getType();
|
||||
KotlinType returnType = outType;
|
||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||
if (returnTypeReference != null) {
|
||||
returnType = typeResolver.resolveType(scopeWithTypeParameters, returnTypeReference, trace, true);
|
||||
if (!TypeUtils.equalTypes(returnType, outType)) {
|
||||
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyDescriptor.getReturnType(), outType));
|
||||
}
|
||||
}
|
||||
|
||||
getterDescriptor = new PropertyGetterDescriptorImpl(
|
||||
propertyDescriptor, getterAnnotations,
|
||||
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
|
||||
@@ -914,10 +904,8 @@ public class DescriptorResolver {
|
||||
/* isDefault = */ false, getter.hasModifier(EXTERNAL_KEYWORD),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, KotlinSourceElementKt.toSourceElement(getter)
|
||||
);
|
||||
if (returnType.isError() && !getter.hasBlockBody() && getter.hasBody()) {
|
||||
returnType = inferReturnTypeFromExpressionBody(storageManager, expressionTypingServices, trace, scopeWithTypeParameters,
|
||||
DataFlowInfoFactory.EMPTY, getter, getterDescriptor);
|
||||
}
|
||||
KotlinType returnType =
|
||||
determineGetterReturnType(scopeWithTypeParameters, trace, getterDescriptor, getter, propertyDescriptor.getType());
|
||||
getterDescriptor.initialize(returnType);
|
||||
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
|
||||
}
|
||||
@@ -930,6 +918,37 @@ public class DescriptorResolver {
|
||||
return getterDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KotlinType determineGetterReturnType(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull PropertyGetterDescriptor getterDescriptor,
|
||||
@NotNull KtPropertyAccessor getter,
|
||||
@NotNull KotlinType propertyType
|
||||
) {
|
||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||
if (returnTypeReference != null) {
|
||||
KotlinType explicitReturnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
||||
if (!TypeUtils.equalTypes(explicitReturnType, propertyType)) {
|
||||
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyType, explicitReturnType));
|
||||
}
|
||||
return explicitReturnType;
|
||||
}
|
||||
|
||||
// If a property has no type specified in the PSI but the getter does (or has an initializer e.g. "val x get() = ..."),
|
||||
// infer the correct type for the getter but leave the error type for the property.
|
||||
// This is useful for an IDE quick fix which would add the type to the property
|
||||
KtProperty property = getter.getProperty();
|
||||
if (!property.hasDelegateExpressionOrInitializer() && property.getTypeReference() == null &&
|
||||
getter.hasBody() && !getter.hasBlockBody()) {
|
||||
return inferReturnTypeFromExpressionBody(
|
||||
storageManager, expressionTypingServices, trace, scope, DataFlowInfoFactory.EMPTY, getter, getterDescriptor
|
||||
);
|
||||
}
|
||||
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
/*package*/ static DeferredType inferReturnTypeFromExpressionBody(
|
||||
@NotNull StorageManager storageManager,
|
||||
|
||||
@@ -203,9 +203,9 @@ object ModifierCheckerCore {
|
||||
trace.report(Errors.REPEATED_MODIFIER.on (secondNode.psi, first))
|
||||
}
|
||||
Compatibility.REDUNDANT ->
|
||||
trace.report(Errors.REDUNDANT_MODIFIER.on(secondNode.psi, first, second))
|
||||
trace.report(Errors.REDUNDANT_MODIFIER.on(secondNode.psi, second, first))
|
||||
Compatibility.REVERSE_REDUNDANT ->
|
||||
trace.report(Errors.REDUNDANT_MODIFIER.on(firstNode.psi, second, first))
|
||||
trace.report(Errors.REDUNDANT_MODIFIER.on(firstNode.psi, first, second))
|
||||
Compatibility.DEPRECATED -> {
|
||||
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(firstNode.psi, first, second))
|
||||
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(secondNode.psi, second, first))
|
||||
|
||||
@@ -1027,7 +1027,7 @@ public class OverrideResolver {
|
||||
all.addAll((Collection) supertype.getMemberScope().getContributedVariables(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
|
||||
for (CallableMemberDescriptor fromSuper : all) {
|
||||
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared, null).getResult() == OVERRIDABLE) {
|
||||
if (Visibilities.isVisibleWithIrrelevantReceiver(fromSuper, declared)) {
|
||||
if (Visibilities.isVisibleIgnoringReceiver(fromSuper, declared)) {
|
||||
throw new IllegalStateException("Descriptor " + fromSuper + " is overridable by " + declared +
|
||||
" and visible but does not appear in its getOverriddenDescriptors()");
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
||||
if (Visibilities.isPrivate(visibility)) return false
|
||||
if (!visibility.mustCheckInImports()) return true
|
||||
}
|
||||
return Visibilities.isVisibleWithIrrelevantReceiver(descriptor, shouldBeVisibleFrom)
|
||||
return Visibilities.isVisibleIgnoringReceiver(descriptor, shouldBeVisibleFrom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
||||
|
||||
private val DEFAULT_CALL_CHECKERS = listOf(CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker(),
|
||||
SafeCallChecker(), InvokeConventionChecker(), CallReturnsArrayOfNothingChecker(),
|
||||
ConstructorHeaderCallChecker)
|
||||
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker)
|
||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_VALIDATORS = listOf(DeprecatedSymbolValidator(), OperatorValidator(), InfixValidator())
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -306,7 +306,7 @@ class TypeResolver(
|
||||
|
||||
val arguments = resolveTypeProjections(c, ErrorUtils.createErrorType("No type").constructor, type.typeArguments)
|
||||
if (!arguments.isEmpty()) {
|
||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(type.typeArgumentList!!, 0))
|
||||
c.trace.report(TYPE_ARGUMENTS_NOT_ALLOWED.on(type.typeArgumentList!!, "for type parameters"))
|
||||
}
|
||||
|
||||
val containing = typeParameter.containingDeclaration
|
||||
@@ -445,7 +445,10 @@ class TypeResolver(
|
||||
|
||||
if (currentArguments.size != currentParameters.size) {
|
||||
c.trace.report(
|
||||
WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierPart.typeArguments ?: qualifierPart.expression, currentParameters.size))
|
||||
WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(
|
||||
qualifierPart.typeArguments ?: qualifierPart.expression, currentParameters.size, classDescriptorChain[index]
|
||||
)
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -461,7 +464,7 @@ class TypeResolver(
|
||||
|
||||
for (qualifierPart in nonClassQualifierParts) {
|
||||
if (qualifierPart.typeArguments != null) {
|
||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierPart.typeArguments, 0))
|
||||
c.trace.report(TYPE_ARGUMENTS_NOT_ALLOWED.on(qualifierPart.typeArguments, "here"))
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -471,7 +474,7 @@ class TypeResolver(
|
||||
val typeParametersToSpecify =
|
||||
parameters.subList(result.size, parameters.size).takeWhile { it.original.containingDeclaration is ClassDescriptor }
|
||||
if (typeParametersToSpecify.any { parameter -> !parameter.isDeclaredInScope(c) }) {
|
||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierParts.last().expression, parameters.size))
|
||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierParts.last().expression, parameters.size, classDescriptor))
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,24 +181,6 @@ fun resolveCallableReferenceTarget(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createReflectionTypeForFunction(
|
||||
descriptor: FunctionDescriptor,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KotlinType? {
|
||||
val returnType = descriptor.returnType ?: return null
|
||||
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.valueParameters)
|
||||
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
||||
}
|
||||
|
||||
private fun createReflectionTypeForProperty(
|
||||
descriptor: PropertyDescriptor,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KotlinType {
|
||||
return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.type, descriptor.isVar)
|
||||
}
|
||||
|
||||
private fun bindFunctionReference(expression: KtCallableReferenceExpression, type: KotlinType, context: ResolutionContext<*>) {
|
||||
val functionDescriptor = AnonymousFunctionDescriptor(
|
||||
context.scope.ownerDescriptor,
|
||||
@@ -230,7 +212,8 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
lhsType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes,
|
||||
trace: BindingTrace?,
|
||||
reportOn: KtExpression?
|
||||
reportOn: KtExpression?,
|
||||
ignoreReceiver: Boolean
|
||||
): KotlinType? {
|
||||
val extensionReceiver = descriptor.extensionReceiverParameter
|
||||
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||
@@ -248,15 +231,19 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
}
|
||||
|
||||
val receiverType =
|
||||
if (extensionReceiver != null || dispatchReceiver != null)
|
||||
if ((extensionReceiver != null || dispatchReceiver != null) && !ignoreReceiver)
|
||||
lhsType ?: extensionReceiver?.type ?: dispatchReceiver?.type
|
||||
else null
|
||||
|
||||
return when (descriptor) {
|
||||
is FunctionDescriptor ->
|
||||
createReflectionTypeForFunction(descriptor, receiverType, reflectionTypes)
|
||||
is PropertyDescriptor ->
|
||||
createReflectionTypeForProperty(descriptor, receiverType, reflectionTypes)
|
||||
is FunctionDescriptor -> {
|
||||
val returnType = descriptor.returnType ?: return null
|
||||
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.valueParameters)
|
||||
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
||||
}
|
||||
is PropertyDescriptor -> {
|
||||
reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.type, descriptor.isVar)
|
||||
}
|
||||
is VariableDescriptor -> {
|
||||
if (reportOn != null) {
|
||||
trace?.report(UNSUPPORTED.on(reportOn, "References to variables aren't supported yet"))
|
||||
@@ -270,9 +257,10 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
|
||||
fun getReflectionTypeForCandidateDescriptor(
|
||||
descriptor: CallableDescriptor,
|
||||
reflectionTypes: ReflectionTypes
|
||||
reflectionTypes: ReflectionTypes,
|
||||
ignoreReceiver: Boolean
|
||||
): KotlinType? =
|
||||
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
|
||||
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null, ignoreReceiver)
|
||||
|
||||
fun createReflectionTypeForResolvedCallableReference(
|
||||
reference: KtCallableReferenceExpression,
|
||||
@@ -282,7 +270,7 @@ fun createReflectionTypeForResolvedCallableReference(
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KotlinType? {
|
||||
val type = createReflectionTypeForCallableDescriptor(
|
||||
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
|
||||
descriptor, lhsType, reflectionTypes, context.trace, reference.callableReference, reference.typeReference == null
|
||||
) ?: return null
|
||||
when (descriptor) {
|
||||
is FunctionDescriptor -> {
|
||||
@@ -310,7 +298,8 @@ fun getResolvedCallableReferenceShapeType(
|
||||
null
|
||||
overloadResolutionResults.isSingleResult ->
|
||||
OverloadResolutionResultsUtil.getResultingCall(overloadResolutionResults, context.contextDependency)?.let { call ->
|
||||
createReflectionTypeForCallableDescriptor(call.resultingDescriptor, lhsType, reflectionTypes, context.trace, reference)
|
||||
createReflectionTypeForCallableDescriptor(call.resultingDescriptor, lhsType, reflectionTypes, context.trace, reference,
|
||||
reference.typeReference == null)
|
||||
}
|
||||
expectedTypeUnknown /* && overload resolution was ambiguous */ ->
|
||||
functionPlaceholders.createFunctionPlaceholderType(emptyList(), false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -315,7 +315,7 @@ public class ArgumentTypeResolver {
|
||||
* Visits function call arguments and determines data flow information changes
|
||||
*/
|
||||
public void analyzeArgumentsAndRecordTypes(
|
||||
@NotNull CallResolutionContext<?> context
|
||||
@NotNull CallResolutionContext<?> context, @NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||
) {
|
||||
MutableDataFlowInfoForArguments infoForArguments = context.dataFlowInfoForArguments;
|
||||
Call call = context.call;
|
||||
@@ -326,7 +326,7 @@ public class ArgumentTypeResolver {
|
||||
|
||||
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument));
|
||||
// Here we go inside arguments and determine additional data flow information for them
|
||||
KotlinTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, SHAPE_FUNCTION_ARGUMENTS);
|
||||
KotlinTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, resolveArgumentsMode);
|
||||
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,14 @@ import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordDataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
|
||||
@@ -38,6 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.CANDIDATES_WITH_WRONG_RECEIVER
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.NAME_NOT_FOUND
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil
|
||||
@@ -64,6 +63,7 @@ import javax.inject.Inject
|
||||
class CallExpressionResolver(
|
||||
private val callResolver: CallResolver,
|
||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||
private val argumentTypeResolver: ArgumentTypeResolver,
|
||||
private val dataFlowAnalyzer: DataFlowAnalyzer,
|
||||
private val builtIns: KotlinBuiltIns,
|
||||
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
||||
@@ -247,6 +247,13 @@ class CallExpressionResolver(
|
||||
temporaryForVariable.commit()
|
||||
context.trace.report(FUNCTION_EXPECTED.on(calleeExpression, calleeExpression,
|
||||
type ?: ErrorUtils.createErrorType("")))
|
||||
argumentTypeResolver.analyzeArgumentsAndRecordTypes(
|
||||
BasicCallResolutionContext.create(
|
||||
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
DataFlowInfoForArgumentsImpl(initialDataFlowInfoForArguments, call)
|
||||
),
|
||||
ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
|
||||
)
|
||||
return noTypeInfo(context)
|
||||
}
|
||||
}
|
||||
@@ -257,13 +264,7 @@ class CallExpressionResolver(
|
||||
private fun KtQualifiedExpression.elementChain(context: ExpressionTypingContext) =
|
||||
qualifiedExpressionResolver.resolveQualifierInExpressionAndUnroll(this, context) {
|
||||
nameExpression ->
|
||||
val temporaryForVariable = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as local variable or property", nameExpression)
|
||||
val call = CallMaker.makePropertyCall(null, null, nameExpression)
|
||||
val contextForVariable = BasicCallResolutionContext.create(
|
||||
context.replaceTraceAndCache(temporaryForVariable),
|
||||
call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS)
|
||||
val resolutionResult = callResolver.resolveSimpleProperty(contextForVariable)
|
||||
val resolutionResult = resolveSimpleName(context, nameExpression)
|
||||
|
||||
if (resolutionResult.isSingleResult && resolutionResult.resultingDescriptor is FakeCallableDescriptorForObject) {
|
||||
false
|
||||
@@ -274,6 +275,17 @@ class CallExpressionResolver(
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveSimpleName(
|
||||
context: ExpressionTypingContext, expression: KtSimpleNameExpression
|
||||
): OverloadResolutionResults<VariableDescriptor> {
|
||||
val temporaryForVariable = TemporaryTraceAndCache.create(context, "trace to resolve as local variable or property", expression)
|
||||
val call = CallMaker.makePropertyCall(null, null, expression)
|
||||
val contextForVariable = BasicCallResolutionContext.create(
|
||||
context.replaceTraceAndCache(temporaryForVariable), call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS
|
||||
)
|
||||
return callResolver.resolveSimpleProperty(contextForVariable)
|
||||
}
|
||||
|
||||
private fun getUnsafeSelectorTypeInfo(
|
||||
receiver: Receiver,
|
||||
callOperationNode: ASTNode?,
|
||||
|
||||
@@ -575,7 +575,7 @@ public class CallResolver {
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
if (context.checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS) {
|
||||
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context);
|
||||
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context, ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS);
|
||||
}
|
||||
|
||||
List<KtTypeProjection> typeArguments = context.call.getTypeArguments();
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.validation.InfixValidator
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
enum class ResolveArgumentsMode {
|
||||
@@ -47,7 +48,7 @@ enum class ResolveArgumentsMode {
|
||||
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
return getParameterArgumentsOfCallableType(type).any {
|
||||
TypeUtils.contains(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
|
||||
it.type.contains { TypeUtils.isDontCarePlaceholder(it) } || ErrorUtils.containsUninferredParameter(it.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||
@@ -58,8 +59,7 @@ class CandidateResolver(
|
||||
private val reflectionTypes: ReflectionTypes,
|
||||
private val smartCastManager: SmartCastManager
|
||||
) {
|
||||
|
||||
fun <D : CallableDescriptor, F : D> performResolutionForCandidateCall(
|
||||
fun <D : CallableDescriptor> performResolutionForCandidateCall(
|
||||
context: CallCandidateResolutionContext<D>,
|
||||
checkArguments: CheckArgumentTypesMode
|
||||
): Unit = with(context) {
|
||||
@@ -76,7 +76,7 @@ class CandidateResolver(
|
||||
}
|
||||
|
||||
if (!context.isDebuggerContext) {
|
||||
checkVisibility()
|
||||
checkVisibilityWithoutReceiver()
|
||||
}
|
||||
|
||||
when (checkArguments) {
|
||||
@@ -98,9 +98,9 @@ class CandidateResolver(
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkValueArguments() = checkAndReport {
|
||||
if (call.getTypeArguments().isEmpty()
|
||||
if (call.typeArguments.isEmpty()
|
||||
&& !candidateDescriptor.typeParameters.isEmpty()
|
||||
&& candidateCall.getKnownTypeParametersSubstitutor() == null
|
||||
&& candidateCall.knownTypeParametersSubstitutor == null
|
||||
) {
|
||||
genericCandidateResolver.inferTypeArguments(this)
|
||||
}
|
||||
@@ -110,41 +110,42 @@ class CandidateResolver(
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.processTypeArguments() = check {
|
||||
val jetTypeArguments = call.getTypeArguments()
|
||||
val ktTypeArguments = call.typeArguments
|
||||
if (candidateCall.knownTypeParametersSubstitutor != null) {
|
||||
candidateCall.setResultingSubstitutor(candidateCall.knownTypeParametersSubstitutor!!)
|
||||
}
|
||||
else if (!jetTypeArguments.isEmpty()) {
|
||||
else if (!ktTypeArguments.isEmpty()) {
|
||||
// Explicit type arguments passed
|
||||
|
||||
val typeArguments = ArrayList<KotlinType>()
|
||||
for (projection in jetTypeArguments) {
|
||||
for (projection in ktTypeArguments) {
|
||||
val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) }
|
||||
?: ErrorUtils.createErrorType("Star projection in a call")
|
||||
typeArguments.add(type)
|
||||
}
|
||||
|
||||
val expectedTypeArgumentCount = candidateDescriptor.typeParameters.size
|
||||
for (index in jetTypeArguments.size..expectedTypeArgumentCount - 1) {
|
||||
for (index in ktTypeArguments.size..expectedTypeArgumentCount - 1) {
|
||||
typeArguments.add(ErrorUtils.createErrorType(
|
||||
"Explicit type argument expected for " + candidateDescriptor.typeParameters.get(index).name))
|
||||
"Explicit type argument expected for " + candidateDescriptor.typeParameters[index].name
|
||||
))
|
||||
}
|
||||
val substitution = FunctionDescriptorUtil.createSubstitution(candidateDescriptor as FunctionDescriptor, typeArguments)
|
||||
val substitutor = TypeSubstitutor.create(SubstitutionFilteringInternalResolveAnnotations(substitution))
|
||||
|
||||
if (expectedTypeArgumentCount != jetTypeArguments.size) {
|
||||
if (expectedTypeArgumentCount != ktTypeArguments.size) {
|
||||
candidateCall.addStatus(OTHER_ERROR)
|
||||
tracing.wrongNumberOfTypeArguments(trace, expectedTypeArgumentCount)
|
||||
tracing.wrongNumberOfTypeArguments(trace, expectedTypeArgumentCount, candidateDescriptor)
|
||||
}
|
||||
else {
|
||||
checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidateDescriptor, substitutor, trace)
|
||||
checkGenericBoundsInAFunctionCall(ktTypeArguments, typeArguments, candidateDescriptor, substitutor, trace)
|
||||
}
|
||||
|
||||
candidateCall.setResultingSubstitutor(substitutor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.mapArguments()
|
||||
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.mapArguments()
|
||||
= check {
|
||||
val argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters(
|
||||
call, tracing, candidateCall, Sets.newLinkedHashSet<ValueArgument>())
|
||||
@@ -153,11 +154,14 @@ class CandidateResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.checkExpectedCallableType()
|
||||
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.checkExpectedCallableType()
|
||||
= check {
|
||||
if (!noExpectedType(expectedType)) {
|
||||
val candidate = candidateCall.getCandidateDescriptor()
|
||||
val candidateReflectionType = getReflectionTypeForCandidateDescriptor(candidate, reflectionTypes);
|
||||
val candidate = candidateCall.candidateDescriptor
|
||||
val candidateReflectionType = getReflectionTypeForCandidateDescriptor(
|
||||
candidate, reflectionTypes,
|
||||
call.callElement.parent.let { it is KtCallableReferenceExpression && it.typeReference == null }
|
||||
);
|
||||
if (candidateReflectionType != null) {
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(candidateReflectionType, expectedType)) {
|
||||
candidateCall.addStatus(OTHER_ERROR)
|
||||
@@ -169,9 +173,17 @@ class CandidateResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkVisibility() = checkAndReport {
|
||||
val invisibleMember = Visibilities.findInvisibleMember(candidateCall.dispatchReceiver, candidateDescriptor, scope.ownerDescriptor)
|
||||
if (invisibleMember != null) {
|
||||
private fun CallCandidateResolutionContext<*>.checkVisibilityWithoutReceiver() = checkAndReport {
|
||||
checkVisibilityWithDispatchReceiver(Visibilities.ALWAYS_SUITABLE_RECEIVER, null)
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkVisibilityWithDispatchReceiver(
|
||||
receiverArgument: ReceiverValue?,
|
||||
smartCastType: KotlinType?
|
||||
): ResolutionStatus {
|
||||
val invisibleMember = Visibilities.findInvisibleMember(
|
||||
getReceiverValueWithSmartCast(receiverArgument, smartCastType), candidateDescriptor, scope.ownerDescriptor)
|
||||
return if (invisibleMember != null) {
|
||||
tracing.invisibleMember(trace, invisibleMember)
|
||||
OTHER_ERROR
|
||||
} else {
|
||||
@@ -179,16 +191,30 @@ class CandidateResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.isCandidateVisibleOrExtensionReceiver(
|
||||
receiverArgument: ReceiverValue?,
|
||||
smartCastType: KotlinType?,
|
||||
isDispatchReceiver: Boolean
|
||||
) = !isDispatchReceiver || isCandidateVisible(receiverArgument, smartCastType)
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.isCandidateVisible(
|
||||
receiverArgument: ReceiverValue?,
|
||||
smartCastType: KotlinType?
|
||||
) = Visibilities.findInvisibleMember(
|
||||
getReceiverValueWithSmartCast(receiverArgument, smartCastType),
|
||||
candidateDescriptor, scope.ownerDescriptor
|
||||
) == null
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkExtensionReceiver() = checkAndReport {
|
||||
val receiverParameter = candidateCall.getCandidateDescriptor().extensionReceiverParameter
|
||||
val receiverArgument = candidateCall.getExtensionReceiver()
|
||||
val receiverParameter = candidateCall.candidateDescriptor.extensionReceiverParameter
|
||||
val receiverArgument = candidateCall.extensionReceiver
|
||||
if (receiverParameter != null && receiverArgument == null) {
|
||||
tracing.missingReceiver(candidateCall.getTrace(), receiverParameter)
|
||||
tracing.missingReceiver(candidateCall.trace, receiverParameter)
|
||||
OTHER_ERROR
|
||||
}
|
||||
else if (receiverParameter == null && receiverArgument != null) {
|
||||
tracing.noReceiverAllowed(candidateCall.getTrace())
|
||||
if (call.getCalleeExpression() is KtSimpleNameExpression) {
|
||||
tracing.noReceiverAllowed(candidateCall.trace)
|
||||
if (call.calleeExpression is KtSimpleNameExpression) {
|
||||
RECEIVER_PRESENCE_ERROR
|
||||
}
|
||||
else {
|
||||
@@ -202,7 +228,7 @@ class CandidateResolver(
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkDispatchReceiver() = checkAndReport {
|
||||
val candidateDescriptor = candidateDescriptor
|
||||
val dispatchReceiver = candidateCall.getDispatchReceiver()
|
||||
val dispatchReceiver = candidateCall.dispatchReceiver
|
||||
if (dispatchReceiver != null) {
|
||||
var nestedClass: ClassDescriptor? = null
|
||||
if (candidateDescriptor is ConstructorDescriptor
|
||||
@@ -214,12 +240,12 @@ class CandidateResolver(
|
||||
nestedClass = candidateDescriptor.getReferencedDescriptor()
|
||||
}
|
||||
if (nestedClass != null) {
|
||||
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.getExplicitReceiverKind())
|
||||
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.explicitReceiverKind)
|
||||
return@checkAndReport OTHER_ERROR
|
||||
}
|
||||
}
|
||||
|
||||
assert((dispatchReceiver != null) == (candidateCall.getResultingDescriptor().dispatchReceiverParameter != null)) {
|
||||
assert((dispatchReceiver != null) == (candidateCall.resultingDescriptor.dispatchReceiverParameter != null)) {
|
||||
"Shouldn't happen because of TaskPrioritizer: $candidateDescriptor"
|
||||
}
|
||||
|
||||
@@ -235,17 +261,17 @@ class CandidateResolver(
|
||||
if (!context.call.callElement.insideScript()) return true
|
||||
|
||||
// In "this@Outer.foo()" the error will be reported on "this@Outer" instead
|
||||
if (context.call.getExplicitReceiver() != null || context.call.getDispatchReceiver() != null) return true
|
||||
if (context.call.explicitReceiver != null || context.call.dispatchReceiver != null) return true
|
||||
|
||||
val candidateThis = getDeclaringClass(context.candidateCall.getCandidateDescriptor())
|
||||
val candidateThis = getDeclaringClass(context.candidateCall.candidateDescriptor)
|
||||
if (candidateThis == null || candidateThis.kind.isSingleton) return true
|
||||
|
||||
return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis)
|
||||
return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.callElement, candidateThis)
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkAbstractAndSuper() = check {
|
||||
val descriptor = candidateDescriptor
|
||||
val expression = candidateCall.getCall().getCalleeExpression()
|
||||
val expression = candidateCall.call.calleeExpression
|
||||
|
||||
if (expression is KtSimpleNameExpression) {
|
||||
// 'B' in 'class A: B()' is JetConstructorCalleeExpression
|
||||
@@ -257,7 +283,7 @@ class CandidateResolver(
|
||||
}
|
||||
}
|
||||
|
||||
val superDispatchReceiver = getReceiverSuper(candidateCall.getDispatchReceiver())
|
||||
val superDispatchReceiver = getReceiverSuper(candidateCall.dispatchReceiver)
|
||||
if (superDispatchReceiver != null) {
|
||||
if (descriptor is MemberDescriptor && descriptor.modality == Modality.ABSTRACT) {
|
||||
tracing.abstractSuperCall(trace)
|
||||
@@ -267,9 +293,9 @@ class CandidateResolver(
|
||||
|
||||
// 'super' cannot be passed as an argument, for receiver arguments expression typer does not track this
|
||||
// See TaskPrioritizer for more
|
||||
val superExtensionReceiver = getReceiverSuper(candidateCall.getExtensionReceiver())
|
||||
val superExtensionReceiver = getReceiverSuper(candidateCall.extensionReceiver)
|
||||
if (superExtensionReceiver != null) {
|
||||
trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText()))
|
||||
trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.text))
|
||||
candidateCall.addStatus(OTHER_ERROR)
|
||||
}
|
||||
}
|
||||
@@ -317,23 +343,19 @@ class CandidateResolver(
|
||||
private fun <D : CallableDescriptor, C : CallResolutionContext<C>> checkValueArgumentTypes(
|
||||
context: CallResolutionContext<C>,
|
||||
candidateCall: MutableResolvedCall<D>,
|
||||
resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult {
|
||||
resolveFunctionArgumentBodies: ResolveArgumentsMode
|
||||
): ValueArgumentsCheckingResult {
|
||||
var resultStatus = SUCCESS
|
||||
val argumentTypes = Lists.newArrayList<KotlinType>()
|
||||
val infoForArguments = candidateCall.getDataFlowInfoForArguments()
|
||||
for (entry in candidateCall.getValueArguments().entries) {
|
||||
val parameterDescriptor = entry.key
|
||||
val resolvedArgument = entry.value
|
||||
|
||||
|
||||
val infoForArguments = candidateCall.dataFlowInfoForArguments
|
||||
for ((parameterDescriptor, resolvedArgument) in candidateCall.valueArguments) {
|
||||
for (argument in resolvedArgument.arguments) {
|
||||
val expression = argument.getArgumentExpression() ?: continue
|
||||
|
||||
val expectedType = getEffectiveExpectedType(parameterDescriptor, argument)
|
||||
|
||||
val newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)).replaceExpectedType(expectedType)
|
||||
val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(
|
||||
expression, newContext, resolveFunctionArgumentBodies)
|
||||
val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(expression, newContext, resolveFunctionArgumentBodies)
|
||||
val type = typeInfoForCall.type
|
||||
infoForArguments.updateInfo(argument, typeInfoForCall.dataFlowInfo)
|
||||
|
||||
@@ -377,15 +399,13 @@ class CandidateResolver(
|
||||
expression: KtExpression,
|
||||
expectedType: KotlinType,
|
||||
actualType: KotlinType,
|
||||
context: ResolutionContext<*>): KotlinType? {
|
||||
context: ResolutionContext<*>
|
||||
): KotlinType? {
|
||||
val receiverToCast = ExpressionReceiver.create(KtPsiUtil.safeDeparenthesize(expression), actualType, context.trace.bindingContext)
|
||||
val variants = smartCastManager.getSmartCastVariantsExcludingReceiver(context, receiverToCast)
|
||||
for (possibleType in variants) {
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) {
|
||||
return possibleType
|
||||
}
|
||||
return variants.firstOrNull { possibleType ->
|
||||
KotlinTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkReceiverTypeError(): Unit = check {
|
||||
@@ -399,7 +419,7 @@ class CandidateResolver(
|
||||
assert(callExtensionReceiver is ReceiverValue?) { "Expected ReceiverValue, got $callExtensionReceiver" }
|
||||
checkReceiverTypeError(extensionReceiver, callExtensionReceiver as ReceiverValue?)
|
||||
}
|
||||
checkReceiverTypeError(dispatchReceiver, candidateCall.getDispatchReceiver())
|
||||
checkReceiverTypeError(dispatchReceiver, candidateCall.dispatchReceiver)
|
||||
}
|
||||
|
||||
private fun CallCandidateResolutionContext<*>.checkReceiverTypeError(
|
||||
@@ -428,15 +448,30 @@ class CandidateResolver(
|
||||
|
||||
resultStatus = resultStatus.combine(context.checkReceiver(
|
||||
candidateCall,
|
||||
candidateCall.getResultingDescriptor().extensionReceiverParameter,
|
||||
candidateCall.resultingDescriptor.extensionReceiverParameter,
|
||||
candidateCall.extensionReceiver as ReceiverValue?,
|
||||
candidateCall.getExplicitReceiverKind().isExtensionReceiver, false))
|
||||
candidateCall.explicitReceiverKind.isExtensionReceiver,
|
||||
implicitInvokeCheck = false, isDispatchReceiver = false
|
||||
))
|
||||
|
||||
resultStatus = resultStatus.combine(context.checkReceiver(candidateCall,
|
||||
candidateCall.getResultingDescriptor().dispatchReceiverParameter, candidateCall.getDispatchReceiver(),
|
||||
candidateCall.getExplicitReceiverKind().isDispatchReceiver,
|
||||
resultStatus = resultStatus.combine(context.checkReceiver(
|
||||
candidateCall,
|
||||
candidateCall.resultingDescriptor.dispatchReceiverParameter, candidateCall.dispatchReceiver,
|
||||
candidateCall.explicitReceiverKind.isDispatchReceiver,
|
||||
// for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error
|
||||
context.call is CallForImplicitInvoke))
|
||||
implicitInvokeCheck = context.call is CallForImplicitInvoke,
|
||||
isDispatchReceiver = true
|
||||
))
|
||||
|
||||
if (!context.isDebuggerContext
|
||||
&& candidateCall.dispatchReceiver != null
|
||||
// Do not report error if it's already reported when checked without receiver
|
||||
&& context.isCandidateVisible(receiverArgument = Visibilities.ALWAYS_SUITABLE_RECEIVER, smartCastType = null)) {
|
||||
resultStatus = resultStatus.combine(
|
||||
context.checkVisibilityWithDispatchReceiver(
|
||||
candidateCall.dispatchReceiver, candidateCall.smartCastDispatchReceiverType))
|
||||
}
|
||||
|
||||
return resultStatus
|
||||
}
|
||||
|
||||
@@ -445,7 +480,9 @@ class CandidateResolver(
|
||||
receiverParameter: ReceiverParameterDescriptor?,
|
||||
receiverArgument: ReceiverValue?,
|
||||
isExplicitReceiver: Boolean,
|
||||
implicitInvokeCheck: Boolean): ResolutionStatus {
|
||||
implicitInvokeCheck: Boolean,
|
||||
isDispatchReceiver: Boolean
|
||||
): ResolutionStatus {
|
||||
if (receiverParameter == null || receiverArgument == null) return SUCCESS
|
||||
val candidateDescriptor = candidateCall.candidateDescriptor
|
||||
if (TypeUtils.dependsOnTypeParameters(receiverParameter.type, candidateDescriptor.typeParameters)) return SUCCESS
|
||||
@@ -465,11 +502,11 @@ class CandidateResolver(
|
||||
val call = candidateCall.call
|
||||
val safeAccess = isExplicitReceiver && !implicitInvokeCheck && call.isExplicitSafeCall()
|
||||
val expectedReceiverParameterType = if (safeAccess) TypeUtils.makeNullable(receiverParameter.type) else receiverParameter.type
|
||||
val smartCastNeeded = !ArgumentTypeResolver.isSubtypeOfForArgumentType(receiverArgument.type, expectedReceiverParameterType)
|
||||
val notNullReceiverExpected = !ArgumentTypeResolver.isSubtypeOfForArgumentType(receiverArgument.type, expectedReceiverParameterType)
|
||||
val smartCastNeeded =
|
||||
notNullReceiverExpected || !isCandidateVisibleOrExtensionReceiver(receiverArgument, null, isDispatchReceiver)
|
||||
var reportUnsafeCall = false
|
||||
|
||||
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, this)
|
||||
val nullability = dataFlowInfo.getPredictableNullability(dataFlowValue)
|
||||
var nullableImplicitInvokeReceiver = false
|
||||
var receiverArgumentType = receiverArgument.type
|
||||
if (implicitInvokeCheck && call is CallForImplicitInvoke && call.isSafeCall()) {
|
||||
@@ -483,6 +520,9 @@ class CandidateResolver(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, this)
|
||||
val nullability = dataFlowInfo.getPredictableNullability(dataFlowValue)
|
||||
val expression = (receiverArgument as? ExpressionReceiver)?.expression
|
||||
if (nullability.canBeNull() && !nullability.canBeNonNull()) {
|
||||
if (!TypeUtils.isNullableType(expectedReceiverParameterType)) {
|
||||
@@ -496,14 +536,20 @@ class CandidateResolver(
|
||||
// Look if smart cast has some useful nullability info
|
||||
|
||||
val smartCastResult = SmartCastManager.checkAndRecordPossibleCast(
|
||||
dataFlowValue, expectedReceiverParameterType, expression, this, candidateCall.call.calleeExpression, /*recordType =*/true
|
||||
dataFlowValue, expectedReceiverParameterType,
|
||||
{ possibleSmartCast -> isCandidateVisibleOrExtensionReceiver(receiverArgument, possibleSmartCast, isDispatchReceiver) },
|
||||
expression, this, candidateCall.call.calleeExpression, /*recordType =*/true
|
||||
)
|
||||
|
||||
if (smartCastResult == null) {
|
||||
reportUnsafeCall = true
|
||||
if (notNullReceiverExpected) {
|
||||
reportUnsafeCall = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
candidateCall.setSmartCastDispatchReceiverType(smartCastResult.resultType)
|
||||
if (isDispatchReceiver) {
|
||||
candidateCall.setSmartCastDispatchReceiverType(smartCastResult.resultType)
|
||||
}
|
||||
if (!smartCastResult.isCorrect) {
|
||||
// Error about unstable smart cast reported within checkAndRecordPossibleCast
|
||||
return OTHER_ERROR
|
||||
@@ -522,16 +568,17 @@ class CandidateResolver(
|
||||
inner class ValueArgumentsCheckingResult(val status: ResolutionStatus, val argumentTypes: List<KotlinType>)
|
||||
|
||||
private fun checkGenericBoundsInAFunctionCall(
|
||||
jetTypeArguments: List<KtTypeProjection>,
|
||||
ktTypeArguments: List<KtTypeProjection>,
|
||||
typeArguments: List<KotlinType>,
|
||||
functionDescriptor: CallableDescriptor,
|
||||
substitutor: TypeSubstitutor,
|
||||
trace: BindingTrace) {
|
||||
trace: BindingTrace
|
||||
) {
|
||||
val typeParameters = functionDescriptor.typeParameters
|
||||
for (i in 0..Math.min(typeParameters.size, jetTypeArguments.size) - 1) {
|
||||
val typeParameterDescriptor = typeParameters.get(i)
|
||||
val typeArgument = typeArguments.get(i)
|
||||
val typeReference = jetTypeArguments.get(i).getTypeReference()
|
||||
for (i in 0..Math.min(typeParameters.size, ktTypeArguments.size) - 1) {
|
||||
val typeParameterDescriptor = typeParameters[i]
|
||||
val typeArgument = typeArguments[i]
|
||||
val typeReference = ktTypeArguments[i].typeReference
|
||||
if (typeReference != null) {
|
||||
DescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace)
|
||||
}
|
||||
@@ -539,7 +586,7 @@ class CandidateResolver(
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.shouldContinue() =
|
||||
candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.getStatus().possibleTransformToSuccess()
|
||||
candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.status.possibleTransformToSuccess()
|
||||
|
||||
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.check(
|
||||
checker: CallCandidateResolutionContext<D>.() -> Unit
|
||||
@@ -547,13 +594,14 @@ class CandidateResolver(
|
||||
if (shouldContinue()) checker()
|
||||
}
|
||||
|
||||
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.
|
||||
checkAndReport(checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus) {
|
||||
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.checkAndReport(
|
||||
checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus
|
||||
) {
|
||||
if (shouldContinue()) {
|
||||
candidateCall.addStatus(checker())
|
||||
}
|
||||
}
|
||||
|
||||
private val CallCandidateResolutionContext<*>.candidateDescriptor: CallableDescriptor get() = candidateCall.getCandidateDescriptor()
|
||||
|
||||
private val CallCandidateResolutionContext<*>.candidateDescriptor: CallableDescriptor
|
||||
get() = candidateCall.candidateDescriptor
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.calls.checkers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.psi.KtConstructorCalleeExpression
|
||||
import org.jetbrains.kotlin.psi.KtConstructorDelegationReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
|
||||
object ProtectedConstructorCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
|
||||
val descriptor = resolvedCall.resultingDescriptor as? ConstructorDescriptor ?: return
|
||||
val constructorOwner = descriptor.containingDeclaration.original
|
||||
val scopeOwner = context.scope.ownerDescriptor
|
||||
|
||||
if (descriptor.visibility.normalize() != Visibilities.PROTECTED) return
|
||||
// Error already reported
|
||||
if (!Visibilities.isVisibleWithAnyReceiver(descriptor, scopeOwner)) return
|
||||
|
||||
val calleeExpression = resolvedCall.call.calleeExpression ?: return
|
||||
|
||||
// Permit constructor super-calls
|
||||
when (calleeExpression) {
|
||||
is KtConstructorCalleeExpression -> if (calleeExpression.parent is KtSuperTypeCallEntry) return
|
||||
is KtConstructorDelegationReferenceExpression -> return
|
||||
}
|
||||
|
||||
// Permit calls within class
|
||||
if (scopeOwner.parentsWithSelf.any { it.original === constructorOwner }) return
|
||||
|
||||
// Using FALSE_IF_PROTECTED helps us to check that descriptor doesn't meet conditions of java package/static-protected
|
||||
// (i.e. being in the same package)
|
||||
// And without ProtectedConstructorCallChecker such calls would be allowed only because they are performed within subclass
|
||||
// of constructor owner
|
||||
@Suppress("DEPRECATION")
|
||||
if (Visibilities.findInvisibleMember(Visibilities.FALSE_IF_PROTECTED, descriptor, scopeOwner) == descriptor) {
|
||||
context.trace.report(Errors.PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL.on(calleeExpression, descriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.resolvedCallUtil
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getOwnerForEffectiveDispatchReceiverParameter
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
@@ -88,4 +87,7 @@ private fun ResolvedCall<*>.hasSafeNullableReceiver(context: CallResolutionConte
|
||||
fun ResolvedCall<*>.makeNullableTypeIfSafeReceiver(type: KotlinType?, context: CallResolutionContext<*>) =
|
||||
type?.let { TypeUtils.makeNullableIfNeeded(type, hasSafeNullableReceiver(context)) }
|
||||
|
||||
fun ResolvedCall<*>.hasBothReceivers() = dispatchReceiver != null && extensionReceiver != null
|
||||
fun ResolvedCall<*>.hasBothReceivers() = dispatchReceiver != null && extensionReceiver != null
|
||||
|
||||
fun ResolvedCall<*>.getDispatchReceiverWithSmartCast(): ReceiverValue?
|
||||
= getReceiverValueWithSmartCast(dispatchReceiver, smartCastDispatchReceiverType)
|
||||
|
||||
@@ -179,9 +179,24 @@ public class SmartCastManager {
|
||||
@NotNull ResolutionContext c,
|
||||
@Nullable KtExpression calleeExpression,
|
||||
boolean recordExpressionType
|
||||
) {
|
||||
return checkAndRecordPossibleCast(
|
||||
dataFlowValue, expectedType, null, expression, c, calleeExpression, recordExpressionType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SmartCastResult checkAndRecordPossibleCast(
|
||||
@NotNull DataFlowValue dataFlowValue,
|
||||
@NotNull KotlinType expectedType,
|
||||
@Nullable Function1<KotlinType, Boolean> additionalPredicate,
|
||||
@Nullable KtExpression expression,
|
||||
@NotNull ResolutionContext c,
|
||||
@Nullable KtExpression calleeExpression,
|
||||
boolean recordExpressionType
|
||||
) {
|
||||
for (KotlinType possibleType : c.dataFlowInfo.getCollectedTypes(dataFlowValue)) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)
|
||||
&& (additionalPredicate == null || additionalPredicate.invoke(possibleType))) {
|
||||
if (expression != null) {
|
||||
recordCastOrError(expression, possibleType, c.trace, dataFlowValue, recordExpressionType);
|
||||
}
|
||||
@@ -209,7 +224,8 @@ public class SmartCastManager {
|
||||
boolean immanentlyNotNull = !dataFlowValue.getImmanentNullability().canBeNull();
|
||||
KotlinType nullableExpectedType = TypeUtils.makeNullable(expectedType);
|
||||
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)
|
||||
&& (additionalPredicate == null || additionalPredicate.invoke(dataFlowValue.getType()))) {
|
||||
if (!immanentlyNotNull) {
|
||||
if (expression != null) {
|
||||
recordCastOrError(expression, dataFlowValue.getType(), c.trace, dataFlowValue, recordExpressionType);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -103,14 +103,13 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {
|
||||
public void wrongNumberOfTypeArguments(
|
||||
@NotNull BindingTrace trace, int expectedTypeArgumentCount, @NotNull CallableDescriptor descriptor
|
||||
) {
|
||||
KtTypeArgumentList typeArgumentList = call.getTypeArgumentList();
|
||||
if (typeArgumentList != null) {
|
||||
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(typeArgumentList, expectedTypeArgumentCount));
|
||||
}
|
||||
else {
|
||||
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(reference, expectedTypeArgumentCount));
|
||||
}
|
||||
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(
|
||||
typeArgumentList != null ? typeArgumentList : reference, expectedTypeArgumentCount, descriptor
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -67,7 +67,7 @@ public interface TracingStrategy {
|
||||
public void noValueForParameter(@NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter) {}
|
||||
|
||||
@Override
|
||||
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {}
|
||||
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount, @NotNull CallableDescriptor descriptor) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors) {}
|
||||
@@ -132,7 +132,11 @@ public interface TracingStrategy {
|
||||
|
||||
void noValueForParameter(@NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter);
|
||||
|
||||
void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount);
|
||||
void wrongNumberOfTypeArguments(
|
||||
@NotNull BindingTrace trace,
|
||||
int expectedTypeArgumentCount,
|
||||
@NotNull CallableDescriptor descriptor
|
||||
);
|
||||
|
||||
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -126,7 +126,7 @@ class TracingStrategyForImplicitConstructorDelegationCall(
|
||||
unexpectedError("noReceiverAllowed")
|
||||
}
|
||||
|
||||
override fun wrongNumberOfTypeArguments(trace: BindingTrace, expectedTypeArgumentCount: Int) {
|
||||
override fun wrongNumberOfTypeArguments(trace: BindingTrace, expectedTypeArgumentCount: Int, descriptor: CallableDescriptor) {
|
||||
unexpectedError("wrongNumberOfTypeArguments")
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ open class FileScopeProviderImpl(
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
if (name in excludedNames) return null
|
||||
val classifier = scope.getContributedClassifier(name, location) ?: return null
|
||||
val visible = Visibilities.isVisibleWithIrrelevantReceiver(classifier as ClassDescriptor, fromDescriptor)
|
||||
val visible = Visibilities.isVisibleIgnoringReceiver(classifier as ClassDescriptor, fromDescriptor)
|
||||
return classifier.check { filteringKind == if (visible) FilteringKind.VISIBLE_CLASSES else FilteringKind.INVISIBLE_CLASSES }
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ class LazyImportScope(
|
||||
val visibility = descriptor.visibility
|
||||
val includeVisible = filteringKind == FilteringKind.VISIBLE_CLASSES
|
||||
if (!visibility.mustCheckInImports()) return includeVisible
|
||||
return Visibilities.isVisibleWithIrrelevantReceiver(descriptor, importResolver.moduleDescriptor) == includeVisible
|
||||
return Visibilities.isVisibleIgnoringReceiver(descriptor, importResolver.moduleDescriptor) == includeVisible
|
||||
}
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
|
||||
@@ -124,9 +124,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
this.declarationProvider = c.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfo);
|
||||
|
||||
StorageManager storageManager = c.getStorageManager();
|
||||
|
||||
this.unsubstitutedMemberScope = createMemberScope(c, this.declarationProvider);
|
||||
this.kind = classLikeInfo.getClassKind();
|
||||
this.staticScope = kind == ClassKind.ENUM_CLASS ? new StaticScopeForKotlinEnum(this) : MemberScope.Empty.INSTANCE;
|
||||
this.staticScope = kind == ClassKind.ENUM_CLASS ? new StaticScopeForKotlinEnum(storageManager, this) : MemberScope.Empty.INSTANCE;
|
||||
|
||||
this.typeConstructor = new LazyClassTypeConstructor();
|
||||
|
||||
@@ -154,8 +156,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
this.isInner = isInnerClass(modifierList) && !ModifiersChecker.isIllegalInner(this);
|
||||
this.isData = modifierList != null && modifierList.hasModifier(KtTokens.DATA_KEYWORD);
|
||||
|
||||
StorageManager storageManager = c.getStorageManager();
|
||||
|
||||
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
|
||||
List<KtAnnotationEntry> annotationEntries = new ArrayList<KtAnnotationEntry>();
|
||||
if (classOrObject != null && classOrObject.getParent() instanceof KtObjectLiteralExpression) {
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.receivers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtConstructorDelegationReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
@@ -40,6 +37,12 @@ interface ExpressionReceiver : ReceiverValue {
|
||||
type: KotlinType
|
||||
) : ExpressionReceiverImpl(expression, type), ThisClassReceiver
|
||||
|
||||
private class SuperExpressionReceiver(
|
||||
override val thisType: KotlinType,
|
||||
expression: KtExpression,
|
||||
type: KotlinType
|
||||
) : ExpressionReceiverImpl(expression, type), SuperCallReceiverValue
|
||||
|
||||
fun create(
|
||||
expression: KtExpression,
|
||||
type: KotlinType,
|
||||
@@ -56,7 +59,14 @@ interface ExpressionReceiver : ReceiverValue {
|
||||
if (referenceExpression != null) {
|
||||
val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression)
|
||||
if (descriptor is ClassDescriptor) {
|
||||
return ThisExpressionClassReceiver(descriptor.original as ClassDescriptor, expression, type)
|
||||
return ThisExpressionClassReceiver(descriptor.original, expression, type)
|
||||
}
|
||||
}
|
||||
else if (expression is KtSuperExpression) {
|
||||
// if there is no THIS_TYPE_FOR_SUPER_EXPRESSION in binding context, we fall through into more restrictive option
|
||||
// i.e. just return common ExpressionReceiverImpl
|
||||
bindingContext[BindingContext.THIS_TYPE_FOR_SUPER_EXPRESSION, expression]?.let {
|
||||
thisType -> return SuperExpressionReceiver(thisType, expression, type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.storage
|
||||
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import org.jetbrains.kotlin.utils.rethrow
|
||||
|
||||
@@ -24,7 +25,10 @@ open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Excep
|
||||
private val cancelledTracker: AtomicLong = AtomicLong()
|
||||
|
||||
override fun handleException(throwable: Throwable): RuntimeException {
|
||||
incCounter()
|
||||
// should not increment counter when ReenteringLazyValueComputationException is thrown since it implements correct frontend behaviour
|
||||
if (throwable !is ReenteringLazyValueComputationException) {
|
||||
incCounter()
|
||||
}
|
||||
throw rethrow(throwable)
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class CastDiagnosticsUtil {
|
||||
if (typeChecker.isSubtypeOf(supertype, subtype)) return false;
|
||||
|
||||
// downcasting to a non-reified type parameter is always erased
|
||||
if (TypeUtils.isNonReifiedTypeParemeter(subtype)) return true;
|
||||
if (TypeUtils.isNonReifiedTypeParameter(subtype)) return true;
|
||||
|
||||
// Check that we are actually casting to a generic type
|
||||
// NOTE: this does not account for 'as Array<List<T>>'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user