mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-26 08:31:31 +00:00
Compare commits
773 Commits
androidxml
...
bugs/rec_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
804a251e5f | ||
|
|
f4a4bd203d | ||
|
|
1d5836f60a | ||
|
|
69303d638f | ||
|
|
a445e8b289 | ||
|
|
2c5b11ed97 | ||
|
|
6166afb911 | ||
|
|
8d7b2a83f7 | ||
|
|
1806b09809 | ||
|
|
7ba16f8a4e | ||
|
|
d6d642be52 | ||
|
|
c3b232cb2f | ||
|
|
a49a44dee3 | ||
|
|
17451c13f0 | ||
|
|
d886066102 | ||
|
|
a4dc6946b8 | ||
|
|
b7ae06f1f5 | ||
|
|
a37144612f | ||
|
|
cbbacd0043 | ||
|
|
7d77005567 | ||
|
|
eea79c6fca | ||
|
|
7b1fd591c2 | ||
|
|
7f8b7fb35c | ||
|
|
a52f6a849b | ||
|
|
3bd3c69bc1 | ||
|
|
483de4d1db | ||
|
|
0c0f400604 | ||
|
|
1abae94a03 | ||
|
|
06c3494aa5 | ||
|
|
81c7d82804 | ||
|
|
630ac58520 | ||
|
|
1f08fef0a2 | ||
|
|
3406d030e5 | ||
|
|
aabe67869b | ||
|
|
6328700ee8 | ||
|
|
009a0d3418 | ||
|
|
c617b73424 | ||
|
|
5fb4f41030 | ||
|
|
d2d9813e12 | ||
|
|
f47d8239c4 | ||
|
|
97cbadef61 | ||
|
|
602be6303c | ||
|
|
3b59a513b0 | ||
|
|
b728ba2b1e | ||
|
|
c0416255c4 | ||
|
|
8cbda20ef2 | ||
|
|
b6d0539795 | ||
|
|
4622b6dd8f | ||
|
|
3a10416192 | ||
|
|
4e99572dbc | ||
|
|
b8c13b851c | ||
|
|
59917f3727 | ||
|
|
951ce827a6 | ||
|
|
632bceef26 | ||
|
|
c36fc42014 | ||
|
|
7bb4e538a6 | ||
|
|
3aadd6f880 | ||
|
|
245e70100d | ||
|
|
0b4c7588da | ||
|
|
448d444b2d | ||
|
|
2e0ccf6984 | ||
|
|
7de15ec2a8 | ||
|
|
567bb6fd1a | ||
|
|
17622f8259 | ||
|
|
0092c952ef | ||
|
|
899a051a8f | ||
|
|
7e147d28c2 | ||
|
|
39cea5999c | ||
|
|
3f6cebbc28 | ||
|
|
82fc0ee394 | ||
|
|
389b14f44f | ||
|
|
1af63cb3be | ||
|
|
3217981a62 | ||
|
|
d67e99d40a | ||
|
|
927fe9d2cb | ||
|
|
f100015e58 | ||
|
|
41cb97ac61 | ||
|
|
3d6da9104c | ||
|
|
abf537e348 | ||
|
|
41c7ec8285 | ||
|
|
3b51858ed9 | ||
|
|
e81631a3af | ||
|
|
7941314c60 | ||
|
|
7762d4e7c6 | ||
|
|
9ac23cd657 | ||
|
|
030faa4630 | ||
|
|
16f117571f | ||
|
|
95bf9e3c1c | ||
|
|
f5e9230a04 | ||
|
|
9e11b40fe1 | ||
|
|
70db76b219 | ||
|
|
8deef10292 | ||
|
|
75a8699467 | ||
|
|
c4ba32a8cc | ||
|
|
8e93719e9d | ||
|
|
cede5ac58b | ||
|
|
abbbd198fd | ||
|
|
a13f334df2 | ||
|
|
a2930a581f | ||
|
|
d0f6f03380 | ||
|
|
dd8c3f0e49 | ||
|
|
25d7c9f20a | ||
|
|
11fd8fe392 | ||
|
|
d1fe9b71ef | ||
|
|
0cd95b5514 | ||
|
|
6090eb5563 | ||
|
|
5d094415ce | ||
|
|
35e956609a | ||
|
|
1fc9c58b24 | ||
|
|
685a1c38e2 | ||
|
|
fb8918bbe6 | ||
|
|
78e12f7cfa | ||
|
|
8d86951a3b | ||
|
|
863ef64c61 | ||
|
|
7d106ee8b5 | ||
|
|
d9ac8155da | ||
|
|
ffba1b6fa0 | ||
|
|
3900ee34ae | ||
|
|
cce22c0df9 | ||
|
|
29d73b9302 | ||
|
|
304c826b47 | ||
|
|
357ea7a995 | ||
|
|
d13fd19a63 | ||
|
|
ea69f5a9a6 | ||
|
|
c50ca3ab86 | ||
|
|
27977cda23 | ||
|
|
07dfde4d2d | ||
|
|
f7ef1c8d4d | ||
|
|
c0901ec8a6 | ||
|
|
d5e80cae1b | ||
|
|
5b3a4ed7e0 | ||
|
|
8c87b242b3 | ||
|
|
a65f0d3b2a | ||
|
|
db8d1b58b8 | ||
|
|
c3efe1b9b7 | ||
|
|
5806a66cf9 | ||
|
|
f2018a8764 | ||
|
|
11b18c2817 | ||
|
|
0070377f2a | ||
|
|
e88db57214 | ||
|
|
a0ad05983a | ||
|
|
8d9f17d09d | ||
|
|
e9fe66b8e4 | ||
|
|
d4d909de5f | ||
|
|
925177f3d8 | ||
|
|
bc7ae4186b | ||
|
|
b2588f610a | ||
|
|
b5e1fe613c | ||
|
|
c492ffee08 | ||
|
|
40da4bd423 | ||
|
|
f5f1aec47b | ||
|
|
d4a9b922e5 | ||
|
|
07a2a16232 | ||
|
|
b212fbd0b5 | ||
|
|
f50d8c0731 | ||
|
|
1a7fd756e5 | ||
|
|
798a6bf689 | ||
|
|
5cdd5f580d | ||
|
|
40bd9fbdf3 | ||
|
|
0862eead00 | ||
|
|
474bc536d6 | ||
|
|
7b3d96e9e9 | ||
|
|
6b605ec4f9 | ||
|
|
565612bc19 | ||
|
|
a988415e22 | ||
|
|
0844a11549 | ||
|
|
b58c5f7df4 | ||
|
|
40bb8968cc | ||
|
|
9e19546ba8 | ||
|
|
82d5e044c7 | ||
|
|
34d4477a12 | ||
|
|
23c5ad78b5 | ||
|
|
dcfeb5829a | ||
|
|
0384e3d323 | ||
|
|
1f548875c6 | ||
|
|
762dc31e98 | ||
|
|
4fd417d419 | ||
|
|
59b66e7579 | ||
|
|
d8dbc46867 | ||
|
|
3a2a7427e7 | ||
|
|
7f55c0626f | ||
|
|
a84488f59a | ||
|
|
f64f08c9b6 | ||
|
|
af883d9165 | ||
|
|
f5f5b514d4 | ||
|
|
4068879d84 | ||
|
|
9cf50154d2 | ||
|
|
65c30902e7 | ||
|
|
e6dbfac232 | ||
|
|
f2a83cdf29 | ||
|
|
042e446694 | ||
|
|
13d9fd083c | ||
|
|
0a24dca821 | ||
|
|
1f632daf85 | ||
|
|
b6d4de7046 | ||
|
|
86a9f47f6c | ||
|
|
fb5806f5fb | ||
|
|
07374b5638 | ||
|
|
23c1eea7d8 | ||
|
|
7200f3cf31 | ||
|
|
7ed7f020d3 | ||
|
|
d28c96837e | ||
|
|
a14eefcea3 | ||
|
|
7b89771953 | ||
|
|
d9f5bd013b | ||
|
|
9bd3ac26e3 | ||
|
|
b5f89c661a | ||
|
|
0e42de4e99 | ||
|
|
71d9ad5e8b | ||
|
|
f06e5581aa | ||
|
|
1ab0edb84c | ||
|
|
8067a9ad56 | ||
|
|
66519d9973 | ||
|
|
f3d9d21757 | ||
|
|
2e3c0505cd | ||
|
|
b3e34cc2b4 | ||
|
|
fedbe26480 | ||
|
|
335771d580 | ||
|
|
98d62283c7 | ||
|
|
6eaa6201f0 | ||
|
|
da20845e9c | ||
|
|
3a8ad45dec | ||
|
|
6e5647bb67 | ||
|
|
102f0d3470 | ||
|
|
51fd654802 | ||
|
|
f8be39b26b | ||
|
|
b9836afb49 | ||
|
|
bc9aa9e34f | ||
|
|
4d9ef1042d | ||
|
|
093dedcd85 | ||
|
|
ae401cac0f | ||
|
|
63366042ed | ||
|
|
fe59dc27b3 | ||
|
|
91105b8183 | ||
|
|
c071ac854e | ||
|
|
1f87bea78f | ||
|
|
09c98226c8 | ||
|
|
0bc05135d8 | ||
|
|
6d16d06120 | ||
|
|
f00823c7bf | ||
|
|
b9a4ea80c5 | ||
|
|
cb00e729ad | ||
|
|
68e2e21fb9 | ||
|
|
4a1a95ea36 | ||
|
|
595b3ffe23 | ||
|
|
c0c9552f4c | ||
|
|
c339df65a9 | ||
|
|
a47729c626 | ||
|
|
b20327770b | ||
|
|
29fa87ee7c | ||
|
|
c0eb894bd9 | ||
|
|
cd3dc5998f | ||
|
|
dfd88b8f24 | ||
|
|
6ddc063a76 | ||
|
|
624e507ec2 | ||
|
|
02861308bc | ||
|
|
66a7a58313 | ||
|
|
6ec71b3fd1 | ||
|
|
1edaf43051 | ||
|
|
f632a34959 | ||
|
|
d3e3039eb2 | ||
|
|
0def7d4b4e | ||
|
|
80321b610a | ||
|
|
f3a219f062 | ||
|
|
f7e947e912 | ||
|
|
be73ec2cc9 | ||
|
|
6bf0152f6d | ||
|
|
ec63394121 | ||
|
|
34269e1a3e | ||
|
|
954a011721 | ||
|
|
0eda00e2df | ||
|
|
f63f1274cd | ||
|
|
5fb5cea4a3 | ||
|
|
be82d4c661 | ||
|
|
f0169f4181 | ||
|
|
6698e0ecc9 | ||
|
|
6387076efe | ||
|
|
159878e09d | ||
|
|
61674fb3d9 | ||
|
|
7315146753 | ||
|
|
79123d6bb6 | ||
|
|
6b163bca8a | ||
|
|
1e5ea703b5 | ||
|
|
0da62a8815 | ||
|
|
6dc17e5a03 | ||
|
|
96a5e573c3 | ||
|
|
8e1a89230e | ||
|
|
f7dc0fca74 | ||
|
|
525a1cc3c6 | ||
|
|
d65d3b9068 | ||
|
|
9663fac5b1 | ||
|
|
50e1ec9c4f | ||
|
|
549171d043 | ||
|
|
6a4fe52e51 | ||
|
|
a128b94e2e | ||
|
|
9feebb1dc6 | ||
|
|
4cb276c47f | ||
|
|
501bb398d4 | ||
|
|
1a3750f31b | ||
|
|
84c7b05781 | ||
|
|
db45f4a062 | ||
|
|
afa59a616c | ||
|
|
2365db1367 | ||
|
|
b18b888161 | ||
|
|
6f5a2172ac | ||
|
|
fff8bfff5f | ||
|
|
3453809b4b | ||
|
|
f41a8d2c00 | ||
|
|
2bf6db003a | ||
|
|
391b57077b | ||
|
|
d25a858214 | ||
|
|
cb9a55b375 | ||
|
|
fbcfed6757 | ||
|
|
b653598df2 | ||
|
|
0d17a71ffa | ||
|
|
ef93a71e78 | ||
|
|
7a6429e35e | ||
|
|
745a7333b1 | ||
|
|
05677e26a4 | ||
|
|
4fe11f0998 | ||
|
|
e1cf002c30 | ||
|
|
e9880e6787 | ||
|
|
a759fc2454 | ||
|
|
7229df26ab | ||
|
|
73f3db5cf8 | ||
|
|
a0e518870d | ||
|
|
0a9adbb777 | ||
|
|
3b85839bf3 | ||
|
|
a84b32af98 | ||
|
|
129c592581 | ||
|
|
a7a1227390 | ||
|
|
5008682bef | ||
|
|
0213d37d82 | ||
|
|
c8da4d90e9 | ||
|
|
a08373fec6 | ||
|
|
f0078b5e0f | ||
|
|
55c19a632a | ||
|
|
40e1292e9a | ||
|
|
f3b9ab9329 | ||
|
|
e73866040d | ||
|
|
229c92e6b8 | ||
|
|
aa13a67371 | ||
|
|
edac2dd3bd | ||
|
|
cff0c35987 | ||
|
|
e1a84802f2 | ||
|
|
c61ee18c03 | ||
|
|
6d69608feb | ||
|
|
043c65b1d4 | ||
|
|
503a8deef1 | ||
|
|
d8b962c7f3 | ||
|
|
38a5b988f0 | ||
|
|
a5223d8a38 | ||
|
|
f9bf214526 | ||
|
|
eabcbb00ab | ||
|
|
a124827c4e | ||
|
|
22c80d2694 | ||
|
|
c5852152b2 | ||
|
|
b1e452b568 | ||
|
|
56d1979d9b | ||
|
|
2b43aad4f9 | ||
|
|
ff082be524 | ||
|
|
dc62d167ad | ||
|
|
0d220c68ea | ||
|
|
f0a0df94b5 | ||
|
|
2e6d4b3501 | ||
|
|
c73c581b11 | ||
|
|
77a5ddbcd0 | ||
|
|
0dafcb6728 | ||
|
|
9206b571f4 | ||
|
|
497e4fab79 | ||
|
|
a3a0edca58 | ||
|
|
a56c54371e | ||
|
|
b06b3ab4c4 | ||
|
|
22d33a5afa | ||
|
|
f202ad9f98 | ||
|
|
f20ee6df4b | ||
|
|
8bd6acec5d | ||
|
|
e54c838482 | ||
|
|
64044800c9 | ||
|
|
49e2262ca7 | ||
|
|
2d634931f6 | ||
|
|
ae39524a95 | ||
|
|
ecb955f5b3 | ||
|
|
88f9621b45 | ||
|
|
1b2aa205ec | ||
|
|
b086a2b7a5 | ||
|
|
c1f8db5962 | ||
|
|
df8232c555 | ||
|
|
ab6eff5a5b | ||
|
|
aa3d0fe1d7 | ||
|
|
869487ac82 | ||
|
|
ef34875061 | ||
|
|
a63bbf317d | ||
|
|
e5c77d1242 | ||
|
|
ee33c09714 | ||
|
|
838ef11f1c | ||
|
|
34a98f2563 | ||
|
|
f202a5c31d | ||
|
|
cc68ed894b | ||
|
|
b20439027c | ||
|
|
4a132599fd | ||
|
|
f7ccfafd1c | ||
|
|
f1675a9162 | ||
|
|
8e8f41e228 | ||
|
|
070a7d4d72 | ||
|
|
e76df4db11 | ||
|
|
9fb09e62af | ||
|
|
619df3a53e | ||
|
|
8eb57f5a75 | ||
|
|
21d31a1a4f | ||
|
|
1214bef3e8 | ||
|
|
890ef7a8ae | ||
|
|
d74b27335e | ||
|
|
94f4ddb762 | ||
|
|
e418a763db | ||
|
|
5be4dda58b | ||
|
|
f5aed51fd0 | ||
|
|
a737352b5d | ||
|
|
f1c66fa6b0 | ||
|
|
3d5d3e00e3 | ||
|
|
57bffaf8fa | ||
|
|
013dd7261e | ||
|
|
4b24c96cca | ||
|
|
6564231040 | ||
|
|
25efd6684f | ||
|
|
52ed640a2b | ||
|
|
aea978cf90 | ||
|
|
fd3f929a11 | ||
|
|
fe2fb60daf | ||
|
|
40932f84c8 | ||
|
|
91b0b83ec3 | ||
|
|
bd21e487fc | ||
|
|
d25a76e044 | ||
|
|
ea3215b361 | ||
|
|
0b6a4df4f4 | ||
|
|
837353d9fd | ||
|
|
50aa918791 | ||
|
|
f5cc3e1a92 | ||
|
|
1dbfe5483a | ||
|
|
107480657a | ||
|
|
d1214d2368 | ||
|
|
12d18533e8 | ||
|
|
364a7a6574 | ||
|
|
920769d36d | ||
|
|
220c360081 | ||
|
|
969beb7898 | ||
|
|
bdbd469aad | ||
|
|
141e731f39 | ||
|
|
6cb1d2e3f7 | ||
|
|
e232697da1 | ||
|
|
583694a450 | ||
|
|
8134d097e3 | ||
|
|
a3d9ff65aa | ||
|
|
c3c72fc528 | ||
|
|
fefadaa171 | ||
|
|
dd2e95b3bc | ||
|
|
bf53222bd9 | ||
|
|
2529bb24d1 | ||
|
|
c699fa96d9 | ||
|
|
867956729b | ||
|
|
bdf7e924b5 | ||
|
|
c2a03d60f0 | ||
|
|
b4f26bde44 | ||
|
|
549df3c0eb | ||
|
|
a39d2bc24f | ||
|
|
b665a1998b | ||
|
|
0cbbb6a0db | ||
|
|
195274370f | ||
|
|
45c1fa3741 | ||
|
|
f7de0e274c | ||
|
|
f11095b1d0 | ||
|
|
687fdce30a | ||
|
|
a2f8def1e8 | ||
|
|
6c50e1b237 | ||
|
|
90e4b09272 | ||
|
|
e268e74fa3 | ||
|
|
ad8de070fa | ||
|
|
a88e9666e4 | ||
|
|
5abc2dac4e | ||
|
|
9d72036ba5 | ||
|
|
860544d299 | ||
|
|
605c9f48b4 | ||
|
|
2a1520228e | ||
|
|
3613fb746c | ||
|
|
ebbd08a546 | ||
|
|
b6d76157c4 | ||
|
|
2ded7bae73 | ||
|
|
b2c288b62a | ||
|
|
8e6618920d | ||
|
|
bb5998048f | ||
|
|
c04b52561e | ||
|
|
6eae62c235 | ||
|
|
4136c80358 | ||
|
|
e703de5796 | ||
|
|
12e76f3d04 | ||
|
|
e7cd4bf6cf | ||
|
|
75853e3aad | ||
|
|
fa70192f75 | ||
|
|
ad1b460bea | ||
|
|
27238a470a | ||
|
|
9829fd83a0 | ||
|
|
0137b7ec3c | ||
|
|
38514673bf | ||
|
|
556b76d9a4 | ||
|
|
9cdea0479c | ||
|
|
2fc2c73374 | ||
|
|
19ec9f9eda | ||
|
|
d7c06f0527 | ||
|
|
b98f000c29 | ||
|
|
ec077d5f8f | ||
|
|
e5bbc2a0d8 | ||
|
|
5649797461 | ||
|
|
787b8f72c5 | ||
|
|
b15963d3fb | ||
|
|
1ce3ddaa82 | ||
|
|
da96385f00 | ||
|
|
141c88aaa9 | ||
|
|
db86ade5fb | ||
|
|
1055aa86aa | ||
|
|
1944f75802 | ||
|
|
062dda89ea | ||
|
|
f9f4aefb2a | ||
|
|
410d5deb1c | ||
|
|
e613e3523e | ||
|
|
e125375654 | ||
|
|
f5c08c4868 | ||
|
|
f45baa9dbe | ||
|
|
d4307c69d2 | ||
|
|
4a078c1143 | ||
|
|
ecb293bd6c | ||
|
|
4b197aafa4 | ||
|
|
1143db85f1 | ||
|
|
3ea2d420b2 | ||
|
|
6c9538b040 | ||
|
|
3e4888afa7 | ||
|
|
7bf84ec84c | ||
|
|
a7fbc1bc6c | ||
|
|
a29773597e | ||
|
|
b172709008 | ||
|
|
e85b36cdff | ||
|
|
ad6a0c4b72 | ||
|
|
50265c311e | ||
|
|
181b10103f | ||
|
|
514a41ac77 | ||
|
|
e554c9f53d | ||
|
|
c7e0e3d391 | ||
|
|
401d9ac831 | ||
|
|
05aaea48e9 | ||
|
|
12b7d218b7 | ||
|
|
93efcd637e | ||
|
|
852fc8bc5d | ||
|
|
31ebee81f0 | ||
|
|
c42b7b1780 | ||
|
|
b26e6665b0 | ||
|
|
61221382b5 | ||
|
|
b5722c9470 | ||
|
|
cc3ca57b75 | ||
|
|
41c4c3befd | ||
|
|
11d02e5485 | ||
|
|
b80f82dffd | ||
|
|
33cdefffe3 | ||
|
|
f8052817a8 | ||
|
|
759e42188b | ||
|
|
b062548392 | ||
|
|
72f96cd55c | ||
|
|
6bcb2e9001 | ||
|
|
6b336be10c | ||
|
|
278e682595 | ||
|
|
bb3f1f1fb7 | ||
|
|
c3cfe33b64 | ||
|
|
212d3da950 | ||
|
|
1e9718f55b | ||
|
|
23fa0ba6ab | ||
|
|
d986b0e565 | ||
|
|
dc97cdb51c | ||
|
|
1904955c82 | ||
|
|
824d79c934 | ||
|
|
ffe8ae3840 | ||
|
|
dd0642e0fc | ||
|
|
d0d207f387 | ||
|
|
989cae9f1f | ||
|
|
7be48c7336 | ||
|
|
e6c98078b3 | ||
|
|
8cafea9f5a | ||
|
|
6d1b89bba3 | ||
|
|
541786a4db | ||
|
|
df15e4767b | ||
|
|
0c3a7a9d99 | ||
|
|
2db1d128a0 | ||
|
|
1e02064a5b | ||
|
|
04d8960a3d | ||
|
|
0dd17535d6 | ||
|
|
bdc4d14f33 | ||
|
|
03f673d6cf | ||
|
|
6f1d362917 | ||
|
|
b84e5969e2 | ||
|
|
9fabdf4587 | ||
|
|
9b04e3e3fe | ||
|
|
10a9c0a434 | ||
|
|
b5ee5877ce | ||
|
|
eec4bc7e04 | ||
|
|
8f6b12d296 | ||
|
|
5a63e34c19 | ||
|
|
9ac193407b | ||
|
|
25172d797e | ||
|
|
20f20f9441 | ||
|
|
b72b036bdb | ||
|
|
c8278fd887 | ||
|
|
dd1fffae40 | ||
|
|
ce4bbb906b | ||
|
|
36bad02e67 | ||
|
|
9290c3aad7 | ||
|
|
7a51ef5723 | ||
|
|
c142253fb9 | ||
|
|
9827a5a21d | ||
|
|
23151936b6 | ||
|
|
80294f53ad | ||
|
|
0cac7c32b6 | ||
|
|
3bc80a6d05 | ||
|
|
d7dfbe40a4 | ||
|
|
4ba4484683 | ||
|
|
5b80eef381 | ||
|
|
5ae756addb | ||
|
|
317607db70 | ||
|
|
89ea4d5a85 | ||
|
|
d876e85eb2 | ||
|
|
2036b87ccf | ||
|
|
6e8002138e | ||
|
|
dd0436cd3a | ||
|
|
44b8e22bef | ||
|
|
3c6566c1b1 | ||
|
|
60a7a57e65 | ||
|
|
27b654cc50 | ||
|
|
c05d30de38 | ||
|
|
774af134fa | ||
|
|
a50720d74d | ||
|
|
03d1c64d27 | ||
|
|
a0404b11b0 | ||
|
|
c80cdb4790 | ||
|
|
74242a5fd9 | ||
|
|
1353e7f56b | ||
|
|
5e6619e368 | ||
|
|
95302fd540 | ||
|
|
b2ec5e1ec4 | ||
|
|
af963ea244 | ||
|
|
8f52f71378 | ||
|
|
8db599c68a | ||
|
|
be2713b59c | ||
|
|
ae7c5e1323 | ||
|
|
b680b74ecb | ||
|
|
5ade563902 | ||
|
|
865c793561 | ||
|
|
58126b28ca | ||
|
|
8386bcd4e0 | ||
|
|
6ad2157806 | ||
|
|
73fc984c4c | ||
|
|
609caa8159 | ||
|
|
15043b3c6d | ||
|
|
0c11ca680e | ||
|
|
d61352c8f3 | ||
|
|
a795ee6218 | ||
|
|
8a607ce9be | ||
|
|
436fc33e84 | ||
|
|
48bd71e0b6 | ||
|
|
f022cd6281 | ||
|
|
886ae36e1f | ||
|
|
0eedb0dc6b | ||
|
|
89d74d94c9 | ||
|
|
3b9232e8d4 | ||
|
|
aa6ab1ffee | ||
|
|
afdec6ecc4 | ||
|
|
b5ab6cbad0 | ||
|
|
d16ddd081a | ||
|
|
1c5338ccf7 | ||
|
|
03539c1945 | ||
|
|
4816e391ff | ||
|
|
d3fce0d0ec | ||
|
|
7a8ba9c733 | ||
|
|
c47732e7eb | ||
|
|
64982aa72e | ||
|
|
d6f8aa6f03 | ||
|
|
fb475775c9 | ||
|
|
6018b103cc | ||
|
|
17a78dd522 | ||
|
|
7fbed5ee86 | ||
|
|
80eca3e49e | ||
|
|
1ad090e3a7 | ||
|
|
cd9349deb7 | ||
|
|
86c253ef6d | ||
|
|
d3a8f78a88 | ||
|
|
0e075c7d5f | ||
|
|
338789664c | ||
|
|
cbb9e9c40e | ||
|
|
da817e7ed2 | ||
|
|
a5688440a1 | ||
|
|
5aaa186180 | ||
|
|
ec6108ee05 | ||
|
|
7f98ceb427 | ||
|
|
ddb3157a58 | ||
|
|
c78169d236 | ||
|
|
1dafa79eaf | ||
|
|
87d108e75e | ||
|
|
1f68b43558 | ||
|
|
78e7b9c32b | ||
|
|
667a22f84e | ||
|
|
49718f143b | ||
|
|
0151b7a2d1 | ||
|
|
f29816f19c | ||
|
|
1aa55f3e54 | ||
|
|
3c4125c233 | ||
|
|
3c7677e73e | ||
|
|
2e38833367 | ||
|
|
e4cd733879 | ||
|
|
60271201fc | ||
|
|
2c443532c5 | ||
|
|
3cdae252ef | ||
|
|
efac671ae6 | ||
|
|
f076ab8f54 | ||
|
|
b880775de5 | ||
|
|
28b3ed67c1 | ||
|
|
2b6045af0f | ||
|
|
53fe237499 | ||
|
|
96e5985ca9 | ||
|
|
d27b7b793f | ||
|
|
915f8734c5 | ||
|
|
15e963de25 | ||
|
|
3f2d4b31be | ||
|
|
987708680f | ||
|
|
1dcc096753 | ||
|
|
0484df00c3 | ||
|
|
a26e77fd93 | ||
|
|
555119f59a | ||
|
|
bbc2d30f60 | ||
|
|
53983774d0 | ||
|
|
593e93b88b | ||
|
|
d71c481606 | ||
|
|
8cb631d6f8 | ||
|
|
c0db84331e | ||
|
|
c6f10ea219 | ||
|
|
879f0d201e | ||
|
|
c7633a5266 | ||
|
|
498d1d5cf8 | ||
|
|
ce01c61811 | ||
|
|
20f3403c80 | ||
|
|
1d2d2f4845 | ||
|
|
f0e7435254 | ||
|
|
bb7b4daef6 | ||
|
|
f76025710e | ||
|
|
bc5f28d9fd | ||
|
|
5c6d74af7d | ||
|
|
9de0e8c9fd | ||
|
|
54b2e994e1 | ||
|
|
260f9fb634 | ||
|
|
7bf622dd26 | ||
|
|
f7edd5abe7 | ||
|
|
236cdc7d82 | ||
|
|
897ebd0347 | ||
|
|
8ada9b68b0 | ||
|
|
35c67734d3 | ||
|
|
6aa5e53a00 | ||
|
|
6a714436f2 | ||
|
|
7c0acd9da5 | ||
|
|
dfe3062340 | ||
|
|
2d54139018 | ||
|
|
72c7d22d5f | ||
|
|
9eb1a38a25 | ||
|
|
92faee3fd7 | ||
|
|
b7dbd7a68d | ||
|
|
a8d77887af | ||
|
|
e25cbcd961 | ||
|
|
23a45ae689 | ||
|
|
691068c0c2 | ||
|
|
f7c1802fb7 |
8
.idea/artifacts/IdeLazyResolver.xml
generated
8
.idea/artifacts/IdeLazyResolver.xml
generated
@@ -1,9 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="IdeLazyResolver">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/IdeLazyResolver</output-path>
|
||||
<root id="archive" name="ide-lazy-resolver.jar">
|
||||
<element id="module-output" name="ide-lazy-resolve" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/idea/ide-lazy-resolve" />
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/internal/</output-path>
|
||||
<root id="archive" name="kotlin-ide-common.jar">
|
||||
<element id="module-output" name="ide-common" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/idea/ide-common" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
2
.idea/artifacts/InjectorGenerator.xml
generated
2
.idea/artifacts/InjectorGenerator.xml
generated
@@ -1,6 +1,6 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="InjectorGenerator">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/InjectorGenerator</output-path>
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/internal/</output-path>
|
||||
<root id="archive" name="injector-generator.jar">
|
||||
<element id="module-output" name="injector-generator" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/injector-generator" />
|
||||
|
||||
5
.idea/artifacts/KotlinPlugin.xml
generated
5
.idea/artifacts/KotlinPlugin.xml
generated
@@ -14,7 +14,6 @@
|
||||
<element id="module-output" name="util" />
|
||||
<element id="module-output" name="util.runtime" />
|
||||
<element id="module-output" name="j2k" />
|
||||
<element id="module-output" name="js.translator" />
|
||||
<element id="module-output" name="js.frontend" />
|
||||
<element id="module-output" name="cli-common" />
|
||||
<element id="module-output" name="ide-compiler-runner" />
|
||||
@@ -30,7 +29,9 @@
|
||||
</element>
|
||||
<element id="module-output" name="eval4j" />
|
||||
<element id="module-output" name="idea-analysis" />
|
||||
<element id="module-output" name="ide-lazy-resolve" />
|
||||
<element id="module-output" name="ide-common" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/resources/manifest.properties" />
|
||||
<element id="module-output" name="kotlin-android-plugin" />
|
||||
</element>
|
||||
<element id="library" level="project" name="javax.inject" />
|
||||
<element id="directory" name="jps">
|
||||
|
||||
2
.idea/dictionaries/valentin.xml
generated
2
.idea/dictionaries/valentin.xml
generated
@@ -2,7 +2,9 @@
|
||||
<dictionary name="valentin">
|
||||
<words>
|
||||
<w>initializers</w>
|
||||
<w>inserter</w>
|
||||
<w>pparent</w>
|
||||
<w>processings</w>
|
||||
<w>rparenth</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
|
||||
19
.idea/libraries/android_plugin.xml
generated
Normal file
19
.idea/libraries/android_plugin.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<component name="libraryTable">
|
||||
<library name="android-plugin">
|
||||
<ANNOTATIONS>
|
||||
<root url="file://$PROJECT_DIR$/annotations" />
|
||||
</ANNOTATIONS>
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/src" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/common/src" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/rt/src" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/jps-plugin/src" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/ultimate/src" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib" recursive="false" />
|
||||
</library>
|
||||
</component>
|
||||
7
.idea/modules.xml
generated
7
.idea/modules.xml
generated
@@ -22,8 +22,8 @@
|
||||
<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" />
|
||||
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" group="compiler" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/ide-common/ide-common.iml" filepath="$PROJECT_DIR$/idea/ide-common/ide-common.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" filepath="$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/ide-lazy-resolve/ide-lazy-resolve.iml" filepath="$PROJECT_DIR$/idea/ide-lazy-resolve/ide-lazy-resolve.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" filepath="$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea_runner/idea_runner.iml" filepath="$PROJECT_DIR$/idea_runner/idea_runner.iml" group="ide" />
|
||||
@@ -34,9 +34,11 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/jps-plugin/jps-plugin.iml" filepath="$PROJECT_DIR$/jps-plugin/jps-plugin.iml" group="ide/jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/js/js.dart-ast/js.dart-ast.iml" filepath="$PROJECT_DIR$/js/js.dart-ast/js.dart-ast.iml" group="compiler/js" />
|
||||
<module fileurl="file://$PROJECT_DIR$/js/js.frontend/js.frontend.iml" filepath="$PROJECT_DIR$/js/js.frontend/js.frontend.iml" group="compiler/js" />
|
||||
<module fileurl="file://$PROJECT_DIR$/js/js.inliner/js.inliner.iml" filepath="$PROJECT_DIR$/js/js.inliner/js.inliner.iml" group="compiler/js" />
|
||||
<module fileurl="file://$PROJECT_DIR$/js/js.tests/js.tests.iml" filepath="$PROJECT_DIR$/js/js.tests/js.tests.iml" group="compiler/js" />
|
||||
<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$/idea/kotlin-android-plugin/kotlin-android-plugin.iml" filepath="$PROJECT_DIR$/idea/kotlin-android-plugin/kotlin-android-plugin.iml" group="ide" />
|
||||
<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/reflection.iml" filepath="$PROJECT_DIR$/core/reflection/reflection.iml" group="core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
|
||||
@@ -46,5 +48,4 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/core/util.runtime/util.runtime.iml" filepath="$PROJECT_DIR$/core/util.runtime/util.runtime.iml" group="core" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
</project>
|
||||
6
.idea/runConfigurations/Generate_Injectors.xml
generated
6
.idea/runConfigurations/Generate_Injectors.xml
generated
@@ -10,7 +10,13 @@
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="generators" />
|
||||
<envs />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="" />
|
||||
<option name="TRANSPORT" value="0" />
|
||||
<option name="LOCAL" value="true" />
|
||||
</RunnerSettings>
|
||||
<RunnerSettings RunnerId="Run" />
|
||||
<ConfigurationWrapper RunnerId="Debug" />
|
||||
<ConfigurationWrapper RunnerId="Run" />
|
||||
<method />
|
||||
</configuration>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
||||
<option name="PACKAGE_NAME" value="org.jetbrains.jet.jps.build" />
|
||||
<option name="MAIN_CLASS_NAME" value="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="TEST_OBJECT" value="pattern" />
|
||||
<option name="VM_PARAMETERS" value="-ea -Xmx512m -XX:MaxPermSize=320m -Dkotlin.incremental.compilation=true" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
@@ -19,7 +19,10 @@
|
||||
<envs>
|
||||
<env name="kotlin.tests.actually.compile" value="false" />
|
||||
</envs>
|
||||
<patterns />
|
||||
<patterns>
|
||||
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
|
||||
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalCacheVersionChangedTest" />
|
||||
</patterns>
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="" />
|
||||
<option name="TRANSPORT" value="0" />
|
||||
|
||||
4
.idea/vcs.xml
generated
4
.idea/vcs.xml
generated
@@ -7,6 +7,10 @@
|
||||
<option name="issueRegexp" value="[A-Z]+\-\d+" />
|
||||
<option name="linkRegexp" value="http://youtrack.jetbrains.com/issue/$0" />
|
||||
</IssueNavigationLink>
|
||||
<IssueNavigationLink>
|
||||
<option name="issueRegexp" value="EA\-(\d+)" />
|
||||
<option name="linkRegexp" value="http://ea.jetbrains.com/browser/ea_problems/$1" />
|
||||
</IssueNavigationLink>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
14
ReadMe.md
14
ReadMe.md
@@ -2,7 +2,7 @@
|
||||
|
||||
Welcome to [Kotlin](http://kotlinlang.org/)! Some handy links:
|
||||
|
||||
* [Getting Started Guide](http://confluence.jetbrains.net/display/Kotlin/Getting+Started)
|
||||
* [Getting Started Guide](http://kotlinlang.org/docs/tutorials/getting-started.html)
|
||||
* [Web Demo](http://kotlin-demo.jetbrains.com/)
|
||||
* [Kotlin Site](http://jetbrains.github.com/kotlin/)
|
||||
* [API](http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/index.html)
|
||||
@@ -10,7 +10,7 @@ Welcome to [Kotlin](http://kotlinlang.org/)! Some handy links:
|
||||
* [Forum](http://devnet.jetbrains.net/community/kotlin?view=discussions)
|
||||
* [Kotlin Blog](http://blog.jetbrains.com/kotlin/)
|
||||
* [follow Kotlin on twitter](http://twitter.com/#!/project_kotlin)
|
||||
* [TeamCity CI build](http://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview)
|
||||
* [TeamCity CI build](https://teamcity.jetbrains.com/project.html?tab=projectOverview&projectId=Kotlin)
|
||||
|
||||
## Editing Kotlin
|
||||
|
||||
@@ -52,7 +52,7 @@ then choose the `tools.jar` in the JDK's `lib` directory.
|
||||
If you are not dealing with Android, you may need to disable the Android Plugin in order to compile the project.
|
||||
|
||||
Since Kotlin project contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in IntelliJ IDEA.
|
||||
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](http://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
|
||||
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](https://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
|
||||
you should install the according to the [instructions below](#plugin-for-contributors).
|
||||
|
||||
If you want to have an IDEA installation without the Kotlin plugin which is separate to your default IDEA installation which has the Kotlin
|
||||
@@ -72,7 +72,7 @@ There are several options for getting Kotlin plugin. A stable version can be obt
|
||||
Preferences -> Plugins -> Browse Repositories -> Search with "Kotlin" string
|
||||
|
||||
The most recent version of the plugin can be downloaded from the
|
||||
[IDEA Plugin and Tests CI build](http://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
|
||||
[IDEA Plugin and Tests CI build](https://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
|
||||
finished you can install it with "Install plugin from disk...":
|
||||
|
||||
Preferences -> Plugins -> Install plugin from disk...
|
||||
@@ -89,15 +89,15 @@ Open
|
||||
|
||||
and add the following URL to your repositories:
|
||||
|
||||
http://teamcity.jetbrains.com/guestAuth/repository/download/bt345/bootstrap.tcbuildtag/updatePlugins.xml
|
||||
https://teamcity.jetbrains.com/guestAuth/repository/download/bt345/bootstrap.tcbuildtag/updatePlugins.xml
|
||||
|
||||
Then update the list of plugins in "Browse Repositories", you'll see two versions of Kotlin there, install the one with the higher version number.
|
||||
|
||||
# Contributing
|
||||
|
||||
We love contributions! There's [lots to do on kotlin](http://youtrack.jetbrains.com/issues/KT) and on the [standard library](http://youtrack.jetbrains.com/issues/KT?q=%23%7BStandard+Library%7D+-Resolved) so why not chat with us on the [forum](http://devnet.jetbrains.net/community/kotlin?view=discussions) about what you're interested in doing?
|
||||
We love contributions! There's [lots to do on kotlin](http://youtrack.jetbrains.com/issues/KT) and on the [standard library](https://youtrack.jetbrains.com/issues/KT?q=Subtask+of%3A+KT-2554+%23Unresolved) so why not chat with us on the [forum](http://devnet.jetbrains.net/community/kotlin?view=discussions) about what you're interested in doing?
|
||||
|
||||
If you want to find some issues to start off with, try [this query](http://youtrack.jetbrains.com/issues?q=tag%3A+%7BUp+For+Grabs%7D) which should find all issues that marked as "up-for-grabs".
|
||||
If you want to find some issues to start off with, try [this query](https://youtrack.jetbrains.com/issues?q=tag%3A+%7BUp+For+Grabs%7D+%23Unresolved) which should find all issues that marked as "up-for-grabs".
|
||||
|
||||
Currently only committers can assign issues to themselves so just add a comment if you're starting work on it.
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<root>
|
||||
<item
|
||||
name='com.android.tools.idea.gradle.output.parser.PatternAwareOutputParser boolean parse(java.lang.String, com.android.tools.idea.gradle.output.parser.OutputLineReader, java.util.List<com.android.tools.idea.gradle.output.GradleMessage>)'>
|
||||
<annotation name='kotlin.jvm.KotlinSignature'>
|
||||
<val name="value"
|
||||
val=""fun parse(line: String, reader: OutputLineReader, messages: MutableList<GradleMessage>): Boolean""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
@@ -168,4 +168,20 @@
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void restoreReferences(com.intellij.codeInsight.editorActions.ReferenceData[], TRef[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.JoinLinesHandlerDelegate int tryJoinLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.JoinLinesHandlerDelegate int tryJoinLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate int tryJoinRawLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate int tryJoinRawLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
|
||||
@@ -1,117 +1,121 @@
|
||||
<root>
|
||||
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.DependentSpacingRule com.intellij.formatting.DependentSpacingRule registerData(com.intellij.formatting.DependentSpacingRule.Anchor, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -8,4 +8,7 @@
|
||||
<item name='com.intellij.ide.util.PsiElementListCellRenderer java.lang.String getElementText(T) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.ide.util.PsiElementListCellRenderer java.util.Comparator<T> getComparator()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
6
annotations/com/intellij/openapi/project/annotations.xml
Normal file
6
annotations/com/intellij/openapi/project/annotations.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<root>
|
||||
<item
|
||||
name='com.intellij.openapi.project.DumbService com.intellij.openapi.project.DumbService getInstance(com.intellij.openapi.project.Project)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -22,7 +22,11 @@
|
||||
<item name='com.intellij.openapi.roots.OrderEnumerator com.intellij.openapi.roots.OrderEnumerator recursively()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
<item
|
||||
name='com.intellij.openapi.roots.OrderEnumerator com.intellij.openapi.roots.OrderEnumerator satisfying(com.intellij.openapi.util.Condition<com.intellij.openapi.roots.OrderEntry>)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.openapi.roots.ProjectFileIndex.SERVICE com.intellij.openapi.roots.ProjectFileIndex getInstance(com.intellij.openapi.project.Project)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='com.intellij.openapi.util.text.StringUtil java.lang.String decapitalize(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -21,4 +21,8 @@
|
||||
<item name='com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler void updateMovedFile(com.intellij.psi.PsiFile) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler$1 void retargetUsages(java.util.List<com.intellij.usageView.UsageInfo>, java.util.Map<com.intellij.psi.PsiElement,com.intellij.psi.PsiElement>) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -1,5 +1,8 @@
|
||||
<root>
|
||||
<item name='org.apache.tools.ant.types.Path java.lang.String[] list()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='org.apache.tools.ant.types.Path org.apache.tools.ant.types.Path createPath()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.buildtools.ant;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.apache.tools.ant.types.Commandline;
|
||||
import org.apache.tools.ant.types.Path;
|
||||
import org.apache.tools.ant.types.Reference;
|
||||
import org.jetbrains.jet.buildtools.core.BytecodeCompiler;
|
||||
import org.jetbrains.jet.buildtools.core.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.buildtools.core.Util.getPath;
|
||||
|
||||
|
||||
/**
|
||||
* Kotlin bytecode compiler Ant task.
|
||||
* <p/>
|
||||
* See
|
||||
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
|
||||
* http://evgeny-goldin.org/javadoc/ant/develop.html
|
||||
* http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
|
||||
*/
|
||||
public class BytecodeCompilerTask extends Task {
|
||||
private File output;
|
||||
private File stdlib;
|
||||
private Path src;
|
||||
private Path externalAnnotations;
|
||||
private Path compileClasspath;
|
||||
private boolean includeRuntime = true;
|
||||
private final List<Commandline.Argument> additionalArguments = new ArrayList<Commandline.Argument>();
|
||||
|
||||
public void setOutput(File output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public void setStdlib(File stdlib) {
|
||||
this.stdlib = stdlib;
|
||||
}
|
||||
|
||||
public void setSrc(Path src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public Path createSrc() {
|
||||
if (src == null) {
|
||||
src = new Path(getProject());
|
||||
}
|
||||
return src.createPath();
|
||||
}
|
||||
|
||||
public void setExternalAnnotations(Path externalAnnotations) {
|
||||
this.externalAnnotations = externalAnnotations;
|
||||
}
|
||||
|
||||
public Path createExternalAnnotations() {
|
||||
if (externalAnnotations == null) {
|
||||
externalAnnotations = new Path(getProject());
|
||||
}
|
||||
return externalAnnotations.createPath();
|
||||
}
|
||||
|
||||
public void setIncludeRuntime(boolean includeRuntime) {
|
||||
this.includeRuntime = includeRuntime;
|
||||
}
|
||||
|
||||
public Commandline.Argument createCompilerArg() {
|
||||
Commandline.Argument argument = new Commandline.Argument();
|
||||
additionalArguments.add(argument);
|
||||
return argument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the classpath to be used for this compilation.
|
||||
*
|
||||
* @param classpath an Ant Path object containing the compilation classpath.
|
||||
*/
|
||||
public void setClasspath(Path classpath) {
|
||||
if (this.compileClasspath == null) {
|
||||
this.compileClasspath = classpath;
|
||||
}
|
||||
else {
|
||||
this.compileClasspath.append(classpath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a reference to a classpath defined elsewhere.
|
||||
*
|
||||
* @param ref a reference to a classpath.
|
||||
*/
|
||||
public void setClasspathRef(Reference ref) {
|
||||
if (this.compileClasspath == null) {
|
||||
this.compileClasspath = new Path(getProject());
|
||||
}
|
||||
this.compileClasspath.createPath().setRefid(ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nested {@code <classpath>} to be used for this compilation.
|
||||
*
|
||||
* @param classpath an Ant Path object containing the compilation classpath.
|
||||
*/
|
||||
public void addConfiguredClasspath(Path classpath) {
|
||||
setClasspath(classpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String stdlibPath = stdlib != null ? getPath(stdlib) : null;
|
||||
String[] classpath = compileClasspath != null ? compileClasspath.list() : null;
|
||||
String[] externalAnnotationsPath = externalAnnotations != null ? externalAnnotations.list() : null;
|
||||
|
||||
List<String> args = new ArrayList<String>();
|
||||
for (Commandline.Argument argument : additionalArguments) {
|
||||
args.addAll(Arrays.asList(argument.getParts()));
|
||||
}
|
||||
|
||||
if (src == null) {
|
||||
throw new BuildException("\"src\" should be specified");
|
||||
}
|
||||
if (output == null) {
|
||||
throw new BuildException("\"output\" should be specified");
|
||||
}
|
||||
|
||||
String[] source = Util.getPaths(src.list());
|
||||
String destination = getPath(output);
|
||||
|
||||
log(String.format("Compiling [%s] => [%s]", Arrays.toString(source), destination));
|
||||
BytecodeCompiler.compileSources(source, destination, includeRuntime, stdlibPath, classpath, externalAnnotationsPath, args);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* Copyright 2010-2014 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.
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.buildtools.ant
|
||||
|
||||
import org.apache.tools.ant.Task
|
||||
import org.apache.tools.ant.types.Path
|
||||
import org.apache.tools.ant.types.Reference
|
||||
import org.jetbrains.jet.buildtools.core.Util
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
|
||||
import org.jetbrains.jet.cli.js.K2JSCompiler
|
||||
@@ -32,9 +29,10 @@ import org.jetbrains.jet.config.Services
|
||||
* Kotlin JavaScript compiler Ant task.
|
||||
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
|
||||
*/
|
||||
public class Kotlin2JsCompilerTask : Task() {
|
||||
public var src: Path? = null
|
||||
public var output: File? = null
|
||||
public class Kotlin2JsTask : KotlinCompilerBaseTask<K2JSCompilerArguments>() {
|
||||
override val arguments = K2JSCompilerArguments()
|
||||
override val compiler = K2JSCompiler()
|
||||
|
||||
public var library: Path? = null
|
||||
public var outputPrefix: File? = null
|
||||
public var outputPostfix: File? = null
|
||||
@@ -46,21 +44,6 @@ public class Kotlin2JsCompilerTask : Task() {
|
||||
*/
|
||||
public var main: String? = null
|
||||
|
||||
public fun createSrc(): Path {
|
||||
val srcPath = src
|
||||
if (srcPath == null) {
|
||||
val t = Path(getProject())
|
||||
src = t
|
||||
return t
|
||||
}
|
||||
|
||||
return srcPath.createPath()
|
||||
}
|
||||
|
||||
public fun setSrcRef(ref: Reference) {
|
||||
createSrc().setRefid(ref)
|
||||
}
|
||||
|
||||
public fun createLibrary(): Path {
|
||||
val libraryPath = library
|
||||
if (libraryPath == null) {
|
||||
@@ -72,28 +55,13 @@ public class Kotlin2JsCompilerTask : Task() {
|
||||
return libraryPath.createPath()
|
||||
}
|
||||
|
||||
override fun execute(): Unit {
|
||||
val arguments = K2JSCompilerArguments()
|
||||
|
||||
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
|
||||
arguments.freeArgs = Util.getPaths(sourcePaths.list()).toList()
|
||||
|
||||
val outputFile = output ?: throw BuildException("\"output\" should be specified")
|
||||
arguments.outputFile = outputFile.canonicalPath
|
||||
override fun fillSpecificArguments() {
|
||||
arguments.outputFile = getPath(output!!)
|
||||
|
||||
arguments.outputPrefix = outputPrefix?.canonicalPath
|
||||
arguments.outputPostfix = outputPostfix?.canonicalPath
|
||||
|
||||
arguments.main = main
|
||||
arguments.sourceMap = sourceMap
|
||||
|
||||
log("Compiling ${arguments.freeArgs} => [${arguments.outputFile}]");
|
||||
|
||||
val compiler = K2JSCompiler()
|
||||
val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, Services.EMPTY, arguments)
|
||||
|
||||
if (exitCode != ExitCode.OK) {
|
||||
throw BuildException("Compilation finished with exit code $exitCode")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.buildtools.ant
|
||||
|
||||
import org.apache.tools.ant.types.Path
|
||||
import org.apache.tools.ant.types.Reference
|
||||
|
||||
import java.io.File
|
||||
import java.io.File.pathSeparator
|
||||
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
|
||||
|
||||
/**
|
||||
* Kotlin bytecode compiler Ant task.
|
||||
* <p/>
|
||||
* See
|
||||
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
|
||||
* http://evgeny-goldin.org/javadoc/ant/develop.html
|
||||
* http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
|
||||
*/
|
||||
public class Kotlin2JvmTask : KotlinCompilerBaseTask<K2JVMCompilerArguments>() {
|
||||
override val arguments = K2JVMCompilerArguments()
|
||||
override val compiler = K2JVMCompiler()
|
||||
|
||||
public var noStdlib: Boolean = false
|
||||
public var externalAnnotations: Path? = null
|
||||
public var includeRuntime: Boolean = true
|
||||
|
||||
private var compileClasspath: Path? = null
|
||||
|
||||
public fun createExternalAnnotations(): Path {
|
||||
if (externalAnnotations == null) {
|
||||
externalAnnotations = Path(getProject())
|
||||
}
|
||||
return externalAnnotations!!.createPath()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the classpath to be used for this compilation.
|
||||
*
|
||||
* @param classpath an Ant Path object containing the compilation classpath.
|
||||
*/
|
||||
public fun setClasspath(classpath: Path) {
|
||||
if (this.compileClasspath == null) {
|
||||
this.compileClasspath = classpath
|
||||
}
|
||||
else {
|
||||
this.compileClasspath!!.append(classpath)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a reference to a classpath defined elsewhere.
|
||||
*
|
||||
* @param ref a reference to a classpath.
|
||||
*/
|
||||
public fun setClasspathRef(ref: Reference) {
|
||||
if (this.compileClasspath == null) {
|
||||
this.compileClasspath = Path(getProject())
|
||||
}
|
||||
this.compileClasspath!!.createPath().setRefid(ref)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nested {@code <classpath>} to be used for this compilation.
|
||||
*
|
||||
* @param classpath an Ant Path object containing the compilation classpath.
|
||||
*/
|
||||
public fun addConfiguredClasspath(classpath: Path) {
|
||||
setClasspath(classpath)
|
||||
}
|
||||
|
||||
override fun fillSpecificArguments() {
|
||||
arguments.destination = getPath(output!!)
|
||||
|
||||
val classpath = arrayListOf<String>()
|
||||
compileClasspath?.let { classpath.addAll(it.list()) }
|
||||
arguments.freeArgs?.forEach {
|
||||
val file = File(it)
|
||||
if (file.isDirectory() || file.extension != "kt") {
|
||||
classpath.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
arguments.classpath = classpath.join(pathSeparator)
|
||||
|
||||
arguments.annotations = externalAnnotations?.list()?.join(pathSeparator)
|
||||
arguments.noStdlib = noStdlib
|
||||
arguments.includeRuntime = includeRuntime
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class KotlinCompilerAdapter extends DefaultCompilerAdapter {
|
||||
public boolean execute() throws BuildException {
|
||||
Javac javac = getJavac();
|
||||
|
||||
BytecodeCompilerTask kotlinTask = new BytecodeCompilerTask();
|
||||
Kotlin2JvmTask kotlinTask = new Kotlin2JvmTask();
|
||||
kotlinTask.setOutput(javac.getDestdir());
|
||||
kotlinTask.setClasspath(javac.getClasspath());
|
||||
kotlinTask.setSrc(javac.getSrcdir());
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.buildtools.ant
|
||||
|
||||
import org.apache.tools.ant.Task
|
||||
import org.apache.tools.ant.types.Path
|
||||
import org.apache.tools.ant.types.Reference
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
|
||||
import java.io.File
|
||||
import org.apache.tools.ant.BuildException
|
||||
import org.jetbrains.jet.cli.common.ExitCode
|
||||
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.jet.cli.common.CLICompiler
|
||||
import org.apache.tools.ant.types.Commandline
|
||||
import com.sampullara.cli.Args
|
||||
import java.io.IOException
|
||||
import org.jetbrains.jet.config
|
||||
import org.jetbrains.jet.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.jet.cli.common.messages.MessageRenderer
|
||||
|
||||
/**
|
||||
* {@code file.getCanonicalPath()} convenience wrapper.
|
||||
*
|
||||
* @param file - file to get its canonical path.
|
||||
* @return file's canonical path
|
||||
*/
|
||||
fun getPath(file: File): String {
|
||||
try {
|
||||
return file.getCanonicalPath()
|
||||
}
|
||||
catch (e: IOException) {
|
||||
throw RuntimeException("Failed to resolve canonical file of [$file]: $e", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for Kotlin compiler Ant tasks.
|
||||
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
|
||||
*/
|
||||
public abstract class KotlinCompilerBaseTask<T : CommonCompilerArguments> : Task() {
|
||||
protected abstract val arguments: T
|
||||
protected abstract val compiler: CLICompiler<T>
|
||||
|
||||
public var src: Path? = null
|
||||
public var output: File? = null
|
||||
public var nowarn: Boolean = false
|
||||
public var verbose: Boolean = false
|
||||
public var printVersion: Boolean = false
|
||||
|
||||
public val additionalArguments: MutableList<Commandline.Argument> = arrayListOf()
|
||||
|
||||
public fun createSrc(): Path {
|
||||
val srcPath = src
|
||||
if (srcPath == null) {
|
||||
val t = Path(getProject())
|
||||
src = t
|
||||
return t
|
||||
}
|
||||
|
||||
return srcPath.createPath()
|
||||
}
|
||||
|
||||
public fun setSrcRef(ref: Reference) {
|
||||
createSrc().setRefid(ref)
|
||||
}
|
||||
|
||||
public fun createCompilerArg(): Commandline.Argument {
|
||||
val argument = Commandline.Argument()
|
||||
additionalArguments.add(argument)
|
||||
return argument
|
||||
}
|
||||
|
||||
abstract fun fillSpecificArguments()
|
||||
|
||||
private fun fillArguments() {
|
||||
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
|
||||
arguments.freeArgs = sourcePaths.list().map { getPath(File(it)) }
|
||||
|
||||
output ?: throw BuildException("\"output\" should be specified")
|
||||
|
||||
arguments.suppressWarnings = nowarn
|
||||
arguments.verbose = verbose
|
||||
arguments.version = printVersion
|
||||
|
||||
val args = additionalArguments.flatMap { it.getParts()!!.toList() }
|
||||
try {
|
||||
Args.parse(arguments, args.copyToArray())
|
||||
}
|
||||
catch (e: IllegalArgumentException) {
|
||||
throw BuildException(e.getMessage())
|
||||
}
|
||||
|
||||
fillSpecificArguments()
|
||||
}
|
||||
|
||||
final override fun execute(): Unit {
|
||||
fillArguments()
|
||||
|
||||
val outputPath = getPath(output!!)
|
||||
|
||||
log("Compiling ${arguments.freeArgs} => [${outputPath}]");
|
||||
|
||||
val collector = PrintingMessageCollector(System.err, MessageRenderer.PLAIN, arguments.verbose)
|
||||
val exitCode = compiler.exec(collector, config.Services.EMPTY, arguments)
|
||||
|
||||
if (exitCode != ExitCode.OK) {
|
||||
throw BuildException("Compilation finished with exit code $exitCode")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@
|
||||
<antlib>
|
||||
<taskdef
|
||||
name = "kotlinc"
|
||||
classname = "org.jetbrains.jet.buildtools.ant.BytecodeCompilerTask"/>
|
||||
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JvmTask"/>
|
||||
<taskdef
|
||||
name = "kotlin2js"
|
||||
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsCompilerTask"/>
|
||||
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsTask"/>
|
||||
<typedef
|
||||
name = "withKotlin"
|
||||
classname = "org.jetbrains.jet.buildtools.ant.KotlinCompilerAdapter"/>
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.buildtools.core;
|
||||
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.sampullara.cli.Args;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
|
||||
|
||||
public class BytecodeCompiler {
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
@NotNull
|
||||
private static CompilerConfiguration createConfiguration(
|
||||
@Nullable String stdlib,
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath,
|
||||
@NotNull String[] sourceRoots,
|
||||
@NotNull List<String> args
|
||||
) {
|
||||
KotlinPaths paths = getKotlinPathsForAntTask();
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||
|
||||
configuration.addAll(CLASSPATH_KEY, PathUtil.getJdkClassesRoots());
|
||||
if ((stdlib != null) && (stdlib.trim().length() > 0)) {
|
||||
configuration.add(CLASSPATH_KEY, new File(stdlib));
|
||||
}
|
||||
else {
|
||||
File path = paths.getRuntimePath();
|
||||
if (path.exists()) {
|
||||
configuration.add(CLASSPATH_KEY, path);
|
||||
}
|
||||
}
|
||||
if ((classpath != null) && (classpath.length > 0)) {
|
||||
for (String path : classpath) {
|
||||
configuration.add(CLASSPATH_KEY, new File(path));
|
||||
}
|
||||
}
|
||||
if ((externalAnnotationsPath != null) && (externalAnnotationsPath.length > 0)) {
|
||||
for (String path : externalAnnotationsPath) {
|
||||
configuration.add(ANNOTATIONS_PATH_KEY, new File(path));
|
||||
}
|
||||
}
|
||||
File jdkAnnotationsPath = paths.getJdkAnnotationsPath();
|
||||
if (jdkAnnotationsPath.exists()) {
|
||||
configuration.add(ANNOTATIONS_PATH_KEY, jdkAnnotationsPath);
|
||||
}
|
||||
|
||||
CompileEnvironmentUtil.addSourceFilesCheckingForDuplicates(configuration, Arrays.asList(sourceRoots));
|
||||
for (String sourceRoot : sourceRoots) {
|
||||
File file = new File(sourceRoot);
|
||||
if (!file.isFile() || !"kt".equals(FileUtilRt.getExtension(file.getName()))) {
|
||||
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, file);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use K2JVMCompiler directly, don't duplicate this code here
|
||||
K2JVMCompilerArguments arguments = new K2JVMCompilerArguments();
|
||||
try {
|
||||
Args.parse(arguments, ArrayUtil.toStringArray(args));
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new BuildException(e.getMessage());
|
||||
}
|
||||
|
||||
K2JVMCompiler.putAdvancedOptions(configuration, arguments);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private static String errorMessage(@NotNull String[] source, boolean exceptionThrown) {
|
||||
return String.format("Compilation of the following source roots failed:" + LINE_SEPARATOR +
|
||||
getAbsolutePaths(source) +
|
||||
(exceptionThrown ? "" : LINE_SEPARATOR + "see \"ERROR:\" messages above for more details."));
|
||||
}
|
||||
|
||||
private static String getAbsolutePaths(String[] source) {
|
||||
return StringUtil.join(
|
||||
source,
|
||||
new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String s) {
|
||||
return " * " + new File(s).getAbsolutePath();
|
||||
}
|
||||
},
|
||||
LINE_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code KotlinToJVMBytecodeCompiler#compileBunchOfSources} wrapper.
|
||||
* @param src compilation source (directory or file)
|
||||
* @param destination compilation destination (directory or jar)
|
||||
* @param includeRuntime whether Kotlin runtime library is included in destination jar
|
||||
* @param stdlib "kotlin-runtime.jar" path
|
||||
* @param args additional command line arguments to Kotlin compiler
|
||||
*/
|
||||
public static void compileSources(
|
||||
@NotNull String[] src,
|
||||
@NotNull String destination,
|
||||
boolean includeRuntime,
|
||||
@Nullable String stdlib,
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath,
|
||||
@NotNull List<String> args
|
||||
) {
|
||||
try {
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createForProduction(
|
||||
Disposer.newDisposable(),
|
||||
createConfiguration(stdlib, classpath, externalAnnotationsPath, src, args)
|
||||
);
|
||||
|
||||
// TODO: use K2JVMCompiler directly, don't duplicate this code here
|
||||
boolean isJar = destination.endsWith(".jar");
|
||||
File jar = isJar ? new File(destination) : null;
|
||||
File outputDir = isJar ? null : new File(destination);
|
||||
|
||||
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, includeRuntime);
|
||||
if (!success) {
|
||||
throw new CompileEnvironmentException(errorMessage(src, false));
|
||||
}
|
||||
}
|
||||
catch (BuildException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (CompileEnvironmentException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new CompileEnvironmentException(errorMessage(src, true), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static KotlinPaths getKotlinPathsForAntTask() {
|
||||
return new KotlinPathsFromHomeDir(PathUtil.getJarPathForClass(BytecodeCompiler.class).getParentFile().getParentFile());
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.buildtools.core;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class Util {
|
||||
private Util() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code file.getCanonicalPath()} convenience wrapper.
|
||||
*
|
||||
* @param f file to get its canonical path.
|
||||
* @return file's canonical path
|
||||
*/
|
||||
@NotNull
|
||||
public static String getPath(@NotNull File f) {
|
||||
try {
|
||||
return f.getCanonicalPath();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(String.format("Failed to resolve canonical file of [%s]: %s", f, e), e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String[] getPaths(String[] paths) {
|
||||
String[] result = new String[paths.length];
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
String path = paths[i];
|
||||
result[i] = getPath(new File(path));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
67
build.xml
67
build.xml
@@ -1,4 +1,6 @@
|
||||
<project name="Kotlin" default="dist">
|
||||
<include file="jslib_files.xml" />
|
||||
|
||||
<property file="resources/manifest.properties"/>
|
||||
|
||||
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
|
||||
@@ -77,6 +79,7 @@
|
||||
<include name="js/js.dart-ast/src"/>
|
||||
<include name="js/js.translator/src"/>
|
||||
<include name="js/js.frontend/src"/>
|
||||
<include name="js/js.inliner/src"/>
|
||||
</dirset>
|
||||
|
||||
<property name="idea.out" value="${basedir}/out/production"/>
|
||||
@@ -99,6 +102,7 @@
|
||||
<include name="js.dart-ast/**"/>
|
||||
<include name="js.translator/**"/>
|
||||
<include name="js.frontend/**"/>
|
||||
<include name="js.inliner/**"/>
|
||||
</patternset>
|
||||
|
||||
<path id="compilerSources.path">
|
||||
@@ -163,6 +167,7 @@
|
||||
<fileset dir="js/js.dart-ast/src"/>
|
||||
<fileset dir="js/js.translator/src"/>
|
||||
<fileset dir="js/js.frontend/src"/>
|
||||
<fileset dir="js/js.inliner/src"/>
|
||||
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
|
||||
|
||||
<manifest>
|
||||
@@ -213,17 +218,18 @@
|
||||
</target>
|
||||
|
||||
<target name="jslib">
|
||||
<property name="compiled.stdlib.js" value="stdlib.js" />
|
||||
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData" />
|
||||
|
||||
<kotlin2js output="${output}/${compiled.stdlib.js}" main="noCall">
|
||||
<src>
|
||||
<fileset refid="kotlin.builtin.files" />
|
||||
<resources refid="js.lib.files" />
|
||||
</src>
|
||||
</kotlin2js>
|
||||
|
||||
<jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar">
|
||||
<fileset dir="${basedir}/js/js.libraries/src">
|
||||
<include name="core/**"/>
|
||||
<include name="jquery/**"/>
|
||||
<include name="dom/**"/>
|
||||
<include name="html5/**"/>
|
||||
<include name="stdlib/TuplesCode.kt"/>
|
||||
</fileset>
|
||||
<fileset dir="${basedir}/core/reflection/src">
|
||||
<include name="kotlin/**"/>
|
||||
</fileset>
|
||||
<resources refid="js.lib.files" />
|
||||
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
|
||||
|
||||
<manifest>
|
||||
@@ -239,21 +245,36 @@
|
||||
classname="com.google.javascript.jscomp.ant.CompileTask"
|
||||
classpath="${dependencies.dir}/closure-compiler.jar"/>
|
||||
|
||||
<!-- value should be one of: whitespace, simple, advanced -->
|
||||
<property name="compilationLevel" value="simple" />
|
||||
<!-- value should be one of: default, quiet, verbose -->
|
||||
<property name="warningLevel" value="default" />
|
||||
|
||||
<closure-compiler
|
||||
compilationLevel="simple"
|
||||
compilationLevel="${compilationLevel}"
|
||||
prettyprint="true"
|
||||
languagein="ECMASCRIPT5_STRICT"
|
||||
warning="verbose"
|
||||
debug="false"
|
||||
output="${kotlin-home}/lib/kotlin.js">
|
||||
warning="${warningLevel}"
|
||||
output="${kotlin-home}/lib/kotlin.js" >
|
||||
|
||||
<sources dir="${basedir}/js/js.translator/testData">
|
||||
<sources dir="${stdlib.js.dir}">
|
||||
<file name="kotlin_lib_ecma5.js"/>
|
||||
<file name="kotlin_lib.js"/>
|
||||
<file name="maps.js"/>
|
||||
<file name="long.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${output}">
|
||||
<file name="${compiled.stdlib.js}"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${stdlib.js.dir}">
|
||||
<file name="export_Kotlin_if_possible.js"/>
|
||||
</sources>
|
||||
|
||||
<externs dir="${stdlib.js.dir}">
|
||||
<file name="externs.js"/>
|
||||
</externs>
|
||||
</closure-compiler>
|
||||
</target>
|
||||
|
||||
@@ -330,6 +351,7 @@
|
||||
</fileset>
|
||||
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
|
||||
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
|
||||
<fileset dir="${basedir}/resources" includes="manifest.properties"/>
|
||||
|
||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||
<zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar" excludes="util.jar"/>
|
||||
@@ -655,7 +677,7 @@
|
||||
depends="init,prepareDist,preloader,builtins,compiler_quick"
|
||||
description="Builds compiler jar from project out dir"/>
|
||||
|
||||
<target name="zip" depends="dist">
|
||||
<target name="zip-compiler" depends="dist">
|
||||
<zip destfile="${output}/${output.name}.zip">
|
||||
<zipfileset prefix="kotlinc" dir="${kotlin-home}" excludes="bin/*"/>
|
||||
<zipfileset prefix="kotlinc/bin" dir="${kotlin-home}/bin" includes="*.bat" filemode="644"/>
|
||||
@@ -670,7 +692,7 @@
|
||||
source="${java.target}" target="${java.target}">
|
||||
<withKotlin externalannotations="${external.annotations.path}"/>
|
||||
<src>
|
||||
<dirset dir="${basedir}/idea/ide-lazy-resolve">
|
||||
<dirset dir="${basedir}/idea/ide-common">
|
||||
<include name="src"/>
|
||||
</dirset>
|
||||
<dirset dir="${basedir}/idea/idea-analysis">
|
||||
@@ -744,7 +766,9 @@
|
||||
<fileset dir="js/js.dart-ast/src"/>
|
||||
<fileset dir="js/js.translator/src"/>
|
||||
<fileset dir="js/js.frontend/src"/>
|
||||
<fileset dir="js/js.inliner/src"/>
|
||||
<fileset dir="idea/idea-analysis/src"/>
|
||||
<fileset dir="idea/ide-common/src"/>
|
||||
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
|
||||
@@ -756,5 +780,12 @@
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build-artifacts" depends="zip,kotlin-for-upsource"/>
|
||||
<target name="zip-test-data">
|
||||
<zip destfile="${output}/kotlin-test-data.zip">
|
||||
<zipfileset dir="compiler/testData" prefix="compiler"/>
|
||||
<zipfileset dir="idea/testData" prefix="ide"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build-artifacts" depends="zip-compiler,kotlin-for-upsource,zip-test-data"/>
|
||||
</project>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.compiler;
|
||||
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -179,11 +180,13 @@ public class CodegenTestsOnAndroidRunner {
|
||||
downloader.downloadAll();
|
||||
downloader.unzipAll();
|
||||
|
||||
PermissionManager.setPermissions(pathManager);
|
||||
|
||||
antRunner.packLibraries();
|
||||
String platformPrefixProperty = System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "Idea");
|
||||
|
||||
try {
|
||||
PermissionManager.setPermissions(pathManager);
|
||||
|
||||
antRunner.packLibraries();
|
||||
|
||||
emulator.createEmulator();
|
||||
emulator.startEmulator();
|
||||
|
||||
@@ -207,6 +210,12 @@ public class CodegenTestsOnAndroidRunner {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if (platformPrefixProperty != null) {
|
||||
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, platformPrefixProperty);
|
||||
}
|
||||
else {
|
||||
System.clearProperty(PlatformUtils.PLATFORM_PREFIX_KEY);
|
||||
}
|
||||
emulator.finishEmulatorProcesses();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ public class SpecialFiles {
|
||||
excludedFiles.add("invokeOnClassObjectOfNestedClass2.kt"); // Cannot change package name
|
||||
excludedFiles.add("invokeOnImportedEnum1.kt"); // Cannot change package name
|
||||
excludedFiles.add("invokeOnImportedEnum2.kt"); // Cannot change package name
|
||||
excludedFiles.add("sortEnumEntries.kt"); // Cannot change package name
|
||||
excludedFiles.add("assertionStackTrace.kt"); // Cannot change package name
|
||||
|
||||
excludedFiles.add("kt326.kt"); // Commented
|
||||
excludedFiles.add("kt1213.kt"); // Commented
|
||||
|
||||
@@ -87,7 +87,7 @@ public fun findTraitImplementation(descriptor: CallableMemberDescriptor): Callab
|
||||
|
||||
// If this implementation is already generated into one of the superclasses, we need not generate it again, it'll be inherited
|
||||
val containingClass = descriptor.getContainingDeclaration() as ClassDescriptor
|
||||
val implClassType = implementation!!.getExpectedThisObject()!!.getType()
|
||||
val implClassType = implementation!!.getDispatchReceiverParameter()!!.getType()
|
||||
for (supertype in containingClass.getDefaultType().getConstructor().getSupertypes()) {
|
||||
if (!DescriptorUtils.isTrait(supertype.getConstructor().getDeclarationDescriptor()!!) &&
|
||||
TypeUtils.getAllSupertypes(supertype).contains(implClassType)) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.backend.common;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegationSpecifier;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
@@ -125,18 +126,32 @@ public class CodegenUtil {
|
||||
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor));
|
||||
}
|
||||
|
||||
public static Map<CallableMemberDescriptor, CallableMemberDescriptor> getDelegates(ClassDescriptor descriptor, ClassDescriptor toClass) {
|
||||
Map<CallableMemberDescriptor, CallableMemberDescriptor> result = new LinkedHashMap<CallableMemberDescriptor, CallableMemberDescriptor>();
|
||||
@NotNull
|
||||
public static Map<FunctionDescriptor, FunctionDescriptor> getTraitMethods(ClassDescriptor descriptor) {
|
||||
Map<FunctionDescriptor, FunctionDescriptor> result = new LinkedHashMap<FunctionDescriptor, FunctionDescriptor>();
|
||||
for (DeclarationDescriptor declaration : descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
|
||||
if (declaration instanceof CallableMemberDescriptor) {
|
||||
CallableMemberDescriptor callableMemberDescriptor = (CallableMemberDescriptor) declaration;
|
||||
if (callableMemberDescriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION) {
|
||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callableMemberDescriptor.getOverriddenDescriptors();
|
||||
for (CallableMemberDescriptor overriddenDescriptor : overriddenDescriptors) {
|
||||
if (overriddenDescriptor.getContainingDeclaration() == toClass) {
|
||||
assert !result.containsKey(callableMemberDescriptor) :
|
||||
"overridden is already set for " + callableMemberDescriptor;
|
||||
result.put(callableMemberDescriptor, overriddenDescriptor);
|
||||
if (!(declaration instanceof CallableMemberDescriptor)) continue;
|
||||
|
||||
CallableMemberDescriptor inheritedMember = (CallableMemberDescriptor) declaration;
|
||||
CallableMemberDescriptor traitMember = BridgesPackage.findTraitImplementation(inheritedMember);
|
||||
if (traitMember == null) continue;
|
||||
|
||||
assert traitMember.getModality() != Modality.ABSTRACT : "Cannot delegate to abstract trait method: " + inheritedMember;
|
||||
|
||||
// inheritedMember can be abstract here. In order for FunctionCodegen to generate the method body, we're creating a copy here
|
||||
// with traitMember's modality
|
||||
CallableMemberDescriptor copy =
|
||||
inheritedMember.copy(inheritedMember.getContainingDeclaration(), traitMember.getModality(), Visibilities.PUBLIC,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, true);
|
||||
|
||||
if (traitMember instanceof SimpleFunctionDescriptor) {
|
||||
result.put((FunctionDescriptor) traitMember, (FunctionDescriptor) copy);
|
||||
}
|
||||
else if (traitMember instanceof PropertyDescriptor) {
|
||||
for (PropertyAccessorDescriptor traitAccessor : ((PropertyDescriptor) traitMember).getAccessors()) {
|
||||
for (PropertyAccessorDescriptor inheritedAccessor : ((PropertyDescriptor) copy).getAccessors()) {
|
||||
if (inheritedAccessor.getClass() == traitAccessor.getClass()) { // same accessor kind
|
||||
result.put(traitAccessor, inheritedAccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.backend.common
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.utils.keysToMapExceptNulls
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.resolve.MemberComparator
|
||||
import java.util.Comparator
|
||||
|
||||
public object CodegenUtilKt {
|
||||
|
||||
// class Foo : Bar by baz
|
||||
// descriptor = Foo
|
||||
// toTrait = Bar
|
||||
// delegateExpressionType = typeof(baz)
|
||||
// return Map<member of Foo, corresponding member of typeOf(baz)>
|
||||
public [platformStatic] fun getDelegates(
|
||||
descriptor: ClassDescriptor,
|
||||
toTrait: ClassDescriptor,
|
||||
delegateExpressionType: JetType? = null
|
||||
): Map<CallableMemberDescriptor, CallableDescriptor> {
|
||||
|
||||
return descriptor.getDefaultType().getMemberScope().getAllDescriptors().stream()
|
||||
.filterIsInstance(javaClass<CallableMemberDescriptor>())
|
||||
.filter { it.getKind() == CallableMemberDescriptor.Kind.DELEGATION }
|
||||
.toList()
|
||||
.sortBy(MemberComparator.INSTANCE as Comparator<CallableMemberDescriptor>) // Workaround for KT-6030
|
||||
.keysToMapExceptNulls {
|
||||
delegatingMember ->
|
||||
|
||||
val actualDelegates = DescriptorUtils.getAllOverriddenDescriptors(delegatingMember)
|
||||
.filter { it.getContainingDeclaration() == toTrait }
|
||||
.map {
|
||||
overriddenDescriptor ->
|
||||
val scope = (delegateExpressionType ?: toTrait.getDefaultType()).getMemberScope()
|
||||
val name = overriddenDescriptor.getName()
|
||||
|
||||
// this is the actual member of delegateExpressionType that we are delegating to
|
||||
(scope.getFunctions(name) + scope.getProperties(name))
|
||||
.first {
|
||||
(listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal())
|
||||
}
|
||||
}
|
||||
assert(actualDelegates.size <= 1) { "Meny delegates found for $delegatingMember: $actualDelegates" }
|
||||
|
||||
actualDelegates.firstOrNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
this.calleeDescriptor = descriptor;
|
||||
|
||||
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getReceiverParameter()),
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : descriptor.getExpectedThisObject(),
|
||||
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getExtensionReceiverParameter()),
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : descriptor.getDispatchReceiverParameter(),
|
||||
copyTypeParameters(descriptor),
|
||||
copyValueParameters(descriptor),
|
||||
descriptor.getReturnType(),
|
||||
|
||||
@@ -34,14 +34,14 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
private final PropertyDescriptor calleeDescriptor;
|
||||
|
||||
public AccessorForPropertyDescriptor(@NotNull PropertyDescriptor pd, @NotNull DeclarationDescriptor containingDeclaration, int index) {
|
||||
this(pd, pd.getType(), DescriptorUtils.getReceiverParameterType(pd.getReceiverParameter()), pd.getExpectedThisObject(), containingDeclaration, index);
|
||||
this(pd, pd.getType(), DescriptorUtils.getReceiverParameterType(pd.getExtensionReceiverParameter()), pd.getDispatchReceiverParameter(), containingDeclaration, index);
|
||||
}
|
||||
|
||||
protected AccessorForPropertyDescriptor(
|
||||
@NotNull PropertyDescriptor original,
|
||||
@NotNull JetType propertyType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
int index
|
||||
) {
|
||||
@@ -50,7 +50,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
|
||||
this.calleeDescriptor = original;
|
||||
setType(propertyType, Collections.<TypeParameterDescriptorImpl>emptyList(), expectedThisObject, receiverType);
|
||||
setType(propertyType, Collections.<TypeParameterDescriptorImpl>emptyList(), dispatchReceiverParameter, receiverType);
|
||||
initialize(new Getter(this), new Setter(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,9 @@ import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.Approximation;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypesPackage;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
@@ -484,29 +486,28 @@ public class AsmUtil {
|
||||
v.xor(Type.INT_TYPE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue genEqualsForExpressionsOnStack(
|
||||
InstructionAdapter v,
|
||||
IElementType opToken,
|
||||
Type leftType,
|
||||
Type rightType
|
||||
@NotNull InstructionAdapter v,
|
||||
@NotNull IElementType opToken,
|
||||
@NotNull Type leftType,
|
||||
@NotNull Type rightType
|
||||
) {
|
||||
if ((isNumberPrimitive(leftType) || leftType.getSort() == Type.BOOLEAN) && leftType == rightType) {
|
||||
if (isPrimitive(leftType) && leftType == rightType) {
|
||||
return StackValue.cmp(opToken, leftType);
|
||||
}
|
||||
else {
|
||||
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
|
||||
return StackValue.cmp(opToken, leftType);
|
||||
}
|
||||
else {
|
||||
v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
|
||||
|
||||
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
|
||||
return StackValue.onStack(Type.BOOLEAN_TYPE);
|
||||
}
|
||||
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
|
||||
return StackValue.cmp(opToken, leftType);
|
||||
}
|
||||
|
||||
v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
|
||||
|
||||
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
|
||||
return StackValue.onStack(Type.BOOLEAN_TYPE);
|
||||
}
|
||||
|
||||
public static void genIncrement(Type expectedType, int myDelta, InstructionAdapter v) {
|
||||
@@ -608,12 +609,15 @@ public class AsmUtil {
|
||||
@NotNull CallableDescriptor descriptor,
|
||||
@NotNull String assertMethodToCall
|
||||
) {
|
||||
// Assertions are generated elsewhere for platform types
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return;
|
||||
|
||||
if (!state.isCallAssertionsEnabled()) return;
|
||||
|
||||
if (!isDeclaredInJava(descriptor)) return;
|
||||
|
||||
JetType type = descriptor.getReturnType();
|
||||
if (type == null || isNullableType(type)) return;
|
||||
if (type == null || isNullableType(TypesPackage.lowerIfFlexible(type))) return;
|
||||
|
||||
Type asmType = state.getTypeMapper().mapReturnType(descriptor);
|
||||
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
|
||||
@@ -625,6 +629,30 @@ public class AsmUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue genNotNullAssertions(
|
||||
@NotNull GenerationState state,
|
||||
@NotNull final StackValue stackValue,
|
||||
@Nullable final Approximation.Info approximationInfo
|
||||
) {
|
||||
if (!state.isCallAssertionsEnabled()) return stackValue;
|
||||
if (approximationInfo == null || !TypesPackage.assertNotNull(approximationInfo)) return stackValue;
|
||||
|
||||
return new StackValue(stackValue.type) {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
stackValue.put(type, v);
|
||||
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
|
||||
v.dup();
|
||||
v.visitLdcInsn(approximationInfo.getMessage());
|
||||
v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull",
|
||||
"(Ljava/lang/Object;Ljava/lang/String;)V", false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor) {
|
||||
CallableDescriptor descriptor = callableDescriptor;
|
||||
while (true) {
|
||||
@@ -667,7 +695,7 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
|
||||
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
|
||||
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
||||
if (isDelegate || isExtensionProperty) {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
@@ -688,7 +716,7 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
|
||||
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
||||
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
|
||||
return !propertyDescriptor.isVar()
|
||||
&& !isExtensionProperty
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
@@ -54,6 +55,7 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
public class ClosureCodegen extends ParentCodegenAware {
|
||||
private final PsiElement fun;
|
||||
private final FunctionDescriptor funDescriptor;
|
||||
private final ClassDescriptor classDescriptor;
|
||||
private final SamType samType;
|
||||
private final JetType superClassType;
|
||||
private final List<JetType> superInterfaceTypes;
|
||||
@@ -86,7 +88,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
this.syntheticClassKind = syntheticClassKind;
|
||||
this.strategy = strategy;
|
||||
|
||||
ClassDescriptor classDescriptor = anonymousClassForFunction(bindingContext, funDescriptor);
|
||||
this.classDescriptor = anonymousClassForFunction(bindingContext, funDescriptor);
|
||||
|
||||
if (samType == null) {
|
||||
this.superInterfaceTypes = new ArrayList<JetType>();
|
||||
@@ -164,6 +166,21 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
FunctionCodegen fc = new FunctionCodegen(context, cv, state, getParentCodegen());
|
||||
fc.generateMethod(OtherOrigin(fun, funDescriptor), jvmMethodSignature, funDescriptor, strategy);
|
||||
|
||||
//TODO: rewrite cause ugly hack
|
||||
if (samType != null) {
|
||||
SimpleFunctionDescriptorImpl descriptorForBridges = SimpleFunctionDescriptorImpl
|
||||
.create(funDescriptor.getContainingDeclaration(), funDescriptor.getAnnotations(), erasedInterfaceFunction.getName(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, funDescriptor.getSource());
|
||||
|
||||
descriptorForBridges
|
||||
.initialize(null, erasedInterfaceFunction.getDispatchReceiverParameter(), erasedInterfaceFunction.getTypeParameters(),
|
||||
erasedInterfaceFunction.getValueParameters(), erasedInterfaceFunction.getReturnType(), Modality.OPEN,
|
||||
erasedInterfaceFunction.getVisibility());
|
||||
|
||||
descriptorForBridges.addOverriddenDescriptor(erasedInterfaceFunction);
|
||||
fc.generateBridges(descriptorForBridges);
|
||||
}
|
||||
|
||||
this.constructor = generateConstructor(cv, superClassAsmType);
|
||||
|
||||
if (isConst(closure)) {
|
||||
@@ -180,7 +197,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
null);
|
||||
|
||||
|
||||
AsmUtil.writeOuterClassAndEnclosingMethod(anonymousClassForFunction(bindingContext, funDescriptor), funDescriptor, typeMapper, cv);
|
||||
AsmUtil.writeOuterClassAndEnclosingMethod(classDescriptor, funDescriptor, typeMapper, cv);
|
||||
cv.done();
|
||||
}
|
||||
|
||||
@@ -193,7 +210,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
v.anew(asmType);
|
||||
v.dup();
|
||||
|
||||
codegen.pushClosureOnStack(closure, false, codegen.defaultCallGenerator);
|
||||
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator);
|
||||
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
|
||||
}
|
||||
return StackValue.onStack(asmType);
|
||||
@@ -230,7 +247,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, asmType);
|
||||
|
||||
ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = funDescriptor.getExtensionReceiverParameter();
|
||||
int count = 1;
|
||||
if (receiver != null) {
|
||||
StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(receiver.getType()), iv);
|
||||
@@ -328,7 +345,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
@NotNull
|
||||
public static FunctionDescriptor getErasedInvokeFunction(@NotNull FunctionDescriptor funDescriptor) {
|
||||
int arity = funDescriptor.getValueParameters().size();
|
||||
ClassDescriptor funClass = funDescriptor.getReceiverParameter() == null
|
||||
ClassDescriptor funClass = funDescriptor.getExtensionReceiverParameter() == null
|
||||
? KotlinBuiltIns.getInstance().getFunction(arity)
|
||||
: KotlinBuiltIns.getInstance().getExtensionFunction(arity);
|
||||
return funClass.getDefaultType().getMemberScope().getFunctions(Name.identifier("invoke")).iterator().next();
|
||||
|
||||
@@ -50,4 +50,11 @@ public class CodegenStatementVisitor extends JetVisitor<StackValue, StackValue>
|
||||
public StackValue visitBlockExpression(@NotNull JetBlockExpression expression, StackValue data) {
|
||||
return codegen.generateBlock(expression, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitLabeledExpression(@NotNull JetLabeledExpression expression, StackValue receiver) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
assert baseExpression != null : "Label expression should have base one: " + expression.getText();
|
||||
return baseExpression.accept(this, receiver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.codegen
|
||||
|
||||
import org.jetbrains.jet.codegen.state.GenerationState
|
||||
import org.jetbrains.jet.lang.descriptors.*
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.*
|
||||
import org.jetbrains.jet.lang.descriptors.impl.*
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.types.*
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||
import java.util.LinkedHashSet
|
||||
import org.jetbrains.jet.lang.resolve.name.Name
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker
|
||||
import java.util.HashSet
|
||||
|
||||
/**
|
||||
* Generates exception-throwing stubs for methods from mutable collection classes not implemented in Kotlin classes which inherit only from
|
||||
* Kotlin's read-only collections. This is required on JVM because Kotlin's read-only collections are mapped to mutable JDK collections
|
||||
*/
|
||||
class CollectionStubMethodGenerator(
|
||||
state: GenerationState,
|
||||
private val descriptor: ClassDescriptor,
|
||||
private val functionCodegen: FunctionCodegen,
|
||||
private val v: ClassBuilder
|
||||
) {
|
||||
private val typeMapper = state.getTypeMapper()
|
||||
|
||||
fun generate() {
|
||||
val superCollectionClasses = findRelevantSuperCollectionClasses()
|
||||
if (superCollectionClasses.isEmpty()) return
|
||||
|
||||
val methodStubsToGenerate = LinkedHashSet<String>()
|
||||
val syntheticStubsToGenerate = LinkedHashSet<String>()
|
||||
|
||||
for ((readOnlyClass, mutableClass) in superCollectionClasses) {
|
||||
// To determine which method stubs we need to generate, we create a synthetic class (named 'child' here) which inherits from
|
||||
// our class ('descriptor') and the corresponding MutableCollection class (for example; the process is the same for every
|
||||
// built-in read-only/mutable class pair). We then construct and bind fake overrides in this synthetic class with the usual
|
||||
// override resolution process. Resulting fake overrides with originals in MutableCollection are considered as candidates for
|
||||
// method stubs or bridges to the actual implementation that happened to be present in the class
|
||||
val (child, typeParameters) = createSyntheticSubclass()
|
||||
// If the original class has any type parameters, we copied them and now we need to substitute types of the newly created type
|
||||
// parameters as arguments for the type parameters of the original class
|
||||
val parentType = newType(descriptor, typeParameters.map { TypeProjectionImpl(it.getDefaultType()) })
|
||||
|
||||
// Now we need to determine the arguments which should be substituted for the MutableCollection super class. To do that,
|
||||
// we look for type arguments which were substituted in the inheritance of the original class from Collection and use them
|
||||
// to construct the needed MutableCollection type. Since getAllSupertypes() may return several types which correspond to the
|
||||
// Collection class descriptor, we find the most specific one (which is guaranteed to exist by front-end)
|
||||
val readOnlyCollectionType = TypeUtils.getAllSupertypes(parentType).findMostSpecificTypeForClass(readOnlyClass)
|
||||
val mutableCollectionType = newType(mutableClass, readOnlyCollectionType.getArguments())
|
||||
|
||||
child.addSupertype(parentType)
|
||||
child.addSupertype(mutableCollectionType)
|
||||
child.createTypeConstructor()
|
||||
|
||||
// Bind fake overrides and for each fake override originated from the MutableCollection, save its signature to generate a stub
|
||||
// or save its descriptor to generate all the needed bridges
|
||||
for (method in findFakeOverridesForMethodsFromMutableCollection(child, mutableClass)) {
|
||||
if (method.getModality() == Modality.ABSTRACT) {
|
||||
// If the fake override is abstract and it's _declared_ as abstract in the class, skip it because the method is already
|
||||
// present in the bytecode (abstract) and we don't want a duplicate signature error
|
||||
if (method.findOverriddenFromDirectSuperClass(descriptor)?.getKind() == DECLARATION) continue
|
||||
|
||||
// Otherwise we can safely generate the stub with the substituted signature
|
||||
val signature = method.signature()
|
||||
methodStubsToGenerate.add(signature)
|
||||
|
||||
// If the substituted signature differs from the original one in MutableCollection, we should also generate a stub with
|
||||
// the original (erased) signature. It doesn't really matter if this is a bridge method delegating to the first stub or
|
||||
// a method with its own exception-throwing code, for simplicity we do the latter here.
|
||||
// What _does_ matter though, is that these two methods can't be both non-synthetic at once: javac issues compilation
|
||||
// errors when compiling Java against such classes because one of them doesn't seem to override the generic method
|
||||
// declared in the Java Collection interface (can't override generic with erased). So we maintain an additional set of
|
||||
// methods which need to be generated with the ACC_SYNTHETIC flag
|
||||
val originalSignature = method.findOverriddenFromDirectSuperClass(mutableClass)!!.getOriginal().signature()
|
||||
if (originalSignature != signature) {
|
||||
syntheticStubsToGenerate.add(originalSignature)
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If the fake override is non-abstract, its implementation is already present in the class or inherited from one of its
|
||||
// super classes, but is not related to the MutableCollection hierarchy. So maybe it uses more specific return types
|
||||
// and we may need to generate some bridges
|
||||
functionCodegen.generateBridges(method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (signature in methodStubsToGenerate) {
|
||||
generateMethodStub(signature, synthetic = false)
|
||||
}
|
||||
|
||||
for (signature in syntheticStubsToGenerate) {
|
||||
generateMethodStub(signature, synthetic = true)
|
||||
}
|
||||
}
|
||||
|
||||
private data class CollectionClassPair(
|
||||
val readOnlyClass: ClassDescriptor,
|
||||
val mutableClass: ClassDescriptor
|
||||
)
|
||||
|
||||
private fun findRelevantSuperCollectionClasses(): Collection<CollectionClassPair> {
|
||||
fun pair(readOnlyClass: ClassDescriptor, mutableClass: ClassDescriptor) = CollectionClassPair(readOnlyClass, mutableClass)
|
||||
|
||||
val collectionClasses = with(KotlinBuiltIns.getInstance()) {
|
||||
listOf(
|
||||
pair(getCollection(), getMutableCollection()),
|
||||
pair(getSet(), getMutableSet()),
|
||||
pair(getList(), getMutableList()),
|
||||
pair(getMap(), getMutableMap()),
|
||||
pair(getMapEntry(), getMutableMapEntry()),
|
||||
pair(getIterable(), getMutableIterable()),
|
||||
pair(getIterator(), getMutableIterator()),
|
||||
pair(getListIterator(), getMutableListIterator())
|
||||
)
|
||||
}
|
||||
|
||||
val allSuperClasses = TypeUtils.getAllSupertypes(descriptor.getDefaultType()).classes().toHashSet()
|
||||
|
||||
val ourSuperCollectionClasses = collectionClasses.filter { pair ->
|
||||
pair.readOnlyClass in allSuperClasses && pair.mutableClass !in allSuperClasses
|
||||
}
|
||||
if (ourSuperCollectionClasses.isEmpty()) return listOf()
|
||||
|
||||
// Filter out built-in classes which are overridden by other built-in classes in the list, to avoid duplicating methods.
|
||||
val redundantClasses = ourSuperCollectionClasses.flatMapTo(HashSet<ClassDescriptor>()) { pair ->
|
||||
pair.readOnlyClass.getTypeConstructor().getSupertypes().classes()
|
||||
}
|
||||
return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses }
|
||||
}
|
||||
|
||||
private fun Collection<JetType>.classes(): Collection<ClassDescriptor> =
|
||||
this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor }
|
||||
|
||||
private fun findFakeOverridesForMethodsFromMutableCollection(
|
||||
klass: ClassDescriptor,
|
||||
mutableCollectionClass: ClassDescriptor
|
||||
): List<FunctionDescriptor> {
|
||||
val result = ArrayList<FunctionDescriptor>()
|
||||
|
||||
OverrideResolver.generateOverridesInAClass(klass, listOf(), object : OverridingUtil.DescriptorSink {
|
||||
override fun addToScope(fakeOverride: CallableMemberDescriptor) {
|
||||
if (fakeOverride !is FunctionDescriptor) return
|
||||
if (fakeOverride.findOverriddenFromDirectSuperClass(mutableCollectionClass) != null) {
|
||||
result.add(fakeOverride)
|
||||
}
|
||||
}
|
||||
|
||||
override fun conflict(fromSuper: CallableMemberDescriptor, fromCurrent: CallableMemberDescriptor) {
|
||||
// Ignore conflicts here
|
||||
// TODO: report a warning that javac will prohibit use/inheritance from such class
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun Collection<JetType>.findMostSpecificTypeForClass(klass: ClassDescriptor): JetType {
|
||||
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
|
||||
if (types.isEmpty()) error("No supertype of $klass in $this")
|
||||
if (types.size == 1) return types.first()
|
||||
// Find the first type in the list such that it's a subtype of every other type in that list
|
||||
return types.first { type ->
|
||||
types.all { other -> JetTypeChecker.DEFAULT.isSubtypeOf(type, other) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun createSyntheticSubclass(): Pair<MutableClassDescriptor, List<TypeParameterDescriptor>> {
|
||||
val child = MutableClassDescriptor(descriptor.getContainingDeclaration(), JetScope.EMPTY, ClassKind.CLASS, false,
|
||||
Name.special("<synthetic inheritor of ${descriptor.getName()}>"), descriptor.getSource())
|
||||
child.setModality(Modality.FINAL)
|
||||
child.setVisibility(Visibilities.PUBLIC)
|
||||
val typeParameters = descriptor.getTypeConstructor().getParameters()
|
||||
val newTypeParameters = ArrayList<TypeParameterDescriptor>(typeParameters.size())
|
||||
DescriptorSubstitutor.substituteTypeParameters(typeParameters, TypeSubstitutor.EMPTY, child, newTypeParameters)
|
||||
child.setTypeParameterDescriptors(typeParameters)
|
||||
return Pair(child, newTypeParameters)
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.findOverriddenFromDirectSuperClass(classDescriptor: ClassDescriptor): FunctionDescriptor? {
|
||||
return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor }
|
||||
}
|
||||
|
||||
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): JetType {
|
||||
return JetTypeImpl(Annotations.EMPTY, classDescriptor.getTypeConstructor(), false, typeArguments,
|
||||
classDescriptor.getMemberScope(typeArguments))
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.signature(): String {
|
||||
val method = typeMapper.mapSignature(this).getAsmMethod()
|
||||
return method.getName() + method.getDescriptor()
|
||||
}
|
||||
|
||||
private fun generateMethodStub(signature: String, synthetic: Boolean) {
|
||||
// TODO: investigate if it makes sense to generate abstract stubs in traits
|
||||
var access = ACC_PUBLIC
|
||||
if (descriptor.getKind() == ClassKind.TRAIT) access = access or ACC_ABSTRACT
|
||||
if (synthetic) access = access or ACC_SYNTHETIC
|
||||
|
||||
val paren = signature.indexOf('(')
|
||||
val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, signature.substring(0, paren), signature.substring(paren), null, null)
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
mv.visitCode()
|
||||
AsmUtil.genThrow(InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection")
|
||||
FunctionCodegen.endVisit(mv, "built-in stub for $signature", null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.context.*;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegen;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
@@ -61,6 +60,7 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.SamConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.jet.lang.types.Approximation;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -88,6 +88,7 @@ import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getR
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.TraitImpl;
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.GETFIELD;
|
||||
@@ -183,7 +184,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CalculatedClosure generateObjectLiteral(@NotNull JetObjectLiteralExpression literal) {
|
||||
public ClassDescriptor generateObjectLiteral(@NotNull JetObjectLiteralExpression literal) {
|
||||
JetObjectDeclaration objectDeclaration = literal.getObjectDeclaration();
|
||||
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS, objectDeclaration);
|
||||
@@ -196,13 +197,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
literal.getContainingFile()
|
||||
);
|
||||
|
||||
|
||||
ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this);
|
||||
|
||||
ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this, OwnerKind.IMPLEMENTATION);
|
||||
new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state, getParentCodegen()).generate();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return bindingContext.get(CLOSURE, classDescriptor);
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -241,7 +239,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
}
|
||||
|
||||
return selector.accept(visitor, receiver);
|
||||
StackValue stackValue = selector.accept(visitor, receiver);
|
||||
|
||||
Approximation.Info approximationInfo = null;
|
||||
if (selector instanceof JetExpression) {
|
||||
approximationInfo = bindingContext.get(BindingContext.EXPRESSION_RESULT_APPROXIMATION, (JetExpression) selector);
|
||||
}
|
||||
|
||||
return genNotNullAssertions(state, stackValue, approximationInfo);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
@@ -285,9 +290,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
Type asmType = asmTypeForAnonymousClass(bindingContext, declaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(OtherOrigin(declaration, descriptor), asmType, declaration.getContainingFile());
|
||||
|
||||
ClassContext objectContext = context.intoAnonymousClass(descriptor, this);
|
||||
ClassContext objectContext = context.intoAnonymousClass(descriptor, this, OwnerKind.IMPLEMENTATION);
|
||||
new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state, getParentCodegen()).generate();
|
||||
|
||||
if (declaration instanceof JetClass && ((JetClass) declaration).isTrait()) {
|
||||
Type traitImplType = state.getTypeMapper().mapTraitImpl(descriptor);
|
||||
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(TraitImpl(declaration, descriptor), traitImplType, declaration.getContainingFile());
|
||||
ClassContext traitImplContext = context.intoAnonymousClass(descriptor, this, OwnerKind.TRAIT_IMPL);
|
||||
new TraitImplBodyCodegen(declaration, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
||||
}
|
||||
|
||||
return StackValue.none();
|
||||
}
|
||||
|
||||
@@ -649,6 +661,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
public void afterBody(@NotNull Label loopExit) {
|
||||
markLineNumber(forExpression);
|
||||
|
||||
increment(loopExit);
|
||||
|
||||
v.mark(bodyEnd);
|
||||
@@ -1326,20 +1340,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@Override
|
||||
public StackValue visitObjectLiteralExpression(@NotNull JetObjectLiteralExpression expression, StackValue receiver) {
|
||||
CalculatedClosure closure = generateObjectLiteral(expression);
|
||||
|
||||
ConstructorDescriptor constructorDescriptor = bindingContext.get(CONSTRUCTOR, expression.getObjectDeclaration());
|
||||
assert constructorDescriptor != null : "Unresolved constructor: " + expression.getText();
|
||||
JvmMethodSignature constructor = typeMapper.mapSignature(constructorDescriptor);
|
||||
|
||||
Type type = typeMapper.mapType(constructorDescriptor.getContainingDeclaration());
|
||||
ClassDescriptor classDescriptor = generateObjectLiteral(expression);
|
||||
Type type = typeMapper.mapType(classDescriptor);
|
||||
|
||||
v.anew(type);
|
||||
v.dup();
|
||||
|
||||
pushClosureOnStack(closure, false, defaultCallGenerator);
|
||||
pushClosureOnStack(classDescriptor, true, defaultCallGenerator);
|
||||
|
||||
ResolvedCall<ConstructorDescriptor> superCall = closure.getSuperCall();
|
||||
//noinspection ConstantConditions
|
||||
ResolvedCall<ConstructorDescriptor> superCall = bindingContext.get(CLOSURE, classDescriptor).getSuperCall();
|
||||
if (superCall != null) {
|
||||
// For an anonymous object, we should also generate all non-default arguments that it captures for its super call
|
||||
ConstructorDescriptor superConstructor = superCall.getResultingDescriptor();
|
||||
@@ -1347,7 +1357,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
int params = superValueParameters.size();
|
||||
List<Type> superMappedTypes = typeMapper.mapToCallableMethod(superConstructor).getValueParameterTypes();
|
||||
assert superMappedTypes.size() >= params : String.format("Incorrect number of mapped parameters vs arguments: %d < %d for %s",
|
||||
superMappedTypes.size(), params, constructorDescriptor);
|
||||
superMappedTypes.size(), params, classDescriptor);
|
||||
|
||||
List<ResolvedValueArgument> valueArguments = new ArrayList<ResolvedValueArgument>(params);
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(params);
|
||||
@@ -1365,33 +1375,33 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
argumentGenerator.generate(valueArguments);
|
||||
}
|
||||
|
||||
ConstructorDescriptor constructorDescriptor = bindingContext.get(CONSTRUCTOR, expression.getObjectDeclaration());
|
||||
assert constructorDescriptor != null : "Unresolved constructor: " + expression.getText();
|
||||
JvmMethodSignature constructor = typeMapper.mapSignature(constructorDescriptor);
|
||||
v.invokespecial(type.getInternalName(), "<init>", constructor.getAsmMethod().getDescriptor(), false);
|
||||
return StackValue.onStack(type);
|
||||
}
|
||||
|
||||
public void pushClosureOnStack(
|
||||
@Nullable CalculatedClosure closure,
|
||||
boolean ignoreThisAndReceiver,
|
||||
@NotNull CallGenerator callGenerator
|
||||
) {
|
||||
public void pushClosureOnStack(@NotNull ClassDescriptor classDescriptor, boolean putThis, @NotNull CallGenerator callGenerator) {
|
||||
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
|
||||
if (closure == null) return;
|
||||
|
||||
int paramIndex = 0;
|
||||
if (!ignoreThisAndReceiver) {
|
||||
|
||||
if (putThis) {
|
||||
ClassDescriptor captureThis = closure.getCaptureThis();
|
||||
if (captureThis != null) {
|
||||
StackValue thisOrOuter = generateThisOrOuter(captureThis, false);
|
||||
|
||||
assert !isPrimitive(thisOrOuter.type) : "This or outer should be non primitive: " + thisOrOuter.type;
|
||||
callGenerator.putCapturedValueOnStack(thisOrOuter, thisOrOuter.type, paramIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
JetType captureReceiver = closure.getCaptureReceiverType();
|
||||
if (captureReceiver != null) {
|
||||
Type asmType = typeMapper.mapType(captureReceiver);
|
||||
StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType);
|
||||
callGenerator.putCapturedValueOnStack(capturedReceiver, capturedReceiver.type, paramIndex++);
|
||||
}
|
||||
JetType captureReceiver = closure.getCaptureReceiverType();
|
||||
if (captureReceiver != null) {
|
||||
Type asmType = typeMapper.mapType(captureReceiver);
|
||||
StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType);
|
||||
callGenerator.putCapturedValueOnStack(capturedReceiver, capturedReceiver.type, paramIndex++);
|
||||
}
|
||||
|
||||
for (Map.Entry<DeclarationDescriptor, EnclosedValueDescriptor> entry : closure.getCaptureVariables().entrySet()) {
|
||||
@@ -1405,8 +1415,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
ResolvedCall<ConstructorDescriptor> superCall = closure.getSuperCall();
|
||||
if (superCall != null) {
|
||||
MutableClosure superClosure = bindingContext.get(CLOSURE, superCall.getResultingDescriptor().getContainingDeclaration());
|
||||
pushClosureOnStack(superClosure, ignoreThisAndReceiver, callGenerator);
|
||||
pushClosureOnStack(
|
||||
superCall.getResultingDescriptor().getContainingDeclaration(),
|
||||
putThis && closure.getCaptureThis() == null,
|
||||
callGenerator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1422,7 +1435,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
StackValue answer = StackValue.none();
|
||||
|
||||
for (Iterator<JetElement> iterator = statements.iterator(); iterator.hasNext(); ) {
|
||||
JetElement statement = iterator.next();
|
||||
JetElement possiblyLabeledStatement = iterator.next();
|
||||
|
||||
JetElement statement = possiblyLabeledStatement instanceof JetExpression
|
||||
? JetPsiUtil.safeDeparenthesize((JetExpression) possiblyLabeledStatement, true)
|
||||
: possiblyLabeledStatement;
|
||||
|
||||
|
||||
if (statement instanceof JetNamedDeclaration) {
|
||||
JetNamedDeclaration declaration = (JetNamedDeclaration) statement;
|
||||
@@ -1451,7 +1469,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.mark(labelBeforeLastExpression);
|
||||
}
|
||||
|
||||
StackValue result = isExpression ? gen(statement) : genStatement(statement);
|
||||
StackValue result = isExpression ? gen(possiblyLabeledStatement) : genStatement(possiblyLabeledStatement);
|
||||
|
||||
if (!iterator.hasNext()) {
|
||||
answer = result;
|
||||
@@ -1880,7 +1898,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
boolean isStatic = DescriptorUtils.isStaticDeclaration(propertyDescriptor);
|
||||
boolean isSuper = superExpression != null;
|
||||
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
|
||||
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
||||
|
||||
JetType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext);
|
||||
boolean isDelegatedProperty = delegateType != null;
|
||||
@@ -2214,6 +2232,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean isInline = state.isInlineEnabled() &&
|
||||
descriptor instanceof SimpleFunctionDescriptor &&
|
||||
((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline();
|
||||
|
||||
if (!isInline) return defaultCallGenerator;
|
||||
|
||||
SimpleFunctionDescriptor original = DescriptorUtils.unwrapFakeOverride((SimpleFunctionDescriptor) descriptor.getOriginal());
|
||||
@@ -2264,11 +2283,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@NotNull
|
||||
private StackValue generateReceiver(@NotNull CallableDescriptor descriptor) {
|
||||
if (context.getCallableDescriptorWithReceiver() == descriptor) {
|
||||
return context.getReceiverExpression(typeMapper);
|
||||
}
|
||||
|
||||
return context.lookupInContext(descriptor, StackValue.local(0, OBJECT_TYPE), state, false);
|
||||
return context.generateReceiver(descriptor, state, false);
|
||||
}
|
||||
|
||||
// SCRIPT: generate script, move to ScriptingUtil
|
||||
@@ -2479,7 +2494,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
PackageFragmentDescriptor containingPackage = (PackageFragmentDescriptor) descriptor.getContainingDeclaration();
|
||||
String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(containingPackage.getFqName());
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
Method factoryMethod;
|
||||
if (receiverParameter != null) {
|
||||
Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_IMPL_TYPE, getType(Class.class)};
|
||||
@@ -2556,21 +2571,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
JetCallExpression fakeExpression = constructFakeFunctionCall();
|
||||
final List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
|
||||
|
||||
final ReceiverValue thisObject = computeAndSaveReceiver(signature, codegen, referencedFunction.getExpectedThisObject());
|
||||
final ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getReceiverParameter());
|
||||
final ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
|
||||
final ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getExtensionReceiverParameter());
|
||||
computeAndSaveArguments(fakeArguments, codegen);
|
||||
|
||||
ResolvedCall<CallableDescriptor> fakeResolvedCall = new DelegatingResolvedCall<CallableDescriptor>(resolvedCall) {
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverValue getReceiverArgument() {
|
||||
public ReceiverValue getExtensionReceiver() {
|
||||
return extensionReceiver;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverValue getThisObject() {
|
||||
return thisObject;
|
||||
public ReceiverValue getDispatchReceiver() {
|
||||
return dispatchReceiver;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -2992,9 +3007,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
StackValue value = gen(lhs); // receiver
|
||||
value.dupReceiver(v); // receiver receiver
|
||||
value.put(lhsType, v); // receiver lhs
|
||||
((IntrinsicMethod) callable).generate(this, v, typeMapper.mapType(descriptor), expression,
|
||||
Type returnType = typeMapper.mapType(descriptor);
|
||||
((IntrinsicMethod) callable).generate(this, v, returnType, expression,
|
||||
Collections.singletonList(expression.getRight()), StackValue.onStack(lhsType));
|
||||
value.store(lhsType, v);
|
||||
value.store(returnType, v);
|
||||
return StackValue.none();
|
||||
}
|
||||
else {
|
||||
@@ -3038,9 +3054,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
JetExpression left = binaryExpression.getLeft();
|
||||
JetExpression right = binaryExpression.getRight();
|
||||
Type leftType = expressionType(left);
|
||||
Type rightType = expressionType(right);
|
||||
|
||||
if (leftType.equals(JAVA_STRING_TYPE) && rightType.equals(JAVA_STRING_TYPE)) {
|
||||
if (leftType.equals(JAVA_STRING_TYPE)) {
|
||||
invokeAppend(left);
|
||||
invokeAppend(right);
|
||||
return;
|
||||
@@ -3069,24 +3084,25 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@Override
|
||||
public StackValue visitPrefixExpression(@NotNull JetPrefixExpression expression, StackValue receiver) {
|
||||
DeclarationDescriptor op = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
|
||||
assert op instanceof FunctionDescriptor : String.valueOf(op);
|
||||
DeclarationDescriptor originalOperation = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
CallableDescriptor op = resolvedCall.getResultingDescriptor();
|
||||
|
||||
assert op instanceof FunctionDescriptor || originalOperation == null : String.valueOf(op);
|
||||
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||
if (callable instanceof IntrinsicMethod) {
|
||||
Type returnType = typeMapper.mapType((FunctionDescriptor) op);
|
||||
Type returnType = typeMapper.mapType(op);
|
||||
((IntrinsicMethod) callable).generate(this, v, returnType, expression,
|
||||
Collections.singletonList(expression.getBaseExpression()), receiver);
|
||||
return StackValue.onStack(returnType);
|
||||
}
|
||||
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
|
||||
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
|
||||
if (isPrimitiveNumberClassDescriptor(cls) || !(originalOperation.getName().asString().equals("inc") || originalOperation.getName().asString().equals("dec"))) {
|
||||
return invokeFunction(resolvedCall, receiver);
|
||||
}
|
||||
|
||||
CallableMethod callableMethod = (CallableMethod) callable;
|
||||
|
||||
StackValue value = gen(expression.getBaseExpression());
|
||||
value.dupReceiver(v);
|
||||
@@ -3094,9 +3110,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
Type type = expressionType(expression.getBaseExpression());
|
||||
value.put(type, v);
|
||||
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
|
||||
|
||||
value.store(callableMethod.getReturnType(), v);
|
||||
StackValue result = invokeFunction(resolvedCall, StackValue.onStack(type));
|
||||
value.store(result.type, v);
|
||||
value.put(type, v);
|
||||
return StackValue.onStack(type);
|
||||
}
|
||||
@@ -3117,29 +3132,33 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return StackValue.onStack(base.type);
|
||||
}
|
||||
|
||||
DeclarationDescriptor op = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
|
||||
if (!(op instanceof FunctionDescriptor)) {
|
||||
throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + op);
|
||||
DeclarationDescriptor originalOperation = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
|
||||
String originalOperationName = originalOperation != null ? originalOperation.getName().asString() : null;
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
DeclarationDescriptor op = resolvedCall.getResultingDescriptor();
|
||||
if (!(op instanceof FunctionDescriptor) || originalOperation == null) {
|
||||
throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + originalOperationName + " " + op);
|
||||
}
|
||||
|
||||
Type asmType = expressionType(expression);
|
||||
Type asmResultType = expressionType(expression);
|
||||
Type asmBaseType = expressionType(expression.getBaseExpression());
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
|
||||
int increment;
|
||||
if (op.getName().asString().equals("inc")) {
|
||||
if (originalOperationName.equals("inc")) {
|
||||
increment = 1;
|
||||
}
|
||||
else if (op.getName().asString().equals("dec")) {
|
||||
else if (originalOperationName.equals("dec")) {
|
||||
increment = -1;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("Unsupported postfix operation: " + op);
|
||||
throw new UnsupportedOperationException("Unsupported postfix operation: " + originalOperationName + " " + op);
|
||||
}
|
||||
|
||||
boolean isPrimitiveNumberClassDescriptor = isPrimitiveNumberClassDescriptor(cls);
|
||||
if (isPrimitiveNumberClassDescriptor) {
|
||||
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
|
||||
JetExpression operand = expression.getBaseExpression();
|
||||
if (operand instanceof JetReferenceExpression && asmType == Type.INT_TYPE) {
|
||||
if (operand instanceof JetReferenceExpression && asmResultType == Type.INT_TYPE) {
|
||||
int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0) {
|
||||
return StackValue.postIncrement(index, increment);
|
||||
@@ -3156,20 +3175,17 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
pushReceiverAndValueViaDup(value, type); // receiver and new value
|
||||
|
||||
Type storeType;
|
||||
if (isPrimitiveNumberClassDescriptor) {
|
||||
genIncrement(asmType, increment, v);
|
||||
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
|
||||
genIncrement(asmResultType, increment, v);
|
||||
storeType = type;
|
||||
}
|
||||
else {
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||
CallableMethod callableMethod = (CallableMethod) callable;
|
||||
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
|
||||
storeType = callableMethod.getReturnType();
|
||||
StackValue result = invokeFunction(resolvedCall, StackValue.onStack(type));
|
||||
storeType = result.type;
|
||||
}
|
||||
|
||||
value.store(storeType, v);
|
||||
return StackValue.onStack(asmType); // old value
|
||||
return StackValue.onStack(asmResultType); // old value
|
||||
}
|
||||
|
||||
private void pushReceiverAndValueViaDup(StackValue value, Type type) {
|
||||
@@ -3316,17 +3332,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
ConstructorDescriptor constructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
|
||||
|
||||
ReceiverParameterDescriptor expectedThisObject = constructor.getExpectedThisObject();
|
||||
if (expectedThisObject != null) {
|
||||
Type receiverType = typeMapper.mapType(expectedThisObject.getType());
|
||||
generateReceiverValue(resolvedCall.getThisObject(), receiverType);
|
||||
ReceiverParameterDescriptor dispatchReceiver = constructor.getDispatchReceiverParameter();
|
||||
if (dispatchReceiver != null) {
|
||||
Type receiverType = typeMapper.mapType(dispatchReceiver.getType());
|
||||
generateReceiverValue(resolvedCall.getDispatchReceiver(), receiverType);
|
||||
}
|
||||
|
||||
MutableClosure closure = bindingContext.get(CLOSURE, constructor.getContainingDeclaration());
|
||||
|
||||
// Resolved call to local class constructor doesn't have expectedThisObject, so we need to generate closure on stack
|
||||
// Resolved call to local class constructor doesn't have dispatchReceiver, so we need to generate closure on stack
|
||||
// See StackValue.receiver for more info
|
||||
pushClosureOnStack(closure, expectedThisObject != null, defaultCallGenerator);
|
||||
pushClosureOnStack(constructor.getContainingDeclaration(), dispatchReceiver == null, defaultCallGenerator);
|
||||
|
||||
ConstructorDescriptor originalOfSamAdapter = (ConstructorDescriptor) SamCodegenUtil.getOriginalIfSamAdapter(constructor);
|
||||
CallableMethod method = typeMapper.mapToCallableMethod(originalOfSamAdapter == null ? constructor : originalOfSamAdapter);
|
||||
@@ -3463,7 +3477,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
else {
|
||||
gen(array, arrayType); // intrinsic method
|
||||
|
||||
int index = operationDescriptor.getReceiverParameter() != null ? 1 : 0;
|
||||
int index = operationDescriptor.getExtensionReceiverParameter() != null ? 1 : 0;
|
||||
|
||||
for (JetExpression jetExpression : expression.getIndexExpressions()) {
|
||||
gen(jetExpression, argumentTypes[index]);
|
||||
@@ -3487,6 +3501,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
public StackValue visitThisExpression(@NotNull JetThisExpression expression, StackValue receiver) {
|
||||
DeclarationDescriptor descriptor = bindingContext.get(REFERENCE_TARGET, expression.getInstanceReference());
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
//TODO rewrite with context.lookupInContext()
|
||||
return StackValue.thisOrOuter(this, (ClassDescriptor) descriptor, false, true);
|
||||
}
|
||||
if (descriptor instanceof CallableDescriptor) {
|
||||
@@ -3687,7 +3702,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
@Override
|
||||
public StackValue visitIsExpression(@NotNull JetIsExpression expression, StackValue receiver) {
|
||||
StackValue match = StackValue.expression(OBJECT_TYPE, expression.getLeftHandSide(), this);
|
||||
return generateIsCheck(match, expression.getTypeRef(), expression.isNegated());
|
||||
return generateIsCheck(match, expression.getTypeReference(), expression.isNegated());
|
||||
}
|
||||
|
||||
private StackValue generateExpressionMatch(StackValue expressionToMatch, JetExpression patternExpression) {
|
||||
@@ -3839,7 +3854,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
StackValue.Local match = subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType);
|
||||
if (condition instanceof JetWhenConditionIsPattern) {
|
||||
JetWhenConditionIsPattern patternCondition = (JetWhenConditionIsPattern) condition;
|
||||
return generateIsCheck(match, patternCondition.getTypeRef(), patternCondition.isNegated());
|
||||
return generateIsCheck(match, patternCondition.getTypeReference(), patternCondition.isNegated());
|
||||
}
|
||||
else if (condition instanceof JetWhenConditionWithExpression) {
|
||||
JetExpression patternExpression = ((JetWhenConditionWithExpression) condition).getExpression();
|
||||
|
||||
@@ -36,10 +36,10 @@ import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ResolvePackage;
|
||||
import org.jetbrains.jet.lang.resolve.annotations.AnnotationsPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.constants.ArrayValue;
|
||||
@@ -50,6 +50,8 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.Approximation;
|
||||
import org.jetbrains.jet.lang.types.TypesPackage;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
@@ -236,7 +238,7 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
}
|
||||
|
||||
if (kind == JvmMethodParameterKind.RECEIVER) {
|
||||
ReceiverParameterDescriptor receiver = functionDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = functionDescriptor.getExtensionReceiverParameter();
|
||||
nullableType = receiver == null || receiver.getType().isNullable();
|
||||
}
|
||||
else {
|
||||
@@ -271,12 +273,12 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
|
||||
@Nullable
|
||||
private static Type getThisTypeForFunction(@NotNull FunctionDescriptor functionDescriptor, @NotNull MethodContext context, @NotNull JetTypeMapper typeMapper) {
|
||||
ReceiverParameterDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
|
||||
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
|
||||
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||
return typeMapper.mapType(functionDescriptor);
|
||||
}
|
||||
else if (expectedThisObject != null) {
|
||||
return typeMapper.mapType(expectedThisObject.getType());
|
||||
else if (dispatchReceiver != null) {
|
||||
return typeMapper.mapType(dispatchReceiver.getType());
|
||||
}
|
||||
else if (isFunctionLiteral(functionDescriptor) || isLocalNamedFun(functionDescriptor)) {
|
||||
return typeMapper.mapType(context.getThisDescriptor());
|
||||
@@ -483,7 +485,7 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
|
||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
|
||||
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
|
||||
if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
|
||||
@@ -515,9 +517,10 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
@NotNull GenerationState state,
|
||||
@NotNull CallableMethod method,
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ClassBuilder classBuilder
|
||||
@NotNull ClassBuilder classBuilder,
|
||||
@NotNull JetClassOrObject classOrObject
|
||||
) {
|
||||
if (!isDefaultConstructorNeeded(state.getBindingContext(), constructorDescriptor)) {
|
||||
if (!isEmptyConstructorNeeded(state.getBindingContext(), constructorDescriptor, classOrObject)) {
|
||||
return;
|
||||
}
|
||||
int flags = getVisibilityAccessFlag(constructorDescriptor);
|
||||
@@ -551,7 +554,7 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
String desc = JetTypeMapper.getDefaultDescriptor(method.getAsmMethod(), false);
|
||||
v.invokespecial(methodOwner.getInternalName(), "<init>", desc, false);
|
||||
v.areturn(Type.VOID_TYPE);
|
||||
endVisit(mv, "default constructor for " + methodOwner.getInternalName(), null);
|
||||
endVisit(mv, "default constructor for " + methodOwner.getInternalName(), classOrObject);
|
||||
}
|
||||
|
||||
void generateDefaultIfNeeded(
|
||||
@@ -740,9 +743,15 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
return needed;
|
||||
}
|
||||
|
||||
private static boolean isDefaultConstructorNeeded(@NotNull BindingContext context, @NotNull ConstructorDescriptor constructorDescriptor) {
|
||||
private static boolean isEmptyConstructorNeeded(
|
||||
@NotNull BindingContext context,
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@NotNull JetClassOrObject classOrObject
|
||||
) {
|
||||
ClassDescriptor classDescriptor = constructorDescriptor.getContainingDeclaration();
|
||||
|
||||
if (classOrObject.isLocal()) return false;
|
||||
|
||||
if (CodegenBinding.canHaveOuter(context, classDescriptor)) return false;
|
||||
|
||||
if (classDescriptor.getVisibility() == Visibilities.PRIVATE ||
|
||||
@@ -791,21 +800,20 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
}
|
||||
|
||||
public void genDelegate(FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
|
||||
genDelegate(functionDescriptor, (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field,
|
||||
typeMapper.mapSignature(functionDescriptor),
|
||||
typeMapper.mapSignature(overriddenDescriptor.getOriginal())
|
||||
genDelegate(functionDescriptor, overriddenDescriptor.getOriginal(), (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field
|
||||
);
|
||||
}
|
||||
|
||||
public void genDelegate(
|
||||
FunctionDescriptor functionDescriptor,
|
||||
final FunctionDescriptor delegateFunction,
|
||||
final FunctionDescriptor delegatedTo,
|
||||
final ClassDescriptor toClass,
|
||||
final StackValue field,
|
||||
final JvmMethodSignature jvmDelegateMethodSignature,
|
||||
final JvmMethodSignature jvmDelegatingMethodSignature
|
||||
final StackValue field
|
||||
) {
|
||||
final JvmMethodSignature jvmDelegateMethodSignature = typeMapper.mapSignature(delegateFunction);
|
||||
final JvmMethodSignature jvmDelegateToMethodSignature = typeMapper.mapSignature(delegatedTo);
|
||||
generateMethod(
|
||||
OtherOrigin(functionDescriptor), jvmDelegateMethodSignature, functionDescriptor,
|
||||
OtherOrigin(delegateFunction), jvmDelegateMethodSignature, delegateFunction,
|
||||
new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
@@ -815,11 +823,11 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
@NotNull MethodContext context,
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
Method overriddenMethod = jvmDelegatingMethodSignature.getAsmMethod();
|
||||
Method delegateToMethod = jvmDelegateToMethodSignature.getAsmMethod();
|
||||
Method delegateMethod = jvmDelegateMethodSignature.getAsmMethod();
|
||||
|
||||
Type[] argTypes = delegateMethod.getArgumentTypes();
|
||||
Type[] originalArgTypes = overriddenMethod.getArgumentTypes();
|
||||
Type[] originalArgTypes = delegateToMethod.getArgumentTypes();
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
@@ -832,13 +840,22 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
|
||||
String internalName = typeMapper.mapType(toClass).getInternalName();
|
||||
if (toClass.getKind() == ClassKind.TRAIT) {
|
||||
iv.invokeinterface(internalName, overriddenMethod.getName(), overriddenMethod.getDescriptor());
|
||||
iv.invokeinterface(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
|
||||
}
|
||||
else {
|
||||
iv.invokevirtual(internalName, overriddenMethod.getName(), overriddenMethod.getDescriptor());
|
||||
iv.invokevirtual(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
|
||||
}
|
||||
|
||||
StackValue.onStack(overriddenMethod.getReturnType()).put(delegateMethod.getReturnType(), iv);
|
||||
StackValue stackValue = AsmUtil.genNotNullAssertions(
|
||||
state,
|
||||
StackValue.onStack(delegateToMethod.getReturnType()),
|
||||
TypesPackage.getApproximationTo(
|
||||
delegatedTo.getReturnType(),
|
||||
delegateFunction.getReturnType(),
|
||||
new Approximation.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)"))
|
||||
);
|
||||
|
||||
stackValue.put(delegateMethod.getReturnType(), iv);
|
||||
|
||||
iv.areturn(delegateMethod.getReturnType());
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import kotlin.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.backend.common.CodegenUtil;
|
||||
import org.jetbrains.jet.backend.common.CodegenUtilKt;
|
||||
import org.jetbrains.jet.backend.common.DataClassMethodGenerator;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
||||
import org.jetbrains.jet.codegen.context.*;
|
||||
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
@@ -50,13 +50,14 @@ import org.jetbrains.jet.lang.resolve.calls.model.VarargValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmClassSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -426,7 +427,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
generateFunctionsForDataClasses();
|
||||
|
||||
generateBuiltinMethodStubs();
|
||||
new CollectionStubMethodGenerator(state, descriptor, functionCodegen, v).generate();
|
||||
|
||||
generateToArray();
|
||||
|
||||
@@ -484,7 +485,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
iv.load(0, classAsmType);
|
||||
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray", "(Ljava/util/Collection;)[Ljava/lang/Object;", false);
|
||||
iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
|
||||
iv.areturn(Type.getType("[Ljava/lang/Object;"));
|
||||
|
||||
FunctionCodegen.endVisit(mv, "toArray", myClass);
|
||||
}
|
||||
@@ -498,98 +499,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
mv.visitCode();
|
||||
|
||||
iv.load(0, classAsmType);
|
||||
iv.load(1, Type.getObjectType("[Ljava/lang/Object;"));
|
||||
iv.load(1, Type.getType("[Ljava/lang/Object;"));
|
||||
|
||||
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray",
|
||||
"(Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;", false);
|
||||
iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
|
||||
iv.areturn(Type.getType("[Ljava/lang/Object;"));
|
||||
|
||||
FunctionCodegen.endVisit(mv, "toArray", myClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MethodStubGenerator {
|
||||
private final Set<String> generatedSignatures = new HashSet<String>();
|
||||
|
||||
public void generate(
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@NotNull ClassifierDescriptor returnedClassifier,
|
||||
@NotNull ClassifierDescriptor... valueParameterClassifiers
|
||||
) {
|
||||
// avoid generating same signature twice
|
||||
if (!generatedSignatures.add(name + desc)) return;
|
||||
if (CodegenUtil.getDeclaredFunctionByRawSignature(
|
||||
descriptor, Name.identifier(name), returnedClassifier, valueParameterClassifiers) == null) {
|
||||
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
||||
ACC_PUBLIC | ACC_ABSTRACT :
|
||||
ACC_PUBLIC;
|
||||
MethodVisitor mv = v.newMethod(NO_ORIGIN, access, name, desc, null, null);
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
mv.visitCode();
|
||||
genThrow(new InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection");
|
||||
FunctionCodegen.endVisit(mv, "built-in stub for " + name + desc, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generateBuiltinMethodStubs() {
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
MethodStubGenerator methodStubs = new MethodStubGenerator();
|
||||
if (isSubclass(descriptor, builtIns.getCollection())) {
|
||||
ClassifierDescriptor classifier = getSubstituteForTypeParameterOf(builtIns.getCollection(), 0);
|
||||
|
||||
methodStubs.generate("add", "(Ljava/lang/Object;)Z", builtIns.getBoolean(), classifier);
|
||||
methodStubs.generate("remove", "(Ljava/lang/Object;)Z", builtIns.getBoolean(), builtIns.getAny());
|
||||
methodStubs.generate("addAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
|
||||
methodStubs.generate("removeAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
|
||||
methodStubs.generate("retainAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
|
||||
methodStubs.generate("clear", "()V", builtIns.getUnit());
|
||||
}
|
||||
|
||||
if (isSubclass(descriptor, builtIns.getList())) {
|
||||
ClassifierDescriptor classifier = getSubstituteForTypeParameterOf(builtIns.getList(), 0);
|
||||
|
||||
methodStubs.generate("set", "(ILjava/lang/Object;)Ljava/lang/Object;", classifier, builtIns.getInt(), classifier);
|
||||
methodStubs.generate("add", "(ILjava/lang/Object;)V", builtIns.getUnit(), builtIns.getInt(), classifier);
|
||||
methodStubs.generate("remove", "(I)Ljava/lang/Object;", classifier, builtIns.getInt());
|
||||
}
|
||||
|
||||
if (isSubclass(descriptor, builtIns.getMap())) {
|
||||
ClassifierDescriptor keyClassifier = getSubstituteForTypeParameterOf(builtIns.getMap(), 0);
|
||||
ClassifierDescriptor valueClassifier = getSubstituteForTypeParameterOf(builtIns.getMap(), 1);
|
||||
|
||||
methodStubs.generate("put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, keyClassifier,
|
||||
valueClassifier);
|
||||
methodStubs.generate("remove", "(Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, builtIns.getAny());
|
||||
methodStubs.generate("putAll", "(Ljava/util/Map;)V", builtIns.getUnit(), builtIns.getMap());
|
||||
methodStubs.generate("clear", "()V", builtIns.getUnit());
|
||||
}
|
||||
|
||||
if (isSubclass(descriptor, builtIns.getMapEntry())) {
|
||||
ClassifierDescriptor valueClassifier = getSubstituteForTypeParameterOf(builtIns.getMapEntry(), 1);
|
||||
|
||||
methodStubs.generate("setValue", "(Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, valueClassifier);
|
||||
}
|
||||
|
||||
if (isSubclass(descriptor, builtIns.getIterator())) {
|
||||
methodStubs.generate("remove", "()V", builtIns.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ClassifierDescriptor getSubstituteForTypeParameterOf(@NotNull ClassDescriptor trait, int index) {
|
||||
TypeParameterDescriptor listTypeParameter = trait.getTypeConstructor().getParameters().get(index);
|
||||
TypeSubstitutor deepSubstitutor = SubstitutionUtils.buildDeepSubstitutor(descriptor.getDefaultType());
|
||||
TypeProjection substitute = deepSubstitutor.substitute(new TypeProjectionImpl(listTypeParameter.getDefaultType()));
|
||||
assert substitute != null : "Couldn't substitute: " + descriptor;
|
||||
ClassifierDescriptor classifier = substitute.getType().getConstructor().getDeclarationDescriptor();
|
||||
assert classifier != null : "No classifier: " + substitute.getType();
|
||||
return classifier;
|
||||
}
|
||||
|
||||
private void generateFunctionsForDataClasses() {
|
||||
if (!KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
||||
|
||||
@@ -644,15 +564,23 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
else {
|
||||
iv.invokestatic("java/util/Arrays", "equals",
|
||||
"([" + elementType.getDescriptor() + "[" + elementType.getDescriptor() + ")Z", false);
|
||||
"(" + asmType.getDescriptor() + asmType.getDescriptor() + ")Z", false);
|
||||
}
|
||||
iv.ifeq(ne);
|
||||
}
|
||||
else if (asmType.getSort() == Type.FLOAT) {
|
||||
iv.invokestatic("java/lang/Float", "compare", "(FF)I", false);
|
||||
iv.ifne(ne);
|
||||
}
|
||||
else if (asmType.getSort() == Type.DOUBLE) {
|
||||
iv.invokestatic("java/lang/Double", "compare", "(DD)I", false);
|
||||
iv.ifne(ne);
|
||||
}
|
||||
else {
|
||||
StackValue value = genEqualsForExpressionsOnStack(iv, JetTokens.EQEQ, asmType, asmType);
|
||||
value.put(Type.BOOLEAN_TYPE, iv);
|
||||
iv.ifeq(ne);
|
||||
}
|
||||
|
||||
iv.ifeq(ne);
|
||||
}
|
||||
|
||||
iv.mark(eq);
|
||||
@@ -1152,7 +1080,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
DefaultParameterValueLoader.DEFAULT, null);
|
||||
|
||||
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor);
|
||||
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v);
|
||||
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v, myClass);
|
||||
|
||||
if (isClassObject(descriptor)) {
|
||||
context.recordSyntheticAccessorIfNeeded(constructorDescriptor, bindingContext);
|
||||
@@ -1286,13 +1214,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
|
||||
PropertyDescriptor propertyDescriptor = CodegenUtil.getDelegatePropertyIfAny(expression, descriptor, bindingContext);
|
||||
|
||||
ClassDescriptor superClassDescriptor = getSuperClass(specifier);
|
||||
|
||||
if (CodegenUtil.isFinalPropertyWithBackingField(propertyDescriptor, bindingContext)) {
|
||||
result.addField((JetDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
|
||||
}
|
||||
else {
|
||||
result.addField((JetDelegatorByExpressionSpecifier) specifier, typeMapper.mapType(superClassDescriptor), "$delegate_" + n);
|
||||
JetType expressionType = state.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
Type asmType =
|
||||
expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier));
|
||||
result.addField((JetDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
@@ -1357,8 +1287,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
|
||||
assert descriptor instanceof CallableDescriptor ||
|
||||
descriptor instanceof ClassDescriptor : "'This' reference target should be class or callable descriptor but was " + descriptor;
|
||||
if (context.getCallableDescriptorWithReceiver() != descriptor) {
|
||||
context.lookupInContext(descriptor, null, state, true);
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
context.lookupInContext(descriptor, StackValue.local(0, OBJECT_TYPE), state, true);
|
||||
}
|
||||
|
||||
if (descriptor instanceof CallableDescriptor) {
|
||||
constructorContext.generateReceiver((CallableDescriptor) descriptor, state, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1385,10 +1319,18 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (superCall != null && !isAnonymousObject(descriptor)) {
|
||||
JetValueArgumentList argumentList = superCall.getValueArgumentList();
|
||||
if (argumentList != null) {
|
||||
argumentList.accept(visitor);
|
||||
if (superCall != null) {
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(superCall, bindingContext);
|
||||
ClassDescriptor superClass = ((ConstructorDescriptor) resolvedCall.getResultingDescriptor()).getContainingDeclaration();
|
||||
if (superClass.isInner()) {
|
||||
constructorContext.lookupInContext(superClass.getContainingDeclaration(), StackValue.local(0, OBJECT_TYPE), state, true);
|
||||
}
|
||||
|
||||
if (!isAnonymousObject(descriptor)) {
|
||||
JetValueArgumentList argumentList = superCall.getValueArgumentList();
|
||||
if (argumentList != null) {
|
||||
argumentList.accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1409,32 +1351,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateTraitMethods() {
|
||||
if (JetPsiUtil.isTrait(myClass)) return;
|
||||
|
||||
for (DeclarationDescriptor declaration : descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
|
||||
if (!(declaration instanceof CallableMemberDescriptor)) continue;
|
||||
|
||||
CallableMemberDescriptor inheritedMember = (CallableMemberDescriptor) declaration;
|
||||
CallableMemberDescriptor traitMember = BridgesPackage.findTraitImplementation(inheritedMember);
|
||||
if (traitMember == null) continue;
|
||||
|
||||
assert traitMember.getModality() != Modality.ABSTRACT : "Cannot delegate to abstract trait method: " + inheritedMember;
|
||||
|
||||
// inheritedMember can be abstract here. In order for FunctionCodegen to generate the method body, we're creating a copy here
|
||||
// with traitMember's modality
|
||||
CallableMemberDescriptor copy =
|
||||
inheritedMember.copy(inheritedMember.getContainingDeclaration(), traitMember.getModality(), Visibilities.PUBLIC,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, true);
|
||||
|
||||
if (traitMember instanceof SimpleFunctionDescriptor) {
|
||||
generateDelegationToTraitImpl((FunctionDescriptor) traitMember, (FunctionDescriptor) copy);
|
||||
}
|
||||
else if (traitMember instanceof PropertyDescriptor) {
|
||||
for (PropertyAccessorDescriptor traitAccessor : ((PropertyDescriptor) traitMember).getAccessors()) {
|
||||
for (PropertyAccessorDescriptor inheritedAccessor : ((PropertyDescriptor) copy).getAccessors()) {
|
||||
if (inheritedAccessor.getClass() == traitAccessor.getClass()) { // same accessor kind
|
||||
generateDelegationToTraitImpl(traitAccessor, inheritedAccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getTraitMethods(descriptor).entrySet()) {
|
||||
FunctionDescriptor traitFun = entry.getKey();
|
||||
//skip java 8 default methods
|
||||
if (!(traitFun instanceof JavaCallableMemberDescriptor)) {
|
||||
generateDelegationToTraitImpl(traitFun, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1508,17 +1429,29 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
for (JvmMethodParameterSignature parameter : parameters) {
|
||||
if (superIndex >= superParameters.size()) break;
|
||||
|
||||
JvmMethodParameterKind superKind = superParameters.get(superIndex).getKind();
|
||||
JvmMethodParameterKind kind = parameter.getKind();
|
||||
Type type = parameter.getAsmType();
|
||||
|
||||
// Stop when we reach the actual value parameters present in the code; they will be generated via ResolvedCall below
|
||||
if (superParameters.get(superIndex).getKind() == JvmMethodParameterKind.VALUE &&
|
||||
kind == JvmMethodParameterKind.SUPER_CALL_PARAM) {
|
||||
if (superKind == JvmMethodParameterKind.VALUE && kind == JvmMethodParameterKind.SUPER_CALL_PARAM) {
|
||||
// Stop when we reach the actual value parameters present in the code; they will be generated via ResolvedCall below
|
||||
break;
|
||||
}
|
||||
|
||||
if (kind == JvmMethodParameterKind.SUPER_CALL_PARAM || kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL ||
|
||||
(kind == JvmMethodParameterKind.OUTER && superConstructor.getContainingDeclaration().isInner())) {
|
||||
if (superKind == JvmMethodParameterKind.OUTER) {
|
||||
assert kind == JvmMethodParameterKind.OUTER || kind == JvmMethodParameterKind.SUPER_CALL_PARAM :
|
||||
String.format("Non-outer parameter incorrectly mapped to outer for %s: %s vs %s",
|
||||
constructorDescriptor, parameters, superParameters);
|
||||
// Super constructor requires OUTER parameter, but our OUTER instance may be different from what is expected by the super
|
||||
// constructor. We need to traverse our outer classes from the bottom up, to find the needed class
|
||||
// TODO: isSuper should be "true" but this makes some tests on inner classes extending outer fail
|
||||
// See innerExtendsOuter.kt, semantics of inner classes extending their outer should be changed to be as in Java
|
||||
ClassDescriptor outerForSuper = (ClassDescriptor) superConstructor.getContainingDeclaration().getContainingDeclaration();
|
||||
StackValue outer = codegen.generateThisOrOuter(outerForSuper, false);
|
||||
outer.put(outer.type, codegen.v);
|
||||
superIndex++;
|
||||
}
|
||||
else if (kind == JvmMethodParameterKind.SUPER_CALL_PARAM || kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL) {
|
||||
iv.load(offset, type);
|
||||
superIndex++;
|
||||
}
|
||||
@@ -1665,7 +1598,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
|
||||
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((JetDelegatorByExpressionSpecifier) specifier);
|
||||
generateDelegateField(field);
|
||||
generateDelegates(getSuperClass(specifier), field);
|
||||
JetExpression delegateExpression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
|
||||
JetType delegateExpressionType = state.getBindingContext().get(BindingContext.EXPRESSION_TYPE, delegateExpression);
|
||||
generateDelegates(getSuperClass(specifier), delegateExpressionType, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1677,17 +1612,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
fieldInfo.name, fieldInfo.type.getDescriptor(), /*TODO*/null, null);
|
||||
}
|
||||
|
||||
protected void generateDelegates(ClassDescriptor toClass, DelegationFieldsInfo.Field field) {
|
||||
for (Map.Entry<CallableMemberDescriptor, CallableMemberDescriptor> entry : CodegenUtil.getDelegates(descriptor, toClass).entrySet()) {
|
||||
protected void generateDelegates(ClassDescriptor toTrait, JetType delegateExpressionType, DelegationFieldsInfo.Field field) {
|
||||
for (Map.Entry<CallableMemberDescriptor, CallableDescriptor> entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) {
|
||||
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
|
||||
CallableMemberDescriptor overriddenDescriptor = entry.getValue();
|
||||
CallableDescriptor delegateTo = entry.getValue();
|
||||
if (callableMemberDescriptor instanceof PropertyDescriptor) {
|
||||
propertyCodegen
|
||||
.genDelegate((PropertyDescriptor) callableMemberDescriptor, (PropertyDescriptor) overriddenDescriptor, field.getStackValue());
|
||||
.genDelegate((PropertyDescriptor) callableMemberDescriptor, (PropertyDescriptor) delegateTo, field.getStackValue());
|
||||
}
|
||||
else if (callableMemberDescriptor instanceof FunctionDescriptor) {
|
||||
functionCodegen
|
||||
.genDelegate((FunctionDescriptor) callableMemberDescriptor, (FunctionDescriptor) overriddenDescriptor, field.getStackValue());
|
||||
.genDelegate((FunctionDescriptor) callableMemberDescriptor, (FunctionDescriptor) delegateTo, field.getStackValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ public class JvmCodegenUtil {
|
||||
if (JetTypeMapper.isAccessor(property)) return false;
|
||||
|
||||
// Inline functions can't use direct access because a field may not be visible at the call site
|
||||
if (context.isInlineFunction()) return false;
|
||||
if (context.isInlineFunction() && property.getVisibility() != Visibilities.PRIVATE) return false;
|
||||
|
||||
// Only properties of the same class can be directly accessed, except when we are evaluating expressions in the debugger
|
||||
if (!isCallInsideSameClassAsDeclared(property, context) && !isDebuggerContext(context)) return false;
|
||||
|
||||
// Delegated and extension properties have no backing fields
|
||||
if (isDelegated || property.getReceiverParameter() != null) return false;
|
||||
if (isDelegated || property.getExtensionReceiverParameter() != null) return false;
|
||||
|
||||
// Class object properties cannot be accessed directly because their backing fields are stored in the containing class
|
||||
if (DescriptorUtils.isClassObject(property.getContainingDeclaration())) return false;
|
||||
@@ -203,7 +203,7 @@ public class JvmCodegenUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getExpectedThisObjectForConstructorCall(
|
||||
public static ClassDescriptor getDispatchReceiverParameterForConstructorCall(
|
||||
@NotNull ConstructorDescriptor descriptor,
|
||||
@Nullable CalculatedClosure closure
|
||||
) {
|
||||
@@ -214,10 +214,10 @@ public class JvmCodegenUtil {
|
||||
|
||||
//for compilation against binaries
|
||||
//TODO: It's best to use this code also for compilation against sources
|
||||
// but sometimes structures that have expectedThisObject (bug?) mapped to static classes
|
||||
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
|
||||
if (expectedThisObject != null) {
|
||||
ClassDescriptor expectedThisClass = (ClassDescriptor) expectedThisObject.getContainingDeclaration();
|
||||
// but sometimes structures that have dispatchReceiver (bug?) mapped to static classes
|
||||
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
|
||||
if (dispatchReceiver != null) {
|
||||
ClassDescriptor expectedThisClass = (ClassDescriptor) dispatchReceiver.getContainingDeclaration();
|
||||
if (!expectedThisClass.getKind().isSingleton()) {
|
||||
return expectedThisClass;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class JvmRuntimeTypes {
|
||||
|
||||
@NotNull
|
||||
public Collection<JetType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
|
||||
List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(2);
|
||||
|
||||
@@ -127,21 +127,21 @@ public class JvmRuntimeTypes {
|
||||
|
||||
@NotNull
|
||||
public Collection<JetType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
|
||||
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
|
||||
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
|
||||
|
||||
List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(2);
|
||||
|
||||
ClassDescriptor classDescriptor;
|
||||
JetType receiverType;
|
||||
if (receiverParameter != null) {
|
||||
if (extensionReceiver != null) {
|
||||
classDescriptor = kExtensionFunctionImpl;
|
||||
receiverType = receiverParameter.getType();
|
||||
receiverType = extensionReceiver.getType();
|
||||
typeArguments.add(new TypeProjectionImpl(receiverType));
|
||||
}
|
||||
else if (expectedThisObject != null) {
|
||||
else if (dispatchReceiver != null) {
|
||||
classDescriptor = kMemberFunctionImpl;
|
||||
receiverType = expectedThisObject.getType();
|
||||
receiverType = dispatchReceiver.getType();
|
||||
typeArguments.add(new TypeProjectionImpl(receiverType));
|
||||
}
|
||||
else {
|
||||
@@ -165,7 +165,7 @@ public class JvmRuntimeTypes {
|
||||
receiverType,
|
||||
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||
descriptor.getReturnType(),
|
||||
receiverParameter != null
|
||||
extensionReceiver != null
|
||||
);
|
||||
|
||||
return Arrays.asList(kFunctionImplType, kFunctionType);
|
||||
|
||||
@@ -366,7 +366,7 @@ public class PackageCodegen {
|
||||
SmartList<PackageFragmentDescriptor> fragments = new SmartList<PackageFragmentDescriptor>();
|
||||
for (JetFile file : files) {
|
||||
PackageFragmentDescriptor fragment = state.getBindingContext().get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file);
|
||||
assert fragment != null : "package fragment is null for " + file;
|
||||
assert fragment != null : "package fragment is null for " + file + "\n" + file.getText();
|
||||
|
||||
assert expectedFqName.equals(fragment.getFqName()) :
|
||||
"expected package fq name: " + expectedFqName + ", actual: " + fragment.getFqName();
|
||||
|
||||
@@ -39,7 +39,8 @@ class PlatformStaticGenerator(
|
||||
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
|
||||
asmMethod.getName()!!,
|
||||
asmMethod.getDescriptor()!!,
|
||||
null, null)
|
||||
typeMapper.mapSignature(descriptor).getGenericsSignature(),
|
||||
FunctionCodegen.getThrownExceptions(descriptor, typeMapper))
|
||||
|
||||
AnnotationCodegen.forMethod(methodVisitor, typeMapper)!!.genAnnotations(descriptor, asmMethod.getReturnType())
|
||||
|
||||
@@ -48,7 +49,7 @@ class PlatformStaticGenerator(
|
||||
val iv = InstructionAdapter(methodVisitor)
|
||||
val classDescriptor = descriptor.getContainingDeclaration() as ClassDescriptor
|
||||
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)!!
|
||||
singletonValue.put(singletonValue.`type`, iv);
|
||||
singletonValue.put(singletonValue.type, iv);
|
||||
var index = 0;
|
||||
for (paramType in asmMethod.getArgumentTypes()) {
|
||||
iv.load(index, paramType);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class PropertyCodegen {
|
||||
if (declaration == null) return true;
|
||||
|
||||
// Delegated or extension properties can only be referenced via accessors
|
||||
if (declaration.hasDelegate() || declaration.getReceiverTypeRef() != null) return true;
|
||||
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
|
||||
|
||||
// Class object properties always should have accessors, because their backing fields are moved/copied to the outer class
|
||||
if (isClassObject(descriptor.getContainingDeclaration())) return true;
|
||||
@@ -206,7 +206,7 @@ public class PropertyCodegen {
|
||||
private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor) {
|
||||
if (descriptor.getAnnotations().isEmpty()) return;
|
||||
|
||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
|
||||
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
|
||||
String desc = receiver == null ? "()V" : "(" + typeMapper.mapType(receiver.getType()) + ")V";
|
||||
|
||||
@@ -395,7 +395,7 @@ public class PropertyCodegen {
|
||||
v.areturn(type);
|
||||
}
|
||||
else if (callableDescriptor instanceof PropertySetterDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = propertyDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = propertyDescriptor.getExtensionReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
paramCode += codegen.typeMapper.mapType(receiverParameter.getType()).getSize();
|
||||
}
|
||||
@@ -484,21 +484,19 @@ public class PropertyCodegen {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
|
||||
}
|
||||
|
||||
public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor overridden, @NotNull StackValue field) {
|
||||
ClassDescriptor toClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor delegateTo, @NotNull StackValue field) {
|
||||
ClassDescriptor toClass = (ClassDescriptor) delegateTo.getContainingDeclaration();
|
||||
|
||||
PropertyGetterDescriptor getter = delegate.getGetter();
|
||||
if (getter != null) {
|
||||
//noinspection ConstantConditions
|
||||
functionCodegen.genDelegate(getter, toClass, field,
|
||||
typeMapper.mapSignature(getter), typeMapper.mapSignature(overridden.getGetter().getOriginal()));
|
||||
functionCodegen.genDelegate(getter, delegateTo.getGetter().getOriginal(), toClass, field);
|
||||
}
|
||||
|
||||
PropertySetterDescriptor setter = delegate.getSetter();
|
||||
if (setter != null) {
|
||||
//noinspection ConstantConditions
|
||||
functionCodegen.genDelegate(setter, toClass, field,
|
||||
typeMapper.mapSignature(setter), typeMapper.mapSignature(overridden.getSetter().getOriginal()));
|
||||
functionCodegen.genDelegate(setter, delegateTo.getSetter().getOriginal(), toClass, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
@@ -149,6 +150,21 @@ public class SamWrapperCodegen {
|
||||
.getFunctions(Name.identifier("invoke")).iterator().next().getOriginal();
|
||||
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false);
|
||||
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
|
||||
|
||||
// generate sam bridges
|
||||
// TODO: erasedInterfaceFunction is actually not an interface function, but function in generated class
|
||||
SimpleFunctionDescriptor originalInterfaceErased = samType.getAbstractMethod().getOriginal();
|
||||
SimpleFunctionDescriptorImpl descriptorForBridges = SimpleFunctionDescriptorImpl
|
||||
.create(erasedInterfaceFunction.getContainingDeclaration(), erasedInterfaceFunction.getAnnotations(), originalInterfaceErased.getName(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, erasedInterfaceFunction.getSource());
|
||||
|
||||
descriptorForBridges
|
||||
.initialize(null, originalInterfaceErased.getDispatchReceiverParameter(), originalInterfaceErased.getTypeParameters(),
|
||||
originalInterfaceErased.getValueParameters(), originalInterfaceErased.getReturnType(), Modality.OPEN,
|
||||
originalInterfaceErased.getVisibility());
|
||||
|
||||
descriptorForBridges.addOverriddenDescriptor(originalInterfaceErased);
|
||||
codegen.generateBridges(descriptorForBridges);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -313,7 +313,7 @@ public abstract class StackValue {
|
||||
|
||||
public static StackValue thisOrOuter(ExpressionCodegen codegen, ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) {
|
||||
// Coerce this/super for traits to support traits with required classes.
|
||||
// Coerce explicit 'this' for the case when it is smartcasted.
|
||||
// Coerce explicit 'this' for the case when it is smart cast.
|
||||
// Do not coerce for other classes due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
|
||||
boolean coerceType = descriptor.getKind() == ClassKind.TRAIT || (isExplicit && !isSuper);
|
||||
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
|
||||
@@ -333,7 +333,7 @@ public abstract class StackValue {
|
||||
ExpressionCodegen codegen,
|
||||
@Nullable CallableMethod callableMethod
|
||||
) {
|
||||
if (resolvedCall.getThisObject().exists() || resolvedCall.getReceiverArgument().exists() || isLocalFunCall(callableMethod)) {
|
||||
if (resolvedCall.getDispatchReceiver().exists() || resolvedCall.getExtensionReceiver().exists() || isLocalFunCall(callableMethod)) {
|
||||
return new CallReceiver(resolvedCall, receiver, codegen, callableMethod, true);
|
||||
}
|
||||
return receiver;
|
||||
@@ -358,6 +358,10 @@ public abstract class StackValue {
|
||||
return field(info.getFieldType(), Type.getObjectType(info.getOwnerInternalName()), info.getFieldName(), true);
|
||||
}
|
||||
|
||||
public static boolean couldSkipReceiverOnStaticCall(StackValue value) {
|
||||
return value instanceof Local || value instanceof Constant;
|
||||
}
|
||||
|
||||
private static class None extends StackValue {
|
||||
public static final None INSTANCE = new None();
|
||||
|
||||
@@ -413,10 +417,17 @@ public abstract class StackValue {
|
||||
put(type, v);
|
||||
}
|
||||
else if (depth == 1) {
|
||||
if (type.getSize() != 1) {
|
||||
int size = this.type.getSize();
|
||||
if (size == 1) {
|
||||
v.swap();
|
||||
} else if (size == 2) {
|
||||
v.dupX2();
|
||||
v.pop();
|
||||
} else {
|
||||
throw new UnsupportedOperationException("don't know how to move type " + type + " to top of stack");
|
||||
}
|
||||
v.swap();
|
||||
|
||||
coerceTo(type, v);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("unsupported move-to-top depth " + depth);
|
||||
@@ -506,7 +517,7 @@ public abstract class StackValue {
|
||||
opcode = jumpIfFalse ? IFGT : IFLE;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("don't know how to generate this condjump");
|
||||
throw new UnsupportedOperationException("Don't know how to generate this condJump: " + opToken);
|
||||
}
|
||||
if (operandType == Type.FLOAT_TYPE || operandType == Type.DOUBLE_TYPE) {
|
||||
if (opToken == JetTokens.GT || opToken == JetTokens.GTEQ) {
|
||||
@@ -692,7 +703,7 @@ public abstract class StackValue {
|
||||
v.store(firstParamIndex, type);
|
||||
}
|
||||
|
||||
ReceiverValue receiverParameter = resolvedGetCall.getReceiverArgument();
|
||||
ReceiverValue receiverParameter = resolvedGetCall.getExtensionReceiver();
|
||||
int receiverIndex = -1;
|
||||
if (receiverParameter.exists()) {
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
@@ -700,9 +711,9 @@ public abstract class StackValue {
|
||||
v.store(receiverIndex, type);
|
||||
}
|
||||
|
||||
ReceiverValue thisObject = resolvedGetCall.getThisObject();
|
||||
ReceiverValue dispatchReceiver = resolvedGetCall.getDispatchReceiver();
|
||||
int thisIndex = -1;
|
||||
if (thisObject.exists()) {
|
||||
if (dispatchReceiver.exists()) {
|
||||
thisIndex = frame.enterTemp(OBJECT_TYPE);
|
||||
v.store(thisIndex, OBJECT_TYPE);
|
||||
}
|
||||
@@ -723,14 +734,14 @@ public abstract class StackValue {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (resolvedSetCall.getThisObject().exists()) {
|
||||
if (resolvedSetCall.getReceiverArgument().exists()) {
|
||||
codegen.generateReceiverValue(resolvedSetCall.getThisObject(), OBJECT_TYPE);
|
||||
if (resolvedSetCall.getDispatchReceiver().exists()) {
|
||||
if (resolvedSetCall.getExtensionReceiver().exists()) {
|
||||
codegen.generateReceiverValue(resolvedSetCall.getDispatchReceiver(), OBJECT_TYPE);
|
||||
}
|
||||
v.load(realReceiverIndex, realReceiverType);
|
||||
}
|
||||
else {
|
||||
if (resolvedSetCall.getReceiverArgument().exists()) {
|
||||
if (resolvedSetCall.getExtensionReceiver().exists()) {
|
||||
v.load(realReceiverIndex, realReceiverType);
|
||||
}
|
||||
else {
|
||||
@@ -780,13 +791,13 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
|
||||
if (call.getThisObject().exists()) {
|
||||
if (call.getReceiverArgument().exists()) {
|
||||
if (call.getDispatchReceiver().exists()) {
|
||||
if (call.getExtensionReceiver().exists()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType())
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getExtensionReceiverParameter().getType())
|
||||
.getSize() != 1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1107,14 +1118,14 @@ public abstract class StackValue {
|
||||
) {
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
|
||||
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
|
||||
|
||||
if (receiverParameter != null) {
|
||||
return callableMethod != null ? callableMethod.getReceiverClass() : typeMapper.mapType(receiverParameter.getType());
|
||||
if (extensionReceiver != null) {
|
||||
return callableMethod != null ? callableMethod.getReceiverClass() : typeMapper.mapType(extensionReceiver.getType());
|
||||
}
|
||||
else if (expectedThisObject != null) {
|
||||
return callableMethod != null ? callableMethod.getThisType() : typeMapper.mapType(expectedThisObject.getType());
|
||||
else if (dispatchReceiver != null) {
|
||||
return callableMethod != null ? callableMethod.getThisType() : typeMapper.mapType(dispatchReceiver.getType());
|
||||
}
|
||||
else if (isLocalFunCall(callableMethod)) {
|
||||
return callableMethod.getGenerateCalleeType();
|
||||
@@ -1127,28 +1138,28 @@ public abstract class StackValue {
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
ReceiverValue thisObject = resolvedCall.getThisObject();
|
||||
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
|
||||
ReceiverValue dispatchReceiver = resolvedCall.getDispatchReceiver();
|
||||
ReceiverValue extensionReceiver = resolvedCall.getExtensionReceiver();
|
||||
int depth = 0;
|
||||
if (thisObject.exists()) {
|
||||
if (dispatchReceiver.exists()) {
|
||||
if (!AnnotationsPackage.isPlatformStaticInObject(descriptor)) {
|
||||
if (receiverArgument.exists()) {
|
||||
if (extensionReceiver.exists()) {
|
||||
//noinspection ConstantConditions
|
||||
Type resultType =
|
||||
callableMethod != null ?
|
||||
callableMethod.getOwner() :
|
||||
codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType());
|
||||
codegen.typeMapper.mapType(descriptor.getDispatchReceiverParameter().getType());
|
||||
|
||||
codegen.generateReceiverValue(thisObject, resultType);
|
||||
codegen.generateReceiverValue(dispatchReceiver, resultType);
|
||||
}
|
||||
else {
|
||||
genReceiver(v, thisObject, type, null, 0);
|
||||
genReceiver(v, dispatchReceiver, type, null, 0);
|
||||
}
|
||||
depth = 1;
|
||||
}
|
||||
}
|
||||
else if (isLocalFunCall(callableMethod)) {
|
||||
assert receiver == none() || receiverArgument.exists() :
|
||||
assert receiver == none() || extensionReceiver.exists() :
|
||||
"Receiver should be present only for local extension function: " + callableMethod;
|
||||
StackValue value = codegen.findLocalOrCapturedValue(descriptor.getOriginal());
|
||||
assert value != null : "Local fun should be found in locals or in captured params: " + resolvedCall;
|
||||
@@ -1157,8 +1168,8 @@ public abstract class StackValue {
|
||||
depth = 1;
|
||||
}
|
||||
|
||||
if (putReceiverArgumentOnStack && receiverArgument.exists()) {
|
||||
genReceiver(v, receiverArgument, type, descriptor.getReceiverParameter(), depth);
|
||||
if (putReceiverArgumentOnStack && extensionReceiver.exists()) {
|
||||
genReceiver(v, extensionReceiver, type, descriptor.getExtensionReceiverParameter(), depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TailRecursionCodegen {
|
||||
}
|
||||
assignParameterValues(fd, callable, arguments);
|
||||
if (callable.getReceiverClass() != null) {
|
||||
if (resolvedCall.getReceiverArgument() != fd.getReceiverParameter().getValue()) {
|
||||
if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) {
|
||||
StackValue expression = context.getReceiverExpression(codegen.typeMapper);
|
||||
expression.store(callable.getReceiverClass(), v);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,12 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
assert descriptor != null :
|
||||
String.format("No descriptor for enum entry \n---\n%s\n---\n", JetPsiUtil.getElementTextWithContext(enumEntry));
|
||||
|
||||
if (!enumEntry.getDeclarations().isEmpty()) {
|
||||
if (enumEntry.getDeclarations().isEmpty()) {
|
||||
for (JetDelegationSpecifier specifier : enumEntry.getDelegationSpecifiers()) {
|
||||
specifier.accept(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
bindingTrace.record(ENUM_ENTRY_CLASS_NEED_SUBCLASS, descriptor);
|
||||
super.visitEnumEntry(enumEntry);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
private final ResolvedCall<ConstructorDescriptor> superCall;
|
||||
|
||||
private final ClassDescriptor enclosingClass;
|
||||
private final CallableDescriptor enclosingReceiverDescriptor;
|
||||
private final CallableDescriptor enclosingFunWithReceiverDescriptor;
|
||||
|
||||
private boolean captureThis;
|
||||
private boolean captureReceiver;
|
||||
@@ -48,7 +48,7 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
) {
|
||||
this.enclosingClass = enclosingClass;
|
||||
this.superCall = superCall;
|
||||
this.enclosingReceiverDescriptor = enclosingExtensionMemberForClass(classDescriptor);
|
||||
this.enclosingFunWithReceiverDescriptor = enclosingExtensionMemberForClass(classDescriptor);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -56,7 +56,7 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
DeclarationDescriptor classContainer = classDescriptor.getContainingDeclaration();
|
||||
if (classContainer instanceof CallableMemberDescriptor) {
|
||||
CallableMemberDescriptor member = getDirectMember((CallableMemberDescriptor) classContainer);
|
||||
if (member.getReceiverParameter() != null) {
|
||||
if (member.getExtensionReceiverParameter() != null) {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
@@ -85,9 +85,8 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
@Override
|
||||
public JetType getCaptureReceiverType() {
|
||||
if (captureReceiver) {
|
||||
//noinspection ConstantConditions
|
||||
ReceiverParameterDescriptor parameter = enclosingReceiverDescriptor.getReceiverParameter();
|
||||
assert parameter != null : "Receiver parameter should exist in " + enclosingReceiverDescriptor;
|
||||
ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor();
|
||||
assert parameter != null : "Receiver parameter should exist in " + enclosingFunWithReceiverDescriptor;
|
||||
return parameter.getType();
|
||||
}
|
||||
|
||||
@@ -95,8 +94,8 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
}
|
||||
|
||||
public void setCaptureReceiver() {
|
||||
if (enclosingReceiverDescriptor == null) {
|
||||
throw new IllegalStateException();
|
||||
if (enclosingFunWithReceiverDescriptor == null) {
|
||||
throw new IllegalStateException("Extension receiver parameter should exist");
|
||||
}
|
||||
this.captureReceiver = true;
|
||||
}
|
||||
@@ -122,12 +121,13 @@ public final class MutableClosure implements CalculatedClosure {
|
||||
|
||||
public void captureVariable(EnclosedValueDescriptor value) {
|
||||
if (captureVariables == null) {
|
||||
captureVariables = new HashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
|
||||
captureVariables = new LinkedHashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
|
||||
}
|
||||
captureVariables.put(value.getDescriptor(), value);
|
||||
}
|
||||
|
||||
public CallableDescriptor getEnclosingReceiverDescriptor() {
|
||||
return enclosingReceiverDescriptor;
|
||||
@Nullable
|
||||
public ReceiverParameterDescriptor getEnclosingReceiverDescriptor() {
|
||||
return enclosingFunWithReceiverDescriptor != null ? enclosingFunWithReceiverDescriptor.getExtensionReceiverParameter() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.storage.NullableLazyValue;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.CAPTURED_THIS_FIELD;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.getVisibilityAccessFlag;
|
||||
@@ -109,7 +106,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
public final CallableDescriptor getCallableDescriptorWithReceiver() {
|
||||
if (contextDescriptor instanceof CallableDescriptor) {
|
||||
CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
|
||||
return callableDescriptor.getReceiverParameter() != null ? callableDescriptor : null;
|
||||
return callableDescriptor.getExtensionReceiverParameter() != null ? callableDescriptor : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -160,8 +157,8 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassContext intoAnonymousClass(@NotNull ClassDescriptor descriptor, @NotNull ExpressionCodegen codegen) {
|
||||
return new AnonymousClassContext(codegen.getState().getTypeMapper(), descriptor, OwnerKind.IMPLEMENTATION, this, codegen);
|
||||
public ClassContext intoAnonymousClass(@NotNull ClassDescriptor descriptor, @NotNull ExpressionCodegen codegen, @NotNull OwnerKind ownerKind) {
|
||||
return new AnonymousClassContext(codegen.getState().getTypeMapper(), descriptor, ownerKind, this, codegen);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -231,7 +228,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
@NotNull
|
||||
public DeclarationDescriptor getAccessor(@NotNull DeclarationDescriptor descriptor, boolean isForBackingFieldInOuterClass, @Nullable JetType delegateType) {
|
||||
if (accessors == null) {
|
||||
accessors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>();
|
||||
accessors = new LinkedHashMap<DeclarationDescriptor, DeclarationDescriptor>();
|
||||
}
|
||||
descriptor = descriptor.getOriginal();
|
||||
DeclarationDescriptor accessor = accessors.get(descriptor);
|
||||
|
||||
@@ -112,7 +112,7 @@ public interface LocalLookup {
|
||||
RECEIVER {
|
||||
@Override
|
||||
public boolean isCase(DeclarationDescriptor d) {
|
||||
return d instanceof CallableDescriptor;
|
||||
return d instanceof ReceiverParameterDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,9 +123,11 @@ public interface LocalLookup {
|
||||
MutableClosure closure,
|
||||
Type classType
|
||||
) {
|
||||
if (closure.getEnclosingReceiverDescriptor() != d) return null;
|
||||
if (closure.getEnclosingReceiverDescriptor() != d) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
|
||||
JetType receiverType = closure.getEnclosingReceiverDescriptor().getType();
|
||||
Type type = state.getTypeMapper().mapType(receiverType);
|
||||
StackValue innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false);
|
||||
closure.setCaptureReceiver();
|
||||
@@ -137,7 +139,7 @@ public interface LocalLookup {
|
||||
@Override
|
||||
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
|
||||
CallableDescriptor descriptor = (CallableDescriptor) d.getDescriptor();
|
||||
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
|
||||
return StackValue.local(descriptor.getDispatchReceiverParameter() != null ? 1 : 0, d.getType());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -25,14 +25,13 @@ import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
|
||||
public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
private final boolean isInliningLambda;
|
||||
private Label methodStartLabel;
|
||||
@@ -59,7 +58,7 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
public StackValue getReceiverExpression(JetTypeMapper typeMapper) {
|
||||
assert getCallableDescriptorWithReceiver() != null;
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getReceiverParameter().getType());
|
||||
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getExtensionReceiverParameter().getType());
|
||||
return StackValue.local(AsmUtil.getReceiverIndex(this, getContextDescriptor()), asmType);
|
||||
}
|
||||
|
||||
@@ -72,6 +71,15 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
return getParentContext().lookupInContext(d, result, state, ignoreNoOuter);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StackValue generateReceiver(@NotNull CallableDescriptor descriptor, @NotNull GenerationState state, boolean ignoreNoOuter) {
|
||||
if (getCallableDescriptorWithReceiver() == descriptor) {
|
||||
return getReceiverExpression(state.getTypeMapper());
|
||||
}
|
||||
ReceiverParameterDescriptor parameter = descriptor.getExtensionReceiverParameter();
|
||||
return lookupInContext(parameter, StackValue.local(0, OBJECT_TYPE), state, ignoreNoOuter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return getParentContext().isStatic();
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.codegen.inline
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.LabelNode
|
||||
import com.google.common.collect.LinkedListMultimap
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import java.util.ArrayList
|
||||
import com.intellij.util.containers.Stack
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import com.google.common.collect.Lists
|
||||
import org.jetbrains.org.objectweb.asm.tree.TryCatchBlockNode
|
||||
import java.util.Comparator
|
||||
import java.util.Collections
|
||||
|
||||
public abstract class CoveringTryCatchNodeProcessor<T: IntervalWithHandler>() {
|
||||
|
||||
private val tryBlockStarts = LinkedListMultimap.create<LabelNode, T>()
|
||||
|
||||
private val tryBlockEnds = LinkedListMultimap.create<LabelNode, T>()
|
||||
|
||||
public val allTryCatchNodes: ArrayList<T> = arrayListOf()
|
||||
|
||||
private val currentCoveringBlocks: Stack<T> = Stack()
|
||||
|
||||
public val coveringFromInnermost: List<T>
|
||||
get() = currentCoveringBlocks.reverse()
|
||||
|
||||
fun addNewTryCatchNode(newInfo: T) {
|
||||
tryBlockStarts.put(newInfo.startLabel, newInfo)
|
||||
tryBlockEnds.put(newInfo.endLabel, newInfo)
|
||||
allTryCatchNodes.add(newInfo)
|
||||
}
|
||||
|
||||
fun remapStartLabel(oldStart: LabelNode, remapped: T) {
|
||||
tryBlockStarts.remove(oldStart, remapped)
|
||||
tryBlockStarts.put(remapped.startLabel, remapped)
|
||||
}
|
||||
|
||||
public fun getStartNodes(label: LabelNode): List<T> {
|
||||
return tryBlockStarts.get(label)
|
||||
}
|
||||
|
||||
public fun getEndNodes(label: LabelNode): List<T> {
|
||||
return tryBlockEnds.get(label)
|
||||
}
|
||||
|
||||
//Keep information about try blocks that cover current instruction -
|
||||
// pushing and popping it to stack entering and exiting tryCatchBlock start and end labels
|
||||
public open fun updateCoveringTryBlocks(curIns: AbstractInsnNode, directOrder: Boolean) {
|
||||
if (curIns !is LabelNode) return
|
||||
|
||||
val infosToClose = if (!directOrder) getStartNodes(curIns) else getEndNodes(curIns)
|
||||
for (startNode in infosToClose) {
|
||||
val pop = currentCoveringBlocks.pop()
|
||||
//Temporary disabled cause during patched structure of exceptions changed
|
||||
// if (startNode != pop) {
|
||||
// throw RuntimeException("Wrong try-catch structure " + startNode + " " + pop + " " + infosToClose.size())
|
||||
// };
|
||||
}
|
||||
|
||||
//Reversing list order cause we should pop external block before internal one
|
||||
// (originally internal blocks goes before external one, such invariant preserved via sortTryCatchBlocks method)
|
||||
val infoToOpen = if (!directOrder) getEndNodes(curIns) else getStartNodes(curIns)
|
||||
for (info in infoToOpen.reverse()) {
|
||||
currentCoveringBlocks.add(info)
|
||||
}
|
||||
}
|
||||
|
||||
public abstract fun instructionIndex(inst: AbstractInsnNode): Int
|
||||
|
||||
private fun isEmptyInterval(node: T): Boolean {
|
||||
val start = node.startLabel
|
||||
var end: AbstractInsnNode = node.endLabel
|
||||
while (end != start && end is LabelNode) {
|
||||
end = end.getPrevious()
|
||||
}
|
||||
return start == end;
|
||||
}
|
||||
|
||||
public fun getNonEmptyNodes(): List<T> {
|
||||
return allTryCatchNodes.filterNot { isEmptyInterval(it) }
|
||||
}
|
||||
|
||||
public fun sortTryCatchBlocks() {
|
||||
val comp = Comparator {(t1: T, t2: T): Int ->
|
||||
var result = instructionIndex(t1.handler) - instructionIndex(t2.handler)
|
||||
if (result == 0) {
|
||||
result = instructionIndex(t1.startLabel) - instructionIndex(t2.startLabel)
|
||||
if (result == 0) {
|
||||
assert(false, "Error: support multicatch finallies!")
|
||||
result = instructionIndex(t1.endLabel) - instructionIndex(t2.endLabel)
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
Collections.sort<T>(allTryCatchNodes, comp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class DefaultProcessor(val node: MethodNode) : CoveringTryCatchNodeProcessor<TryCatchBlockNodeWrapper>() {
|
||||
|
||||
{
|
||||
node.tryCatchBlocks.forEach { addNode(it) }
|
||||
}
|
||||
|
||||
fun addNode(node: TryCatchBlockNode) {
|
||||
addNewTryCatchNode(TryCatchBlockNodeWrapper(node))
|
||||
}
|
||||
|
||||
override fun instructionIndex(inst: AbstractInsnNode): Int {
|
||||
return node.instructions.indexOf(inst)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TryCatchBlockNodeWrapper(val node: TryCatchBlockNode) : IntervalWithHandler {
|
||||
override val startLabel: LabelNode
|
||||
get() = node.start
|
||||
override val endLabel: LabelNode
|
||||
get() = node.end
|
||||
override val handler: LabelNode
|
||||
get() = node.handler
|
||||
override val type: String?
|
||||
get() = node.type
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen.inline;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
@@ -31,7 +32,6 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedSimpl
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
@@ -42,25 +42,26 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.types.lang.InlineStrategy;
|
||||
import org.jetbrains.jet.lang.types.lang.InlineUtil;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
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.commons.Method;
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.LabelNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.TryCatchBlockNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.getMethodAsmFlags;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.isPrimitive;
|
||||
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.addInlineMarker;
|
||||
|
||||
public class InlineCodegen implements CallGenerator {
|
||||
private final GenerationState state;
|
||||
private final JetTypeMapper typeMapper;
|
||||
private final BindingContext bindingContext;
|
||||
|
||||
private final SimpleFunctionDescriptor functionDescriptor;
|
||||
private final JvmMethodSignature jvmSignature;
|
||||
@@ -90,7 +91,6 @@ public class InlineCodegen implements CallGenerator {
|
||||
this.codegen = codegen;
|
||||
this.callElement = callElement;
|
||||
this.functionDescriptor = functionDescriptor.getOriginal();
|
||||
bindingContext = codegen.getBindingContext();
|
||||
initialFrameSize = codegen.getFrameMap().getCurrentSize();
|
||||
|
||||
context = (MethodContext) getContext(functionDescriptor, state);
|
||||
@@ -241,7 +241,7 @@ public class InlineCodegen implements CallGenerator {
|
||||
}
|
||||
}
|
||||
};
|
||||
List<MethodInliner.ExternalFinallyBlockInfo> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
|
||||
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
|
||||
generateAndInsertFinallyBlocks(adapter, infos);
|
||||
|
||||
adapter.accept(new InliningInstructionAdapter(codegen.v));
|
||||
@@ -418,7 +418,7 @@ public class InlineCodegen implements CallGenerator {
|
||||
private void putClosureParametersOnStack() {
|
||||
for (LambdaInfo next : expressionMap.values()) {
|
||||
activeLambda = next;
|
||||
codegen.pushClosureOnStack(next.closure, false, this);
|
||||
codegen.pushClosureOnStack(next.getClassDescriptor(), true, this);
|
||||
}
|
||||
activeLambda = null;
|
||||
}
|
||||
@@ -483,19 +483,62 @@ public class InlineCodegen implements CallGenerator {
|
||||
}
|
||||
|
||||
|
||||
public void generateAndInsertFinallyBlocks(MethodNode intoNode, List<MethodInliner.ExternalFinallyBlockInfo> insertPoints) {
|
||||
public void generateAndInsertFinallyBlocks(MethodNode intoNode, List<MethodInliner.PointForExternalFinallyBlocks> insertPoints) {
|
||||
if (!codegen.hasFinallyBlocks()) return;
|
||||
|
||||
for (MethodInliner.ExternalFinallyBlockInfo insertPoint : insertPoints) {
|
||||
MethodNode finallyNode = InlineCodegenUtil.createEmptyMethodNode();
|
||||
ExpressionCodegen finallyCodegen =
|
||||
new ExpressionCodegen(finallyNode, codegen.getFrameMap(), codegen.getReturnType(),
|
||||
codegen.getContext(), codegen.getState(), codegen.getParentCodegen());
|
||||
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.getBlockStackElements());
|
||||
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints =
|
||||
new HashMap<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks>();
|
||||
for (MethodInliner.PointForExternalFinallyBlocks insertPoint : insertPoints) {
|
||||
extensionPoints.put(insertPoint.beforeIns, insertPoint);
|
||||
}
|
||||
|
||||
finallyCodegen.generateFinallyBlocksIfNeeded(insertPoint.returnType);
|
||||
DefaultProcessor processor = new DefaultProcessor(intoNode);
|
||||
|
||||
InlineCodegenUtil.insertNodeBefore(finallyNode, intoNode, insertPoint.beforeIns);
|
||||
AbstractInsnNode curInstr = intoNode.instructions.getFirst();
|
||||
while (curInstr != null) {
|
||||
processor.updateCoveringTryBlocks(curInstr, true);
|
||||
|
||||
MethodInliner.PointForExternalFinallyBlocks extension = extensionPoints.get(curInstr);
|
||||
if (extension != null) {
|
||||
Label start = new Label();
|
||||
Label end = new Label();
|
||||
|
||||
MethodNode finallyNode = InlineCodegenUtil.createEmptyMethodNode();
|
||||
finallyNode.visitLabel(start);
|
||||
|
||||
ExpressionCodegen finallyCodegen =
|
||||
new ExpressionCodegen(finallyNode, codegen.getFrameMap(), codegen.getReturnType(),
|
||||
codegen.getContext(), codegen.getState(), codegen.getParentCodegen());
|
||||
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.getBlockStackElements());
|
||||
|
||||
finallyCodegen.generateFinallyBlocksIfNeeded(extension.returnType);
|
||||
finallyNode.visitLabel(end);
|
||||
|
||||
//Exception table for external try/catch/finally blocks will be generated in original codegen after exiting this method
|
||||
InlineCodegenUtil.insertNodeBefore(finallyNode, intoNode, curInstr);
|
||||
|
||||
List<TryCatchBlockNodeWrapper> blocks = processor.getCoveringFromInnermost();
|
||||
ListIterator<TryCatchBlockNodeWrapper> iterator = blocks.listIterator(blocks.size());
|
||||
while (iterator.hasPrevious()) {
|
||||
TryCatchBlockNodeWrapper previous = iterator.previous();
|
||||
LabelNode oldStart = previous.getStartLabel();
|
||||
TryCatchBlockNode node = previous.getNode();
|
||||
node.start = (LabelNode) end.info;
|
||||
processor.remapStartLabel(oldStart, previous);
|
||||
|
||||
TryCatchBlockNode additionalNode = new TryCatchBlockNode(oldStart, (LabelNode) start.info, node.handler, node.type);
|
||||
processor.addNode(additionalNode);
|
||||
}
|
||||
}
|
||||
|
||||
curInstr = curInstr.getNext();
|
||||
}
|
||||
|
||||
processor.sortTryCatchBlocks();
|
||||
Iterable<TryCatchBlockNodeWrapper> nodes = processor.getNonEmptyNodes();
|
||||
intoNode.tryCatchBlocks.clear();
|
||||
for (TryCatchBlockNodeWrapper node : nodes) {
|
||||
intoNode.tryCatchBlocks.add(node.getNode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,21 +17,25 @@
|
||||
package org.jetbrains.jet.codegen.inline;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.codegen.AsmUtil;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.tree.*;
|
||||
import org.jetbrains.org.objectweb.asm.util.Textifier;
|
||||
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.*;
|
||||
|
||||
public class InternalFinallyBlockInliner {
|
||||
public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor<TryCatchBlockNodeInfo> {
|
||||
|
||||
private static class FinallyBlockInfo {
|
||||
|
||||
@@ -43,6 +47,18 @@ public class InternalFinallyBlockInliner {
|
||||
startIns = inclusiveStart;
|
||||
endInsExclusive = exclusiveEnd;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
if (!(startIns instanceof LabelNode)) {
|
||||
return false;
|
||||
|
||||
}
|
||||
AbstractInsnNode end = endInsExclusive;
|
||||
while (end != startIns && end instanceof LabelNode) {
|
||||
end = end.getPrevious();
|
||||
}
|
||||
return startIns == end;
|
||||
}
|
||||
}
|
||||
|
||||
public static void processInlineFunFinallyBlocks(@NotNull MethodNode inlineFun, int lambdaTryCatchBlockNodes) {
|
||||
@@ -60,22 +76,18 @@ public class InternalFinallyBlockInliner {
|
||||
@NotNull
|
||||
private final MethodNode inlineFun;
|
||||
|
||||
private final List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo;
|
||||
|
||||
private final ListMultimap<LabelNode, TryCatchBlockNodeInfo> tryBlockStarts = LinkedListMultimap.create();
|
||||
|
||||
private final ListMultimap<LabelNode, TryCatchBlockNodeInfo> tryBlockEnds = LinkedListMultimap.create();
|
||||
|
||||
//lambdaTryCatchBlockNodes is number of TryCatchBlockNodes that was inlined with lambdas into function
|
||||
//due to code generation specific they placed before function TryCatchBlockNodes
|
||||
private InternalFinallyBlockInliner(@NotNull MethodNode inlineFun, List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
|
||||
this.inlineFun = inlineFun;
|
||||
this.inlineFunTryBlockInfo = inlineFunTryBlockInfo;
|
||||
for (TryCatchBlockNodeInfo block : inlineFunTryBlockInfo) {
|
||||
addNewTryCatchNode(block);
|
||||
}
|
||||
}
|
||||
|
||||
private int initAndGetVarIndexForNonLocalReturnValue() {
|
||||
//sortTryCatchBlocks();/*TODO maybe remove*/
|
||||
mapLabelsToTryCatchBlocks();
|
||||
|
||||
MaxLocalsCalculator tempCalcNode = new MaxLocalsCalculator(
|
||||
InlineCodegenUtil.API,
|
||||
@@ -88,7 +100,6 @@ public class InternalFinallyBlockInliner {
|
||||
private void processInlineFunFinallyBlocks() {
|
||||
int nextTempNonLocalVarIndex = initAndGetVarIndexForNonLocalReturnValue();
|
||||
|
||||
Stack<TryCatchBlockNodeInfo> coveringTryCatchBlocks = new Stack<TryCatchBlockNodeInfo>();
|
||||
InsnList instructions = inlineFun.instructions;
|
||||
|
||||
//As we do finally block code search after non-local return instruction
|
||||
@@ -96,10 +107,19 @@ public class InternalFinallyBlockInliner {
|
||||
// So we do instruction processing in reverse order!
|
||||
AbstractInsnNode curIns = instructions.getLast();
|
||||
while (curIns != null) {
|
||||
updateCoveringTryBlocks(coveringTryCatchBlocks, curIns);
|
||||
updateCoveringTryBlocks(curIns);
|
||||
|
||||
//At this point only global return is possible, local one already substituted with: goto endLabel
|
||||
if (!InlineCodegenUtil.isReturnOpcode(curIns.getOpcode()) || !InlineCodegenUtil.isMarkedReturn(curIns)) {
|
||||
if (!InlineCodegenUtil.isReturnOpcode(curIns.getOpcode()) ||
|
||||
!InlineCodegenUtil.isMarkedReturn(curIns)) {
|
||||
curIns = curIns.getPrevious();
|
||||
continue;
|
||||
}
|
||||
|
||||
List<TryCatchBlockNodeInfo> currentCoveringNodes = getCoveringFromInnermost();
|
||||
checkCoveringBlocksInvariant(currentCoveringNodes);
|
||||
if (currentCoveringNodes.isEmpty() ||
|
||||
currentCoveringNodes.get(currentCoveringNodes.size() - 1).getOnlyCopyNotProcess()) {
|
||||
curIns = curIns.getPrevious();
|
||||
continue;
|
||||
}
|
||||
@@ -113,69 +133,59 @@ public class InternalFinallyBlockInliner {
|
||||
// Each group that corresponds to try/*catches*/finally contains tryCatch block with default handler.
|
||||
// For each such group we should insert corresponding finally before non-local return.
|
||||
// So we split all try blocks on current instructions to groups and process them independently
|
||||
List<TryBlockCluster<TryCatchBlockNodeInfo>> clusters = InlinePackage.doClustering(coveringTryCatchBlocks);
|
||||
ListIterator<TryBlockCluster<TryCatchBlockNodeInfo>> tryCatchBlockIterator = clusters.listIterator(clusters.size());
|
||||
//Reverse visiting cause innermost tryCatchBlocks in the end
|
||||
while (tryCatchBlockIterator.hasPrevious()) {
|
||||
TryBlockCluster originalFinallyCluster = tryCatchBlockIterator.previous();
|
||||
List<TryCatchBlockNodeInfo> clusterBlocks = originalFinallyCluster.getBlocks();
|
||||
TryCatchBlockNodeInfo originalFinallyBlock = clusterBlocks.get(0);
|
||||
List<TryBlockCluster<TryCatchBlockNodeInfo>> clustersFromInnermost = InlinePackage.doClustering(currentCoveringNodes);
|
||||
Iterator<TryBlockCluster<TryCatchBlockNodeInfo>> tryCatchBlockIterator = clustersFromInnermost.iterator();
|
||||
|
||||
FinallyBlockInfo finallyInfo = findFinallyBlockBody(originalFinallyBlock, inlineFunTryBlockInfo);
|
||||
checkClusterInvariant(clustersFromInnermost);
|
||||
|
||||
List<TryCatchBlockNodeInfo> additionalNodesToSplit = new ArrayList<TryCatchBlockNodeInfo>();
|
||||
while (tryCatchBlockIterator.hasNext()) {
|
||||
TryBlockCluster clusterToFindFinally = tryCatchBlockIterator.next();
|
||||
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();
|
||||
TryCatchBlockNodeInfo nodeWithDefaultHandlerIfExists = clusterBlocks.get(clusterBlocks.size() - 1);
|
||||
|
||||
FinallyBlockInfo finallyInfo = findFinallyBlockBody(nodeWithDefaultHandlerIfExists, getAllTryCatchNodes());
|
||||
if (finallyInfo == null) continue;
|
||||
|
||||
if (nodeWithDefaultHandlerIfExists.getOnlyCopyNotProcess()) {
|
||||
additionalNodesToSplit.addAll(clusterBlocks);
|
||||
continue;
|
||||
}
|
||||
|
||||
instructions.resetLabels();
|
||||
|
||||
List<TryCatchBlockNodePosition> tryCatchBlockInlinedInFinally = findTryCatchBlocksInlinedInFinally(finallyInfo);
|
||||
|
||||
//Keep some information about label nodes, we need it to understand whether it's jump inside finally block or outside
|
||||
// in first case we do call VISIT on instruction otherwise recreating jump instruction (see below)
|
||||
Set<LabelNode> labelsInsideFinally = rememberOriginalLabelNodes(finallyInfo);
|
||||
|
||||
//Creating temp node for finally block copy with some additional instruction
|
||||
MethodNode finallyBlockCopy = createEmptyMethodNode();
|
||||
Label newFinallyStart = new Label();
|
||||
Label newFinallyEnd = new Label();
|
||||
Label insertedBlockEnd = new Label();
|
||||
|
||||
if (nonLocalReturnType != Type.VOID_TYPE) {
|
||||
boolean generateAloadAstore = nonLocalReturnType != Type.VOID_TYPE && !finallyInfo.isEmpty();
|
||||
if (generateAloadAstore) {
|
||||
finallyBlockCopy.visitVarInsn(nonLocalReturnType.getOpcode(Opcodes.ISTORE), nextTempNonLocalVarIndex);
|
||||
}
|
||||
finallyBlockCopy.visitLabel(newFinallyStart);
|
||||
|
||||
//Keep some information about label nodes, we need it to understand whether it's jump inside finally block or outside
|
||||
// in first case we do call VISIT on instruction otherwise recreating jump instruction (see below)
|
||||
Set<LabelNode> labelsInsideFinally = rememberOriginalLabelNodes(finallyInfo);
|
||||
//Writing finally block body to temporary node
|
||||
AbstractInsnNode currentIns = finallyInfo.startIns;
|
||||
while (currentIns != finallyInfo.endInsExclusive) {
|
||||
//This condition allows another model for non-local returns processing
|
||||
if (false && InlineCodegenUtil.isReturnOpcode(currentIns.getOpcode()) && !InlineCodegenUtil.isMarkedReturn(currentIns)) {
|
||||
//substitute all local returns in finally finallyInfo with non-local one lambdaFinallyBlocks try finallyInfo
|
||||
//TODO same for jumps
|
||||
Type localReturnType = InlineCodegenUtil.getReturnType(currentIns.getOpcode());
|
||||
substituteReturnValueInFinally(nextTempNonLocalVarIndex, nonLocalReturnType, finallyBlockCopy,
|
||||
localReturnType, true);
|
||||
boolean isInsOrJumpInsideFinally =
|
||||
!(currentIns instanceof JumpInsnNode) ||
|
||||
labelsInsideFinally.contains(((JumpInsnNode) currentIns).label);
|
||||
|
||||
instrInsertFinallyBefore.accept(finallyBlockCopy);
|
||||
curIns.accept(finallyBlockCopy);
|
||||
}
|
||||
else {
|
||||
boolean isInsOrJumpInsideFinally =
|
||||
!(currentIns instanceof JumpInsnNode) ||
|
||||
labelsInsideFinally.contains(((JumpInsnNode) currentIns).label);
|
||||
|
||||
if (isInsOrJumpInsideFinally) {
|
||||
currentIns.accept(finallyBlockCopy); //VISIT
|
||||
}
|
||||
else {
|
||||
//keep original jump: add currentIns clone
|
||||
finallyBlockCopy.instructions.add(new JumpInsnNode(currentIns.getOpcode(), ((JumpInsnNode) currentIns).label));
|
||||
}
|
||||
}
|
||||
copyInstruction(nextTempNonLocalVarIndex, curIns, instrInsertFinallyBefore, nonLocalReturnType, finallyBlockCopy,
|
||||
currentIns, isInsOrJumpInsideFinally);
|
||||
|
||||
currentIns = currentIns.getNext();
|
||||
}
|
||||
|
||||
finallyBlockCopy.visitLabel(newFinallyEnd);
|
||||
if (nonLocalReturnType != Type.VOID_TYPE) {
|
||||
if (generateAloadAstore) {
|
||||
finallyBlockCopy.visitVarInsn(nonLocalReturnType.getOpcode(Opcodes.ILOAD), nextTempNonLocalVarIndex);
|
||||
nextTempNonLocalVarIndex += nonLocalReturnType.getSize(); //TODO: do more wise indexing
|
||||
}
|
||||
@@ -185,15 +195,76 @@ public class InternalFinallyBlockInliner {
|
||||
//Copying finally body before non-local return instruction
|
||||
InlineCodegenUtil.insertNodeBefore(finallyBlockCopy, inlineFun, instrInsertFinallyBefore);
|
||||
|
||||
nextPrev = updateExceptionTable(coveringTryCatchBlocks, nextPrev, clusterBlocks, newFinallyStart, newFinallyEnd,
|
||||
tryCatchBlockInlinedInFinally, labelsInsideFinally, (LabelNode) insertedBlockEnd.info);
|
||||
updateExceptionTable(clusterBlocks, newFinallyStart, newFinallyEnd,
|
||||
tryCatchBlockInlinedInFinally, labelsInsideFinally, (LabelNode) insertedBlockEnd.info, additionalNodesToSplit);
|
||||
}
|
||||
|
||||
//skip just inserted finally
|
||||
curIns = curIns.getPrevious();
|
||||
while (curIns != null && curIns != nextPrev) {
|
||||
updateCoveringTryBlocks(curIns);
|
||||
curIns = curIns.getPrevious();
|
||||
}
|
||||
curIns = nextPrev;
|
||||
}
|
||||
|
||||
inlineFun.tryCatchBlocks.clear();
|
||||
for (TryCatchBlockNodeInfo info : inlineFunTryBlockInfo) {
|
||||
inlineFun.tryCatchBlocks.add(info.getNode());
|
||||
substituteTryBlockNodes();
|
||||
}
|
||||
|
||||
private static void copyInstruction(
|
||||
int nextTempNonLocalVarIndex,
|
||||
@NotNull AbstractInsnNode curIns,
|
||||
@NotNull AbstractInsnNode instrInsertFinallyBefore,
|
||||
@NotNull Type nonLocalReturnType,
|
||||
@NotNull MethodNode finallyBlockCopy,
|
||||
@NotNull AbstractInsnNode currentIns,
|
||||
boolean isInsOrJumpInsideFinally
|
||||
) {
|
||||
//This condition allows another model for non-local returns processing
|
||||
if (false) {
|
||||
boolean isReturnForSubstitution =
|
||||
InlineCodegenUtil.isReturnOpcode(currentIns.getOpcode()) && !InlineCodegenUtil.isMarkedReturn(currentIns);
|
||||
if (!isInsOrJumpInsideFinally || isReturnForSubstitution) {
|
||||
//substitute all local returns and jumps outside finally with non-local return
|
||||
Type localReturnType = InlineCodegenUtil.getReturnType(currentIns.getOpcode());
|
||||
substituteReturnValueInFinally(nextTempNonLocalVarIndex, nonLocalReturnType, finallyBlockCopy,
|
||||
localReturnType, isReturnForSubstitution);
|
||||
|
||||
instrInsertFinallyBefore.accept(finallyBlockCopy);
|
||||
curIns.accept(finallyBlockCopy);
|
||||
} else {
|
||||
currentIns.accept(finallyBlockCopy); //VISIT
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isInsOrJumpInsideFinally) {
|
||||
currentIns.accept(finallyBlockCopy); //VISIT
|
||||
}
|
||||
else {
|
||||
//keep original jump: add currentIns clone
|
||||
finallyBlockCopy.instructions.add(new JumpInsnNode(currentIns.getOpcode(), ((JumpInsnNode) currentIns).label));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkCoveringBlocksInvariant(List<TryCatchBlockNodeInfo> coveringTryCatchBlocks) {
|
||||
boolean isWasOnlyLocal = false;
|
||||
for (TryCatchBlockNodeInfo info : Lists.reverse(coveringTryCatchBlocks)) {
|
||||
assert !isWasOnlyLocal || info.getOnlyCopyNotProcess();
|
||||
if (info.getOnlyCopyNotProcess()) {
|
||||
isWasOnlyLocal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkClusterInvariant(List<TryBlockCluster<TryCatchBlockNodeInfo>> clusters) {
|
||||
boolean isWasOnlyLocal;
|
||||
isWasOnlyLocal = false;
|
||||
for (TryBlockCluster<TryCatchBlockNodeInfo> cluster : Lists.reverse(clusters)) {
|
||||
TryCatchBlockNodeInfo info = cluster.getBlocks().get(0);
|
||||
assert !isWasOnlyLocal || info.getOnlyCopyNotProcess();
|
||||
if (info.getOnlyCopyNotProcess()) {
|
||||
isWasOnlyLocal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,17 +279,14 @@ public class InternalFinallyBlockInliner {
|
||||
return labelsInsideFinally;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AbstractInsnNode updateExceptionTable(
|
||||
@NotNull Stack<TryCatchBlockNodeInfo> coveringTryBlocks,
|
||||
@Nullable AbstractInsnNode nextPrev,
|
||||
private void updateExceptionTable(
|
||||
@NotNull List<TryCatchBlockNodeInfo> updatingClusterBlocks,
|
||||
@NotNull Label newFinallyStart,
|
||||
@NotNull Label newFinallyEnd,
|
||||
@NotNull List<TryCatchBlockNodePosition> tryCatchBlockPresentInFinally,
|
||||
@NotNull Set<LabelNode> labelsInsideFinally,
|
||||
@NotNull LabelNode insertedBlockEnd
|
||||
|
||||
@NotNull LabelNode insertedBlockEnd,
|
||||
@NotNull List<TryCatchBlockNodeInfo> patched
|
||||
) {
|
||||
|
||||
//copy tryCatchFinallies that totally in finally block
|
||||
@@ -246,9 +314,7 @@ public class InternalFinallyBlockInliner {
|
||||
assert inlineFun.instructions.indexOf(additionalTryCatchBlock.start) <= inlineFun.instructions.indexOf(additionalTryCatchBlock.end);
|
||||
|
||||
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, true);
|
||||
tryBlockStarts.put(newInfo.getStartLabel(), newInfo);
|
||||
tryBlockEnds.put(newInfo.getEndLabel(), newInfo);
|
||||
inlineFunTryBlockInfo.add(newInfo);
|
||||
addNewTryCatchNode(newInfo);
|
||||
}
|
||||
}
|
||||
else if (clusterPosition == TryCatchPosition.END) {
|
||||
@@ -272,7 +338,7 @@ public class InternalFinallyBlockInliner {
|
||||
|
||||
assert Objects.equal(startNode.getType(), endNode.getType()) : "Different handler types : " + startNode.getType() + " " + endNode.getType();
|
||||
|
||||
patchTryBlocks((LabelNode) startNode.getStartLabel().getLabel().info, endNode, false);
|
||||
patchTryBlocks((LabelNode) startNode.getStartLabel().getLabel().info, endNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,7 +350,7 @@ public class InternalFinallyBlockInliner {
|
||||
//TODO rewrite to clusters
|
||||
for (TryCatchBlockNodePosition endBlockPosition : singleCluster.getBlocks()) {
|
||||
TryCatchBlockNodeInfo endNode = endBlockPosition.getNodeInfo();
|
||||
patchTryBlocks((LabelNode) insertedBlockEnd.getLabel().info, endNode, true);
|
||||
patchTryBlocks((LabelNode) insertedBlockEnd.getLabel().info, endNode);
|
||||
//nextPrev = (AbstractInsnNode) insertedBlockEnd.getLabel().info;
|
||||
}
|
||||
|
||||
@@ -293,38 +359,35 @@ public class InternalFinallyBlockInliner {
|
||||
}
|
||||
assert handler2Cluster.isEmpty() : "Unmatched clusters " + handler2Cluster.size();
|
||||
|
||||
List<TryCatchBlockNodeInfo > toProcess = new ArrayList<TryCatchBlockNodeInfo>();
|
||||
toProcess.addAll(patched);
|
||||
toProcess.addAll(updatingClusterBlocks);
|
||||
patched.clear();
|
||||
// Inserted finally shouldn't be handled by corresponding catches,
|
||||
// so we should split original interval by inserted finally one
|
||||
for (TryCatchBlockNodeInfo block : updatingClusterBlocks) {
|
||||
for (TryCatchBlockNodeInfo block : toProcess) {
|
||||
//update exception mapping
|
||||
LabelNode oldStartNode = block.getNode().start;
|
||||
tryBlockStarts.remove(oldStartNode, block);
|
||||
block.getNode().start = (LabelNode) newFinallyEnd.info;
|
||||
//tryBlockStarts.put(block.getStartLabel(), block);
|
||||
remapStartLabel(oldStartNode, block);
|
||||
|
||||
patched.add(block);
|
||||
|
||||
TryCatchBlockNode additionalTryCatchBlock =
|
||||
new TryCatchBlockNode(oldStartNode, (LabelNode) newFinallyStart.info, block.getNode().handler, block.getNode().type);
|
||||
|
||||
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, false);
|
||||
tryBlockStarts.put(additionalTryCatchBlock.start, newInfo);
|
||||
tryBlockEnds.put(additionalTryCatchBlock.end, newInfo);
|
||||
|
||||
inlineFunTryBlockInfo.add(newInfo);
|
||||
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, block.getOnlyCopyNotProcess());
|
||||
addNewTryCatchNode(newInfo);
|
||||
|
||||
//TODO add assert
|
||||
nextPrev = additionalTryCatchBlock.end;
|
||||
coveringTryBlocks.pop();
|
||||
}
|
||||
sortTryCatchBlocks(inlineFunTryBlockInfo);
|
||||
return nextPrev;
|
||||
sortTryCatchBlocks();
|
||||
}
|
||||
|
||||
private void patchTryBlocks(@NotNull LabelNode newStartLabelNode, @NotNull TryCatchBlockNodeInfo endNode, boolean sort) {
|
||||
private void patchTryBlocks(@NotNull LabelNode newStartLabelNode, @NotNull TryCatchBlockNodeInfo endNode) {
|
||||
LabelNode oldStart = endNode.getStartLabel();
|
||||
endNode.getNode().start = newStartLabelNode;
|
||||
tryBlockStarts.remove(oldStart, endNode);
|
||||
tryBlockStarts.put(endNode.getNode().start, endNode);
|
||||
|
||||
remapStartLabel(oldStart, endNode);
|
||||
|
||||
TryCatchBlockNode endTryBlock = endNode.getNode();
|
||||
TryCatchBlockNode additionalTryCatchBlock =
|
||||
@@ -334,10 +397,7 @@ public class InternalFinallyBlockInliner {
|
||||
endTryBlock.type);
|
||||
|
||||
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, endNode.getOnlyCopyNotProcess());
|
||||
tryBlockStarts.put(newInfo.getStartLabel(), newInfo);
|
||||
tryBlockEnds.put(newInfo.getEndLabel(), newInfo);
|
||||
|
||||
inlineFunTryBlockInfo.add(newInfo);
|
||||
addNewTryCatchNode(newInfo);
|
||||
}
|
||||
|
||||
private static LabelNode getNewOrOldLabel(LabelNode oldHandler, @NotNull Set<LabelNode> labelsInsideFinally) {
|
||||
@@ -350,25 +410,9 @@ public class InternalFinallyBlockInliner {
|
||||
|
||||
//Keep information about try blocks that cover current instruction -
|
||||
// pushing and popping it to stack entering and exiting tryCatchBlock start and end labels
|
||||
private void updateCoveringTryBlocks(Stack<TryCatchBlockNodeInfo> coveringTryBlocks, AbstractInsnNode curIns) {
|
||||
if (!(curIns instanceof LabelNode)) return;
|
||||
|
||||
List<TryCatchBlockNodeInfo> infos = tryBlockStarts.get((LabelNode) curIns);
|
||||
for (TryCatchBlockNodeInfo startNode : infos) {
|
||||
if (!startNode.getOnlyCopyNotProcess()) {
|
||||
TryCatchBlockNodeInfo pop = coveringTryBlocks.pop();
|
||||
//Temporary disabled cause during patched structure of exceptions changed
|
||||
//assert startNode == pop : "Wrong try-catch structure " + startNode + " " + pop + " " + infos.size();
|
||||
}
|
||||
}
|
||||
|
||||
//Reversing list order cause we should pop external block before internal one
|
||||
// (originally internal blocks goes before external one, such invariant preserved via sortTryCatchBlocks method)
|
||||
for (TryCatchBlockNodeInfo info : Lists.reverse(tryBlockEnds.get((LabelNode) curIns))) {
|
||||
if (!info.getOnlyCopyNotProcess()) {
|
||||
coveringTryBlocks.add(info);
|
||||
}
|
||||
}
|
||||
public void updateCoveringTryBlocks(@NotNull AbstractInsnNode curIns) {
|
||||
super.updateCoveringTryBlocks(curIns, false);
|
||||
checkCoveringBlocksInvariant(getCoveringFromInnermost());
|
||||
}
|
||||
|
||||
private static boolean hasFinallyBlocks(List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
|
||||
@@ -380,13 +424,6 @@ public class InternalFinallyBlockInliner {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mapLabelsToTryCatchBlocks() {
|
||||
for (TryCatchBlockNodeInfo block : inlineFunTryBlockInfo) {
|
||||
tryBlockStarts.put(block.getNode().start, block);
|
||||
tryBlockEnds.put(block.getNode().end, block);
|
||||
}
|
||||
}
|
||||
|
||||
//As described above all tryCatch group that have finally block also should contains tryCatchBlockNode with default handler.
|
||||
//So we assume that instructions between end of tryCatchBlock and start of next tryCatchBlock with same default handler is required finally body.
|
||||
//There is at least two tryCatchBlockNodes in list cause there is always tryCatchBlockNode on first instruction of default handler:
|
||||
@@ -396,6 +433,15 @@ public class InternalFinallyBlockInliner {
|
||||
@NotNull TryCatchBlockNodeInfo tryCatchBlock,
|
||||
@NotNull List<TryCatchBlockNodeInfo> tryCatchBlocks
|
||||
) {
|
||||
if (tryCatchBlock.getOnlyCopyNotProcess()) {
|
||||
AbstractInsnNode start = new LabelNode();
|
||||
AbstractInsnNode end = new LabelNode();
|
||||
InsnList insnList = new InsnList();
|
||||
insnList.add(start);
|
||||
insnList.add(end);
|
||||
return new FinallyBlockInfo(start, end);
|
||||
}
|
||||
|
||||
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<TryCatchBlockNodeInfo>();
|
||||
LabelNode defaultHandler = null;
|
||||
boolean afterStartBlock = false;
|
||||
@@ -427,7 +473,13 @@ public class InternalFinallyBlockInliner {
|
||||
AbstractInsnNode endFinallyChainExclusive = skipLastGotoIfNeeded(nextIntervalWithSameDefaultHandler.getNode().handler,
|
||||
nextIntervalWithSameDefaultHandler.getNode().start);
|
||||
|
||||
return new FinallyBlockInfo(startFinallyChain.getNext(), endFinallyChainExclusive);
|
||||
FinallyBlockInfo finallyInfo = new FinallyBlockInfo(startFinallyChain.getNext(), endFinallyChainExclusive);
|
||||
|
||||
if (inlineFun.instructions.indexOf(finallyInfo.startIns) > inlineFun.instructions.indexOf(finallyInfo.endInsExclusive)) {
|
||||
throw new AssertionError("Inconsistent finally: block end occurs before start " + traceInterval(finallyInfo.endInsExclusive, finallyInfo.startIns));
|
||||
}
|
||||
|
||||
return finallyInfo;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -470,22 +522,20 @@ public class InternalFinallyBlockInliner {
|
||||
private List<TryCatchBlockNodePosition> findTryCatchBlocksInlinedInFinally(@NotNull FinallyBlockInfo finallyInfo) {
|
||||
List<TryCatchBlockNodePosition> result = new ArrayList<TryCatchBlockNodePosition>();
|
||||
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<TryCatchBlockNodeInfo, TryCatchBlockNodePosition>();
|
||||
|
||||
for (AbstractInsnNode curInstr = finallyInfo.startIns; curInstr != finallyInfo.endInsExclusive; curInstr = curInstr.getNext()) {
|
||||
if (!(curInstr instanceof LabelNode)) continue;
|
||||
|
||||
LabelNode curLabel = (LabelNode) curInstr;
|
||||
List<TryCatchBlockNodeInfo> startedTryBlocks = tryBlockStarts.get(curLabel);
|
||||
if (startedTryBlocks != null) {
|
||||
for (TryCatchBlockNodeInfo block : startedTryBlocks) {
|
||||
assert !processedBlocks.containsKey(block) : "Try catch block already processed before start label!!! " + block;
|
||||
TryCatchBlockNodePosition info = new TryCatchBlockNodePosition(block, TryCatchPosition.START);
|
||||
processedBlocks.put(block, info);
|
||||
result.add(info);
|
||||
}
|
||||
List<TryCatchBlockNodeInfo> startedTryBlocks = getStartNodes(curLabel);
|
||||
for (TryCatchBlockNodeInfo block : startedTryBlocks) {
|
||||
assert !processedBlocks.containsKey(block) : "Try catch block already processed before start label!!! " + block;
|
||||
TryCatchBlockNodePosition info = new TryCatchBlockNodePosition(block, TryCatchPosition.START);
|
||||
processedBlocks.put(block, info);
|
||||
result.add(info);
|
||||
}
|
||||
|
||||
List<TryCatchBlockNodeInfo> endedTryBlocks = tryBlockEnds.get(curLabel);
|
||||
if (endedTryBlocks == null) continue;
|
||||
List<TryCatchBlockNodeInfo> endedTryBlocks = getEndNodes(curLabel);
|
||||
|
||||
for (TryCatchBlockNodeInfo block : endedTryBlocks) {
|
||||
TryCatchBlockNodePosition info = processedBlocks.get(block);
|
||||
@@ -527,21 +577,38 @@ public class InternalFinallyBlockInliner {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void sortTryCatchBlocks(@NotNull List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
|
||||
Comparator<TryCatchBlockNodeInfo> comp = new Comparator<TryCatchBlockNodeInfo>() {
|
||||
@Override
|
||||
public int compare(@NotNull TryCatchBlockNodeInfo t1, @NotNull TryCatchBlockNodeInfo t2) {
|
||||
int result = inlineFun.instructions.indexOf(t1.getNode().handler) - inlineFun.instructions.indexOf(t2.getNode().handler);
|
||||
if (result == 0) {
|
||||
result = inlineFun.instructions.indexOf(t1.getNode().start) - inlineFun.instructions.indexOf(t2.getNode().start);
|
||||
if (result == 0) {
|
||||
assert false : "Error: support multicatch finallies!";
|
||||
result = inlineFun.instructions.indexOf(t1.getNode().end) - inlineFun.instructions.indexOf(t2.getNode().end);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
Collections.sort(inlineFunTryBlockInfo, comp);
|
||||
@Override
|
||||
public int instructionIndex(@NotNull AbstractInsnNode inst) {
|
||||
return inlineFun.instructions.indexOf(inst);
|
||||
}
|
||||
|
||||
private void substituteTryBlockNodes() {
|
||||
inlineFun.tryCatchBlocks.clear();
|
||||
for (TryCatchBlockNodeInfo info : getNonEmptyNodes()) {
|
||||
inlineFun.tryCatchBlocks.add(info.getNode());
|
||||
}
|
||||
}
|
||||
|
||||
private static String traceInterval(AbstractInsnNode startNode, AbstractInsnNode stopNode) {
|
||||
Textifier p = new Textifier();
|
||||
TraceMethodVisitor visitor = new TraceMethodVisitor(p);
|
||||
while (startNode != stopNode) {
|
||||
startNode.accept(visitor);
|
||||
startNode = startNode.getNext();
|
||||
}
|
||||
startNode.accept(visitor);
|
||||
StringWriter out = new StringWriter();
|
||||
p.print(new PrintWriter(out));
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration", "UseOfSystemOutOrSystemErr"})
|
||||
@TestOnly
|
||||
private void flushCurrentState(@NotNull AbstractInsnNode curNonLocal) {
|
||||
substituteTryBlockNodes();
|
||||
System.out.println("Will process instruction at : " + inlineFun.instructions.indexOf(curNonLocal) + " " + curNonLocal.toString());
|
||||
String text = getNodeText(inlineFun);
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.jetbrains.jet.codegen.inline;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
import org.jetbrains.jet.codegen.AsmUtil;
|
||||
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
|
||||
@@ -32,12 +29,15 @@ import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.anonymousClassForFunction;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.asmTypeForAnonymousClass;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
|
||||
public class LambdaInfo implements CapturedParamOwner, LabelOwner {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
|
||||
@Nullable
|
||||
public final String labelName;
|
||||
|
||||
public final CalculatedClosure closure;
|
||||
private final CalculatedClosure closure;
|
||||
|
||||
private MethodNode node;
|
||||
|
||||
|
||||
@@ -356,7 +356,6 @@ public class MethodInliner {
|
||||
|
||||
AbstractInsnNode cur = node.instructions.getFirst();
|
||||
int index = 0;
|
||||
Set<LabelNode> possibleDeadLabels = new HashSet<LabelNode>();
|
||||
|
||||
while (cur != null) {
|
||||
Frame<SourceValue> frame = sources[index];
|
||||
@@ -416,15 +415,12 @@ public class MethodInliner {
|
||||
if (frame == null) {
|
||||
//clean dead code otherwise there is problems in unreachable finally block, don't touch label it cause try/catch/finally problems
|
||||
if (prevNode.getType() == AbstractInsnNode.LABEL) {
|
||||
possibleDeadLabels.add((LabelNode) prevNode);
|
||||
//NB: Cause we generate exception table for default handler using gaps (see ExpressionCodegen.visitTryExpression)
|
||||
//it may occurs that interval for default handler starts before catch start label, so this label seems as dead,
|
||||
//but as result all this labels will be merged into one (see KT-5863)
|
||||
} else {
|
||||
node.instructions.remove(prevNode);
|
||||
}
|
||||
} else {
|
||||
//Cause we generate exception table for default handler using gaps (see ExpressionCodegen.visitTryExpression)
|
||||
//it may occurs that interval for default handler starts before catch start label, so this label seems as dead,
|
||||
//but as result all this labels will be merged into one (see KT-5863)
|
||||
possibleDeadLabels.remove(prevNode.getPrevious());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +428,7 @@ public class MethodInliner {
|
||||
List<TryCatchBlockNode> blocks = node.tryCatchBlocks;
|
||||
for (Iterator<TryCatchBlockNode> iterator = blocks.iterator(); iterator.hasNext(); ) {
|
||||
TryCatchBlockNode block = iterator.next();
|
||||
if (possibleDeadLabels.contains(block.start) && possibleDeadLabels.contains(block.end)) {
|
||||
if (isEmptyTryInterval(block)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -440,6 +436,15 @@ public class MethodInliner {
|
||||
return node;
|
||||
}
|
||||
|
||||
private static boolean isEmptyTryInterval(@NotNull TryCatchBlockNode tryCatchBlockNode) {
|
||||
LabelNode start = tryCatchBlockNode.start;
|
||||
AbstractInsnNode end = tryCatchBlockNode.end;
|
||||
while (end != start && end instanceof LabelNode) {
|
||||
end = end.getPrevious();
|
||||
}
|
||||
return start == end;
|
||||
}
|
||||
|
||||
public LambdaInfo getLambdaIfExists(AbstractInsnNode insnNode) {
|
||||
if (insnNode.getOpcode() == Opcodes.ALOAD) {
|
||||
int varIndex = ((VarInsnNode) insnNode).var;
|
||||
@@ -581,11 +586,11 @@ public class MethodInliner {
|
||||
|
||||
@NotNull
|
||||
//process local and global returns (local substituted with goto end-label global kept unchanged)
|
||||
public static List<ExternalFinallyBlockInfo> processReturns(@NotNull MethodNode node, @NotNull LabelOwner labelOwner, boolean remapReturn, Label endLabel) {
|
||||
public static List<PointForExternalFinallyBlocks> processReturns(@NotNull MethodNode node, @NotNull LabelOwner labelOwner, boolean remapReturn, Label endLabel) {
|
||||
if (!remapReturn) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ExternalFinallyBlockInfo> result = new ArrayList<ExternalFinallyBlockInfo>();
|
||||
List<PointForExternalFinallyBlocks> result = new ArrayList<PointForExternalFinallyBlocks>();
|
||||
InsnList instructions = node.instructions;
|
||||
AbstractInsnNode insnNode = instructions.getFirst();
|
||||
while (insnNode != null) {
|
||||
@@ -616,7 +621,7 @@ public class MethodInliner {
|
||||
}
|
||||
|
||||
//genetate finally block before nonLocalReturn flag/return/goto
|
||||
result.add(new ExternalFinallyBlockInfo(isLocalReturn ? insnNode : insnNode.getPrevious(), getReturnType(insnNode.getOpcode())
|
||||
result.add(new PointForExternalFinallyBlocks(isLocalReturn ? insnNode : insnNode.getPrevious(), getReturnType(insnNode.getOpcode())
|
||||
));
|
||||
}
|
||||
insnNode = insnNode.getNext();
|
||||
@@ -624,13 +629,14 @@ public class MethodInliner {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class ExternalFinallyBlockInfo {
|
||||
//Place to insert finally blocks from try blocks that wraps inline fun call
|
||||
public static class PointForExternalFinallyBlocks {
|
||||
|
||||
final AbstractInsnNode beforeIns;
|
||||
|
||||
final Type returnType;
|
||||
|
||||
public ExternalFinallyBlockInfo(AbstractInsnNode beforeIns, Type returnType) {
|
||||
public PointForExternalFinallyBlocks(AbstractInsnNode beforeIns, Type returnType) {
|
||||
this.beforeIns = beforeIns;
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ trait IntervalWithHandler {
|
||||
val startLabel: LabelNode
|
||||
val endLabel: LabelNode
|
||||
val handler: LabelNode
|
||||
val `type`: String?
|
||||
val type: String?
|
||||
}
|
||||
|
||||
class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess: Boolean) : IntervalWithHandler {
|
||||
@@ -43,16 +43,16 @@ class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess:
|
||||
override val endLabel: LabelNode
|
||||
get() = node.end
|
||||
override val handler: LabelNode
|
||||
get() = node.handler!!
|
||||
override val `type`: String?
|
||||
get() = node.`type`
|
||||
get() = node.handler
|
||||
override val type: String?
|
||||
get() = node.type
|
||||
}
|
||||
|
||||
class TryCatchBlockNodePosition(val nodeInfo: TryCatchBlockNodeInfo, var position: TryCatchPosition): IntervalWithHandler by nodeInfo
|
||||
|
||||
class TryBlockCluster<T : IntervalWithHandler>(val blocks: MutableList<T>) {
|
||||
val defaultHandler: T?
|
||||
get() = blocks.firstOrNull() { it.`type` == null }
|
||||
get() = blocks.firstOrNull() { it.type == null }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,10 +39,18 @@ public class ArrayGet extends IntrinsicMethod {
|
||||
List<JetExpression> arguments,
|
||||
StackValue receiver
|
||||
) {
|
||||
int argumentIndex;
|
||||
if (receiver == null || receiver == StackValue.none()) {
|
||||
receiver = codegen.gen(arguments.get(0));
|
||||
argumentIndex = 1;
|
||||
} else {
|
||||
argumentIndex = 0;
|
||||
}
|
||||
receiver.put(receiver.type, v);
|
||||
|
||||
Type type = correctElementType(receiver.type);
|
||||
|
||||
codegen.gen(arguments.get(0), Type.INT_TYPE);
|
||||
codegen.gen(arguments.get(argumentIndex), Type.INT_TYPE);
|
||||
|
||||
v.aload(type);
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ public class Clone extends IntrinsicMethod {
|
||||
}
|
||||
|
||||
private static boolean isSuperCall(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
ReceiverValue thisObject = resolvedCall.getThisObject();
|
||||
return thisObject instanceof ExpressionReceiver &&
|
||||
((ExpressionReceiver) thisObject).getExpression() instanceof JetSuperExpression;
|
||||
ReceiverValue dispatchReceiver = resolvedCall.getDispatchReceiver();
|
||||
return dispatchReceiver instanceof ExpressionReceiver &&
|
||||
((ExpressionReceiver) dispatchReceiver).getExpression() instanceof JetSuperExpression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,21 @@ package org.jetbrains.jet.codegen.intrinsics;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetParenthesizedExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.genIncrement;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.isPrimitive;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.EXPRESSION_TYPE;
|
||||
|
||||
public class Increment extends IntrinsicMethod {
|
||||
private final int myDelta;
|
||||
@@ -51,15 +54,15 @@ public class Increment extends IntrinsicMethod {
|
||||
assert isPrimitive(returnType) : "Return type of Increment intrinsic should be of primitive type : " + returnType;
|
||||
|
||||
if (arguments.size() > 0) {
|
||||
JetExpression operand = arguments.get(0);
|
||||
while (operand instanceof JetParenthesizedExpression) {
|
||||
operand = ((JetParenthesizedExpression) operand).getExpression();
|
||||
}
|
||||
JetExpression operand = JetPsiUtil.deparenthesize(arguments.get(0));
|
||||
if (operand instanceof JetReferenceExpression && returnType == Type.INT_TYPE) {
|
||||
int index = codegen.indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0) {
|
||||
StackValue.preIncrement(index, myDelta).put(returnType, v);
|
||||
return returnType;
|
||||
JetType operandType = codegen.getBindingContext().get(EXPRESSION_TYPE, operand);
|
||||
if (operandType != null && KotlinBuiltIns.getInstance().isPrimitiveType(operandType)) {
|
||||
StackValue.preIncrement(index, myDelta).put(returnType, v);
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
}
|
||||
StackValue value = codegen.genQualified(receiver, operand);
|
||||
|
||||
@@ -106,7 +106,7 @@ class IntrinsicsMap {
|
||||
|
||||
@Nullable
|
||||
private static FqNameUnsafe getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
if (receiverParameter == null) return null;
|
||||
|
||||
ClassifierDescriptor classifier = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.codegen.intrinsics;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.AsmUtil;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
@@ -44,6 +45,10 @@ public class JavaClassProperty extends IntrinsicMethod {
|
||||
) {
|
||||
Type type = receiver.type;
|
||||
if (isPrimitive(type)) {
|
||||
if (!StackValue.couldSkipReceiverOnStaticCall(receiver)) {
|
||||
receiver.put(type, v);
|
||||
AsmUtil.pop(v, type);
|
||||
}
|
||||
v.getstatic(boxType(type).getInternalName(), "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -144,9 +144,13 @@ public class BoxingInterpreter extends OptimizationBasicInterpreter {
|
||||
private static boolean isBoxing(@NotNull AbstractInsnNode insn) {
|
||||
if (insn.getOpcode() != Opcodes.INVOKESTATIC) return false;
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) insn;
|
||||
MethodInsnNode node = (MethodInsnNode) insn;
|
||||
|
||||
return isWrapperClassName(methodInsnNode.owner) && "valueOf".equals(methodInsnNode.name);
|
||||
return isWrapperClassName(node.owner) && "valueOf".equals(node.name) &&
|
||||
Type.getMethodDescriptor(
|
||||
Type.getObjectType(node.owner),
|
||||
AsmUtil.unboxType(Type.getObjectType(node.owner))
|
||||
).equals(node.desc);
|
||||
}
|
||||
|
||||
private static boolean isNextMethodCallOfProgressionIterator(
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.util.containers.MultiMap
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactory
|
||||
import org.jetbrains.jet.codegen.SignatureCollectingClassBuilderFactory
|
||||
import org.jetbrains.jet.lang.descriptors.*
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.*
|
||||
import java.util.*
|
||||
@@ -31,11 +30,12 @@ import org.jetbrains.jet.utils.addIfNotNull
|
||||
import org.jetbrains.jet.codegen.ClassBuilderMode
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink
|
||||
|
||||
class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
builderFactory: ClassBuilderFactory,
|
||||
bindingContext: BindingContext,
|
||||
private val diagnostics: DiagnosticHolder
|
||||
private val diagnostics: DiagnosticSink
|
||||
) : SignatureCollectingClassBuilderFactory(builderFactory) {
|
||||
|
||||
// Avoid errors when some classes are not loaded for some reason
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.codegen.optimization.OptimizationClassBuilderFactory;
|
||||
import org.jetbrains.jet.codegen.when.MappingsClassesForWhenByEnum;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.reflect.ReflectionTypes;
|
||||
@@ -120,7 +120,7 @@ public class GenerationState {
|
||||
@NotNull List<JetFile> files
|
||||
) {
|
||||
this(project, builderFactory, Progress.DEAF, module, bindingContext, files, true, true, GenerateClassFilter.GENERATE_ALL,
|
||||
false, false, null, null, DiagnosticHolder.DO_NOTHING, null);
|
||||
false, false, null, null, DiagnosticSink.DO_NOTHING, null);
|
||||
}
|
||||
|
||||
public GenerationState(
|
||||
@@ -137,7 +137,7 @@ public class GenerationState {
|
||||
boolean disableOptimization,
|
||||
@Nullable Collection<FqName> packagesWithRemovedFiles,
|
||||
@Nullable String moduleId,
|
||||
@NotNull DiagnosticHolder diagnostics,
|
||||
@NotNull DiagnosticSink diagnostics,
|
||||
@Nullable File outDirectory
|
||||
) {
|
||||
this.project = project;
|
||||
|
||||
@@ -159,7 +159,9 @@ public class JetTypeMapper {
|
||||
private Type mapReturnType(@NotNull CallableDescriptor descriptor, @Nullable BothSignatureWriter sw) {
|
||||
JetType returnType = descriptor.getReturnType();
|
||||
assert returnType != null : "Function has no return type: " + descriptor;
|
||||
if (returnType.equals(KotlinBuiltIns.getInstance().getUnitType()) && !(descriptor instanceof PropertyGetterDescriptor)) {
|
||||
if (returnType.equals(KotlinBuiltIns.getInstance().getUnitType())
|
||||
&& !TypeUtils.isNullableType(returnType)
|
||||
&& !(descriptor instanceof PropertyGetterDescriptor)) {
|
||||
if (sw != null) {
|
||||
sw.writeAsmType(Type.VOID_TYPE);
|
||||
}
|
||||
@@ -220,7 +222,7 @@ public class JetTypeMapper {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
FqNameUnsafe className = DescriptorUtils.getFqName(descriptor);
|
||||
if (className.isSafe()) {
|
||||
known = KotlinToJavaTypesMap.getInstance().getJavaAnalog(className.toSafe(), jetType.isNullable());
|
||||
known = KotlinToJavaTypesMap.getInstance().getJavaAnalog(className.toSafe(), TypeUtils.isNullableType(jetType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,7 +526,7 @@ public class JetTypeMapper {
|
||||
Type calleeType = isLocalNamedFun(functionDescriptor) ? owner : null;
|
||||
|
||||
Type receiverParameterType;
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getOriginal().getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getOriginal().getExtensionReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
receiverParameterType = mapType(receiverParameter.getType());
|
||||
}
|
||||
@@ -624,7 +626,7 @@ public class JetTypeMapper {
|
||||
sw.writeParametersStart();
|
||||
writeThisIfNeeded(f, kind, sw);
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = f.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = f.getExtensionReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.getType());
|
||||
}
|
||||
@@ -664,7 +666,7 @@ public class JetTypeMapper {
|
||||
public Method mapDefaultMethod(@NotNull FunctionDescriptor functionDescriptor, @NotNull OwnerKind kind, @NotNull CodegenContext<?> context) {
|
||||
Method jvmSignature = mapSignature(functionDescriptor, kind).getAsmMethod();
|
||||
Type ownerType = mapOwner(functionDescriptor, isCallInsideSameModuleAsDeclared(functionDescriptor, context, getOutDirectory()));
|
||||
String descriptor = getDefaultDescriptor(jvmSignature, functionDescriptor.getReceiverParameter() != null);
|
||||
String descriptor = getDefaultDescriptor(jvmSignature, functionDescriptor.getExtensionReceiverParameter() != null);
|
||||
boolean isConstructor = "<init>".equals(jvmSignature.getName());
|
||||
if (!isStaticMethod(kind, functionDescriptor) && !isConstructor) {
|
||||
descriptor = descriptor.replace("(", "(" + ownerType.getDescriptor());
|
||||
@@ -683,7 +685,7 @@ public class JetTypeMapper {
|
||||
//noinspection ConstantConditions
|
||||
if (!KotlinBuiltIns.getInstance().isPrimitiveType(descriptor.getReturnType())) return false;
|
||||
|
||||
for (FunctionDescriptor overridden : OverrideResolver.getAllOverriddenDescriptors(descriptor)) {
|
||||
for (FunctionDescriptor overridden : getAllOverriddenDescriptors(descriptor)) {
|
||||
//noinspection ConstantConditions
|
||||
if (!KotlinBuiltIns.getInstance().isPrimitiveType(overridden.getOriginal().getReturnType())) return true;
|
||||
}
|
||||
@@ -713,7 +715,7 @@ public class JetTypeMapper {
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
thisType = getTraitImplThisParameterClass((ClassDescriptor) descriptor.getContainingDeclaration());
|
||||
}
|
||||
else if (isAccessor(descriptor) && descriptor.getExpectedThisObject() != null) {
|
||||
else if (isAccessor(descriptor) && descriptor.getDispatchReceiverParameter() != null) {
|
||||
thisType = (ClassDescriptor) descriptor.getContainingDeclaration();
|
||||
}
|
||||
else return;
|
||||
@@ -804,7 +806,7 @@ public class JetTypeMapper {
|
||||
private void writeAdditionalConstructorParameters(@NotNull ConstructorDescriptor descriptor, @NotNull BothSignatureWriter sw) {
|
||||
CalculatedClosure closure = bindingContext.get(CodegenBinding.CLOSURE, descriptor.getContainingDeclaration());
|
||||
|
||||
ClassDescriptor captureThis = getExpectedThisObjectForConstructorCall(descriptor, closure);
|
||||
ClassDescriptor captureThis = getDispatchReceiverParameterForConstructorCall(descriptor, closure);
|
||||
if (captureThis != null) {
|
||||
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType());
|
||||
}
|
||||
@@ -930,7 +932,7 @@ public class JetTypeMapper {
|
||||
return asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof PropertyDescriptor || descriptor instanceof FunctionDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) descriptor).getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) descriptor).getExtensionReceiverParameter();
|
||||
assert receiverParameter != null : "Callable should have a receiver parameter: " + descriptor;
|
||||
return StackValue.sharedTypeForType(mapType(receiverParameter.getType()));
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.NullValue;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
@@ -135,7 +136,7 @@ abstract public class SwitchCodegen {
|
||||
|
||||
assert subjectJetType != null : "subject type can't be null (i.e. void)";
|
||||
|
||||
if (subjectJetType.isNullable()) {
|
||||
if (TypeUtils.isNullableType(subjectJetType)) {
|
||||
int nullEntryIndex = findNullEntryIndex(expression);
|
||||
Label nullLabel = nullEntryIndex == -1 ? defaultLabel : entryLabels.get(nullEntryIndex);
|
||||
Label notNullLabel = new Label();
|
||||
|
||||
@@ -38,6 +38,9 @@ public abstract class CommonCompilerArguments {
|
||||
@Argument(value = "X", description = "Print a synopsis of advanced options")
|
||||
public boolean extraHelp;
|
||||
|
||||
@Argument(value = "Xno-inline", description = "Disable method inlining")
|
||||
public boolean noInline;
|
||||
|
||||
public List<String> freeArgs = new SmartList<String>();
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -63,9 +63,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java")
|
||||
public boolean noParamAssertions;
|
||||
|
||||
@Argument(value = "Xno-inline", description = "Disable method inlining")
|
||||
public boolean noInline;
|
||||
|
||||
@Argument(value = "Xno-optimize", description = "Disable optimizations")
|
||||
public boolean noOptimize;
|
||||
|
||||
|
||||
@@ -116,14 +116,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
errStream.print(messageRenderer.renderPreamble());
|
||||
|
||||
printVersionIfNeeded(errStream, arguments, messageRenderer);
|
||||
|
||||
MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
||||
|
||||
if (arguments.suppressWarnings) {
|
||||
collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||
}
|
||||
|
||||
try {
|
||||
return exec(collector, services, arguments);
|
||||
}
|
||||
@@ -134,6 +128,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
@NotNull
|
||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
||||
printVersionIfNeeded(messageCollector, arguments);
|
||||
|
||||
if (arguments.suppressWarnings) {
|
||||
messageCollector = new FilteringMessageCollector(messageCollector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||
}
|
||||
|
||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||
try {
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
@@ -164,17 +164,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
@NotNull Disposable rootDisposable
|
||||
);
|
||||
|
||||
protected void printVersionIfNeeded(
|
||||
@NotNull PrintStream errStream,
|
||||
@NotNull A arguments,
|
||||
@NotNull MessageRenderer messageRenderer
|
||||
) {
|
||||
if (arguments.version) {
|
||||
String versionMessage = messageRenderer.render(CompilerMessageSeverity.INFO,
|
||||
"Kotlin Compiler version " + KotlinVersion.VERSION,
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
errStream.println(versionMessage);
|
||||
}
|
||||
protected void printVersionIfNeeded(@NotNull MessageCollector messageCollector, @NotNull A arguments) {
|
||||
if (!arguments.version) return;
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.INFO,
|
||||
"Kotlin Compiler version " + KotlinVersion.VERSION,
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.Function0;
|
||||
@@ -48,7 +49,6 @@ import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.analyze.TopDownAnalyzerFacadeForJS;
|
||||
import org.jetbrains.k2js.config.*;
|
||||
import org.jetbrains.k2js.facade.K2JSTranslator;
|
||||
import org.jetbrains.k2js.facade.MainCallParameters;
|
||||
|
||||
import java.io.File;
|
||||
@@ -58,6 +58,7 @@ import java.util.List;
|
||||
import static org.jetbrains.jet.cli.common.ExitCode.COMPILATION_ERROR;
|
||||
import static org.jetbrains.jet.cli.common.ExitCode.OK;
|
||||
import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_LOCATION;
|
||||
import static org.jetbrains.k2js.facade.K2JSTranslator.translateWithMainCallParameters;
|
||||
|
||||
public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
|
||||
@@ -170,7 +171,8 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
@Nullable File outputPostfix
|
||||
) {
|
||||
try {
|
||||
return K2JSTranslator.translateWithMainCallParameters(mainCall, sourceFiles, outputFile, outputPrefix, outputPostfix, config);
|
||||
//noinspection unchecked
|
||||
return translateWithMainCallParameters(mainCall, sourceFiles, outputFile, outputPrefix, outputPostfix, config, Consumer.EMPTY_CONSUMER);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -196,12 +198,14 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
}
|
||||
EcmaVersion ecmaVersion = EcmaVersion.defaultVersion();
|
||||
String moduleId = FileUtil.getNameWithoutExtension(new File(arguments.outputFile));
|
||||
boolean inlineEnabled = !arguments.noInline;
|
||||
|
||||
if (arguments.libraryFiles != null) {
|
||||
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourceMap);
|
||||
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourceMap, inlineEnabled);
|
||||
}
|
||||
else {
|
||||
// lets discover the JS library definitions on the classpath
|
||||
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourceMap);
|
||||
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourceMap, inlineEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,4 +217,4 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
return MainCallParameters.mainWithoutArguments();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
}
|
||||
}
|
||||
|
||||
public static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
|
||||
private static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions);
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions);
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline);
|
||||
|
||||
@@ -47,7 +47,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForJavaDescriptorResolver {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final BindingTrace bindingTrace;
|
||||
private final GlobalContextImpl globalContext;
|
||||
@@ -73,7 +73,7 @@ public class InjectorForJavaDescriptorResolver {
|
||||
private final AnnotationDescriptorLoader annotationDescriptorLoader;
|
||||
private final DescriptorLoadersStorage descriptorLoadersStorage;
|
||||
private final ConstantDescriptorLoader constantDescriptorLoader;
|
||||
|
||||
|
||||
public InjectorForJavaDescriptorResolver(
|
||||
@NotNull Project project,
|
||||
@NotNull BindingTrace bindingTrace
|
||||
@@ -138,25 +138,25 @@ public class InjectorForJavaDescriptorResolver {
|
||||
javaClassFinder.initialize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public GlobalContextImpl getGlobalContext() {
|
||||
return this.globalContext;
|
||||
}
|
||||
|
||||
|
||||
public ModuleDescriptorImpl getModule() {
|
||||
return this.module;
|
||||
}
|
||||
|
||||
|
||||
public JavaDescriptorResolver getJavaDescriptorResolver() {
|
||||
return this.javaDescriptorResolver;
|
||||
}
|
||||
|
||||
|
||||
public JavaClassFinderImpl getJavaClassFinder() {
|
||||
return this.javaClassFinder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedMethodSignatureCheck
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
@@ -71,7 +72,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForLazyResolveWithJava {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final GlobalContext globalContext;
|
||||
private final StorageManager storageManager;
|
||||
@@ -92,6 +93,7 @@ public class InjectorForLazyResolveWithJava {
|
||||
private final PsiBasedExternalAnnotationResolver psiBasedExternalAnnotationResolver;
|
||||
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
|
||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
||||
private final AdditionalCheckerProvider additionalCheckerProvider;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
private final CallResolver callResolver;
|
||||
@@ -121,7 +123,7 @@ public class InjectorForLazyResolveWithJava {
|
||||
private final AnnotationDescriptorLoader annotationDescriptorLoader;
|
||||
private final DescriptorLoadersStorage descriptorLoadersStorage;
|
||||
private final ConstantDescriptorLoader constantDescriptorLoader;
|
||||
|
||||
|
||||
public InjectorForLazyResolveWithJava(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@@ -154,6 +156,7 @@ public class InjectorForLazyResolveWithJava {
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(storageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, lazyResolveBasedCache, javaPropertyInitializerEvaluator, javaSourceElementFactory, moduleClassResolver);
|
||||
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, module);
|
||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, module);
|
||||
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
||||
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
@@ -250,6 +253,7 @@ public class InjectorForLazyResolveWithJava {
|
||||
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(javaFlexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(module);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -277,17 +281,17 @@ public class InjectorForLazyResolveWithJava {
|
||||
javaClassFinder.initialize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public ResolveSession getResolveSession() {
|
||||
return this.resolveSession;
|
||||
}
|
||||
|
||||
|
||||
public JavaDescriptorResolver getJavaDescriptorResolver() {
|
||||
return this.javaDescriptorResolver;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationRe
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
|
||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
@@ -59,6 +60,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
|
||||
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
|
||||
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
|
||||
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
|
||||
@@ -81,7 +83,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnalyzer {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final GlobalContext globalContext;
|
||||
private final StorageManager storageManager;
|
||||
@@ -104,6 +106,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
|
||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||
private final SingleModuleClassResolver singleModuleClassResolver;
|
||||
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
||||
private final VirtualFileFinder virtualFileFinder;
|
||||
private final BodyResolver bodyResolver;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
@@ -125,6 +128,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private final CandidateResolver candidateResolver;
|
||||
private final ControlFlowAnalyzer controlFlowAnalyzer;
|
||||
private final DeclarationsChecker declarationsChecker;
|
||||
private final ModifiersChecker modifiersChecker;
|
||||
private final FunctionAnalyzerExtension functionAnalyzerExtension;
|
||||
private final ScriptBodyResolver scriptBodyResolver;
|
||||
private final DeclarationResolver declarationResolver;
|
||||
@@ -141,7 +145,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private final AnnotationDescriptorLoader annotationDescriptorLoader;
|
||||
private final DescriptorLoadersStorage descriptorLoadersStorage;
|
||||
private final ConstantDescriptorLoader constantDescriptorLoader;
|
||||
|
||||
|
||||
public InjectorForTopDownAnalyzerForJvm(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@@ -177,6 +181,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
this.deserializationGlobalContextForJava = new DeserializationGlobalContextForJava(storageManager, getModuleDescriptor(), javaClassDataFinder, annotationDescriptorLoader, constantDescriptorLoader, lazyJavaPackageFragmentProvider);
|
||||
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
||||
this.globalSearchScope = com.intellij.psi.search.GlobalSearchScope.allScope(project);
|
||||
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
||||
this.bodyResolver = new BodyResolver();
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
@@ -197,6 +202,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
|
||||
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
|
||||
this.declarationsChecker = new DeclarationsChecker();
|
||||
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
|
||||
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
|
||||
this.scriptBodyResolver = new ScriptBodyResolver();
|
||||
this.declarationResolver = new DeclarationResolver();
|
||||
@@ -300,6 +306,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(javaFlexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(moduleDescriptor);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -307,8 +314,8 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
|
||||
controlFlowAnalyzer.setTrace(bindingTrace);
|
||||
|
||||
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
|
||||
declarationsChecker.setDescriptorResolver(descriptorResolver);
|
||||
declarationsChecker.setModifiersChecker(modifiersChecker);
|
||||
declarationsChecker.setTrace(bindingTrace);
|
||||
|
||||
functionAnalyzerExtension.setTrace(bindingTrace);
|
||||
@@ -358,29 +365,29 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
javaClassFinder.initialize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public ModuleDescriptor getModuleDescriptor() {
|
||||
return this.moduleDescriptor;
|
||||
}
|
||||
|
||||
|
||||
public TopDownAnalyzer getTopDownAnalyzer() {
|
||||
return this.topDownAnalyzer;
|
||||
}
|
||||
|
||||
|
||||
public LazyTopDownAnalyzer getLazyTopDownAnalyzer() {
|
||||
return this.lazyTopDownAnalyzer;
|
||||
}
|
||||
|
||||
|
||||
public JavaDescriptorResolver getJavaDescriptorResolver() {
|
||||
return this.javaDescriptorResolver;
|
||||
}
|
||||
|
||||
|
||||
public DeserializationGlobalContextForJava getDeserializationGlobalContextForJava() {
|
||||
return this.deserializationGlobalContextForJava;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,17 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
package org.jetbrains.jet.lang.resolve.java
|
||||
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider
|
||||
import org.jetbrains.jet.lang.types.FlexibleTypeCapabilities
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.types.LazyJavaTypeResolver
|
||||
|
||||
public interface PsiJetImportDirectiveStub extends StubElement<JetImportDirective> {
|
||||
boolean isAbsoluteInRootPackage();
|
||||
boolean isAllUnder();
|
||||
@Nullable
|
||||
String getAliasName();
|
||||
boolean isValid();
|
||||
}
|
||||
public class JavaFlexibleTypeCapabilitiesProvider : FlexibleTypeCapabilitiesProvider() {
|
||||
override fun getCapabilities(): FlexibleTypeCapabilities = LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
try {
|
||||
checkForSyntaxErrors(altPropertyDeclaration);
|
||||
checkFieldAnnotation(altPropertyDeclaration, field, isVar);
|
||||
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeRef(),
|
||||
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeReference(),
|
||||
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>());
|
||||
}
|
||||
catch (AlternativeSignatureMismatchException e) {
|
||||
@@ -73,7 +73,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
field.getName().asString(), altProperty.getName());
|
||||
}
|
||||
|
||||
if (altProperty.getTypeRef() == null) {
|
||||
if (altProperty.getTypeReference() == null) {
|
||||
throw new AlternativeSignatureMismatchException("Field annotation for shouldn't have type reference");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.ExternalAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaMember;
|
||||
@@ -89,7 +90,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
computeValueParameters(valueParameters);
|
||||
|
||||
if (originalReturnType != null) {
|
||||
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getReturnTypeRef(), originalToAltTypeParameters);
|
||||
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getTypeReference(), originalToAltTypeParameters);
|
||||
}
|
||||
|
||||
if (hasSuperMethods) {
|
||||
@@ -101,11 +102,25 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ValueParameterDescriptor> updateNames(
|
||||
List<ValueParameterDescriptor> originalValueParameters,
|
||||
List<ValueParameterDescriptor> altValueParameters
|
||||
) {
|
||||
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
||||
for (int i = 0; i < originalValueParameters.size(); i++) {
|
||||
ValueParameterDescriptor originalValueParameter = originalValueParameters.get(i);
|
||||
ValueParameterDescriptor altValueParameter = altValueParameters.get(i);
|
||||
result.add(originalValueParameter.copy(originalValueParameter.getContainingDeclaration(), altValueParameter.getName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void checkParameterAndReturnTypesForOverridingMethods(
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
@Nullable JetType returnType
|
||||
) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return;
|
||||
TypeSubstitutor substitutor = DescriptorResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
||||
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMapBuilder;
|
||||
|
||||
/* package */ class CollectionClassMapping extends JavaToKotlinClassMapBuilder {
|
||||
public class CollectionClassMapping extends JavaToKotlinClassMapBuilder {
|
||||
private static CollectionClassMapping instance = null;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaSignatureFormatter;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class JavaToKotlinMethodMap {
|
||||
public static final JavaToKotlinMethodMap INSTANCE = new JavaToKotlinMethodMap();
|
||||
|
||||
private final JavaToKotlinMethodMapGenerated mapContainer = new JavaToKotlinMethodMapGenerated();
|
||||
|
||||
private JavaToKotlinMethodMap() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<FunctionDescriptor> getFunctions(
|
||||
@NotNull JavaMethod javaMethod,
|
||||
@NotNull FqName classFqName,
|
||||
@NotNull ClassDescriptor containingClass
|
||||
) {
|
||||
ImmutableCollection<ClassData> classDatas = mapContainer.map.get(classFqName.asString());
|
||||
|
||||
List<FunctionDescriptor> result = Lists.newArrayList();
|
||||
|
||||
Set<ClassDescriptor> allSuperClasses = new HashSet<ClassDescriptor>(DescriptorUtils.getSuperclassDescriptors(containingClass));
|
||||
|
||||
String serializedMethod = JavaSignatureFormatter.getInstance().formatMethod(javaMethod);
|
||||
for (ClassData classData : classDatas) {
|
||||
String expectedSerializedFunction = classData.method2Function.get(serializedMethod);
|
||||
if (expectedSerializedFunction == null) continue;
|
||||
|
||||
ClassDescriptor kotlinClass = classData.kotlinClass;
|
||||
if (!allSuperClasses.contains(kotlinClass)) continue;
|
||||
|
||||
Collection<FunctionDescriptor> functions = kotlinClass.getDefaultType().getMemberScope().getFunctions(javaMethod.getName());
|
||||
|
||||
for (FunctionDescriptor function : functions) {
|
||||
if (expectedSerializedFunction.equals(serializeFunction(function))) {
|
||||
result.add(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String serializeFunction(@NotNull FunctionDescriptor fun) {
|
||||
return DescriptorRenderer.COMPACT.render(fun);
|
||||
}
|
||||
|
||||
// used in generated code
|
||||
static Pair<String, String> pair(String a, String b) {
|
||||
return Pair.create(a, b);
|
||||
}
|
||||
|
||||
// used in generated code
|
||||
static void put(
|
||||
ImmutableMultimap.Builder<String, ClassData> builder,
|
||||
String javaFqName,
|
||||
String kotlinQualifiedName,
|
||||
Pair<String, String>... methods2Functions
|
||||
) {
|
||||
ImmutableMap<String, String> methods2FunctionsMap = pairs2Map(methods2Functions);
|
||||
|
||||
ClassDescriptor kotlinClass;
|
||||
if (kotlinQualifiedName.contains(".")) { // Map.Entry and MutableMap.MutableEntry
|
||||
String[] kotlinNames = kotlinQualifiedName.split("\\.");
|
||||
assert kotlinNames.length == 2 : "unexpected qualified name " + kotlinQualifiedName;
|
||||
|
||||
ClassDescriptor outerClass = KotlinBuiltIns.getInstance().getBuiltInClassByName(Name.identifier(kotlinNames[0]));
|
||||
kotlinClass = DescriptorUtils.getInnerClassByName(outerClass, kotlinNames[1]);
|
||||
assert kotlinClass != null : "Class not found: " + kotlinQualifiedName;
|
||||
}
|
||||
else {
|
||||
kotlinClass = KotlinBuiltIns.getInstance().getBuiltInClassByName(Name.identifier(kotlinQualifiedName));
|
||||
}
|
||||
|
||||
builder.put(javaFqName, new ClassData(kotlinClass, methods2FunctionsMap));
|
||||
}
|
||||
|
||||
private static ImmutableMap<String, String> pairs2Map(Pair<String, String>[] pairs) {
|
||||
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
|
||||
for (Pair<String, String> pair : pairs) {
|
||||
builder.put(pair.first, pair.second);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static class ClassData {
|
||||
@NotNull
|
||||
public final ClassDescriptor kotlinClass;
|
||||
@NotNull
|
||||
public Map<String, String> method2Function;
|
||||
|
||||
public ClassData(@NotNull ClassDescriptor kotlinClass, @NotNull Map<String, String> method2Function) {
|
||||
this.kotlinClass = kotlinClass;
|
||||
this.method2Function = method2Function;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.kotlinSignature.JavaToKotlinMethodMap.*;
|
||||
|
||||
/* This file is generated by org.jetbrains.jet.generators.jvm.GenerateJavaToKotlinMethodMap. DO NOT EDIT! */
|
||||
@SuppressWarnings("unchecked")
|
||||
class JavaToKotlinMethodMapGenerated {
|
||||
final ImmutableMultimap<String, JavaToKotlinMethodMap.ClassData> map;
|
||||
|
||||
JavaToKotlinMethodMapGenerated() {
|
||||
ImmutableMultimap.Builder<String, JavaToKotlinMethodMap.ClassData> b = ImmutableMultimap.builder();
|
||||
|
||||
put(b, "java.lang.Object", "Any",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.String", "String",
|
||||
pair("compareTo(java.lang.String)", "fun compareTo(other: kotlin.String): kotlin.Int"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.CharSequence", "CharSequence",
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Throwable", "Throwable",
|
||||
pair("getCause()", "fun getCause(): kotlin.Throwable?"),
|
||||
pair("getMessage()", "fun getMessage(): kotlin.String?"),
|
||||
pair("printStackTrace()", "fun printStackTrace(): kotlin.Unit"),
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Comparable", "Comparable",
|
||||
pair("compareTo(T)", "fun compareTo(other: T): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Enum", "Enum",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("name()", "fun name(): kotlin.String"),
|
||||
pair("ordinal()", "fun ordinal(): kotlin.Int"),
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.annotation.Annotation", "Annotation",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("toString()", "fun toString(): kotlin.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Iterable", "Iterable",
|
||||
pair("iterator()", "fun iterator(): kotlin.Iterator<T>")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Iterable", "MutableIterable",
|
||||
pair("iterator()", "fun iterator(): kotlin.MutableIterator<T>")
|
||||
);
|
||||
|
||||
put(b, "java.util.Iterator", "Iterator",
|
||||
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
|
||||
pair("next()", "fun next(): T")
|
||||
);
|
||||
|
||||
put(b, "java.util.Iterator", "MutableIterator",
|
||||
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
|
||||
pair("next()", "fun next(): T"),
|
||||
pair("remove()", "fun remove(): kotlin.Unit")
|
||||
);
|
||||
|
||||
put(b, "java.util.Collection", "Collection",
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
|
||||
pair("size()", "fun size(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.Collection", "MutableCollection",
|
||||
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
|
||||
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
|
||||
pair("clear()", "fun clear(): kotlin.Unit"),
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
|
||||
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("size()", "fun size(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.List", "List",
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("get(int)", "fun get(index: kotlin.Int): E"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
|
||||
pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
|
||||
pair("listIterator()", "fun listIterator(): kotlin.ListIterator<E>"),
|
||||
pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.ListIterator<E>"),
|
||||
pair("size()", "fun size(): kotlin.Int"),
|
||||
pair("subList(int, int)", "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.List<E>")
|
||||
);
|
||||
|
||||
put(b, "java.util.List", "MutableList",
|
||||
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
|
||||
pair("add(int, E)", "fun add(index: kotlin.Int, element: E): kotlin.Unit"),
|
||||
pair("addAll(int, java.util.Collection<? extends E>)", "fun addAll(index: kotlin.Int, c: kotlin.Collection<E>): kotlin.Boolean"),
|
||||
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
|
||||
pair("clear()", "fun clear(): kotlin.Unit"),
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("get(int)", "fun get(index: kotlin.Int): E"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
|
||||
pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
|
||||
pair("listIterator()", "fun listIterator(): kotlin.MutableListIterator<E>"),
|
||||
pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.MutableListIterator<E>"),
|
||||
pair("remove(int)", "fun remove(index: kotlin.Int): E"),
|
||||
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("set(int, E)", "fun set(index: kotlin.Int, element: E): E"),
|
||||
pair("size()", "fun size(): kotlin.Int"),
|
||||
pair("subList(int, int)", "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.MutableList<E>")
|
||||
);
|
||||
|
||||
put(b, "java.util.Set", "Set",
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
|
||||
pair("size()", "fun size(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.Set", "MutableSet",
|
||||
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
|
||||
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
|
||||
pair("clear()", "fun clear(): kotlin.Unit"),
|
||||
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
|
||||
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
|
||||
pair("size()", "fun size(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.Map", "Map",
|
||||
pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("entrySet()", "fun entrySet(): kotlin.Set<kotlin.Map.Entry<K, V>>"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("keySet()", "fun keySet(): kotlin.Set<K>"),
|
||||
pair("size()", "fun size(): kotlin.Int"),
|
||||
pair("values()", "fun values(): kotlin.Collection<V>")
|
||||
);
|
||||
|
||||
put(b, "java.util.Map", "MutableMap",
|
||||
pair("clear()", "fun clear(): kotlin.Unit"),
|
||||
pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("entrySet()", "fun entrySet(): kotlin.MutableSet<kotlin.MutableMap.MutableEntry<K, V>>"),
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
|
||||
pair("keySet()", "fun keySet(): kotlin.MutableSet<K>"),
|
||||
pair("put(K, V)", "fun put(key: K, value: V): V?"),
|
||||
pair("putAll(java.util.Map<? extends K,? extends V>)", "fun putAll(m: kotlin.Map<out K, V>): kotlin.Unit"),
|
||||
pair("remove(java.lang.Object)", "fun remove(key: kotlin.Any?): V?"),
|
||||
pair("size()", "fun size(): kotlin.Int"),
|
||||
pair("values()", "fun values(): kotlin.MutableCollection<V>")
|
||||
);
|
||||
|
||||
put(b, "java.util.Map.Entry", "Map.Entry",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("getKey()", "fun getKey(): K"),
|
||||
pair("getValue()", "fun getValue(): V"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.Map.Entry", "MutableMap.MutableEntry",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
|
||||
pair("getKey()", "fun getKey(): K"),
|
||||
pair("getValue()", "fun getValue(): V"),
|
||||
pair("hashCode()", "fun hashCode(): kotlin.Int"),
|
||||
pair("setValue(V)", "fun setValue(value: V): V")
|
||||
);
|
||||
|
||||
put(b, "java.util.ListIterator", "ListIterator",
|
||||
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
|
||||
pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"),
|
||||
pair("next()", "fun next(): T"),
|
||||
pair("nextIndex()", "fun nextIndex(): kotlin.Int"),
|
||||
pair("previous()", "fun previous(): T"),
|
||||
pair("previousIndex()", "fun previousIndex(): kotlin.Int")
|
||||
);
|
||||
|
||||
put(b, "java.util.ListIterator", "MutableListIterator",
|
||||
pair("add(E)", "fun add(e: T): kotlin.Unit"),
|
||||
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
|
||||
pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"),
|
||||
pair("next()", "fun next(): T"),
|
||||
pair("nextIndex()", "fun nextIndex(): kotlin.Int"),
|
||||
pair("previous()", "fun previous(): T"),
|
||||
pair("previousIndex()", "fun previousIndex(): kotlin.Int"),
|
||||
pair("remove()", "fun remove(): kotlin.Unit"),
|
||||
pair("set(E)", "fun set(e: T): kotlin.Unit")
|
||||
);
|
||||
|
||||
map = b.build();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaMethodDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmSignaturePackage;
|
||||
@@ -57,10 +58,12 @@ public class SignaturesPropagationData {
|
||||
KotlinToJvmSignatureMapper.class.getClassLoader()
|
||||
).iterator().next();
|
||||
|
||||
private final JavaMethodDescriptor autoMethodDescriptor;
|
||||
|
||||
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
||||
private final ValueParameters modifiedValueParameters;
|
||||
private final JetType modifiedReturnType;
|
||||
|
||||
private final JetType modifiedReturnType;
|
||||
private final List<String> signatureErrors = Lists.newArrayList();
|
||||
private final List<FunctionDescriptor> superFunctions;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
||||
@@ -76,7 +79,7 @@ public class SignaturesPropagationData {
|
||||
) {
|
||||
this.containingClass = containingClass;
|
||||
|
||||
JavaMethodDescriptor autoMethodDescriptor =
|
||||
autoMethodDescriptor =
|
||||
createAutoMethodDescriptor(containingClass, method, autoReturnType, receiverType, autoValueParameters, autoTypeParameters);
|
||||
|
||||
superFunctions = getSuperFunctionsForMethod(method, autoMethodDescriptor, containingClass);
|
||||
@@ -150,6 +153,8 @@ public class SignaturesPropagationData {
|
||||
private JetType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull JetType autoType // type built by JavaTypeTransformer
|
||||
) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return autoType;
|
||||
|
||||
List<TypeAndVariance> typesFromSuperMethods = ContainerUtil.map(superFunctions,
|
||||
new Function<FunctionDescriptor, TypeAndVariance>() {
|
||||
@Override
|
||||
@@ -162,6 +167,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private List<TypeParameterDescriptor> modifyTypeParametersAccordingToSuperMethods(List<TypeParameterDescriptor> autoTypeParameters) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return autoTypeParameters;
|
||||
|
||||
List<TypeParameterDescriptor> result = Lists.newArrayList();
|
||||
|
||||
for (TypeParameterDescriptor autoParameter : autoTypeParameters) {
|
||||
@@ -215,7 +222,7 @@ public class SignaturesPropagationData {
|
||||
new Function<FunctionDescriptor, TypeAndName>() {
|
||||
@Override
|
||||
public TypeAndName fun(FunctionDescriptor superFunction) {
|
||||
ReceiverParameterDescriptor receiver = superFunction.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = superFunction.getExtensionReceiverParameter();
|
||||
int index = receiver != null ? originalIndex - 1 : originalIndex;
|
||||
if (index == -1) {
|
||||
assert receiver != null : "can't happen: index is -1, while function is not extension";
|
||||
@@ -318,7 +325,7 @@ public class SignaturesPropagationData {
|
||||
boolean someSupersNotExtension = false;
|
||||
|
||||
for (FunctionDescriptor superFunction : superFunctions) {
|
||||
if (superFunction.getReceiverParameter() != null) {
|
||||
if (superFunction.getExtensionReceiverParameter() != null) {
|
||||
someSupersExtension = true;
|
||||
}
|
||||
else {
|
||||
@@ -343,7 +350,7 @@ public class SignaturesPropagationData {
|
||||
boolean someSupersNotVararg = false;
|
||||
for (FunctionDescriptor superFunction : superFunctions) {
|
||||
int originalIndex = originalParam.getIndex();
|
||||
int index = superFunction.getReceiverParameter() != null ? originalIndex - 1 : originalIndex;
|
||||
int index = superFunction.getExtensionReceiverParameter() != null ? originalIndex - 1 : originalIndex;
|
||||
if (index != -1 && superFunction.getValueParameters().get(index).getVarargElementType() != null) {
|
||||
someSupersVararg = true;
|
||||
}
|
||||
@@ -399,9 +406,9 @@ public class SignaturesPropagationData {
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
if (autoType.isError()) {
|
||||
return autoType;
|
||||
}
|
||||
if (autoType.isError()) return autoType;
|
||||
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return autoType;
|
||||
|
||||
boolean resultNullable = typeMustBeNullable(autoType, typesFromSuper, howThisTypeIsUsed);
|
||||
ClassifierDescriptor resultClassifier = modifyTypeClassifier(autoType, typesFromSuper);
|
||||
@@ -430,11 +437,14 @@ public class SignaturesPropagationData {
|
||||
@NotNull ClassifierDescriptor classifier,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
if (typesFromSuper.isEmpty()) return autoType.getArguments();
|
||||
|
||||
List<TypeProjection> autoArguments = autoType.getArguments();
|
||||
|
||||
if (!(classifier instanceof ClassDescriptor)) {
|
||||
assert autoArguments.isEmpty() :
|
||||
"Unexpected type arguments when type constructor is not ClassDescriptor, type = " + autoType;
|
||||
"Unexpected type arguments when type constructor is not ClassDescriptor, type = " + autoType +
|
||||
", classifier = " + classifier + ", classifier class = " + classifier.getClass();
|
||||
return autoArguments;
|
||||
}
|
||||
|
||||
@@ -462,6 +472,8 @@ public class SignaturesPropagationData {
|
||||
@NotNull TypeProjection argument,
|
||||
@NotNull List<TypeProjectionAndVariance> projectionsFromSuper
|
||||
) {
|
||||
if (projectionsFromSuper.isEmpty()) return argument.getProjectionKind();
|
||||
|
||||
Set<Variance> projectionKindsInSuper = Sets.newLinkedHashSet();
|
||||
for (TypeProjectionAndVariance projectionAndVariance : projectionsFromSuper) {
|
||||
projectionKindsInSuper.add(projectionAndVariance.typeProjection.getProjectionKind());
|
||||
@@ -575,7 +587,7 @@ public class SignaturesPropagationData {
|
||||
boolean someSupersCovariantNullable = false;
|
||||
boolean someSupersNotNull = false;
|
||||
for (TypeAndVariance typeFromSuper : typesFromSuper) {
|
||||
if (!typeFromSuper.type.isNullable()) {
|
||||
if (!TypeUtils.isNullableType(typeFromSuper.type)) {
|
||||
someSupersNotNull = true;
|
||||
}
|
||||
else {
|
||||
@@ -590,23 +602,23 @@ public class SignaturesPropagationData {
|
||||
|
||||
if (someSupersNotNull && someSupersNotCovariantNullable) {
|
||||
reportError("Incompatible types in superclasses: " + typesFromSuper);
|
||||
return autoType.isNullable();
|
||||
return TypeUtils.isNullableType(autoType);
|
||||
}
|
||||
else if (someSupersNotNull) {
|
||||
return false;
|
||||
}
|
||||
else if (someSupersNotCovariantNullable || someSupersCovariantNullable) {
|
||||
boolean annotatedAsNotNull = howThisTypeIsUsed != TYPE_ARGUMENT && !autoType.isNullable();
|
||||
boolean annotatedAsNotNull = howThisTypeIsUsed != TYPE_ARGUMENT && !TypeUtils.isNullableType(autoType);
|
||||
|
||||
if (annotatedAsNotNull && someSupersNotCovariantNullable) {
|
||||
DescriptorRenderer renderer = DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES;
|
||||
DescriptorRenderer renderer = DescriptorRenderer.SHORT_NAMES_IN_TYPES;
|
||||
reportError("In superclass type is nullable: " + typesFromSuper + ", in subclass it is not: " + renderer.renderType(autoType));
|
||||
return true;
|
||||
}
|
||||
|
||||
return !annotatedAsNotNull;
|
||||
}
|
||||
return autoType.isNullable();
|
||||
return TypeUtils.isNullableType(autoType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -616,7 +628,7 @@ public class SignaturesPropagationData {
|
||||
) {
|
||||
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
||||
if (!(classifier instanceof ClassDescriptor)) {
|
||||
assert classifier != null : "no declaration descriptor for type " + autoType;
|
||||
assert classifier != null : "no declaration descriptor for type " + autoType + ", auto method descriptor: " + autoMethodDescriptor;
|
||||
|
||||
if (classifier instanceof TypeParameterDescriptor && autoTypeParameterToModified.containsKey(classifier)) {
|
||||
return autoTypeParameterToModified.get(classifier);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.KotlinToJavaTypesMap;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
||||
@@ -72,7 +73,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
|
||||
@Override
|
||||
public JetType visitNullableType(@NotNull JetNullableType nullableType, Void aVoid) {
|
||||
if (!originalType.isNullable() && typeUsage != TYPE_ARGUMENT) {
|
||||
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
|
||||
}
|
||||
@@ -83,7 +84,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
|
||||
@Override
|
||||
public JetType visitFunctionType(@NotNull JetFunctionType type, Void data) {
|
||||
return visitCommonType(type.getReceiverTypeRef() == null
|
||||
return visitCommonType(type.getReceiverTypeReference() == null
|
||||
? KotlinBuiltIns.getInstance().getFunction(type.getParameters().size())
|
||||
: KotlinBuiltIns.getInstance().getExtensionFunction(type.getParameters().size()), type);
|
||||
}
|
||||
@@ -133,6 +134,8 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
List<TypeProjection> arguments = originalType.getArguments();
|
||||
|
||||
if (arguments.size() != type.getTypeArgumentsAsTypes().size()) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) return originalType;
|
||||
|
||||
throw new AlternativeSignatureMismatchException("'%s' type in method signature has %d type arguments, while '%s' in alternative signature has %d of them",
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), arguments.size(), type.getText(),
|
||||
type.getTypeArgumentsAsTypes().size());
|
||||
@@ -185,7 +188,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
if (type instanceof JetUserType) {
|
||||
JetTypeProjection typeProjection = ((JetUserType) type).getTypeArguments().get(i);
|
||||
altProjectionKind = TypeResolver.resolveProjectionKind(typeProjection.getProjectionKind());
|
||||
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT) {
|
||||
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT && !JavaPackage.getPLATFORM_TYPES()) {
|
||||
throw new AlternativeSignatureMismatchException("Projection kind mismatch, actual: %s, in alternative signature: %s",
|
||||
projectionKind, altProjectionKind);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeFieldSignatureData;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
|
||||
@@ -94,6 +95,12 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
returnType, typeParameters, hasSuperMethods);
|
||||
|
||||
if (data.isAnnotated() && !data.hasErrors()) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) {
|
||||
// We only take parameter names from the @KotlinSignature
|
||||
return new AlternativeMethodSignature(returnType, receiverType,
|
||||
AlternativeMethodSignatureData.updateNames(valueParameters, data.getValueParameters()),
|
||||
typeParameters, Collections.<String>emptyList(), true);
|
||||
}
|
||||
return new AlternativeMethodSignature(data.getReturnType(), receiverType, data.getValueParameters(), data.getTypeParameters(),
|
||||
Collections.<String>emptyList(), true);
|
||||
}
|
||||
@@ -113,6 +120,9 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
new AlternativeFieldSignatureData(externalAnnotationResolver, field, returnType, project, isVar);
|
||||
|
||||
if (data.isAnnotated() && !data.hasErrors()) {
|
||||
if (JavaPackage.getPLATFORM_TYPES()) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
return new AlternativeFieldSignature(data.getReturnType(), null);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,14 @@ public class JavaAnnotationImpl extends JavaElementImpl<PsiAnnotation> implement
|
||||
@Nullable
|
||||
public ClassId getClassId() {
|
||||
PsiClass resolved = resolvePsi();
|
||||
return resolved == null ? null : computeClassId(resolved);
|
||||
if (resolved != null) return computeClassId(resolved);
|
||||
|
||||
// External annotations do not have PSI behind them,
|
||||
// so we can only heuristically reconstruct annotation class ids from qualified names
|
||||
String qualifiedName = getPsi().getQualifiedName();
|
||||
if (qualifiedName != null) return ClassId.topLevel(new FqName(qualifiedName));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
@@ -43,4 +44,11 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotNullCompileTimeConstant(@NotNull JavaField field) {
|
||||
// PsiUtil.isCompileTimeConstant returns false for null-initialized fields,
|
||||
// see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression()
|
||||
return PsiUtil.isCompileTimeConstant(((JavaFieldImpl) field).getPsi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
package org.jetbrains.jet.lang.resolve.kotlin
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider
|
||||
import com.google.common.collect.Lists
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationChecker
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.descriptors.MemberDescriptor
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder
|
||||
import org.jetbrains.jet.lang.resolve.annotations.hasPlatformStaticAnnotation
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
@@ -30,21 +28,40 @@ import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.jet.lang.descriptors.Visibilities
|
||||
import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
|
||||
public object JavaDeclarationCheckerProvider : AdditionalCheckerProvider {
|
||||
|
||||
override val annotationCheckers: List<AnnotationChecker> = listOf(PlatformStaticAnnotationChecker())
|
||||
override val annotationCheckers: List<AnnotationChecker> = listOf(PlatformStaticAnnotationChecker(), LocalFunInlineChecker())
|
||||
}
|
||||
|
||||
public class LocalFunInlineChecker : AnnotationChecker {
|
||||
|
||||
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
||||
if (descriptor.hasInlineAnnotation() &&
|
||||
declaration is JetNamedFunction &&
|
||||
descriptor is FunctionDescriptor &&
|
||||
descriptor.getVisibility() == Visibilities.LOCAL) {
|
||||
diagnosticHolder.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PlatformStaticAnnotationChecker : AnnotationChecker {
|
||||
|
||||
override fun check(declaration: JetDeclaration, descriptor: MemberDescriptor, diagnosticHolder: DiagnosticHolder) {
|
||||
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
||||
if (descriptor.hasPlatformStaticAnnotation()) {
|
||||
if (declaration is JetNamedFunction) {
|
||||
val insideObject = DescriptorUtils.containerKindIs(descriptor, ClassKind.OBJECT)
|
||||
val insideClassObject = DescriptorUtils.containerKindIs(descriptor, ClassKind.CLASS_OBJECT)
|
||||
|
||||
if (!insideObject && !(insideClassObject && DescriptorUtils.containerKindIs(descriptor.getContainingDeclaration(), ClassKind.CLASS))) {
|
||||
if (!insideObject && !(insideClassObject && DescriptorUtils.containerKindIs(descriptor.getContainingDeclaration()!!, ClassKind.CLASS))) {
|
||||
diagnosticHolder.report(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT.on(declaration, descriptor));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,11 @@ public class VirtualFileKotlinClass private(
|
||||
deprecated("Use KotlinBinaryClassCache")
|
||||
fun create(file: VirtualFile): VirtualFileKotlinClass? {
|
||||
assert(file.getFileType() == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" }
|
||||
val byteContent = file.contentsToByteArray()
|
||||
if (byteContent.isEmpty()) return null
|
||||
|
||||
try {
|
||||
return FileBasedKotlinClass.create(file.contentsToByteArray()) {
|
||||
return FileBasedKotlinClass.create(byteContent) {
|
||||
name, header, innerClasses ->
|
||||
VirtualFileKotlinClass(file, name, header, innerClasses)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.analyzer
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.di.InjectorForMacros
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.types.TypeUtils
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
|
||||
@@ -108,9 +108,9 @@ public class CheckerTestUtil {
|
||||
});
|
||||
// this code is used in tests and in internal action 'copy current file as diagnostic test'
|
||||
//noinspection TestOnlyProblems
|
||||
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.AUTOCAST).keySet()) {
|
||||
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.SMARTCAST).keySet()) {
|
||||
if (PsiTreeUtil.isAncestor(root, expression, false)) {
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.AUTOCAST));
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.SMARTCAST));
|
||||
}
|
||||
}
|
||||
return debugAnnotations;
|
||||
@@ -411,7 +411,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
|
||||
public static class DebugInfoDiagnosticFactory extends DiagnosticFactory<DebugInfoDiagnostic> {
|
||||
public static final DebugInfoDiagnosticFactory AUTOCAST = new DebugInfoDiagnosticFactory("AUTOCAST");
|
||||
public static final DebugInfoDiagnosticFactory SMARTCAST = new DebugInfoDiagnosticFactory("SMARTCAST");
|
||||
public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE");
|
||||
public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET");
|
||||
public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED");
|
||||
|
||||
@@ -37,12 +37,14 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
|
||||
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
|
||||
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
|
||||
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -51,7 +53,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForBodyResolve {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final GlobalContext globalContext;
|
||||
private final StorageManager storageManager;
|
||||
@@ -73,15 +75,17 @@ public class InjectorForBodyResolve {
|
||||
private final DescriptorResolver descriptorResolver;
|
||||
private final DelegatedPropertyResolver delegatedPropertyResolver;
|
||||
private final TypeResolver typeResolver;
|
||||
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
|
||||
private final QualifiedExpressionResolver qualifiedExpressionResolver;
|
||||
private final CallResolverExtensionProvider callResolverExtensionProvider;
|
||||
private final CallCompleter callCompleter;
|
||||
private final CandidateResolver candidateResolver;
|
||||
private final ControlFlowAnalyzer controlFlowAnalyzer;
|
||||
private final DeclarationsChecker declarationsChecker;
|
||||
private final ModifiersChecker modifiersChecker;
|
||||
private final FunctionAnalyzerExtension functionAnalyzerExtension;
|
||||
private final ScriptBodyResolver scriptBodyResolver;
|
||||
|
||||
|
||||
public InjectorForBodyResolve(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@@ -110,12 +114,14 @@ public class InjectorForBodyResolve {
|
||||
this.descriptorResolver = new DescriptorResolver();
|
||||
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
|
||||
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
|
||||
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
|
||||
this.candidateResolver = new CandidateResolver();
|
||||
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
|
||||
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
|
||||
this.declarationsChecker = new DeclarationsChecker();
|
||||
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
|
||||
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
|
||||
this.scriptBodyResolver = new ScriptBodyResolver();
|
||||
|
||||
@@ -176,6 +182,7 @@ public class InjectorForBodyResolve {
|
||||
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(moduleDescriptor);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -183,8 +190,8 @@ public class InjectorForBodyResolve {
|
||||
|
||||
controlFlowAnalyzer.setTrace(bindingTrace);
|
||||
|
||||
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
|
||||
declarationsChecker.setDescriptorResolver(descriptorResolver);
|
||||
declarationsChecker.setModifiersChecker(modifiersChecker);
|
||||
declarationsChecker.setTrace(bindingTrace);
|
||||
|
||||
functionAnalyzerExtension.setTrace(bindingTrace);
|
||||
@@ -192,13 +199,13 @@ public class InjectorForBodyResolve {
|
||||
scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public BodyResolver getBodyResolver() {
|
||||
return this.bodyResolver;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
|
||||
@@ -51,7 +52,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForLazyResolve {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final GlobalContext globalContext;
|
||||
private final StorageManager storageManager;
|
||||
@@ -74,6 +75,7 @@ public class InjectorForLazyResolve {
|
||||
private final DescriptorResolver descriptorResolver;
|
||||
private final DelegatedPropertyResolver delegatedPropertyResolver;
|
||||
private final TypeResolver typeResolver;
|
||||
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
|
||||
private final QualifiedExpressionResolver qualifiedExpressionResolver;
|
||||
private final CallResolverExtensionProvider callResolverExtensionProvider;
|
||||
private final CallCompleter callCompleter;
|
||||
@@ -81,7 +83,7 @@ public class InjectorForLazyResolve {
|
||||
private final JetImportsFactory jetImportsFactory;
|
||||
private final ScopeProvider scopeProvider;
|
||||
private final ScriptBodyResolver scriptBodyResolver;
|
||||
|
||||
|
||||
public InjectorForLazyResolve(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@@ -112,6 +114,7 @@ public class InjectorForLazyResolve {
|
||||
this.descriptorResolver = new DescriptorResolver();
|
||||
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
|
||||
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
|
||||
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
|
||||
this.candidateResolver = new CandidateResolver();
|
||||
@@ -175,6 +178,7 @@ public class InjectorForLazyResolve {
|
||||
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(moduleDescriptor);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -185,13 +189,13 @@ public class InjectorForLazyResolve {
|
||||
scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public ResolveSession getResolveSession() {
|
||||
return this.resolveSession;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
@@ -45,7 +46,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForMacros {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final ModuleDescriptor moduleDescriptor;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
@@ -57,6 +58,7 @@ public class InjectorForMacros {
|
||||
private final AdditionalCheckerProvider additionalCheckerProvider;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
private final TypeResolver typeResolver;
|
||||
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
|
||||
private final QualifiedExpressionResolver qualifiedExpressionResolver;
|
||||
private final CallExpressionResolver callExpressionResolver;
|
||||
private final DescriptorResolver descriptorResolver;
|
||||
@@ -69,7 +71,7 @@ public class InjectorForMacros {
|
||||
private final ArgumentTypeResolver argumentTypeResolver;
|
||||
private final CallCompleter callCompleter;
|
||||
private final CandidateResolver candidateResolver;
|
||||
|
||||
|
||||
public InjectorForMacros(
|
||||
@NotNull Project project,
|
||||
@NotNull ModuleDescriptor moduleDescriptor
|
||||
@@ -85,6 +87,7 @@ public class InjectorForMacros {
|
||||
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider.Empty.INSTANCE$;
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
|
||||
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
|
||||
this.callExpressionResolver = new CallExpressionResolver();
|
||||
this.descriptorResolver = new DescriptorResolver();
|
||||
@@ -127,6 +130,7 @@ public class InjectorForMacros {
|
||||
annotationResolver.setTypeResolver(typeResolver);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(moduleDescriptor);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -151,21 +155,21 @@ public class InjectorForMacros {
|
||||
candidateResolver.setArgumentTypeResolver(argumentTypeResolver);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public ExpressionTypingServices getExpressionTypingServices() {
|
||||
return this.expressionTypingServices;
|
||||
}
|
||||
|
||||
|
||||
public ExpressionTypingComponents getExpressionTypingComponents() {
|
||||
return this.expressionTypingComponents;
|
||||
}
|
||||
|
||||
|
||||
public CallResolver getCallResolver() {
|
||||
return this.callResolver;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,12 +40,14 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
|
||||
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
|
||||
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
|
||||
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
|
||||
@@ -61,7 +63,7 @@ import javax.annotation.PreDestroy;
|
||||
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
|
||||
@SuppressWarnings("all")
|
||||
public class InjectorForTopDownAnalyzerBasic {
|
||||
|
||||
|
||||
private final Project project;
|
||||
private final GlobalContext globalContext;
|
||||
private final StorageManager storageManager;
|
||||
@@ -86,12 +88,14 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
private final DescriptorResolver descriptorResolver;
|
||||
private final DelegatedPropertyResolver delegatedPropertyResolver;
|
||||
private final TypeResolver typeResolver;
|
||||
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
|
||||
private final QualifiedExpressionResolver qualifiedExpressionResolver;
|
||||
private final CallResolverExtensionProvider callResolverExtensionProvider;
|
||||
private final CallCompleter callCompleter;
|
||||
private final CandidateResolver candidateResolver;
|
||||
private final ControlFlowAnalyzer controlFlowAnalyzer;
|
||||
private final DeclarationsChecker declarationsChecker;
|
||||
private final ModifiersChecker modifiersChecker;
|
||||
private final FunctionAnalyzerExtension functionAnalyzerExtension;
|
||||
private final ScriptBodyResolver scriptBodyResolver;
|
||||
private final DeclarationResolver declarationResolver;
|
||||
@@ -101,7 +105,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
private final OverrideResolver overrideResolver;
|
||||
private final TypeHierarchyResolver typeHierarchyResolver;
|
||||
private final ScriptHeaderResolver scriptHeaderResolver;
|
||||
|
||||
|
||||
public InjectorForTopDownAnalyzerBasic(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@@ -133,12 +137,14 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
this.descriptorResolver = new DescriptorResolver();
|
||||
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
|
||||
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
|
||||
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
|
||||
this.candidateResolver = new CandidateResolver();
|
||||
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
|
||||
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
|
||||
this.declarationsChecker = new DeclarationsChecker();
|
||||
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
|
||||
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
|
||||
this.scriptBodyResolver = new ScriptBodyResolver();
|
||||
this.declarationResolver = new DeclarationResolver();
|
||||
@@ -225,6 +231,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
typeResolver.setAnnotationResolver(annotationResolver);
|
||||
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
|
||||
typeResolver.setModuleDescriptor(moduleDescriptor);
|
||||
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
|
||||
|
||||
@@ -232,8 +239,8 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
|
||||
controlFlowAnalyzer.setTrace(bindingTrace);
|
||||
|
||||
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
|
||||
declarationsChecker.setDescriptorResolver(descriptorResolver);
|
||||
declarationsChecker.setModifiersChecker(modifiersChecker);
|
||||
declarationsChecker.setTrace(bindingTrace);
|
||||
|
||||
functionAnalyzerExtension.setTrace(bindingTrace);
|
||||
@@ -266,21 +273,21 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
scriptHeaderResolver.setTrace(bindingTrace);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public ModuleDescriptor getModuleDescriptor() {
|
||||
return this.moduleDescriptor;
|
||||
}
|
||||
|
||||
|
||||
public TopDownAnalyzer getTopDownAnalyzer() {
|
||||
return this.topDownAnalyzer;
|
||||
}
|
||||
|
||||
|
||||
public LazyTopDownAnalyzer getLazyTopDownAnalyzer() {
|
||||
return this.lazyTopDownAnalyzer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.
|
||||
*/
|
||||
|
||||
/* The following code was generated by JFlex 1.4.3 on 7/15/14 9:40 PM */
|
||||
/* The following code was generated by JFlex 1.4.3 on 10/13/14 2:48 PM */
|
||||
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
@@ -28,8 +12,8 @@ import java.lang.Character;
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 7/15/14 9:40 PM from the specification file
|
||||
* <tt>C:/Projects/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex</tt>
|
||||
* on 10/13/14 2:48 PM from the specification file
|
||||
* <tt>/Users/abreslav/work/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex</tt>
|
||||
*/
|
||||
class _KDocLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
@@ -569,11 +553,6 @@ class _KDocLexer implements FlexLexer {
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 5:
|
||||
{ if (isLastToken()) return KDocTokens.END;
|
||||
else return KDocTokens.TEXT;
|
||||
}
|
||||
case 11: break;
|
||||
case 3:
|
||||
{ if (yytextContainLineBreaks()) {
|
||||
yybegin(LINE_BEGINNING);
|
||||
@@ -583,6 +562,11 @@ class _KDocLexer implements FlexLexer {
|
||||
return KDocTokens.TEXT; // internal white space
|
||||
}
|
||||
}
|
||||
case 11: break;
|
||||
case 5:
|
||||
{ if (isLastToken()) return KDocTokens.END;
|
||||
else return KDocTokens.TEXT;
|
||||
}
|
||||
case 12: break;
|
||||
case 9:
|
||||
{ yybegin(CONTENTS);
|
||||
@@ -594,9 +578,9 @@ class _KDocLexer implements FlexLexer {
|
||||
return KDocTokens.WIKI_LINK_CLOSE;
|
||||
}
|
||||
case 14: break;
|
||||
case 6:
|
||||
case 8:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
|
||||
return KDocTokens.WIKI_LINK_OPEN;
|
||||
}
|
||||
case 15: break;
|
||||
case 10:
|
||||
@@ -604,24 +588,24 @@ class _KDocLexer implements FlexLexer {
|
||||
return KDocTokens.START;
|
||||
}
|
||||
case 16: break;
|
||||
case 1:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 17: break;
|
||||
case 6:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
|
||||
}
|
||||
case 18: break;
|
||||
case 2:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 17: break;
|
||||
case 1:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 18: break;
|
||||
case 19: break;
|
||||
case 4:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
case 19: break;
|
||||
case 8:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.WIKI_LINK_OPEN;
|
||||
}
|
||||
case 20: break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
|
||||
@@ -157,8 +157,6 @@ public interface JetControlFlowBuilder {
|
||||
@NotNull List<PseudoValue> inputValues
|
||||
);
|
||||
|
||||
void compilationError(@NotNull JetElement element, @NotNull String message);
|
||||
|
||||
void write(
|
||||
@NotNull JetElement assignment,
|
||||
@NotNull JetElement lValue,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user