Compare commits

...

298 Commits

Author SHA1 Message Date
Yan Zhulanow
255e028637 Exclude :daemon-common-new module in JPS as it's unused there 2021-03-03 16:17:26 +09:00
Yan Zhulanow
9d11494c64 Remove dependency on parcelize-runtime in the Parcelize compiler plugin 2021-03-03 15:48:04 +09:00
Yan Zhulanow
aab9c79a93 Remove CLI and some of daemon-related modules from IDE dependencies
These modules is not required by the plugin, and the plugin verifier
warns about unsatisfied dependencies of the modules.

CLI is needed in tests so a separate artifact is created instead.
2021-03-02 18:48:34 +09:00
Nikita Bobko
89a285b190 Merge remote-tracking branch 'origin/1.4.30' into 1.4.30-for-ide 2021-02-22 11:59:19 +01:00
Vladimir Dolzhenko
929b6dd92f Do not swallow PCE
#KT-39776 Fixed

(cherry picked from commit b8d1bbdd0d)
2021-02-22 10:44:39 +01:00
Dmitriy Dolovov
fbe977a7f5 Update Kotlin/Native: 1.4.31-release-146 2021-02-19 21:06:38 +03:00
Pavel Kirpichenkov
d0e09004ad Backport "Fix cache service for resolution anchors"
Use project cache correctly instead of storing values in instance fields
Move logger from instance field

Original commit: 59a10424e6a9be45fd25ad926957223e1b3b6744 (kotlin-ide)
2021-02-19 16:08:28 +03:00
Dmitriy Dolovov
65f9781398 Update Kotlin/Native: 1.4.31-dev-141 2021-02-19 11:11:54 +03:00
Dmitriy Dolovov
434c1995eb Update Kotlin/Native: 1.4.31-dev-141 2021-02-18 23:10:06 +03:00
Vladimir Dolzhenko
67b1c62ab2 Fix NPE
#KTIJ-898 Fixed

Original commit: 12d8e88b846f29598ca3904b49996bd6a9891ccd

(cherry picked from commit 6352814d45)
2021-02-18 18:21:03 +03:00
Vladimir Dolzhenko
6cbcb9ad27 Fixed NPE on StandaloneScriptRootsCache instantiation
Relates to ^EA-218043
#KTIJ-1137 Fixed

Original commit: 1d63a1b48d480b958ff44676c42b698a8ca5f64a

(cherry picked from commit 98ba379e07)
2021-02-18 18:21:02 +03:00
Vladimir Dolzhenko
4f82188b97 Lightweight hashCode calc for LibraryInfo
#EA-6040509 Fixed
#KTIJ-696 Fixed

(cherry picked from commit bf9fa4c9da)
2021-02-18 18:21:02 +03:00
Vladimir Dolzhenko
1a007ae7c7 Check declaration modifier for actual method to avoid freeze
Checking modifier aims to get rid of unnecessary resolve for methods in non MPP (the most) cases

Relates to #KTIJ-1200

(cherry picked from commit 872effc21e)
2021-02-18 18:21:01 +03:00
Sergey Igushkin
2d2343539c Fix extracted metadata for IDE erased when scopes conflict, KT-44845
The root cause was that extractors for different scopes used the same
base directory, and each erased its contents. Using different base dirs
fixes the issue.

Issue #KT-44845

(cherry picked from commit a719656118)
2021-02-18 18:21:01 +03:00
Vladimir Dolzhenko
d1814fbda4 Fix NPE
#KTIJ-898 Fixed

Original commit: 12d8e88b846f29598ca3904b49996bd6a9891ccd

(cherry picked from commit 6352814d45)
2021-02-16 15:33:22 +01:00
Vladimir Dolzhenko
4c61fb4579 Fixed NPE on StandaloneScriptRootsCache instantiation
Relates to ^EA-218043
#KTIJ-1137 Fixed

Original commit: 1d63a1b48d480b958ff44676c42b698a8ca5f64a

(cherry picked from commit 98ba379e07)
2021-02-16 15:29:25 +01:00
Vladimir Dolzhenko
e148cbede3 Lightweight hashCode calc for LibraryInfo
#EA-6040509 Fixed
#KTIJ-696 Fixed

(cherry picked from commit bf9fa4c9da)
2021-02-15 10:36:35 +01:00
Vladimir Dolzhenko
36d91aeec0 Check declaration modifier for actual method to avoid freeze
Checking modifier aims to get rid of unnecessary resolve for methods in non MPP (the most) cases

Relates to #KTIJ-1200

(cherry picked from commit 872effc21e)
2021-02-12 16:57:39 +01:00
Sergey Igushkin
2d14378b30 Fix extracted metadata for IDE erased when scopes conflict, KT-44845
The root cause was that extractors for different scopes used the same
base directory, and each erased its contents. Using different base dirs
fixes the issue.

Issue #KT-44845

(cherry picked from commit a719656118)
2021-02-12 18:52:26 +03:00
Nikita Bobko
e65a2cbad2 Fix typo 2021-02-10 13:52:17 +01:00
Nikita Bobko
74b4b0abe3 Fix typo 2021-02-10 13:51:02 +01:00
Nikita Bobko
b432dbd22a [1.4.30-only] Publish separate kotlin-stdlib-for-ide artifact for kotlin-ide needs
Publish separate `kotlin-stdlib-for-ide` artifact which include JvmBuiltins specifically for
needs of Kotlin IDE plugin in new infrastructure

KTIJ-1203

This commit is intended only for 1.4.30 branch of Kotlin repo and used as workaround.
KTIJ-1203 is fixed in kotlin/master without hacks

previous commit: 28f68f8414
2021-02-10 12:55:06 +01:00
Nikita Bobko
d44d1ac160 [1.4.30-only] Publish separate kotlin-stdlib-for-ide artifact for kotlin-ide needs
Publish separate `kotlin-stdlib-for-ide` artifact which include JvmBuiltins specifically for
needs of Kotlin IDE plugin in new infrastructure

KTIJ-1203

This commit is intended only for 1.4.30 branch of Kotlin repo and used as workaround.
KTIJ-1203 is fixed in kotlin/master without hacks

previous commit: 28f68f8414
2021-02-10 12:53:32 +01:00
Dmitry Gridin
cb3e2dd37d [notification] make title of new jvm ir shorter to avoid clipping
^KT-44523
^KT-44697
2021-02-08 11:44:21 +00:00
Stanislav Erokhin
bc20993b2f Regenerate tests: advance the year in the copyright 2021-02-05 15:57:38 +01:00
Dmitry Gridin
0eba4e7c88 [notification] add notification about new kotlin jvm ir backend
^KT-44523 Fixed
^KT-44697 Fixed
2021-02-05 11:08:26 +00:00
Yan Zhulanow
90ecf0fd45 Revert "[notification] add notification about new jvm ir backend"
This reverts commit 5a7c3451
2021-02-03 00:59:08 +09:00
Dmitriy Dolovov
8d2706ad8f Update Kotlin/Native: 1.4.30-release-115 2021-02-02 00:10:39 +03:00
Anton Yalyshev
fd948c0d31 Add change-notes for 1.4.30 release
(cherry picked from commit 3e59adc7f3)
2021-02-01 20:24:18 +03:00
Dmitriy Dolovov
2d8c18bc9b Update Kotlin/Native: 1.4.30-dev-112 2021-02-01 14:56:50 +03:00
Sergey Igushkin
f71f16292e Add API version 1.5 to accepted values in MPP language settings 2021-02-01 10:27:19 +03:00
Dmitriy Novozhilov
63b35c7600 Introduce ApiVersion.KOTLIN_1_5 2021-02-01 10:27:18 +03:00
Steven Schäfer
4d6a1a8fb6 JVM IR: Fix inline class mangling for calls to internal functions
...in a different module, e.g., using -Xfriend-paths.
2021-01-29 18:50:08 +01:00
Dmitry Gridin
5a7c34517e [notification] add notification about new jvm ir backend
^KT-44523 Fixed
2021-01-29 14:39:50 +00:00
Victor Petukhov
f9dd87890f Propagate all annotations during creating simple functional types
^KT-44563 Fixed
2021-01-29 14:11:11 +03:00
Mads Ager
5a686eac9e [JVM_IR] Reduce the amount of super suffixes on accesibility bridges.
The super suffix was used for any static field/method that needed
an accessor. We should only use it when that field or method is
inherited.

(cherry picked from commit ef36b81c67)
2021-01-28 04:20:50 -08:00
Vladimir Dolzhenko
ddc6238b37 Add LightClassUtil.getLightClassMethodsByName to avoid resolving all lightClassMethods and filtration later on
Relates to #KTIJ-1069
Relates to #EA-249999

(cherry picked from commit 6331a135c8)
2021-01-28 10:47:04 +01:00
Victor Petukhov
8995424f6d Propagate nullness flexibility into the result type from type variables in other constraints during result type finding, to prevent variable fixation to less flexible type
^KT-44540 Fixed

(cherry picked from commit 977ac7cbe7)
2021-01-27 18:49:31 +03:00
Dmitriy Dolovov
eb7961d2c2 Update Kotlin/Native: 1.4.30-dev-99 2021-01-27 14:55:46 +03:00
Sergey Shanshin
b2c972da00 Returned support for generic serializers in @UseSerializers (#4055)
Fixes Kotlin/kotlinx.serialization#1305

(cherry picked from commit 122d04b9fa)
2021-01-27 11:34:52 +03:00
Sergey Shanshin
2d2c9853b5 Returned support for nullable types by not null serializers
Fixes Kotlin/kotlinx.serialization#1265

(cherry picked from commit 10d9259df5)
2021-01-27 11:34:35 +03:00
Vladimir Dolzhenko
453a36acc6 Do not leak LowMemoryWatcher on plugin unload
#KT-44543 Fixed

(cherry picked from commit 8019dbe06c)
2021-01-26 16:14:44 +01:00
Dmitriy Dolovov
4038591d40 Update Kotlin/Native: 1.4.30-dev-93 2021-01-26 14:13:16 +03:00
Steven Schäfer
a9e5304d7e JVM: Take inline class mangling state into account for default methods 2021-01-25 18:23:06 +01:00
Victor Petukhov
5d59157371 Fix failing tests after 8bd78064be 2021-01-25 16:14:25 +03:00
Victor Petukhov
6b39e6f5ae Approximate definitely not-null types for type parameter's types if they are already not-null (has not-null upper bounds)
^KT-44440 Fixed

(cherry picked from commit f06a5321a6)
2021-01-25 15:45:44 +03:00
Victor Petukhov
510968ecde Do substitution of a type enhancement, not only lower and upper bounds
^KT-44439 Fixed

(cherry picked from commit 8bd78064be)
2021-01-25 12:50:28 +03:00
Victor Petukhov
1625afe876 Build type enhancement properly, by taking into account both bounds of the original flexible type
^KT-44420 Fixed

(cherry picked from commit 83c93aca2e)
2021-01-25 12:50:21 +03:00
Mikhail Zarechenskiy
a12121af0a Fix add import quick fix for unresolved conventional invoke operator
After adding extension invoke on DeepRecursiveFunction in 1.4,
 the compiler start reporting another error and now it doesn't write
 info about callable descriptor. Therefore it's needed to use another
 source of info for expression type

 ^KT-40926 Fixed
2021-01-22 21:13:48 +03:00
Mikhail Zarechenskiy
b499972dea Report more specific diagnostic for variable + invoke calls
Do not report same set of diagnostics for variable call if actual
 error was happened with a function candidate. Here the candidate is
 invoke function on DeepRecursiveFunction

 ^KT-40991 Fixed
 ^KT-41491 Fixed
 ^KT-40926 In Progress
2021-01-22 21:13:47 +03:00
Steven Schäfer
42ce1d603b JVM IR: Fix signature mapping for inline classes using new mangling
When resolving inline class methods in binary dependencies we look for
methods matching both the new and the old mangling scheme. On the IR
backend the method signature has to be computed for the inline class
replacement, since the logic for signature mangling is not contained in
the method signature mapping, unlike in the old backend.
2021-01-21 17:46:06 +01:00
Andrei Klunnyi
2f99eabfa4 KT-44250 [Sealed interfaces]: completion fails for 'when' with sealed
(cherry picked from commit 77ffc318f2)
2021-01-21 14:36:06 +01:00
Andrei Klunnyi
7f59152934 Revert "KT-44043 [Sealed interfaces]: quickfix for top level abstractions"
This reverts commit cef49675
2021-01-18 13:19:29 +01:00
Andrei Klunnyi
0eb57d6e50 Revert "KT-44043 [Sealed interfaces]: quickfix for nested -> to upper level"
This reverts commit 7f3b23ce
2021-01-18 13:11:13 +01:00
Andrei Klunnyi
b1655a14c6 Revert "KT-44043 [Sealed interfaces]: quickfix for nested -> to another file"
This reverts commit 94cc45ac
2021-01-18 13:10:32 +01:00
Andrei Klunnyi
f7627ec5e7 Revert "KT-44043 [Sealed interfaces]: tests"
This reverts commit be981a8f
2021-01-18 13:10:01 +01:00
Andrei Klunnyi
be981a8f58 KT-44043 [Sealed interfaces]: tests
So far, quick-fix tests infrastructure neither supports the check
for multiple files (several .before/.after pairs) nor multi module
structure. Provided tests are quite limited yet allow to make sure that
the fix in question appears in expected context and get activated.

^KT-44043 fixed

(cherry picked from commit eed27906e3)
2021-01-18 12:41:17 +01:00
Andrei Klunnyi
94cc45ac8b KT-44043 [Sealed interfaces]: quickfix for nested -> to another file
(cherry picked from commit 43cc022613)
2021-01-18 12:41:12 +01:00
Andrei Klunnyi
7f3b23ce19 KT-44043 [Sealed interfaces]: quickfix for nested -> to upper level
(cherry picked from commit da98fc4b07)
2021-01-18 12:41:07 +01:00
Andrei Klunnyi
cef496758c KT-44043 [Sealed interfaces]: quickfix for top level abstractions
(cherry picked from commit 521bebee0f)
2021-01-18 12:41:01 +01:00
sebastian.sellmair
6eb8468ad1 Add sourcesJar from metadata target to root multiplatform publication
^KT-44298 fixed
2021-01-13 16:11:33 +01:00
Ivan Gavrilovic
7bfbe986e6 Revert "Sort class members to ensure deterministic builds"
This reverts commit 4bf63a9539.

(cherry picked from commit a320152a03)
2021-01-13 22:52:19 +09:00
Ivan Gavrilovic
7b01df5844 KT-44020: Rename KAPT configuration used as task property
This is so AGP does not try to apply AndroidX substitution
to dependencies found in the annotation processor classpath.
AGP does this by checking if the configuration name starts
with "kapt".

Test: Kapt3Android42IT
(cherry picked from commit 1c8a25c106)
2021-01-13 16:32:26 +09:00
Mikhail Zarechenskiy
881907ca9d Show pre-released 1.5 version in configuration preferences
^KT-44116 Fixed
2021-01-12 18:12:09 +03:00
Ilya Goncharov
b742f769fd [Gradle, JS] Add possibility to set jvmArgs for dce process
^KT-44104 fixed

(cherry picked from commit df75cddcb8)
2021-01-12 16:52:59 +03:00
Dmitriy Dolovov
197102543b Update Kotlin/Native: 1.4.30-rc1-8 2021-01-12 13:23:30 +03:00
Ilya Chernikov
59cbbccca9 Do not check script discovery file extension
it is optional (so far), so this check was incorrect.
#KT-44117 fixed

(cherry picked from commit bd708da82c)
2021-01-12 10:09:52 +01:00
Denis.Zharkov
40486cdb39 Fix ultra light structure for @JvmRecord classes 2021-01-12 10:35:56 +03:00
Mikhail Glukhikh
065703c17c Fix broken ABI in DiagnosticFactory #KT-44145 Fixed
(cherry picked from commit 3f5e515bd6)
2021-01-12 10:29:30 +03:00
Ilya Chernikov
3f9ab89ec5 [minor] document -compiler-path option for kotlin runner 2021-01-11 19:38:43 +01:00
Ilya Chernikov
6411ab97b5 Implement -howtorun option for kotlin runner
Implement -no-stdlib argument support in kotlin runner

#KT-43534 fixed
2021-01-11 19:38:43 +01:00
Ilya Chernikov
3ca5011f6b Implement -no-stdlib argument support in kotlin runner
#KT-43294 fixed
2021-01-11 19:38:43 +01:00
Ilya Chernikov
3f919ec280 Implement -X arguments passing from kotlin runner to compiler 2021-01-11 19:38:43 +01:00
Ilya Chernikov
ffacf1eada Implement support for -Xdefault-script-extension cli option 2021-01-11 19:38:42 +01:00
Ilya Chernikov
77824e81a7 [minor] use new kotlin.io.path API in tests 2021-01-11 19:38:42 +01:00
Ilya Chernikov
f4ce103d17 Fix provided properties access generation
The presense of accessors in the descriptor led to the wrong code
generation in some cases.
#KT-43176 fixed
2021-01-11 19:38:42 +01:00
Alexander Udalov
805adfa8a1 Add warning if both -Xuse-ir and -Xuse-old-backend are passed
(cherry picked from commit 12078666c2)
2021-01-11 17:16:19 +01:00
Alexander Udalov
191cb849d7 Enable JVM IR by default if language version is >= 1.5
#KT-44021 Fixed

(cherry picked from commit cb3191769d)
2021-01-11 17:16:16 +01:00
Alexander Udalov
9a0b6a3774 Rename -Xno-use-ir -> -Xuse-old-backend, add Gradle option
As soon as JVM IR is enabled by default (in language version 1.5), use
the CLI argument `-Xuse-old-backend` or Gradle option `useOldBackend` to
switch to the old JVM backend.

(cherry picked from commit 22d0e5eb65)
2021-01-11 17:16:12 +01:00
Abduqodiri Qurbonzoda
7000218d44 Straighten Char-to-code and Char-to-digit conversions out #KT-23451
(cherry picked from commit 662787b12b)
2020-12-31 12:44:29 +03:00
Abduqodiri Qurbonzoda
9bf8040472 Locale-agnostic case conversions by default #KT-43023
(cherry picked from commit 1314adb6f7)
2020-12-30 17:00:15 +03:00
Svyatoslav Kuzmich
aa52e019e4 [Wasm] Support init blocks in inline classes 2020-12-30 15:17:00 +03:00
Svyatoslav Kuzmich
5c0e497e99 [JS IR] Support init blocks in inline classes 2020-12-30 15:17:00 +03:00
Roman Artemev
123d2c5fcc Add test for KT-42036
(cherry picked from commit 826985450e)
2020-12-30 11:14:08 +03:00
Victor Petukhov
05089eb3df Don't approximate abbreviation during substitution it as it can't be projected at top-level
^KT-42036 Fixed

(cherry picked from commit 30a5eee481)
2020-12-30 11:14:07 +03:00
Denis.Zharkov
14e65cdfec Revert "Fix ISE when inferring type of a property that delegates to itself"
This reverts commit 42e253929f.

The reason is that original change seems to be breaking (see KT-44137).

^KT-44137 Relates
^KT-37796 Open
2020-12-29 18:17:14 +03:00
Victor Petukhov
dce0f29b12 Add missed type arguments for a star projection into the enhanced type arguments list
(cherry picked from commit 27dd9484ba)
2020-12-29 12:38:46 +03:00
Andrei Klunnyi
85cc48feda KT-43941 [Sealed interfaces]: subclass intention
Restriction for sealed inheritors was relaxed. Instead of being nested
class members now they can be the members of the same module and
package.

(cherry picked from commit 3f287d344e)
2020-12-28 15:02:06 +01:00
Andrei Klunnyi
b365b8ceb4 KT-43941 [Sealed interfaces]: preliminary, J2K
(cherry picked from commit 1cac8b0d61)
2020-12-28 15:02:01 +01:00
Andrei Klunnyi
f142bfe47d KT-43941 [Sealed interfaces]: preliminary, code cleanup
(cherry picked from commit 86792131cd)
2020-12-28 15:01:57 +01:00
LepilkinaElena
9ecc74242b Update Kotlin/Native: 1.4.30-rc1-56 (#3999) 2020-12-27 10:15:00 +03:00
Simon Ogorodnik
41c79d8884 KT-40200: Fix main function detector in lazy resolve overload resolver
(cherry picked from commit 9bf2dfaa02)
2020-12-25 16:51:11 +03:00
Victor Petukhov
2dbd8e3cea Fix failing tests 2020-12-25 14:29:35 +03:00
Victor Petukhov
eaf0a6b34b Mute wasm tests around builder inference and callable references 2020-12-25 13:36:52 +03:00
Victor Petukhov
6a4a5be3f6 Fail calls constraints of which contain uninferred type parameter
^KT-44055 Fixed

It's possible only if there is a callable reference among subcalls which go though the old type inference (and the error for uninferred type parameter wasn't reported)
2020-12-25 13:36:48 +03:00
Victor Petukhov
851d5f1f18 Unwrap block expressions to report errors on them about not enough type information
^KT-44055 Fixed
2020-12-25 13:36:47 +03:00
Victor Petukhov
667603f4fb Report errors on callable references which contains postponed type variables in the receiver type 2020-12-25 13:36:47 +03:00
Victor Petukhov
f63e74a906 Reuse information from already recorder descriptor for some callable references and don't rewrite at slice 2020-12-25 13:36:47 +03:00
Victor Petukhov
cb68128280 Report error about uninferred type parameter for some special call' subcalls 2020-12-25 13:36:46 +03:00
Victor Petukhov
fdebc9c78f Don't create DONT_CARE type for CR and lambdas within builder inference calls
It leads to leak such type to the back-end. Calls within a builder call should be updated without marking CR and lambdas with DONT_CARE type.

^KT-43845 Fixed
^KT-43956 Fixed
^KT-42622 Fixed
2020-12-25 13:36:46 +03:00
Victor Petukhov
c9073fda91 Don't clean type info for containment operator if the resolution was unsuccessful, but all diagnostics were about only input types and non-strict only input types check was enabled 2020-12-25 13:36:41 +03:00
Victor Petukhov
6462ffc916 Compute type for callable references and lambdas inside not null assertion if couldn't get already recorded type 2020-12-25 13:36:36 +03:00
Victor Petukhov
2f7dea07b8 Move tests for builder inference into the corresponding directory 2020-12-25 13:30:42 +03:00
Andrei Klunnyi
e6f003fe95 KT-44043 Sealed interfaces: 201/203 compatibility fix
(cherry picked from commit faa24e3230)
2020-12-24 17:52:53 +01:00
Andrei Klunnyi
e51c3d8bfd KT-44075 Sealed interfaces: New Kotlin Class/File menu update
^KT-44075 Fixed
2020-12-24 14:27:26 +01:00
Ilmir Usmanov
9b56082e5b IC Mangling: correctly mangle inline default functions
#KT-43682 Fixed
2020-12-24 14:22:44 +01:00
Denis.Zharkov
42e253929f Fix ISE when inferring type of a property that delegates to itself
^KT-37796 Fixed
2020-12-24 15:41:42 +03:00
Denis.Zharkov
694d122d47 Fix AE: No receiver found on incomplete code with $-signs
^KT-24158 Fixed
2020-12-24 15:41:41 +03:00
Denis.Zharkov
47a6776a45 Fix light classes exception occurring on obfuscated Kotlin libraries
^KT-29454 Fixed
2020-12-24 15:41:41 +03:00
Denis.Zharkov
8bc0192ef5 Fix exceptions caused by cyclic dependency between ModuleDescriptor and JvmBuiltIns
^KT-39105 Fixed
^KT-42001 Fixed

See also EA-216604 and EA-211562
2020-12-24 15:41:41 +03:00
Denis.Zharkov
8b8c0bd008 Rename JvmBuiltInsSettings -> JvmBuiltInsCustomizer 2020-12-24 15:41:41 +03:00
Dmitriy Novozhilov
f1264cef06 [FE] Fix error message of SEALED_INHERITOR_IN_DIFFERENT_PACKAGE diagnostic 2020-12-24 14:53:26 +03:00
Dmitriy Novozhilov
eb6a643ba4 [FE] Detect recursion when typealias referenced as annotation in its RHS 2020-12-24 14:53:26 +03:00
Mikhail Glukhikh
1f13593c5c Make FileDescriptorForVisibilityCheck subtype of PackageFragmentDescriptor
#KT-20548 Fixed

(cherry picked from commit 107a825c5f)
2020-12-23 18:30:49 +03:00
Vyacheslav Gerasimov
63f40f642c Build: Disable plugin marker publication for sonatype 2020-12-22 19:31:51 +03:00
Denis.Zharkov
09a1fe9162 Extract record related parts into smaller bunch files for 201 2020-12-22 15:03:33 +03:00
Ilya Chernikov
b7c79cd3de Remove assertion about dispatch receiver in scripts
#KT-42530 fixed
2020-12-21 12:42:37 +01:00
Ilya Chernikov
c4298b683d Support destructuring declarations in scratch files
#KT-25038 fixed
2020-12-21 12:42:37 +01:00
Ilya Chernikov
f5548251f9 Do not throw assertion on recursion in typealias declaration,
return empty list of descriptors instead, allowing for proper error
reporting later.
#KT-18344 fixed
2020-12-21 12:42:37 +01:00
Ilya Chernikov
e008c9bd9e Add support for a callback on recursion for memoized functions 2020-12-21 12:42:36 +01:00
Andrei Klunnyi
b7d1573a8f KTIJ-717 [Java side inspection]: "implementation of Kotlin sealed"
(cherry picked from commit 3e8016ed25)
2020-12-21 11:47:41 +01:00
Alexander Udalov
f52aca5b75 JVM IR: output stable ABI binaries by default
#KT-43592 Fixed

(cherry picked from commit eef06cded3)
2020-12-21 07:14:30 +01:00
Alexander Udalov
f043a4022d Minor, extract CompilerConfiguration.messageCollector to extension property
(cherry picked from commit e0593ff70f)
2020-12-21 07:14:25 +01:00
Alexander Udalov
a6786a0cb4 JVM IR, FIR: set IR configuration key to true if FIR is enabled
(cherry picked from commit 691b20a685)
2020-12-21 07:14:21 +01:00
Alexander Udalov
c97b0d835e Change CLI flags for controlling diagnostics for ABI of FIR and JVM IR
- Use a more generic `-Xallow-unstable-dependencies` instead of
  `-Xallow-jvm-ir-dependencies`
- Change `-Xir-binary-with-stable-abi` to `-Xabi-stability=stable`, with
  an additional option to specify `unstable` after a subsequent commit
  where JVM IR becomes stable by default

 #KT-43592

(cherry picked from commit 06805ffbaa)
2020-12-21 07:14:16 +01:00
Alexander Udalov
2092fbfa99 Add new metadata flag for class files compiled with FIR
Report a separate error when class files compiled with FIR are in
dependencies, in addition to the one for class files compiled with FE
1.0 + JVM IR.

 #KT-43592

(cherry picked from commit 3f517d7e8d)
2020-12-21 07:14:12 +01:00
Alexander Udalov
220225924c Refactor boolean IR ABI stability flag to enum
Introduce an enum DeserializedContainerAbiStability with two values.
This is needed in order to support another reason for ABI instability in
a subsequent commit, namely "unstable because compiled by FIR".

 #KT-43592

(cherry picked from commit cbd90c3af5)
2020-12-21 07:14:07 +01:00
Alexander Udalov
bf5efc7883 Minor, invert analysis flag that allows unstable dependencies
(cherry picked from commit b7d32a8754)
2020-12-21 07:13:58 +01:00
Alexander Udalov
ca63b0bae4 JVM IR, FIR: add JvmBackendExtension instead of MetadataSerializerFactory
This might be a better place for future behavior that should be
abstracted between FE 1.0 and FIR, in JVM IR.

(cherry picked from commit 7d37030095)
2020-12-21 07:13:45 +01:00
Leonid Startsev
c0b892ba01 Update error about unsupported inline classes
Remove unused declarations

(cherry picked from commit a5ddb1fdf1)
2020-12-20 16:58:32 +03:00
Leonid Startsev
d01d23f2c3 Support serializable inline classes in IR plugin
as well as standard unsigned types.

(cherry picked from commit 272273baed)
2020-12-20 16:58:24 +03:00
Leonid Startsev
b3811bdca0 Support old serialization runtime versions
(where exception signatures weren't changed)

after f671c27f27

(cherry picked from commit 631a72d14a)
2020-12-20 16:58:17 +03:00
Leonid Startsev
34e8264dcc Adapt serialization exceptions constructor calls in legacy JS
to signature change

(see https://github.com/Kotlin/kotlinx.serialization/pull/1054
and commit eea4ff33a0)

(cherry picked from commit f671c27f27)
2020-12-20 16:58:07 +03:00
Leonid Startsev
3bcba533f1 Additional fix for Compose:
directly search for fields in IR class w/o using the symbol table.
Because Compose copies whole IR, fields got referenced incorrectly.
In the end, bytecode generator thinks that this is a field from other
class and creates a synthetic setter, which is prohibited in Java 9+
(Update to non-static final field ... attempted from a different method than <init>)

(cherry picked from commit 18e7a1485c)
2020-12-20 16:57:59 +03:00
Shagen Ogandzhanian
12a3a64fbe [JS IR] Initialize enum fields before accessing them in companion object
(cherry-picked from 4f96f9d6a1)
2020-12-19 00:04:31 +01:00
Ilmir Usmanov
9f5a2151c7 Value classes: Add JvmInlineValueClasses language feature 2020-12-18 18:23:42 +01:00
Victor Petukhov
e68689d3a6 Review fixes around type enhancement and loading type use annotations 2020-12-18 19:30:37 +03:00
Victor Petukhov
5a813ed8ef Report warnings about type mismatches based on freshly supported nullability annotations deeply 2020-12-18 19:30:37 +03:00
Victor Petukhov
fc8a7291c3 Mark freshly supported annotations to use that mark for reporting corresponding warnings 2020-12-18 19:30:37 +03:00
Victor Petukhov
b10794d2c2 Add tests for type enhancement uncluding with compiled java 2020-12-18 19:30:37 +03:00
Victor Petukhov
b248c0d3b9 Support diagnostic tests with Kotlin against compiled Java 2020-12-18 19:30:36 +03:00
Victor Petukhov
3c969d32d1 Put type enhancement improvements under the compiler flag 2020-12-18 19:30:36 +03:00
Victor Petukhov
c662128551 Support preference of TYPE_USE annotations to enhance over others like METHOD, FIELD and VALUE_PARAMETER to avoid double applying them in case of arrays: @NotNull Integer [] (both to the array element and to the entire array)
^KT-24392 Fixed
2020-12-18 19:30:36 +03:00
Victor Petukhov
ac4a471b45 Exclude tests for loading type use annotations and type enhancement based on them to pass using javac and psi class files reading 2020-12-18 19:30:36 +03:00
Victor Petukhov
2221e26ba5 Support type enhancement for super classes' types 2020-12-18 19:30:36 +03:00
Victor Petukhov
f730463f70 Support enhancement of type parameter's bound for all nullability annotations 2020-12-18 19:30:36 +03:00
Victor Petukhov
f5749a0f4a Support type use annotations on fields 2020-12-18 19:30:36 +03:00
Victor Petukhov
5b768a38e5 Add forced mark "isDeprecated" as false for missing types among javac types 2020-12-18 19:30:36 +03:00
Victor Petukhov
78dfa7338e Use new jetbrains annotations with type use target for "load java 8" tests 2020-12-18 19:30:36 +03:00
Victor Petukhov
5c440639b7 Avoid a cycle of analysing of type parameters via checking that it's a type parameter first 2020-12-18 19:30:35 +03:00
Victor Petukhov
f696b0fb4b Support reading from class files of the type use annotations on type parameters and type arguments
^KT-11454 Fixed
2020-12-18 19:30:35 +03:00
Victor Petukhov
73be4df77d Support annotations on array types
^KT-24392 Fixed
^KT-18768 Fixed
2020-12-18 19:30:35 +03:00
Victor Petukhov
02a9850f5f Clean up some code in compiler.resolution.common.jvm 2020-12-18 19:30:35 +03:00
Mikhail Glukhikh
f848503cbc Allow KtEnumEntry...RefExpression.referencedElement be nullable
This commit fixes KNPE provoked by RemoveExplicitTypeArgumentsIntention
#KT-29735 Fixed

(cherry picked from commit d907c48d9c)
2020-12-18 14:10:16 +03:00
Dmitriy Novozhilov
5677c5dbb9 Probably fix issue with creating module descriptor for SDK twice
During creation and initialization of module descriptor for sdk
  in IdeaResolverForProject.BuiltInsCache.getOrCreateIfNeeded
  AbstractResolverForProject asks for sdk dependency for module
  descriptor for this sdk, so sometimes this module descriptor was
  created twice

#KT-42001 Fixed
EA-211562
2020-12-18 13:42:03 +03:00
Andrei Klunnyi
daebb1650f KTIJ-650 [Code completion]: "sealed interface" is for 1.5+ only
(cherry picked from commit 3eb0745b58)
2020-12-18 11:32:22 +01:00
Andrei Klunnyi
4a324fb2e9 KTIJ-650 [Code completion]: test framework fix
This commit fixes test infrastructure issue.
Usage of "COMPILER_ARGUMENTS" test-data-instruction resulted in side
effect. Test cases following the one that used it got broken
LanguageVersionSetting - LanguageFeature.MultiPlatformProjects escaped,
languageVersion could be wrong.

Why it happened

KotlinProjectDescriptorWithFacet defines default values
of (language-version, isMultiplatform) settings for the test-case.
The values themselves are stored in KotlinFacetSettings and passed there
only once. After every test-case (if it uses "COMPILER_ARGUMENTS")
infrastructure calls
KotlinLightCodeInsightFixtureTestCaseKt#rollbackCompilerOptions which
resets mentioned values (among others) in KotlinFacetSettings.
Instances of KotlinProjectDescriptorWithFacet are reused hence facet
settings remained reset.

(cherry picked from commit 27ebb6c946)
2020-12-18 11:32:16 +01:00
Andrei Klunnyi
5a115f3e0f KTIJ-664 [SealedClassInheritorsProvider]: test fixes
(cherry picked from commit efc7ab5023)
2020-12-18 11:32:12 +01:00
Andrei Klunnyi
7be1b0adfb KTIJ-664 [SealedClassInheritorsProvider]: test fixes
(cherry picked from commit 2b3fc330ad)
2020-12-18 11:32:09 +01:00
Andrei Klunnyi
1f52604d8c KTIJ-664 [SealedClassInheritorsProvider]: IDE-specific implementation
(cherry picked from commit 3af0257b38)
2020-12-18 11:32:05 +01:00
Andrei Klunnyi
429e19465f KTIJ-650 [Code completion]: no "sealed" for classes with modifiers
annotation, data, enum, inner, open - classes supplied with these
modifiers cannot be sealed.

Commit fixes code completion - "sealed" is no longer suggested in
the mentioned case.

(cherry picked from commit f02b73103b)
2020-12-18 11:31:50 +01:00
Andrei Klunnyi
8fe012d8d5 KTIJ-650 [Code completion]: support for "sealed interface"
^KTIJ-650 fixed

(cherry picked from commit fe64b13140)
2020-12-18 11:31:47 +01:00
Nikolay Krasko
4515a4ab5e Make a longer description for Kotlin Android plugin
Try to overcome `Plugin description must not be generic, please
elaborate.` from the Gradle plugin portal.
2020-12-17 11:59:41 +01:00
Igor Chevdar
0ccc73f2b7 [IR] Fixed bug with thread unsafety
There is no need in a singleton here
2020-12-16 20:20:12 +05:00
Victor Petukhov
3196f55839 Revert "Report warning on @JvmStatic in private companion objects"
This reverts commit 9669ab14
2020-12-16 10:31:24 +03:00
Victor Petukhov
c3a5e2cf6f Revert "Minor: cover negative cases with test +m"
This reverts commit 04a4f9cd
2020-12-16 10:31:10 +03:00
Victor Petukhov
5fa153cdd7 Reuse captured arguments for flexible type's bounds properly, by equality of type constructors modulo mutability and type argument
^KT-43630 Fixed
2020-12-16 10:29:19 +03:00
Victor Petukhov
7b14416644 Add FlexibleTypeBoundsChecker which can answer the question: "can two types be different bounds of the same flexible type?"; and provide the base bound for the given bound.
For instance: `MutableList` and `List` may be within the same flexible type.
2020-12-16 10:29:19 +03:00
Victor Petukhov
12a227b02b Fix formatting in flexibleTypes.kt 2020-12-16 10:29:19 +03:00
Ilya Gorbunov
329e1a975c Correctly implement specialized MutableEntrySet.contains KT-41278
This is a workaround for the problem KT-43321.

Introduce an intermediate abstract set specialized for Map.Entry elements
and implement 'contains(Map.Entry)' method there.

Then inherit that intermediate set in entrysets of JS HashMap,
JS LinkedHashMap, JVM MapBuilder, that are specialized for
MutableMap.MutableEntry elements, so that no override of 'contains' is
required anymore.

This allows to avoid incorrect special 'contains' bridge being generated
that otherwise rejects all arguments except ones of MutableEntry type.

(cherry picked from commit 28168bf230)
2020-12-14 14:34:44 +03:00
Dmitriy Novozhilov
e49d35b5ba [FE] Call SealedClassInheritorsProvider only for sealed classes 2020-12-14 10:44:08 +03:00
Andrey Uskov
276f732e4d Fixed out-of-process compiler execution if project directy is absent
If project directory does not exist and out-of-process execution is used
the file with compiler arguments should be created in project directory
(if exists) or in temp directory.
#KT-43740 Fixed
2020-12-13 20:21:08 +03:00
Andrey Uskov
a3c0074bb0 Reformat DirtyClassesMap 2020-12-13 20:21:05 +03:00
Andrey Uskov
8086541143 Fix synchronization when working with IC caches
IC caches could be modified and read from different threads.
In JPS builder these threads are RMI worker (invoked from Compiler
Daemon) and JPS worker thread. Proper synchronization fixes cases
when caches could become broken.
#KT-42265 Fixed
#KT-42194 Fixed
#KT-42265 Fixed
#KT-42937 Fixed
2020-12-13 20:21:00 +03:00
Andrey Uskov
383ace2ac1 Add explicit path sensitivity for InspectClassesForMultiModuleIC
Gradle uses PathSensitivity.ABSOLUTE by default, so this change
just explicitly specifies it in order to avoid warnings.
#KT-43895 Fixed
2020-12-13 20:20:56 +03:00
Andrey Uskov
c42fb935fc Add tests for incremental compilation of sealed interfaces 2020-12-13 20:20:53 +03:00
Andrey Uskov
f8a4182450 IC of sealed classes
Supported case then children of sealed classes could be declared
anywhere in a module. If list of classes implementing sealing class
changes the sealed class and all its inheritors should be recompiled
(now sealed class should be compiled together with children in order
to calculate all possible inheritors at compile time) and and
invalidated (as they could have when operators).
2020-12-13 20:20:51 +03:00
Denis.Zharkov
4280122730 Refine diagnostic text for NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER
^KT-43225 Fixed
2020-12-11 14:26:42 +03:00
Ilya Goncharov
ef15352791 [JS IR] Assert createdOn equals 0 for properties initialization fun for file
(cherry picked from commit 167e60b9fb)
2020-12-10 19:44:03 +03:00
Ilya Goncharov
1154b563bf [JS IR] Add properties lazy initialization with multiple modules
[JS IR] Move tests into compiler/testData

[JS IR] Add cyclic dependencies with lazy property initialization

[JS IR] Add test on not initialization in case of call non properties (classed, objects, enum classes, const vals)

[JS IR] Add initialization through top level

[JS IR] Ignore enum getInstance function in property lazy initialization

[JS IR] Use let function with useful result instead of pure apply and also

[JS IR] Remove duplicated tests in js.translator

(cherry picked from commit 697b2b02f1)
2020-12-10 19:44:01 +03:00
Mads Ager
583c9d7837 [JVM_IR] Refactor and add bytecode text tests for compose-like code.
Tests that the default argument mask is not in the local variable
table.

(cherry picked from commit fadedc84db)
2020-12-10 17:22:38 +01:00
Mads Ager
1d77408ce8 [JVM_IR] Add tests of Compose-like default argument handling.
(cherry picked from commit 83588e9f22)
2020-12-10 17:22:38 +01:00
Mads Ager
9d9d379564 [IR] Fix remapping of arguments in LocalDeclarationsLowering.
It only remapped arguments for IrGetValue and not for IrSetValue.
This is hitting Compose which has non-standard default argument
handling.

(cherry picked from commit a7efa5c98b)
2020-12-10 17:22:37 +01:00
Denis.Zharkov
33eaeee8f9 Fix freshly added CLI tests for windows agents 2020-12-10 16:16:07 +03:00
Denis.Zharkov
0a29b890ec Fix compilation for 201 in 1.4.30 2020-12-10 14:09:53 +03:00
Dmitriy Novozhilov
29216645fa [IR] Don't assume subclasses as part of member scope of sealed class
(cherry picked from commit d5c1e5681c)
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
0a4cd22434 [FE] Rename FreedomForSealedClasses feature with more meaningful name
(cherry picked from commit b6bd7c48f4)
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
74c446f594 [FE] Add bunch files to fix compilation on 201 platform
(cherry picked from commit 77aad06008)
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
1873d6a212 [IC] Add ability to pass additional compiler args to IC tests
Additional arguments should be declared in `args.txt` file in test
  directory in common CLI arguments format
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
318172cd69 [FE] Prohibit inheritance of sealed classes in different module
KT-20423

(cherry picked from commit 57a081c399)
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
f2887577c6 [FE] Temporary disable exhaustiveness checker for java sealed classes
KT-43551
KT-41215

(cherry picked from commit f8d6f79c17)
2020-12-10 12:33:02 +03:00
Dmitriy Novozhilov
b6a2481586 [FE] Prohibit implementing java sealed classes
(cherry picked from commit 1c9f9130e6)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
5a9d947505 [FE] Extract computation of sealed class inheritors into separate component
This is needed to provide more optimal provider in IDE plugin

(cherry picked from commit 6809adee9c)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
4f83e53a4e [FE] Add test for compiling against library with kotlin sealed classes and interfaces
#KT-20423
#KT-13495

(cherry picked from commit c0a1aecf9b)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
fab98d7c2c [FE] Support sealed classes and interfaces from java
KT-43551
KT-41215

(cherry picked from commit 7897bb6adb)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
5f87753e52 [FE] Add sealed classes related properties to java model
(cherry picked from commit bdfb71b149)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
0c0cfd9bd6 [FE] Properly support sealed interfaces in exhaustiveness checker
#KT-20423

(cherry picked from commit 8e9e34350f)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
aa55e1557e [FE] Allow using sealed modifier on interface and compute sealed modality for them
#KT-20423

(cherry picked from commit 9609954560)
2020-12-10 12:33:01 +03:00
Dmitriy Novozhilov
51ae634432 [FE] Prohibit inheritors of sealed classes which are declared in different package
#KT-13495

(cherry picked from commit d605c7e491)
2020-12-10 12:33:00 +03:00
Dmitriy Novozhilov
2bae08a9d8 [FE] Collect inheritors of sealed classes from new places in computeSealedSubclasses
#KT-13495

(cherry picked from commit e76acc8ee0)
2020-12-10 12:33:00 +03:00
Dmitriy Novozhilov
69a4bf7f23 [FE] Allow declare sealed class inheritors as inner or nested classes
#KT-13495

(cherry picked from commit 70c61be1ef)
2020-12-10 12:33:00 +03:00
Dmitriy Novozhilov
0eb6b804a6 [FE] Allow declare sealed class inheritors in different files in one module
#KT-13495

(cherry picked from commit f5f1984a60)
2020-12-10 12:33:00 +03:00
Ilmir Usmanov
d0a204c76f JVM_IR: Unbox argument of type kotlin.Result
if the argument has different type in parent: either generic or Any.
 #KT-41163 Fixed
 #KT-43536 Fixed
2020-12-10 08:28:04 +01:00
Ilmir Usmanov
3ff89644d3 Value classes: Forbid any identity equality check on value class
#KT-31130 Fixed
2020-12-10 08:25:22 +01:00
Denis.Zharkov
703671ca55 Temporary clear sinceVersion for ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
^KT-36770 Related
^KT-26245 Related
2020-12-10 10:22:23 +03:00
Jiaxiang Chen
b5b37d2b60 Allow AnalysisHandlerExtension to provide additional classpath on retry
(cherry picked from commit 1a377069dd)
2020-12-09 22:28:39 +03:00
Jiaxiang Chen
4731b9fe0c Allow multiple retry for AnalysisHandlerExtension
(cherry picked from commit a6cb156ce9)
2020-12-09 22:28:38 +03:00
Denis.Zharkov
0c30e813b1 Add 201 bunch files for JavaClass implementations
In 201, there's an old ASM version and PSI doesn't have record-related API
2020-12-09 21:11:13 +03:00
Denis.Zharkov
7c1961b6fe Minor. Specify targetBackend for new IR tests 2020-12-09 21:11:13 +03:00
Denis.Zharkov
e80ff88d37 Report incorrect JVM target only when @JvmRecord is actually used 2020-12-09 21:11:13 +03:00
Denis.Zharkov
fef31c2034 Add some tests on corner cases for @JvmRecord 2020-12-09 21:11:13 +03:00
Denis.Zharkov
98456f1a23 Prohibit explicit j.l.Record supertype even for @JvmRecord 2020-12-09 21:11:13 +03:00
Denis.Zharkov
b1331eeb5f Temporary avoid using constant from the new ASM
To make it compilable with 201 platform
2020-12-09 21:11:12 +03:00
Denis.Zharkov
6f54071e75 Temporary add another env variable JDK_15_0 that is set on TC agents 2020-12-09 21:11:12 +03:00
Denis.Zharkov
cb53e7d81d Separate JVM target option from javac's --enable-preview analogue 2020-12-09 21:11:12 +03:00
Denis.Zharkov
f0c688c94b Adapt CliTests for api requirement of @JvmRecord 2020-12-09 21:11:12 +03:00
Denis.Zharkov
fd22c793d1 Support cross-module usages of @JvmRecord classes
The problem is that JvmRecord has SOURCE retention
Probably, increasing its retention might be a more reliable solution
(or in some other way serializing that the class is a record)

Just checking supertypes seems like a reasonable approximation:
only records kotlin are allowed to extend j.l.Record.
But the relevant diagnostic has been added only since 1.4.30,
so potentially there could have been exist a non-record class with
such supertype compiled by 1.4.20, but this case seems to be ill-formed
and marginal anyway.

For Java classes, it's irrelevant since they don't have member properties
(only synthetic extensions)

^KT-43677 In Progress
2020-12-09 21:11:12 +03:00
Denis.Zharkov
33d47a2bea Minor. Extract runJvmInstance for running BB tests with custom JVM 2020-12-09 21:11:12 +03:00
Denis.Zharkov
ae143a8b03 Add @SinceKotlin("1.5") on JvmRecord annotation 2020-12-09 21:11:12 +03:00
Denis.Zharkov
0d2bd296aa Prohibit extending java.lang.Record from non-@JvmRecord classes 2020-12-09 21:11:12 +03:00
Denis.Zharkov
a0478cc75b Check JvmRecordSupport language feature before generating synthetic properties 2020-12-09 21:11:11 +03:00
Denis.Zharkov
4ddff7084e Support @JvmRecord for JVM_IR
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
31b7811d1f Add check for bytecode target when @JvmRecord is used
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
0a9192cb6d Separate JvmTarget::bytecodeVersion version into major/minor parts 2020-12-09 21:11:11 +03:00
Denis.Zharkov
66e91fa67b Prohibit @JvmRecord for non-data classes
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
1bf1539a32 Adapt test infrastructure to the latest changes
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
596c78b948 Move earlier generated tests
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
1cbb29355f Prohibit irrelevant fields in @JvmRecord classes
^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
0c914ac3b6 Add initial support for @JvmRecord in backend
- Write relevant class files attributes
- Emit property accessors with records-convention: propertyName -> propertyName()

^KT-43677 In Progress
2020-12-09 21:11:11 +03:00
Denis.Zharkov
def7acdbbe Prepare ClassBuilder for record components
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
5b3a932aca Add @JvmRecord diagnostics for open and enums
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
698e356181 Correct descriptor shape for @JvmRecord annotated classes
This commit adds relevant functions: hashCode, toString, equals
(if the class is not a data class)
And supertype j.l.Record

It only affects descriptor contents, i.e. works for FE

^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
982e45d669 Minor. Move @JvmRecord tests to relevant directory
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
4834fd8fa7 Add check that we have JDK 15 in classpath when using @JvmRecord
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
2aa5ef46c3 Add check that @JvmRecord classes cannot inherit other classes
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
d2a726638b Add @JvmRecord annotation and relevant diagnostics
^KT-43677 In Progress
2020-12-09 21:11:10 +03:00
Denis.Zharkov
b818468d29 Make BlackBox tests for Java 9 generated 2020-12-09 21:11:10 +03:00
Denis.Zharkov
15919e736d Add simple JDK15 BlackBox test
^KT-43677 In Progress
2020-12-09 21:11:09 +03:00
Denis.Zharkov
23e5cb0269 Support loading Java records
^KT-43677 In Progress
2020-12-09 21:11:09 +03:00
Denis.Zharkov
efde013ff6 Introduce FULL_JDK_15 TestJdkKind 2020-12-09 21:11:09 +03:00
Denis.Zharkov
199a87f05a Setup 15_PREVIEW LanguageLevel for Java sources in CLI
It's necessary to read preview-features related Java PSI parts
It should be OK to set it unconditionally because we don't compile Java
sources, only obtain declaration structure from them
2020-12-09 21:11:09 +03:00
anastasiia.spaseeva
16091fd96c Wizard: Fix tests 2020-12-09 18:07:17 +03:00
Mikhael Bogdanov
917acfe494 Generate correct names for companion @JvmStatic accessors in annotation class
#KT-31389 Fixed

(cherry picked from commit 1cfb81455c)
2020-12-09 15:25:10 +01:00
Ilya Goncharov
18cd7fec21 [Gradle, JS] Null library and libraryTarget when they are null
^KT-43842 fixed

(cherry picked from commit ff52a3f867)
2020-12-09 16:06:03 +03:00
Dmitry Petrov
ec5d8c2bcf Minor: regenerate tests, update testData 2020-12-09 13:52:10 +03:00
Dmitry Petrov
616dc5b504 JVM_IR KT-43109 generate internal bridge for custom internal 'toArray'
Also add some tests for internal collection stubs.

(cherry picked from commit 3dbe02b7fe)
2020-12-09 13:52:10 +03:00
Dmitry Petrov
2eab762d9a JVM_IR KT-43721 coerce intrinsic result to corresponding unsigned type
(cherry picked from commit caea0a9df0)
2020-12-09 13:52:09 +03:00
Dmitry Petrov
ce3bb5b997 JVM_IR no static inline class members for Kotlin JvmDefault methods
KT-43698 KT-43051

(cherry picked from commit e6a3e38c4d)
2020-12-09 13:52:09 +03:00
Dmitry Petrov
b1d41819c6 Minor: ignore nestedBigArityFunCalls.kt in WASM
(cherry picked from commit ae8abd1832)
2020-12-09 13:52:09 +03:00
Dmitry Petrov
ec80300a7c JVM_IR KT-43524 static wrappers for deprecated accessors are deprecated
(cherry picked from commit 1412ee96f8)
2020-12-09 13:52:08 +03:00
Dmitry Petrov
eca336aa37 JVM_IR KT-43519 no delegates for external funs in multifile facades
Also add ABI tests for @JvmStatic/JvmOverloads + 'external'.

(cherry picked from commit e96fc74ffa)
2020-12-09 13:52:08 +03:00
Dmitry Petrov
a4af2696a4 JVM_IR KT-43459 fix $annotations method receiver type
(cherry picked from commit 2b4564059e)
2020-12-09 13:52:08 +03:00
Dmitry Petrov
f637ffb83c JVM_IR KT-43051 no static inline class members for default Java methods
(cherry picked from commit 85b5948931)
2020-12-09 13:52:08 +03:00
Dmitry Petrov
2ca1b07895 JVM_IR KT-41911 process big arity 'invoke' arguments recursively
(cherry picked from commit 4c3ffc3451)
2020-12-09 13:52:08 +03:00
anastasiia.spaseeva
67f404541d Wizard: Do not add bintray repoitory for eap versions 2020-12-09 13:02:01 +03:00
Dmitry Petrov
af536c3f05 PSI2IR KT-41284 use getters for open data class property values
'allopen' compiler plug-in can make data classes and their members open,
which is a compilation error in usual case, but makes sense for Spring
and other frameworks that generate proxy-classes.

(cherry picked from commit 69c88a8a0a)
2020-12-09 11:25:30 +03:00
Ilmir Usmanov
1029703489 IC Mangling: search parents for method if descriptor is fake override
Otherwise, the compiler generates call using old mangling scheme
because classfile does not contain the method.
2020-12-09 07:51:21 +01:00
Mikhail Zarechenskiy
a24c7554e5 Fix exception on resolving collection literal inside lambda
#KT-31907 Fixed
 #EA-90906 Fixed
2020-12-08 12:59:03 +03:00
Ivan Gavrilovic
7abe38bdd4 Fix KAPT cli tests on windows
- Fix line separator issue
- Always quote args with delimiters (=, :)
- fix one of args files by removing obsolete stdlib reference
- Fix kotlinc.bat to ensure lazy evaluation of additional classpath

(cherry picked from commit 078aa18479)
2020-12-08 06:40:15 +01:00
Ilmir Usmanov
482903a1c5 Generate correct $default method for actual suspend function
In order to do this, we need to get initial expect suspend function
before generating default value parameters checks.
 #KT-43587 Fixed
2020-12-08 04:37:06 +01:00
Vyacheslav Gerasimov
76278b1784 Build: Fix kotlin-compiler-internal-test-framework empty sources jar
Should also pack pack test source set from :compiler:tests-common

(cherry picked from commit b6d80a1149)
2020-12-07 19:20:01 +03:00
Vyacheslav Gerasimov
a515b8b6cb Build: Publish kotlin-compiler-internal-test-framework maven artifact
(cherry picked from commit 7354bcbc99)
2020-12-07 19:20:00 +03:00
Shagen Ogandzhanian
d82b872142 [JS IR] Remove redundant guard assertion for extension funs with default params
Introduce corresponding test
See https://youtrack.jetbrains.com/issue/KT-41076

(cherry picked from commit d512158c25)
2020-12-07 12:54:52 +01:00
Ilya Goncharov
e589221b4f [Gradle, JS] Add nodeArgs to NodeJsExec
^KT-43793 fixed

(cherry picked from commit 82ad230e0d)
2020-12-07 13:11:23 +03:00
Nikita Bobko
34e1153754 Fix double registered "com.intellij.psi.classFileDecompiler" for 203 platform
This commit addresses 1243c641296e74a572a4f274df72a4cda60635c6 in intellij
In intellij they added registration of "com.intellij.psi.classFileDecompiler" in
`JavaCoreApplicationEnvironment`. And because the `KotlinCoreApplicationEnvironment` inherits
`JavaCoreApplicationEnvironment` we don't need to register this EP ourselves.

This commit fixes in 203 tests + 1.4.30 compiler:
```
java.lang.RuntimeException: Duplicate registration for EP 'com.intellij.psi.classFileDecompiler': first in com.intellij.openapi.extensions.DefaultPluginDescriptor@44f464d1, second in PluginDescriptor(name=org.jetbrains.kotlin, id=org.jetbrains.kotlin, path=/home/builduser/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-for-ide/1.4.30-M1-30/kotlin-compiler-for-ide-1.4.30-M1-30.jar, version=1.2)
	at com.intellij.openapi.components.ComponentManager.createError(ComponentManager.java:167)
	at com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.registerExtensionPoints(ExtensionsAreaImpl.java:262)
	at com.intellij.ide.plugins.PluginManagerCore.registerExtensionPointAndExtensions(PluginManagerCore.java:1334)
	...
```

(cherry picked from commit 0d8cdb7bdb)
2020-12-07 10:33:48 +03:00
Alexander Udalov
0ed3306600 Fix compilation error in :noarg-ide-plugin
Was overlooked in a06bffc4b9.

(cherry picked from commit c87edc44f3)
2020-12-05 01:02:00 +01:00
Ilmir Usmanov
4367ca416d Value classes: Forbid cloneable value classes
#KT-43741 Fixed
2020-12-04 23:28:24 +01:00
Alexander Udalov
bf95822527 JVM IR: support noarg compiler plugin
#KT-41265 Fixed

(cherry picked from commit 25c228297a)
2020-12-04 22:17:01 +01:00
Alexander Udalov
9ca614b6e5 Noarg: prohibit noarg for inner and local classes
Report warning if old JVM backend is used, and error for JVM IR, which
is supposed to be enabled as default in the next Kotlin release.

 #KT-43725 Fixed

(cherry picked from commit a06bffc4b9)
2020-12-04 22:16:06 +01:00
Alexander Udalov
f5d9b09cd0 Noarg: somewhat refactor tests
Extract method that registers components, merge abstract test classes
into one file.

(cherry picked from commit a343fffe9e)
2020-12-04 22:14:18 +01:00
Alexander Udalov
249c1b8d9f IR: minor, deduplicate unbound symbol in error message
(cherry picked from commit b10e206144)
2020-12-04 22:14:17 +01:00
Ilya Gorbunov
4a47244c0d Revert using regex Pattern in String.replace
Use String.indexOf(..., ignoreCase) instead in all branches to preserve
compatibility with behavior before 1.4.20 that used String.split which
essentially relied on that String.indexOf

#KT-43745 Fixed

(cherry picked from commit 149bcc2d22)
2020-12-04 19:19:46 +03:00
Mads Ager
1ca28f941e [JVM_IR] Fix incorrect name in inner class attributes.
(cherry picked from commit c776fcbd00)
2020-12-04 17:12:53 +01:00
Mads Ager
ece8c5dd9a [JVM] Do not put the name of default lambda parameter in LVT.
If we do, the local variable table will not make sense. As as
example:

```
inline fun foo(getString: () -> String = { "OK" }) {
  println(getString())
}

inline fun bar() {
}

fun main() {
    bar()
    foo()
}
```

leads to the following bytecode:

```
  public static final void main();
    descriptor: ()V
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    Code:
      stack=2, locals=4, args_size=0
         0: iconst_0
         1: istore_0
         2: nop
         3: nop
         4: iconst_0
         5: istore_1
         6: nop
         7: ldc           #53                 // String OK
         9: astore_2
        10: iconst_0
        11: istore_3
        12: getstatic     #30                 // Field java/lang/System.out:Ljava/io/PrintStream;
        15: aload_2
        16: invokevirtual #36                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
        19: nop
        20: return
      LineNumberTable:
        line 9: 0
        line 13: 2
        line 10: 3
        line 14: 4
        line 15: 6
        line 16: 7
        line 17: 19
        line 11: 20
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            2       1     0 $i$f$bar   I
            6      14     1 $i$f$foo   I
            4      16     0 getString$iv   Lkotlin/jvm/functions/Function0;
```

The `getString$iv` local should not be there. It has been inlined away.
Leaving it in the local variable table leads to inconsistent locals
info. Local 0 contains an int but we declare a local of type
Function0.

(cherry picked from commit fae5b8da4b)
2020-12-04 17:12:51 +01:00
Mads Ager
f9ead56021 [IR] Make isHidden and isAssignable explicit on IrValueParameter.
There were a couple of places where they were confused and
isAssignable was passed as a positional parameter in the position
of isHidden.

(cherry picked from commit 5d9e86863a)
2020-12-04 17:05:51 +01:00
Vyacheslav Gerasimov
e5187adeef Build: Set file access rights explicitly in kotlin-stdlib-js jar
Workaround for #KTI-401. Since gradle 6.6 ant.replaceregexp call sets
incorrect access rights `-rw-------` instead of `-rw-r--r--`
2020-12-04 17:11:25 +03:00
Ilmir Usmanov
56e1faa44e Value Classes: Forbid var properties with value class receivers 2020-12-04 09:46:34 +01:00
Ilmir Usmanov
f0dad4dd64 IC: Forbid inner classes inside inline classes
#KT-43067 Fixed
2020-12-04 06:15:09 +01:00
Ilmir Usmanov
6bccf61a40 Value classes: Allow nested inline classes 2020-12-04 06:15:07 +01:00
Ilmir Usmanov
77a4b1ce96 Value classes: Allow unsigned arrays in annotations
including varargs, apparently.
So, we allow unsigned types and unsigned arrays in annotations,
but disallow user-defined inline classes.
 #KT-23816 Fixed
2020-12-03 17:22:47 +01:00
LepilkinaElena
e599934ee4 Fix gradle test for endorsed libraries in K/N (#3953) 2020-12-03 13:59:12 +03:00
Ilmir Usmanov
cf91dc3c55 Value classes: Raise retention of @JvmInline to RUNTIME
so it will be visible by reflection
2020-12-03 00:38:28 +01:00
Ilmir Usmanov
dba4b9dc73 Value classes: Generate @JvmInline annotation for inline classes
but not for value classes.
Since inline classes and value classes share the same flag, we use
presence of the annotation to distinguish them.
2020-12-03 00:38:26 +01:00
Ivan Gavrilovic
ee90525e9b KAPT: add tests for processed types, remove dead code, simplify logic
Add integration test which checks if only types can be
reprocessed in an incremental round. Also, remove unused
`invalidateTypesForFiles` method.

Furthermore, clarify that types that are reprocessed
(i.e types from .class files) are not necessarily
aggregating types, but simply types that should be reprocessed.

Test: KaptIncrementalWithIsolatingApt.testClasspathChangesCauseTypesToBeReprocessed
(cherry picked from commit 11673bd09c)
2020-12-02 17:13:47 +01:00
Ivan Gavrilovic
31b78452a5 Incremental KAPT: fix typo and do check processed sources on
clean build

(cherry picked from commit 08a2b47c77)
2020-12-02 17:13:47 +01:00
Ivan Gavrilovic
d44c4cdcaf Incremental KAPT: add test for isolating AP with classpath origin
Add a regression test for KT-34340 that allows APs to have
classpath types as origins.

(cherry picked from commit 0522583602)
2020-12-02 17:13:46 +01:00
Ivan Gavrilovic
a80d119660 Incremental KAPT: simplify impacted types computation
Process aggregating types first, and when computing impacted types
compute isolating generated impacted by classpath changes first.

(cherry picked from commit 05e47da458)
2020-12-02 17:13:45 +01:00
Ivan Gavrilovic
9bb717da9c Use types are origins for incremental KAPT and track generated source
This change introduces tracking of generated sources structure in order
to e.g track classpath changes impacting generated sources. This fixes KT-42182.

Also, origin tracking for isolating processors is now using types, allowing
for origin elements from classpath. This fixes KT-34340. However, classpath
origin is used only to invalidate generated files when the type changes and
processing will not be requested for that type. This is in line with the
incap spec.

(cherry picked from commit c7e5beece5)
2020-12-02 17:13:44 +01:00
anastasiia.spaseeva
4d6d9a7d13 Fix as42 misc test compilation 2020-12-02 17:01:46 +03:00
Vladimir Dolzhenko
33b5aab3b5 Run tests AS42 under JDK 11
Due to built dependency with java9
2020-12-02 17:01:46 +03:00
Vladimir Dolzhenko
c079c23404 Clean up non failed tests in AS42 2020-12-02 17:01:45 +03:00
Vladimir Dolzhenko
1ec4ec7f3e Don't set KOTLIN_BUNDLED in unit tests in AS42 2020-12-02 17:01:45 +03:00
Stanislav Erokhin
f82b829727 Use absolute path to the project in test in AS 4.2
It seems like sometimes by some reason here used relative path, but
also seems like corresponding function prefer absolute path.
Without it tests failing (for example ConfigureKotlinTest)
2020-12-02 17:01:44 +03:00
Yan Zhulanow
1286c8a52b Fix ClassNotFoundException: org.w3c.dom.ElementTraversal 2020-12-02 17:01:44 +03:00
Stanislav Erokhin
85f004033d Fix compilation 2020-12-02 17:01:43 +03:00
Stanislav Erokhin
3cab7f6e71 Register DumpUtil if it has not been registered yet in AS42 2020-12-02 17:01:42 +03:00
Stanislav Erokhin
168ab67de9 Fix compilation in AS 4.2
Previous method was deprecated, replaced to the new one based on the
implementation of deprecated `openExistingProject`
2020-12-02 17:01:41 +03:00
Ilya Gorbunov
e92d12e172 Pack jvm builtins into kotlin-stdlib shipped with idea plugin
This lessens the possibility that kotlin plugin will get different
variants of builtins in the classpath, thus making builtins resources
loading less order-dependent.
2020-12-01 16:05:16 +03:00
2192 changed files with 33200 additions and 8703 deletions

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.incremental
import com.intellij.util.io.EnumeratorStringDescriptor
import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.metadata.deserialization.TypeTable
import org.jetbrains.kotlin.metadata.deserialization.supertypes
@@ -34,12 +35,15 @@ interface IncrementalCacheCommon {
val thisWithDependentCaches: Iterable<AbstractIncrementalCache<*>>
fun classesFqNamesBySources(files: Iterable<File>): Collection<FqName>
fun getSubtypesOf(className: FqName): Sequence<FqName>
fun getSupertypesOf(className: FqName): Sequence<FqName>
fun getSourceFileIfClass(fqName: FqName): File?
fun markDirty(removedAndCompiledSources: Collection<File>)
fun clearCacheForRemovedClasses(changesCollector: ChangesCollector)
fun getComplementaryFilesRecursive(dirtyFiles: Collection<File>): Collection<File>
fun updateComplementaryFiles(dirtyFiles: Collection<File>, expectActualTracker: ExpectActualTrackerImpl)
fun dump(): String
fun isSealed(className: FqName): Boolean?
}
/**
@@ -50,6 +54,7 @@ abstract class AbstractIncrementalCache<ClassName>(
protected val pathConverter: FileToPathConverter
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
companion object {
private val CLASS_ATTRIBUTES = "class-attributes"
private val SUBTYPES = "subtypes"
private val SUPERTYPES = "supertypes"
private val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source"
@@ -71,6 +76,7 @@ abstract class AbstractIncrementalCache<ClassName>(
result
}
internal val classAttributesMap = registerMap(ClassAttributesMap(CLASS_ATTRIBUTES.storageFile))
private val subtypesMap = registerMap(SubtypesMap(SUBTYPES.storageFile))
private val supertypesMap = registerMap(SupertypesMap(SUPERTYPES.storageFile))
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, pathConverter))
@@ -90,6 +96,14 @@ abstract class AbstractIncrementalCache<ClassName>(
override fun getSubtypesOf(className: FqName): Sequence<FqName> =
subtypesMap[className].asSequence()
override fun getSupertypesOf(className: FqName): Sequence<FqName> {
return supertypesMap[className].asSequence()
}
override fun isSealed(className: FqName): Boolean? {
return classAttributesMap[className]?.isSealed
}
override fun getSourceFileIfClass(fqName: FqName): File? =
classFqNameToSourceMap[fqName]
@@ -118,6 +132,7 @@ abstract class AbstractIncrementalCache<ClassName>(
supertypesMap[child] = parents
classFqNameToSourceMap[child] = srcFile
classAttributesMap[child] = ICClassesAttributes(ProtoBuf.Modality.SEALED == Flags.MODALITY.get(proto.flags))
}
protected fun removeAllFromClassStorage(removedClasses: Collection<FqName>, changesCollector: ChangesCollector) {
@@ -152,14 +167,17 @@ abstract class AbstractIncrementalCache<ClassName>(
}
}
removedFqNames.forEach { classFqNameToSourceMap.remove(it) }
removedFqNames.forEach {
classFqNameToSourceMap.remove(it)
classAttributesMap.remove(it)
}
}
protected class ClassFqNameToSourceMap(
storageFile: File,
private val pathConverter: FileToPathConverter
) :
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
) : BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
operator fun set(fqName: FqName, sourceFile: File) {
storage[fqName.asString()] = pathConverter.toPath(sourceFile)
}

View File

@@ -19,12 +19,14 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.metadata.deserialization.supertypes
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.protobuf.MessageLite
import org.jetbrains.kotlin.serialization.deserialization.getClassId
class ChangesCollector {
private val removedMembers = hashMapOf<FqName, MutableSet<String>>()
private val changedParents = hashMapOf<FqName, MutableSet<FqName>>()
private val changedMembers = hashMapOf<FqName, MutableSet<String>>()
private val areSubclassesAffected = hashMapOf<FqName, Boolean>()
@@ -47,6 +49,10 @@ class ChangesCollector {
changes.add(ChangeInfo.SignatureChanged(fqName, areSubclassesAffected))
}
for ((fqName, changedParents) in changedParents) {
changes.add(ChangeInfo.ParentsChanged(fqName, changedParents))
}
return changes
}
@@ -79,12 +85,12 @@ class ChangesCollector {
}
if (oldData == null) {
newData!!.collectAll(isRemoved = false, collectAllMembersForNewClass = collectAllMembersForNewClass)
newData!!.collectAll(isRemoved = false, isAdded = true, collectAllMembersForNewClass = collectAllMembersForNewClass)
return
}
if (newData == null) {
oldData.collectAll(isRemoved = true)
oldData.collectAll(isRemoved = true, isAdded = false)
return
}
@@ -98,6 +104,7 @@ class ChangesCollector {
collectSignature(oldData, diff.areSubclassesAffected)
}
collectChangedMembers(fqName, diff.changedMembersNames)
addChangedParents(fqName, diff.changedSupertypes)
}
is PackagePartProtoData -> {
collectSignature(oldData, areSubclassesAffected = true)
@@ -121,10 +128,11 @@ class ChangesCollector {
private fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> =
members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet()
private fun ProtoData.collectAll(isRemoved: Boolean, collectAllMembersForNewClass: Boolean = false) =
//TODO remember all sealed parent classes
private fun ProtoData.collectAll(isRemoved: Boolean, isAdded: Boolean, collectAllMembersForNewClass: Boolean = false) =
when (this) {
is PackagePartProtoData -> collectAllFromPackage(isRemoved)
is ClassProtoData -> collectAllFromClass(isRemoved, collectAllMembersForNewClass)
is ClassProtoData -> collectAllFromClass(isRemoved, isAdded, collectAllMembersForNewClass)
}
private fun PackagePartProtoData.collectAllFromPackage(isRemoved: Boolean) {
@@ -143,7 +151,7 @@ class ChangesCollector {
}
}
private fun ClassProtoData.collectAllFromClass(isRemoved: Boolean, collectAllMembersForNewClass: Boolean = false) {
private fun ClassProtoData.collectAllFromClass(isRemoved: Boolean, isAdded: Boolean, collectAllMembersForNewClass: Boolean = false) {
val classFqName = nameResolver.getClassId(proto.fqName).asSingleFqName()
val kind = Flags.CLASS_KIND.get(proto.flags)
@@ -162,6 +170,23 @@ class ChangesCollector {
collectSignature(classFqName, areSubclassesAffected = true)
}
if (isRemoved || isAdded) {
collectChangedParents(classFqName, proto.supertypeList)
}
}
private fun addChangedParents(fqName: FqName, parents: Collection<FqName>) {
if (parents.isNotEmpty()) {
changedParents.getOrPut(fqName) { HashSet() }.addAll(parents)
}
}
private fun ClassProtoData.collectChangedParents(fqName: FqName, parents: Collection<ProtoBuf.Type>) {
val changedParentsFqNames = parents.map { type ->
nameResolver.getClassId(type.className).asSingleFqName()
}
addChangedParents(fqName, changedParentsFqNames)
}
private fun ClassProtoData.getNonPrivateMemberNames(): Set<String> {

View File

@@ -145,6 +145,7 @@ open class IncrementalJvmCache(
}
protoMap.remove(className, changesCollector)
classFqNameToSourceMap.remove(className.fqNameForClassNameWithoutDollars)
classAttributesMap.remove(className.fqNameForClassNameWithoutDollars)
internalNameToSource.remove(className.internalName)
// TODO NO_CHANGES? (delegates only)
@@ -271,6 +272,7 @@ open class IncrementalJvmCache(
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
@Synchronized
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
return put(kotlinClass, changesCollector)
}
@@ -282,10 +284,12 @@ open class IncrementalJvmCache(
// from files compiled during last round.
// However there is no need to compare old and new data in this case
// (also that would fail with exception).
@Synchronized
fun storeModuleMapping(className: JvmClassName, bytes: ByteArray) {
storage[className.internalName] = ProtoMapValue(isPackageFacade = false, bytes = bytes, strings = emptyArray())
}
@Synchronized
private fun put(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
val header = kotlinClass.classHeader
@@ -308,6 +312,7 @@ open class IncrementalJvmCache(
operator fun get(className: JvmClassName): ProtoMapValue? =
storage[className.internalName]
@Synchronized
fun remove(className: JvmClassName, changesCollector: ChangesCollector) {
val key = className.internalName
val oldValue = storage[key] ?: return
@@ -324,6 +329,8 @@ open class IncrementalJvmCache(
private inner class JavaSourcesProtoMap(storageFile: File) :
BasicStringMap<SerializedJavaClass>(storageFile, JavaClassProtoMapValueExternalizer) {
@Synchronized
fun process(jvmClassName: JvmClassName, newData: SerializedJavaClass, changesCollector: ChangesCollector) {
val key = jvmClassName.internalName
val oldData = storage[key]
@@ -335,6 +342,7 @@ open class IncrementalJvmCache(
)
}
@Synchronized
fun remove(className: JvmClassName, changesCollector: ChangesCollector) {
val key = className.internalName
val oldValue = storage[key] ?: return
@@ -374,6 +382,7 @@ open class IncrementalJvmCache(
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
@Synchronized
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
val key = kotlinClass.className.internalName
val oldMap = storage[key] ?: emptyMap()
@@ -390,6 +399,7 @@ open class IncrementalJvmCache(
}
}
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}
@@ -522,6 +532,7 @@ open class IncrementalJvmCache(
return result
}
@Synchronized
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
val key = kotlinClass.className.internalName
val oldMap = storage[key] ?: emptyMap()
@@ -547,6 +558,7 @@ open class IncrementalJvmCache(
private fun functionNameBySignature(signature: String): String =
signature.substringBefore("(")
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}
@@ -568,6 +580,7 @@ sealed class ChangeInfo(val fqName: FqName) {
class SignatureChanged(fqName: FqName, val areSubclassesAffected: Boolean) : ChangeInfo(fqName)
class ParentsChanged(fqName: FqName, val parentsChanged: Collection<FqName>) : ChangeInfo(fqName)
protected open fun toStringProperties(): String = "fqName = $fqName"

View File

@@ -136,7 +136,8 @@ fun LookupStorage.update(
data class DirtyData(
val dirtyLookupSymbols: Collection<LookupSymbol> = emptyList(),
val dirtyClassesFqNames: Collection<FqName> = emptyList()
val dirtyClassesFqNames: Collection<FqName> = emptyList(),
val dirtyClassesFqNamesForceRecompile: Collection<FqName> = emptyList()
)
fun ChangesCollector.getDirtyData(
@@ -146,6 +147,9 @@ fun ChangesCollector.getDirtyData(
val dirtyLookupSymbols = HashSet<LookupSymbol>()
val dirtyClassesFqNames = HashSet<FqName>()
val sealedParents = HashMap<FqName, MutableSet<FqName>>()
val notSealedParents = HashSet<FqName>()
for (change in changes()) {
reporter.reportVerbose { "Process $change" }
@@ -170,10 +174,35 @@ fun ChangesCollector.getDirtyData(
}
fqNames.mapTo(dirtyLookupSymbols) { LookupSymbol(SAM_LOOKUP_NAME.asString(), it.asString()) }
} else if (change is ChangeInfo.ParentsChanged) {
fun FqName.isSealed(): Boolean {
if (notSealedParents.contains(this)) return false
if (sealedParents.containsKey(this)) return true
return isSealed(this, caches).also { sealed ->
if (sealed) {
sealedParents[this] = HashSet()
} else {
notSealedParents.add(this)
}
}
}
change.parentsChanged.forEach { parent ->
if (parent.isSealed()) {
sealedParents.getOrPut(parent) { HashSet() }.add(change.fqName)
}
}
}
}
return DirtyData(dirtyLookupSymbols, dirtyClassesFqNames)
val forceRecompile = HashSet<FqName>().apply {
addAll(sealedParents.keys)
//we should recompile all inheritors with parent sealed class: add known subtypes
addAll(sealedParents.keys.flatMap { withSubtypes(it, caches) })
//we should recompile all inheritors with parent sealed class: add new subtypes
addAll(sealedParents.values.flatten())
}
return DirtyData(dirtyLookupSymbols, dirtyClassesFqNames, forceRecompile)
}
fun mapLookupSymbolsToFiles(
@@ -217,6 +246,11 @@ fun mapClassesFqNamesToFiles(
return fqNameToAffectedFiles.values.flattenTo(HashSet())
}
fun isSealed(
fqName: FqName,
caches: Iterable<IncrementalCacheCommon>
): Boolean = caches.any { it.isSealed(fqName) ?: false }
fun withSubtypes(
typeFqName: FqName,
caches: Iterable<IncrementalCacheCommon>

View File

@@ -28,12 +28,14 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.protobuf.MessageLite
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
import org.jetbrains.kotlin.serialization.deserialization.descriptorVisibility
import org.jetbrains.kotlin.serialization.deserialization.getClassId
import java.util.*
data class Difference(
val isClassAffected: Boolean = false,
val areSubclassesAffected: Boolean = false,
val changedMembersNames: Set<String> = emptySet()
val changedMembersNames: Set<String> = emptySet(),
val changedSupertypes: Set<FqName> = emptySet()
)
sealed class ProtoData
@@ -187,6 +189,7 @@ class DifferenceCalculatorForClass(
var isClassAffected = false
var areSubclassesAffected = false
val changedSupertypes = HashSet<FqName>()
val names = hashSetOf<String>()
val classIsSealed = newProto.isSealed && oldProto.isSealed
@@ -247,12 +250,21 @@ class DifferenceCalculatorForClass(
ProtoBufClassKind.FLAGS,
ProtoBufClassKind.FQ_NAME,
ProtoBufClassKind.TYPE_PARAMETER_LIST,
ProtoBufClassKind.SUPERTYPE_LIST,
ProtoBufClassKind.SUPERTYPE_ID_LIST,
ProtoBufClassKind.JS_EXT_CLASS_ANNOTATION_LIST -> {
isClassAffected = true
areSubclassesAffected = true
}
ProtoBufClassKind.SUPERTYPE_LIST,
ProtoBufClassKind.SUPERTYPE_ID_LIST -> {
isClassAffected = true
areSubclassesAffected = true
val oldSupertypes = oldProto.supertypeList.map { oldNameResolver.getClassId(it.className).asSingleFqName() }
val newSupertypes = newProto.supertypeList.map { newNameResolver.getClassId(it.className).asSingleFqName() }
val changed = (oldSupertypes union newSupertypes) subtract (oldSupertypes intersect newSupertypes)
changedSupertypes.addAll(changed)
}
ProtoBufClassKind.JVM_EXT_CLASS_MODULE_NAME,
ProtoBufClassKind.JS_EXT_CLASS_CONTAINING_FILE_ID -> {
// TODO
@@ -281,7 +293,7 @@ class DifferenceCalculatorForClass(
}
}
return Difference(isClassAffected, areSubclassesAffected, names)
return Difference(isClassAffected, areSubclassesAffected, names, changedSupertypes)
}
}

View File

@@ -30,6 +30,7 @@ open class BasicMapsOwner(val cachesDir: File) {
protected val String.storageFile: File
get() = File(cachesDir, this + "." + CACHE_EXTENSION)
@Synchronized
protected fun <K, V, M : BasicMap<K, V>> registerMap(map: M): M {
maps.add(map)
return map
@@ -47,6 +48,7 @@ open class BasicMapsOwner(val cachesDir: File) {
forEachMapSafe("flush") { it.flush(memoryCachesOnly) }
}
@Synchronized
private fun forEachMapSafe(actionName: String, action: (BasicMap<*, *>) -> Unit) {
val actionExceptions = LinkedHashMap<String, Exception>()
maps.forEach {
@@ -66,5 +68,6 @@ open class BasicMapsOwner(val cachesDir: File) {
}
@TestOnly
@Synchronized
fun dump(): String = maps.joinToString("\n\n") { it.dump() }
}

View File

@@ -17,9 +17,11 @@
package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.IOUtil
import com.intellij.util.io.KeyDescriptor
import com.intellij.util.io.PersistentHashMap
import java.io.File
import java.io.IOException
/**
@@ -30,7 +32,6 @@ class CachingLazyStorage<K, V>(
private val keyDescriptor: KeyDescriptor<K>,
private val valueExternalizer: DataExternalizer<V>
) : LazyStorage<K, V> {
@Volatile
private var storage: PersistentHashMap<K, V>? = null
@Synchronized
@@ -80,8 +81,10 @@ class CachingLazyStorage<K, V>(
try {
storage?.close()
} finally {
PersistentHashMap.deleteFilesStartingWith(storageFile)
storage = null
if (!IOUtil.deleteAllFilesStartingWith(storageFile)) {
throw IOException("Could not delete internal storage: ${storageFile.absolutePath}")
}
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import org.jetbrains.kotlin.name.FqName
import java.io.DataInput
import java.io.DataOutput
import java.io.File
internal data class ICClassesAttributes(val isSealed: Boolean)
internal object ICClassesAttributesExternalizer : DataExternalizer<ICClassesAttributes> {
override fun read(input: DataInput): ICClassesAttributes {
return ICClassesAttributes(input.readBoolean())
}
override fun save(output: DataOutput, value: ICClassesAttributes) {
output.writeBoolean(value.isSealed)
}
}
internal open class ClassAttributesMap(
storageFile: File
) : BasicStringMap<ICClassesAttributes>(storageFile, ICClassesAttributesExternalizer) {
override fun dumpValue(value: ICClassesAttributes): String = value.toString()
operator fun set(key: FqName, value: ICClassesAttributes) {
storage[key.asString()] = value
}
operator fun get(key: FqName): ICClassesAttributes? = storage[key.asString()]
fun remove(key: FqName) {
storage.remove(key.asString())
}
}

View File

@@ -20,18 +20,18 @@ import org.jetbrains.kotlin.incremental.dumpCollection
import org.jetbrains.kotlin.name.FqName
import java.io.File
internal open class ClassOneToManyMap(
storageFile: File
) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
internal open class ClassOneToManyMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
override fun dumpValue(value: Collection<String>): String = value.dumpCollection()
@Synchronized
fun add(key: FqName, value: FqName) {
storage.append(key.asString(), listOf(value.asString()))
}
operator fun get(key: FqName): Collection<FqName> =
storage[key.asString()]?.map(::FqName) ?: setOf()
storage[key.asString()]?.map(::FqName) ?: setOf()
@Synchronized
operator fun set(key: FqName, values: Collection<FqName>) {
if (values.isEmpty()) {
remove(key)
@@ -41,10 +41,14 @@ internal open class ClassOneToManyMap(
storage[key.asString()] = values.map(FqName::asString)
}
@Synchronized
fun remove(key: FqName) {
storage.remove(key.asString())
}
// Access to caches could be done from multiple threads (e.g. JPS worker and RMI). The underlying collection is already synchronized,
// thus we need synchronization of this method and all modification methods.
@Synchronized
fun removeValues(key: FqName, removed: Set<FqName>) {
val notRemoved = this[key].filter { it !in removed }
this[key] = notRemoved

View File

@@ -25,8 +25,7 @@ internal class DirtyClassesJvmNameMap(storageFile: File) : AbstractDirtyClassesM
internal class DirtyClassesFqNameMap(storageFile: File) : AbstractDirtyClassesMap<FqName>(FqNameTransformer, storageFile)
internal abstract class AbstractDirtyClassesMap<Name>(
private val nameTransformer: NameTransformer<Name>,
storageFile: File
private val nameTransformer: NameTransformer<Name>, storageFile: File
) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
fun markDirty(className: Name) {
storage[nameTransformer.asString(className)] = true
@@ -37,10 +36,10 @@ internal abstract class AbstractDirtyClassesMap<Name>(
}
fun getDirtyOutputClasses(): Collection<Name> =
storage.keys.map { nameTransformer.asName(it) }
storage.keys.map { nameTransformer.asName(it) }
fun isDirty(className: Name): Boolean =
storage.contains(nameTransformer.asString(className))
storage.contains(nameTransformer.asString(className))
override fun dumpValue(value: Boolean) = ""
}

View File

@@ -17,9 +17,11 @@
package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.IOUtil
import com.intellij.util.io.KeyDescriptor
import com.intellij.util.io.PersistentHashMap
import java.io.File
import java.io.IOException
class NonCachingLazyStorage<K, V>(
@@ -27,7 +29,6 @@ class NonCachingLazyStorage<K, V>(
private val keyDescriptor: KeyDescriptor<K>,
private val valueExternalizer: DataExternalizer<V>
) : LazyStorage<K, V> {
@Volatile
private var storage: PersistentHashMap<K, V>? = null
@Synchronized
@@ -76,11 +77,12 @@ class NonCachingLazyStorage<K, V>(
override fun clean() {
try {
storage?.close()
} catch (ignored: Throwable) {
} finally {
storage = null
if (!IOUtil.deleteAllFilesStartingWith(storageFile)) {
throw IOException("Could not delete internal storage: ${storageFile.absolutePath}")
}
}
PersistentHashMap.deleteFilesStartingWith(storageFile)
storage = null
}
@Synchronized

View File

@@ -188,7 +188,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.4.30-dev-17395"
extra["versions.kotlin-native"] = "1.4.31-release-146"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -304,7 +304,6 @@ extra["compilerModulesForJps"] = listOf(
":compiler:cli-common",
":kotlin-compiler-runner",
":daemon-common",
":daemon-common-new",
":core:compiler.common",
":core:compiler.common.jvm",
":core:descriptors",
@@ -905,13 +904,14 @@ tasks {
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-build-common-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-compiler-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:compiler-components-for-jps:publish",
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-stdlib-for-ide:publish",
":kotlin-script-runtime:publish",
":kotlin-script-util:publish",
":kotlin-scripting-common:publish",

View File

@@ -254,14 +254,14 @@ fun Project.idePluginDependency(block: () -> Unit) {
}
}
fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List<String> = emptyList()) {
fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List<String> = emptyList(), configuration: String? = null) {
apply<JavaPlugin>()
val fatJarContents by configurations.creating
dependencies {
for (projectName in projects) {
fatJarContents(project(projectName)) { isTransitive = false }
fatJarContents(project(projectName, configuration)) { isTransitive = false }
}
for (libraryDependency in libraryDependencies) {

View File

@@ -20,6 +20,10 @@ internal const val PLUGIN_MARKER_SUFFIX = ".gradle.plugin"
@OptIn(ExperimentalStdlibApi::class)
fun Project.publishPluginMarkers(withEmptyJars: Boolean = true) {
fun Project.isSonatypePublish(): Boolean =
hasProperty("isSonatypePublish") && property("isSonatypePublish") as Boolean
val pluginDevelopment = extensions.getByType<PluginBundleExtension>()
val publishingExtension = extensions.getByType<PublishingExtension>()
val mainPublication = publishingExtension.publications[KotlinBuildPublishingPlugin.PUBLICATION_NAME] as MavenPublication
@@ -32,7 +36,12 @@ fun Project.publishPluginMarkers(withEmptyJars: Boolean = true) {
tasks.named<PublishToMavenRepository>(
"publish${markerPublication.name.capitalize(Locale.ROOT)}PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository"
).configureRepository()
).apply {
configureRepository()
configure {
onlyIf { !isSonatypePublish() }
}
}
}
}

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.org.objectweb.asm.Opcodes
// This object should help compiling against different ASM versions in different bunch versions
object VersionIndependentOpcodes {
const val ACC_RECORD = Opcodes.ACC_RECORD
}

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.org.objectweb.asm.Opcodes
// This object should help compiling against different ASM versions from different bunch versions
object VersionIndependentOpcodes {
const val ACC_RECORD = 0
}

View File

@@ -26,13 +26,13 @@ import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.*;
import java.util.ArrayList;
import java.util.List;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.GENERATE_SMAP;
public abstract class AbstractClassBuilder implements ClassBuilder {
protected static final MethodVisitor EMPTY_METHOD_VISITOR = new MethodVisitor(Opcodes.API_VERSION) {};
public static final RecordComponentVisitor EMPTY_RECORD_VISITOR = new RecordComponentVisitor(Opcodes.API_VERSION) {};
protected static final FieldVisitor EMPTY_FIELD_VISITOR = new FieldVisitor(Opcodes.API_VERSION) {};
private String thisName;
@@ -91,6 +91,16 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
return visitor;
}
@NotNull
@Override
public RecordComponentVisitor newRecordComponent(@NotNull String name, @NotNull String desc, @Nullable String signature) {
RecordComponentVisitor visitor = getVisitor().visitRecordComponent(name, desc, signature);
if (visitor == null) {
return EMPTY_RECORD_VISITOR;
}
return visitor;
}
@Override
@NotNull
public JvmSerializationBindings getSerializationBindings() {

View File

@@ -0,0 +1,158 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.FileMapping;
import org.jetbrains.kotlin.codegen.inline.SMAPBuilder;
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.*;
import java.util.List;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.GENERATE_SMAP;
public abstract class AbstractClassBuilder implements ClassBuilder {
protected static final MethodVisitor EMPTY_METHOD_VISITOR = new MethodVisitor(Opcodes.API_VERSION) {};
protected static final FieldVisitor EMPTY_FIELD_VISITOR = new FieldVisitor(Opcodes.API_VERSION) {};
private String thisName;
private final JvmSerializationBindings serializationBindings = new JvmSerializationBindings();
private String sourceName;
private String debugInfo;
public static class Concrete extends AbstractClassBuilder {
private final ClassVisitor v;
public Concrete(@NotNull ClassVisitor v) {
this.v = v;
}
@Override
@NotNull
public ClassVisitor getVisitor() {
return v;
}
}
@Override
@NotNull
public FieldVisitor newField(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable Object value
) {
FieldVisitor visitor = getVisitor().visitField(access, name, desc, signature, value);
if (visitor == null) {
return EMPTY_FIELD_VISITOR;
}
return visitor;
}
@Override
@NotNull
public MethodVisitor newMethod(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable String[] exceptions
) {
MethodVisitor visitor = getVisitor().visitMethod(access, name, desc, signature, exceptions);
if (visitor == null) {
return EMPTY_METHOD_VISITOR;
}
return visitor;
}
@Override
@NotNull
public JvmSerializationBindings getSerializationBindings() {
return serializationBindings;
}
@Override
@NotNull
public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
return getVisitor().visitAnnotation(desc, visible);
}
@Override
public void done() {
getVisitor().visitSource(sourceName, debugInfo);
getVisitor().visitEnd();
}
@Override
public void defineClass(
@Nullable PsiElement origin,
int version,
int access,
@NotNull String name,
@Nullable String signature,
@NotNull String superName,
@NotNull String[] interfaces
) {
thisName = name;
getVisitor().visit(version, access, name, signature, superName, interfaces);
}
@Override
public void visitSource(@NotNull String name, @Nullable String debug) {
assert sourceName == null || sourceName.equals(name) : "inconsistent file name: " + sourceName + " vs " + name;
sourceName = name;
debugInfo = debug;
}
@Override
public void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax) {
if (!GENERATE_SMAP) return;
List<FileMapping> fileMappings = smap.getResultMappings();
if (fileMappings.isEmpty()) return;
visitSource(fileMappings.get(0).getName(), SMAPBuilder.INSTANCE.build(fileMappings, backwardsCompatibleSyntax));
}
@Override
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
getVisitor().visitOuterClass(owner, name, desc);
}
@Override
public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
getVisitor().visitInnerClass(name, outerName, innerName, access);
}
@Override
@NotNull
public String getThisName() {
assert thisName != null : "This name isn't set";
return thisName;
}
}

View File

@@ -19,14 +19,10 @@ package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.FileMapping;
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
import org.jetbrains.org.objectweb.asm.ClassVisitor;
import org.jetbrains.org.objectweb.asm.FieldVisitor;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.*;
public interface ClassBuilder {
@NotNull
@@ -49,6 +45,12 @@ public interface ClassBuilder {
@Nullable String[] exceptions
);
@NotNull RecordComponentVisitor newRecordComponent(
@NotNull String name,
@NotNull String desc,
@Nullable String signature
);
@NotNull
JvmSerializationBindings getSerializationBindings();

View File

@@ -0,0 +1,79 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.*;
public interface ClassBuilder {
@NotNull
FieldVisitor newField(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable Object value
);
@NotNull
MethodVisitor newMethod(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable String[] exceptions
);
@NotNull
JvmSerializationBindings getSerializationBindings();
@NotNull
AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible);
void done();
@NotNull
ClassVisitor getVisitor();
void defineClass(
@Nullable PsiElement origin,
int version,
int access,
@NotNull String name,
@Nullable String signature,
@NotNull String superName,
@NotNull String[] interfaces
);
void visitSource(@NotNull String name, @Nullable String debug);
void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax);
void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc);
void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access);
@NotNull
String getThisName();
}

View File

@@ -0,0 +1,10 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
fun ClassBuilder.addRecordComponent(name: String, desc: String, signature: String?) {
newRecordComponent(name, desc, signature)
}

View File

@@ -0,0 +1,10 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
fun ClassBuilder.addRecordComponent(name: String, desc: String, signature: String?) {
// newRecordComponent(name, desc, signature)
}

View File

@@ -19,14 +19,10 @@ package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.FileMapping;
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
import org.jetbrains.org.objectweb.asm.ClassVisitor;
import org.jetbrains.org.objectweb.asm.FieldVisitor;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.*;
public abstract class DelegatingClassBuilder implements ClassBuilder {
@NotNull
@@ -58,6 +54,14 @@ public abstract class DelegatingClassBuilder implements ClassBuilder {
return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
}
@NotNull
@Override
public RecordComponentVisitor newRecordComponent(
@NotNull String name, @NotNull String desc, @Nullable String signature
) {
return getDelegate().newRecordComponent(name, desc, signature);
}
@NotNull
@Override
public JvmSerializationBindings getSerializationBindings() {

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.*;
public abstract class DelegatingClassBuilder implements ClassBuilder {
@NotNull
protected abstract ClassBuilder getDelegate();
@NotNull
@Override
public FieldVisitor newField(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable Object value
) {
return getDelegate().newField(origin, access, name, desc, signature, value);
}
@NotNull
@Override
public MethodVisitor newMethod(
@NotNull JvmDeclarationOrigin origin,
int access,
@NotNull String name,
@NotNull String desc,
@Nullable String signature,
@Nullable String[] exceptions
) {
return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
}
@NotNull
@Override
public JvmSerializationBindings getSerializationBindings() {
return getDelegate().getSerializationBindings();
}
@NotNull
@Override
public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
return getDelegate().newAnnotation(desc, visible);
}
@Override
public void done() {
getDelegate().done();
}
@NotNull
@Override
public ClassVisitor getVisitor() {
return getDelegate().getVisitor();
}
@Override
public void defineClass(
@Nullable PsiElement origin,
int version,
int access,
@NotNull String name,
@Nullable String signature,
@NotNull String superName,
@NotNull String[] interfaces
) {
getDelegate().defineClass(origin, version, access, name, signature, superName, interfaces);
}
@Override
public void visitSource(@NotNull String name, @Nullable String debug) {
getDelegate().visitSource(name, debug);
}
@Override
public void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax) {
getDelegate().visitSMAP(smap, backwardsCompatibleSyntax);
}
@Override
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
getDelegate().visitOuterClass(owner, name, desc);
}
@Override
public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
getDelegate().visitInnerClass(name, outerName, innerName, access);
}
@NotNull
@Override
public String getThisName() {
return getDelegate().getThisName();
}
}

View File

@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver
import org.jetbrains.kotlin.resolve.JVM_INLINE_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
@@ -55,6 +56,13 @@ class ErasedInlineClassBodyCodegen(
generateUnboxMethod()
generateFunctionsFromAny()
generateSpecializedEqualsStub()
generateJvmInlineAnnotation()
}
private fun generateJvmInlineAnnotation() {
if (descriptor.isInline) {
v.newAnnotation(JVM_INLINE_ANNOTATION_FQ_NAME.topLevelClassAsmType().descriptor, true).visitEnd()
}
}
private fun generateFunctionsFromAny() {

View File

@@ -1221,7 +1221,12 @@ public class FunctionCodegen {
// 'null' because the "could not find expected declaration" error has been already reported in isDefaultNeeded earlier
List<ValueParameterDescriptor> valueParameters =
CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null);
functionDescriptor.isSuspend()
? CollectionsKt.plus(
CodegenUtil.getFunctionParametersForDefaultValueGeneration(
CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(functionDescriptor), null),
CollectionsKt.last(functionDescriptor.getValueParameters()))
: CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null);
boolean isStatic = isStaticMethod(methodContext.getContextKind(), functionDescriptor);
FrameMap frameMap = createFrameMap(state, signature, functionDescriptor.getExtensionReceiverParameter(), valueParameters, isStatic);

View File

@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature;
@@ -221,6 +222,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
access |= ACC_ENUM;
}
if (JvmAnnotationUtilKt.isJvmRecord(descriptor)) {
access |= VersionIndependentOpcodes.ACC_RECORD;
}
v.defineClass(
myClass.getPsiOrParent(),
state.getClassFileVersion(),

View File

@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
@@ -435,9 +436,10 @@ public class PropertyCodegen {
v.getSerializationBindings().put(FIELD_FOR_PROPERTY, propertyDescriptor, new Pair<>(type, name));
if (isBackingFieldOwner) {
String signature = isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor);
FieldVisitor fv = builder.newField(
JvmDeclarationOriginKt.OtherOrigin(propertyDescriptor), modifiers, name, type.getDescriptor(),
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
signature, defaultValue
);
if (annotatedField != null) {
@@ -450,6 +452,10 @@ public class PropertyCodegen {
AnnotationCodegen.forField(fv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(annotatedField, type, propertyDescriptor.getType(), null, additionalVisibleAnnotations);
}
if (propertyDescriptor.getContainingDeclaration() instanceof ClassDescriptor && JvmAnnotationUtilKt.isJvmRecord((ClassDescriptor) propertyDescriptor.getContainingDeclaration())) {
ClassBuilderRecordKt.addRecordComponent(builder, name, type.getDescriptor(), signature);
}
}
}

View File

@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicArrayConstructors
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.Position
import org.jetbrains.kotlin.incremental.components.ScopeKind
@@ -513,7 +514,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
companion object {
internal fun createInlineMethodNode(
functionDescriptor: FunctionDescriptor,
methodOwner: Type,
@@ -529,10 +529,15 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
return SMAPAndMethodNode(intrinsic, createDefaultFakeSMAP())
}
val asmMethod = if (callDefault)
state.typeMapper.mapDefaultMethod(functionDescriptor, sourceCompilerForInline.contextKind)
else
mangleSuspendInlineFunctionAsmMethodIfNeeded(functionDescriptor, jvmSignature.asmMethod)
var asmMethod = mapMethod(state, functionDescriptor, sourceCompilerForInline, jvmSignature, callDefault)
if (asmMethod.name.contains("-") &&
!state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME) &&
classFileContainsMethod(functionDescriptor, state, asmMethod) == false
) {
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = true
asmMethod = mapMethod(state, functionDescriptor, sourceCompilerForInline, jvmSignature, callDefault)
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = false
}
val directMember = getDirectMemberAndCallableFromObject(functionDescriptor)
if (!isBuiltInArrayIntrinsic(functionDescriptor) && directMember !is DescriptorWithContainerSource) {
@@ -544,6 +549,16 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
return getCompiledMethodNodeInner(functionDescriptor, directMember, asmMethod, methodOwner, state, jvmSignature)
}
private fun mapMethod(
state: GenerationState,
functionDescriptor: FunctionDescriptor,
sourceCompiler: SourceCompilerForInline,
jvmSignature: JvmMethodSignature,
callDefault: Boolean
): Method =
if (callDefault) state.typeMapper.mapDefaultMethod(functionDescriptor, sourceCompiler.contextKind)
else mangleSuspendInlineFunctionAsmMethodIfNeeded(functionDescriptor, jvmSignature.asmMethod)
internal fun createSpecialInlineMethodNodeFromBinaries(functionDescriptor: FunctionDescriptor, state: GenerationState): MethodNode {
val directMember = getDirectMemberAndCallableFromObject(functionDescriptor)
assert(directMember is DescriptorWithContainerSource) {

View File

@@ -130,7 +130,9 @@ fun <T, R : DefaultLambda> expandMaskConditionsAndUpdateVariableNodes(
node.instructions.insert(position, newInsn)
}
node.localVariables.removeIf { it.start in toDelete && it.end in toDelete }
node.localVariables.removeIf {
(it.start in toDelete && it.end in toDelete) || defaultLambdas.contains(it.index)
}
node.remove(toDelete)

View File

@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
@@ -44,6 +41,10 @@ fun CallableDescriptor.isGenericParameter(): Boolean {
fun classFileContainsMethod(descriptor: FunctionDescriptor, state: GenerationState, method: Method): Boolean? {
if (descriptor !is DeserializedSimpleFunctionDescriptor) return null
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
return descriptor.overriddenDescriptors.any { classFileContainsMethod(it, state, method) == true }
}
val classId: ClassId = when {
descriptor.containingDeclaration is DeserializedClassDescriptor -> {
(descriptor.containingDeclaration as DeserializedClassDescriptor).classId ?: return null

View File

@@ -201,7 +201,7 @@ class GenerationState private constructor(
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
val runtimeStringConcat =
if (target.bytecodeVersion >= JvmTarget.JVM_9.bytecodeVersion)
if (target.majorVersion >= JvmTarget.JVM_9.majorVersion)
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
else JvmStringConcat.INLINE
@@ -272,7 +272,10 @@ class GenerationState private constructor(
val rootContext: CodegenContext<*> = RootContext(this)
val classFileVersion: Int = target.bytecodeVersion
val classFileVersion: Int = run {
val minorVersion = if (configuration.getBoolean(JVMConfigurationKeys.ENABLE_JVM_PREVIEW)) 0xffff else 0
(minorVersion shl 16) + target.majorVersion
}
val generateParametersMetadata: Boolean = configuration.getBoolean(JVMConfigurationKeys.PARAMETERS_METADATA)
@@ -295,7 +298,7 @@ class GenerationState private constructor(
?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE
else JvmMetadataVersion(1, 1, 18)
val isIrWithStableAbi = configuration.getBoolean(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI)
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
val globalSerializationBindings = JvmSerializationBindings()
var mapInlineClass: (ClassDescriptor) -> Type = { descriptor -> typeMapper.mapType(descriptor.defaultType) }

View File

@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall
import org.jetbrains.kotlin.resolve.BindingContextUtils.isBoxedLocalCapturedInClosure
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -60,6 +61,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.DEFAULT_CONSTRUCTOR_MARKER
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
import org.jetbrains.kotlin.resolve.jvm.JAVA_LANG_RECORD_FQ_NAME
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.annotations.isCompiledToJvmDefault
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
@@ -372,13 +374,27 @@ class KotlinTypeMapper @JvmOverloads constructor(
kind: OwnerKind? = null,
resolvedCall: ResolvedCall<*>? = null
): CallableMethod {
fun mapDefaultCallback(descriptor: FunctionDescriptor, kind: OwnerKind): () -> Method {
if (useOldManglingRulesForFunctionAcceptingInlineClass && !useOldInlineClassesManglingScheme) {
return {
val prevManglingState = useOldManglingRulesForFunctionAcceptingInlineClass
useOldManglingRulesForFunctionAcceptingInlineClass = true
mapDefaultMethod(descriptor, kind).also {
useOldManglingRulesForFunctionAcceptingInlineClass = prevManglingState
}
}
} else {
return { mapDefaultMethod(descriptor, kind) }
}
}
// we generate constructors of inline classes as usual functions
if (descriptor is ConstructorDescriptor && kind != OwnerKind.ERASED_INLINE_CLASS) {
val method = mapSignatureSkipGeneric(descriptor.original)
val owner = mapOwner(descriptor)
val originalDescriptor = descriptor.original
return CallableMethod(
owner, owner, { mapDefaultMethod(originalDescriptor, OwnerKind.IMPLEMENTATION) }, method, INVOKESPECIAL,
owner, owner, mapDefaultCallback(originalDescriptor, OwnerKind.IMPLEMENTATION), method, INVOKESPECIAL,
null, null, null, null, null, originalDescriptor.returnType, isInterfaceMethod = false, isDefaultMethodInInterface = false
)
}
@@ -543,7 +559,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
return CallableMethod(
owner, ownerForDefaultImpl,
{ mapDefaultMethod(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)) },
mapDefaultCallback(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)),
signature, invokeOpcode, thisClass, dispatchReceiverKotlinType, receiverParameterType, extensionReceiverKotlinType,
calleeType, returnKotlinType,
if (jvmTarget >= JvmTarget.JVM_1_8) isInterfaceMember else invokeOpcode == INVOKEINTERFACE,
@@ -563,10 +579,16 @@ class KotlinTypeMapper @JvmOverloads constructor(
return when {
descriptor is PropertyAccessorDescriptor -> {
val property = descriptor.correspondingProperty
if (isAnnotationClass(property.containingDeclaration)) {
val containingDeclaration = property.containingDeclaration
if (isAnnotationClass(containingDeclaration) &&
(!property.hasJvmStaticAnnotation() && !descriptor.hasJvmStaticAnnotation())
) {
return property.name.asString()
}
if ((containingDeclaration as? ClassDescriptor)?.hasJavaLangRecordSupertype() == true) return property.name.asString()
val isAccessor = property is AccessorForPropertyDescriptor
val propertyName = if (isAccessor)
(property as AccessorForPropertyDescriptor).accessorSuffix
@@ -601,6 +623,9 @@ class KotlinTypeMapper @JvmOverloads constructor(
}
}
private fun ClassDescriptor.hasJavaLangRecordSupertype() =
typeConstructor.supertypes.any { KotlinBuiltIns.isConstructedFromGivenClass(it, JAVA_LANG_RECORD_FQ_NAME) }
private val shouldMangleByReturnType =
languageVersionSettings.supportsFeature(LanguageFeature.MangleClassMembersReturningInlineClasses)

View File

@@ -49,6 +49,7 @@ if "%_KOTLIN_RUNNER%"=="1" (
"%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
) else (
setlocal EnableDelayedExpansion
SET _ADDITIONAL_CLASSPATH=
if not "%_KOTLIN_TOOL%"=="" (
@@ -56,7 +57,7 @@ if "%_KOTLIN_RUNNER%"=="1" (
)
"%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar%_ADDITIONAL_CLASSPATH%" ^
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
)

View File

@@ -2,6 +2,8 @@
<id>org.jetbrains.kotlin</id>
<version>1.2</version>
<!-- Don't add more extension points here! Logic in KotlinCoreEnvironment assumes that there is only one EP. -->
<!-- And this file should be removed once 202 is no longer supported -->
<extensionPoints>
<extensionPoint qualifiedName="com.intellij.psi.classFileDecompiler"
interface="com.intellij.psi.compiled.ClassFileDecompilers$Decompiler"

View File

@@ -85,8 +85,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xuse-ir", description = "Use the IR backend")
var useIR: Boolean by FreezableVar(false)
@Argument(value = "-Xno-use-ir", description = "Do not use the IR backend. Useful for a custom-built compiler where IR backend is enabled by default")
var noUseIR: Boolean by FreezableVar(false)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-Xuse-old-backend", description = "Use the old JVM backend")
var useOldBackend: Boolean by FreezableVar(false)
@Argument(
value = "-Xir-check-local-names",
@@ -95,18 +96,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
var irCheckLocalNames: Boolean by FreezableVar(false)
@Argument(
value = "-Xallow-jvm-ir-dependencies",
description = "When not using the IR backend, do not report errors on those classes in dependencies, " +
"which were compiled by the IR backend"
value = "-Xallow-unstable-dependencies",
description = "Do not report errors on classes in dependencies, which were compiled by an unstable version of the Kotlin compiler"
)
var allowJvmIrDependencies: Boolean by FreezableVar(false)
var allowUnstableDependencies: Boolean by FreezableVar(false)
@Argument(
value = "-Xir-binary-with-stable-abi",
description = "When using the IR backend, produce binaries which can be read by non-IR backend.\n" +
"The author is responsible for verifying that the resulting binaries do indeed have the correct ABI"
value = "-Xabi-stability",
valueDescription = "{stable|unstable}",
description = "When using unstable compiler features such as FIR, use 'stable' to mark generated class files as stable\n" +
"to prevent diagnostics from stable compilers at the call site.\n" +
"When using the JVM IR backend, conversely, use 'unstable' to mark generated class files as unstable\n" +
"to force diagnostics to be reported."
)
var isIrWithStableAbi: Boolean by FreezableVar(false)
var abiStability: String? by FreezableVar(null)
@Argument(
value = "-Xir-do-not-clear-binding-context",
@@ -312,6 +315,13 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var jvmDefault: String by FreezableVar(JvmDefaultMode.DEFAULT.description)
@Argument(
value = "-Xdefault-script-extension",
valueDescription = "<script filename extension>",
description = "Compile expressions and unrecognized scripts passed with the -script argument as scripts with given filename extension"
)
var defaultScriptExtension: String? by FreezableVar(null)
@Argument(value = "-Xdisable-standard-script", description = "Disable standard kotlin script support")
var disableStandardScript: Boolean by FreezableVar(false)
@@ -418,6 +428,13 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var useOldInlineClassesManglingScheme: Boolean by FreezableVar(false)
@Argument(
value = "-Xjvm-enable-preview",
description = "Allow using features from Java language that are in preview phase.\n" +
"Works as `--enable-preview` in Java. All class files are marked as preview-generated thus it won't be possible to use them in release environment"
)
var enableJvmPreview: Boolean by FreezableVar(false)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
@@ -438,7 +455,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
result[JvmAnalysisFlags.suppressMissingBuiltinsError] = suppressMissingBuiltinsError
result[JvmAnalysisFlags.irCheckLocalNames] = irCheckLocalNames
result[AnalysisFlags.reportErrorsOnIrDependencies] = !useIR && !useFir && !allowJvmIrDependencies
result[JvmAnalysisFlags.enableJvmPreview] = enableJvmPreview
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies || useFir
result[JvmAnalysisFlags.disableUltraLightClasses] = disableUltraLightClasses
return result
}
@@ -452,7 +470,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
}
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
if (!useIR) return
if (!useIR || useOldBackend) return
if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_3
|| languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3

View File

@@ -34,22 +34,36 @@ object Main {
KOTLIN_HOME = File(home)
}
enum class HowToRun(val argName: String) {
GUESS("guess"),
CLASSFILE("classfile"),
JAR("jar"),
SCRIPT("script");
// TODO: consider implementing REPL as well
companion object {
val validValues = "${GUESS.argName} (default), ${CLASSFILE.argName}, ${JAR.argName}, ${SCRIPT.argName} (or .<script filename extension>)"
fun fromArg(name: String): HowToRun? =
HowToRun.values().find { it.argName == name }
}
}
private fun run(args: Array<String>) {
val classpath = arrayListOf<URL>()
val compilerClasspath = arrayListOf<URL>()
var runner: Runner? = null
var collectingArguments = false
var collectingExpressions = false
var needsCompiler = false
val arguments = arrayListOf<String>()
var expression: String? = null
val compilerArguments = arrayListOf<String>()
var noStdLib = false
var noReflect = false
var howtorun = HowToRun.GUESS
fun setExpression(expr: String) {
if (expression == null) {
expression = expr
fun setRunner(newRunner: Runner) {
if (runner == null) {
runner = newRunner
} else {
throw RunnerException("Only single -e/-expression argument supported")
throw AssertionError("conflicting runner settings")
}
}
@@ -64,20 +78,8 @@ object Main {
return args[i]
}
if (collectingExpressions) {
if ("-expression" == arg || "-e" == arg) {
setExpression(next())
i++
continue
} else {
collectingArguments = true
}
}
if (collectingArguments) {
arguments.add(arg)
i++
continue
fun restAsArguments() {
arguments.addAll(args.copyOfRange(i+1, args.size))
}
if ("-help" == arg || "-h" == arg) {
@@ -96,29 +98,55 @@ object Main {
compilerClasspath.addPath(path)
}
}
else if ("-howtorun" == arg) {
if (howtorun != HowToRun.GUESS) {
throw RunnerException("-howtorun is already set to ${howtorun.argName}")
}
val howToRunArg = next()
if (howToRunArg.startsWith(".")) {
howtorun = HowToRun.SCRIPT
compilerArguments.add("-Xdefault-script-extension=$howToRunArg")
} else {
howtorun = HowToRun.fromArg(howToRunArg)
?: throw RunnerException("invalid argument to the option -howtorun $howToRunArg, valid arguments are: ${HowToRun.validValues}")
}
}
else if ("-expression" == arg || "-e" == arg) {
setExpression(next())
collectingExpressions = true
needsCompiler = true
if (howtorun != HowToRun.GUESS && howtorun != HowToRun.SCRIPT) {
throw RunnerException("expression evaluation is not compatible with -howtorun argument ${howtorun.argName}")
}
setRunner(ExpressionRunner(next()))
restAsArguments()
break
}
else if ("-no-stdlib" == arg) {
noStdLib = true
compilerArguments.add(arg)
}
else if ("-no-reflect" == arg) {
noReflect = true
compilerArguments.add(arg)
}
else if (arg.startsWith("-X")) {
compilerArguments.add(arg)
}
else if (arg.startsWith("-")) {
throw RunnerException("unsupported argument: $arg")
throw RunnerException("unknown option: $arg")
}
else if (arg.endsWith(".jar")) {
runner = JarRunner(arg)
collectingArguments = true
else if (howtorun == HowToRun.JAR || (howtorun == HowToRun.GUESS && arg.endsWith(".jar"))) {
setRunner(JarRunner(arg))
restAsArguments()
break
}
else if (arg.endsWith(".kts")) {
runner = ScriptRunner(arg)
collectingArguments = true
needsCompiler = true
else if (howtorun == HowToRun.SCRIPT || (howtorun == HowToRun.GUESS && arg.endsWith(".kts"))) {
setRunner(ScriptRunner(arg))
restAsArguments()
break
}
else {
runner = MainClassRunner(arg)
collectingArguments = true
setRunner(MainClassRunner(arg))
restAsArguments()
break
}
i++
}
@@ -127,26 +155,25 @@ object Main {
classpath.addPath(".")
}
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
if (!noStdLib) {
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
}
if (!noReflect) {
classpath.addPath("$KOTLIN_HOME/lib/kotlin-reflect.jar")
}
if (expression != null) {
runner = ExpressionRunner(expression!!)
} else if (runner == null) {
runner = ReplRunner()
needsCompiler = true
if (runner == null) {
setRunner(ReplRunner())
}
if (needsCompiler && compilerClasspath.isEmpty()) {
if (runner is RunnerWithCompiler && compilerClasspath.isEmpty()) {
findCompilerJar(this::class.java, KOTLIN_HOME.resolve("lib")).forEach {
compilerClasspath.add(it.absoluteFile.toURI().toURL())
}
}
runner.run(classpath, arguments, compilerClasspath)
runner!!.run(classpath, compilerArguments, arguments, compilerClasspath)
}
private fun MutableList<URL>.addPath(path: String) {
@@ -167,21 +194,31 @@ object Main {
private fun printUsageAndExit() {
println("""kotlin: run Kotlin programs, scripts or REPL.
Usage: kotlin <options> <command> <arguments>
where command may be one of:
foo.Bar Runs the 'main' function from the class with the given qualified name
app.jar Runs the given JAR file as 'java -jar' would do
(-classpath argument is ignored and no Kotlin runtime is added to the classpath)
""" +
// script.kts Compiles and runs the given script
// -expression (-e) '2+2' Evaluates the expression and prints the result
"""and possible options include:
Usage: kotlin <options> <command> [<arguments>]
where possible options include:
-howtorun <value> How to run the supplied command with arguments,
valid values: ${HowToRun.validValues}
-classpath (-cp) <path> Paths where to find user class files
-Dname=value Set a system JVM property
-J<option> Pass an option directly to JVM
-no-stdlib Don't include Kotlin standard library into classpath
-no-reflect Don't include Kotlin reflection implementation into classpath
-compiler-path Kotlin compiler classpath for compiling script or expression or running REPL
If not specified, try to find the compiler in the environment
-X<flag>[=value] Pass -X argument to the compiler
-version Display Kotlin version
-help (-h) Print a synopsis of options
and command is interpreted according to the -howtorun option argument
or, in case of guess, according to the following rules:
foo.Bar Runs the 'main' function from the class with the given qualified name
(compiler arguments are ignored)
app.jar Runs the given JAR file as 'java -jar' would do
(compiler arguments are ignored and no Kotlin stdlib is added to the classpath)
script.kts Compiles and runs the given script, passing <arguments> to it
-expression (-e) '2+2' Evaluates the expression and prints the result, passing <arguments> to it
<no command> Runs Kotlin REPL
arguments are passed to the main function when running class or jar file, and for standard script definitions
as the 'args' parameter when running script or expression
""")
exitProcess(0)
}

View File

@@ -21,6 +21,7 @@ import java.net.URL
interface Runner {
fun run(
classpath: List<URL>,
compilerArguments: List<String>,
arguments: List<String>,
compilerClasspath: List<URL>
)

View File

@@ -32,7 +32,7 @@ abstract class AbstractRunner : Runner {
protected abstract fun createClassLoader(classpath: List<URL>): ClassLoader
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
val classLoader = createClassLoader(classpath)
val mainClass = try {
@@ -127,39 +127,45 @@ private fun MutableList<String>.addClasspathArgIfNeeded(classpath: List<URL>) {
}
}
private fun ArrayList<String>.addScriptArguments(arguments: List<String>) {
if (arguments.isNotEmpty() && arguments.first() != "--") {
add("--")
}
addAll(arguments)
}
class ReplRunner : RunnerWithCompiler() {
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
val compilerArgs = ArrayList<String>()
compilerArgs.addClasspathArgIfNeeded(classpath)
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
val compilerArgs = ArrayList<String>().apply {
addClasspathArgIfNeeded(classpath)
addAll(compilerArguments)
addScriptArguments(arguments)
}
runCompiler(compilerClasspath, compilerArgs)
}
}
class ScriptRunner(private val path: String) : RunnerWithCompiler() {
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
val compilerArgs = ArrayList<String>().apply {
addClasspathArgIfNeeded(classpath)
addAll(compilerArguments)
add("-script")
add(path)
if (arguments.isNotEmpty() && arguments.first() != "--") {
add("--")
}
addAll(arguments)
addScriptArguments(arguments)
}
runCompiler(compilerClasspath, compilerArgs)
}
}
class ExpressionRunner(private val code: String) : RunnerWithCompiler() {
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
val compilerArgs = ArrayList<String>().apply {
addClasspathArgIfNeeded(classpath)
addAll(compilerArguments)
add("-expression")
add(code)
if (arguments.isNotEmpty() && arguments.first() != "--") {
add("--")
}
addAll(arguments)
addScriptArguments(arguments)
}
runCompiler(compilerClasspath, compilerArgs)
}

View File

@@ -182,11 +182,19 @@ class AnalyzerWithCompilerReport(
)
}
if (diagnostics.any { it.factory == Errors.IR_COMPILED_CLASS }) {
if (diagnostics.any { it.factory == Errors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS }) {
messageCollector.report(
ERROR,
"Classes compiled by a new Kotlin compiler backend were found in dependencies. " +
"Remove them from the classpath or use '-Xallow-jvm-ir-dependencies' to suppress errors"
"Classes compiled by an unstable version of the Kotlin compiler were found in dependencies. " +
"Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors"
)
}
if (diagnostics.any { it.factory == Errors.FIR_COMPILED_CLASS }) {
messageCollector.report(
ERROR,
"Classes compiled by the new Kotlin compiler frontend were found in dependencies. " +
"Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors"
)
}

View File

@@ -0,0 +1,14 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.pom.java.LanguageLevel
fun Project.setupHighestLanguageLevel() {
LanguageLevelProjectExtension.getInstance(this).languageLevel = LanguageLevel.JDK_15_PREVIEW
}

View File

@@ -0,0 +1,14 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.pom.java.LanguageLevel
fun Project.setupHighestLanguageLevel() {
// LanguageLevelProjectExtension.getInstance(this).languageLevel = LanguageLevel.JDK_15_PREVIEW
}

View File

@@ -33,13 +33,16 @@ import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.extensions.ExtensionsArea
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.pom.java.LanguageLevel
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.compiled.ClassFileDecompilers
import com.intellij.psi.impl.JavaClassSupersImpl
import com.intellij.psi.impl.PsiElementFinderImpl
import com.intellij.psi.impl.PsiTreeChangePreprocessor
@@ -249,6 +252,8 @@ class KotlinCoreEnvironment private constructor(
project.putUserData(APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY, fun(roots: List<File>) {
updateClasspath(roots.map { JavaSourceRoot(it, null) })
})
project.setupHighestLanguageLevel()
}
private fun collectAdditionalSources(project: MockProject) {
@@ -509,7 +514,11 @@ class KotlinCoreEnvironment private constructor(
val applicationEnvironment = KotlinCoreApplicationEnvironment.create(parentDisposable, unitTestMode)
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/compiler.xml")
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/core.xml")
// FIX ME WHEN BUNCH 202 REMOVED: this code is required to support compiler bundled to both 202 and 203.
// Please, remove "com.intellij.psi.classFileDecompiler" EP registration once 202 is no longer supported by the compiler
if (!Extensions.getRootArea().hasExtensionPoint("com.intellij.psi.classFileDecompiler")) {
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/core.xml")
}
registerApplicationServicesForCLI(applicationEnvironment)
registerApplicationServices(applicationEnvironment)

View File

@@ -649,8 +649,10 @@ class KotlinCoreEnvironment private constructor(
registerService(CliLightClassGenerationSupport::class.java, cliLightClassGenerationSupport)
registerService(KotlinAsJavaSupport::class.java, kotlinAsJavaSupport)
registerService(CodeAnalyzerInitializer::class.java, traceHolder)
@Suppress("UnstableApiUsage")
registerService(DumbUtil::class.java, KotlinCoreDumbUtil())
if (getService(DumbUtil::class.java) == null) {
@Suppress("UnstableApiUsage")
registerService(DumbUtil::class.java, KotlinCoreDumbUtil())
}
val area = Extensions.getArea(this)

View File

@@ -52,10 +52,10 @@ import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.container.get
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
import org.jetbrains.kotlin.fir.backend.jvm.FirMetadataSerializer
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendExtension
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
import org.jetbrains.kotlin.fir.session.FirJvmModuleInfo
@@ -389,10 +389,8 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyIRGenerationStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, sourceManager, extensions
) { context, irClass, _, serializationBindings, parent ->
FirMetadataSerializer(session, context, irClass, serializationBindings, parent)
}
generationState, moduleFragment, symbolTable, sourceManager, extensions, FirJvmBackendExtension(session, components)
)
CodegenFactory.doCheckCancelled(generationState)
generationState.factory.done()
@@ -463,6 +461,10 @@ object KotlinToJVMBytecodeCompiler {
environment.updateClasspath(result.additionalJavaRoots.map { JavaSourceRoot(it, null) })
}
if (result.additionalClassPathRoots.isNotEmpty()) {
environment.updateClasspath(result.additionalClassPathRoots.map { JvmClasspathRoot(it, false) })
}
if (result.additionalKotlinRoots.isNotEmpty()) {
environment.addKotlinSourceRoots(result.additionalKotlinRoots)
}
@@ -472,8 +474,8 @@ object KotlinToJVMBytecodeCompiler {
// Clear all diagnostic messages
configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]?.clear()
// Repeat analysis with additional Java roots (kapt generated sources)
return analyze(environment)
// Repeat analysis with additional source roots generated by compiler plugins.
return repeatAnalysisIfNeeded(analyze(environment), environment)
}
return result
@@ -568,8 +570,6 @@ object KotlinToJVMBytecodeCompiler {
sourceFiles: List<KtFile>,
module: Module?
): GenerationState {
val isIR = (configuration.getBoolean(JVMConfigurationKeys.IR) ||
configuration.getBoolean(CommonConfigurationKeys.USE_FIR))
val generationState = GenerationState.Builder(
environment.project,
ClassBuilderFactories.BINARIES,
@@ -579,13 +579,12 @@ object KotlinToJVMBytecodeCompiler {
configuration
)
.codegenFactory(
if (isIR) JvmIrCodegenFactory(
if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory(
configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases)
) else DefaultCodegenFactory
)
.withModule(module)
.onIndependentPartCompilationEnd(createOutputFilesFlushingCallbackIfPossible(configuration))
.isIrBackend(isIR)
.build()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()

View File

@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.getLibraryFromHome
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.cli.jvm.config.JvmModulePathRoot
@@ -19,9 +20,6 @@ import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArguments) {
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
put(JVMConfigurationKeys.INCLUDE_RUNTIME, arguments.includeRuntime)
putIfNotNull(JVMConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.asList())
@@ -39,7 +37,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
}
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion) {
if (jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion) {
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
if (jvmDefaultMode.forAllMethodsWithBody) {
messageCollector.report(
@@ -53,7 +51,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
val runtimeStringConcat = JvmStringConcat.fromString(arguments.stringConcat!!)
if (runtimeStringConcat != null) {
put(JVMConfigurationKeys.STRING_CONCAT, runtimeStringConcat)
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_9.bytecodeVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
if (jvmTarget.majorVersion < JvmTarget.JVM_9.majorVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
messageCollector.report(
WARNING,
"`-Xstring-concat=${arguments.stringConcat}` does nothing with JVM target `${jvmTarget.description}`."
@@ -71,9 +69,6 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
}
fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): Boolean {
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
if (arguments.noJdk) {
put(JVMConfigurationKeys.NO_JDK, true)
@@ -84,7 +79,7 @@ fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): B
}
if (arguments.jdkHome != null) {
val jdkHome = File(arguments.jdkHome)
val jdkHome = File(arguments.jdkHome!!)
if (!jdkHome.exists()) {
messageCollector.report(ERROR, "JDK home directory does not exist: $jdkHome")
return false
@@ -114,7 +109,6 @@ fun CompilerConfiguration.configureExplicitContentRoots(arguments: K2JVMCompiler
}
fun CompilerConfiguration.configureStandardLibs(paths: KotlinPaths?, arguments: K2JVMCompilerArguments) {
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
val isModularJava = isModularJava()
fun addRoot(moduleName: String, libraryName: String, getLibrary: (KotlinPaths) -> File, noLibraryArgument: String) {
@@ -171,8 +165,38 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
put(JVMConfigurationKeys.IR, arguments.useIR && !arguments.noUseIR)
put(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI, arguments.isIrWithStableAbi)
val useIR = arguments.useFir ||
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) {
!arguments.useOldBackend
} else {
arguments.useIR && !arguments.useOldBackend
}
if (arguments.useIR && arguments.useOldBackend) {
messageCollector.report(
STRONG_WARNING,
"Both -Xuse-ir and -Xuse-old-backend are passed. This is an inconsistent configuration. " +
"The compiler will use the ${if (useIR) "JVM IR" else "old JVM"} backend"
)
}
messageCollector.report(LOGGING, "Using ${if (useIR) "JVM IR" else "old JVM"} backend")
put(JVMConfigurationKeys.IR, useIR)
val abiStability = JvmAbiStability.fromStringOrNull(arguments.abiStability)
if (arguments.abiStability != null) {
if (abiStability == null) {
messageCollector.report(
ERROR,
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.values().map { it.description }}"
)
} else if (!useIR && abiStability == JvmAbiStability.UNSTABLE) {
messageCollector.report(ERROR, "-Xabi-stability=unstable is not supported in the old JVM backend")
} else {
put(JVMConfigurationKeys.ABI_STABILITY, abiStability)
}
}
put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, arguments.doNotClearBindingContext)
put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions)
put(JVMConfigurationKeys.DISABLE_RECEIVER_ASSERTIONS, arguments.noReceiverAssertions)
@@ -189,57 +213,54 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.NO_UNIFIED_NULL_CHECKS, arguments.noUnifiedNullChecks)
if (!JVMConstructorCallNormalizationMode.isSupportedValue(arguments.constructorCallNormalizationMode)) {
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
messageCollector.report(
ERROR,
"Unknown constructor call normalization mode: ${arguments.constructorCallNormalizationMode}, " +
"supported modes: ${JVMConstructorCallNormalizationMode.values().map { it.description }}"
)
}
val constructorCallNormalizationMode =
JVMConstructorCallNormalizationMode.fromStringOrNull(arguments.constructorCallNormalizationMode)
val constructorCallNormalizationMode = JVMConstructorCallNormalizationMode.fromStringOrNull(arguments.constructorCallNormalizationMode)
if (constructorCallNormalizationMode != null) {
put(
JVMConfigurationKeys.CONSTRUCTOR_CALL_NORMALIZATION_MODE,
constructorCallNormalizationMode
)
put(JVMConfigurationKeys.CONSTRUCTOR_CALL_NORMALIZATION_MODE, constructorCallNormalizationMode)
}
val assertionsMode =
JVMAssertionsMode.fromStringOrNull(arguments.assertionsMode)
if (assertionsMode == null) {
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
messageCollector.report(
ERROR,
"Unknown assertions mode: ${arguments.assertionsMode}, " +
"supported modes: ${JVMAssertionsMode.values().map { it.description }}"
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.values().map { it.description }}"
)
}
put(
JVMConfigurationKeys.ASSERTIONS_MODE,
assertionsMode ?: JVMAssertionsMode.DEFAULT
)
put(JVMConfigurationKeys.ASSERTIONS_MODE, assertionsMode ?: JVMAssertionsMode.DEFAULT)
put(JVMConfigurationKeys.USE_TYPE_TABLE, arguments.useTypeTable)
put(JVMConfigurationKeys.SKIP_RUNTIME_VERSION_CHECK, arguments.skipRuntimeVersionCheck)
put(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING, arguments.useOldClassFilesReading)
if (arguments.useOldClassFilesReading) {
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
.report(INFO, "Using the old java class files reading implementation")
messageCollector.report(INFO, "Using the old java class files reading implementation")
}
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
put(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS, arguments.useOldSpilledVarTypeAnalysis)
put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme)
put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview)
if (arguments.enableJvmPreview) {
messageCollector.report(INFO, "Using preview Java language features")
}
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
}
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
assert(arguments.useIR || arguments.klibLibraries == null) { "Klib libraries can only be used with IR backend" }
arguments.klibLibraries?.split(File.pathSeparator.toRegex())
?.toTypedArray()
?.filterNot { it.isEmpty() }
?.let { put(JVMConfigurationKeys.KLIB_PATHS, it) }
}
val libraries = arguments.klibLibraries ?: return
assert(arguments.useIR && !arguments.useOldBackend) { "Klib libraries can only be used with IR backend" }
put(JVMConfigurationKeys.KLIB_PATHS, libraries.split(File.pathSeparator.toRegex()).filterNot(String::isEmpty))
}
private val CompilerConfiguration.messageCollector: MessageCollector
get() = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)

View File

@@ -117,8 +117,8 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<List<String>> KLIB_PATHS =
CompilerConfigurationKey.create("Paths to .klib libraries");
public static final CompilerConfigurationKey<Boolean> IS_IR_WITH_STABLE_ABI =
CompilerConfigurationKey.create("Is IR with stable ABI");
public static final CompilerConfigurationKey<JvmAbiStability> ABI_STABILITY =
CompilerConfigurationKey.create("ABI stability of class files produced by JVM IR and/or FIR");
public static final CompilerConfigurationKey<Boolean> DO_NOT_CLEAR_BINDING_CONTEXT =
CompilerConfigurationKey.create("When using the IR backend, do not clear BindingContext between psi2ir and lowerings");
@@ -140,4 +140,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> USE_OLD_INLINE_CLASSES_MANGLING_SCHEME =
CompilerConfigurationKey.create("Use old, 1.4 version of inline classes mangling scheme");
public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW =
CompilerConfigurationKey.create("Enable Java language preview features");
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.config
enum class JvmAbiStability(val description: String) {
STABLE("stable"),
UNSTABLE("unstable"),
;
companion object {
fun fromStringOrNull(string: String?): JvmAbiStability? =
values().find { it.description == string }
}
}

View File

@@ -33,6 +33,9 @@ object JvmAnalysisFlags {
@JvmStatic
val disableUltraLightClasses by AnalysisFlag.Delegates.Boolean
@JvmStatic
val enableJvmPreview by AnalysisFlag.Delegates.Boolean
private object Delegates {
object JavaTypeEnhancementStateWarnByDefault {
operator fun provideDelegate(instance: Any?, property: KProperty<*>): AnalysisFlag.Delegate<JavaTypeEnhancementState> =

View File

@@ -19,32 +19,21 @@ package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.platform.TargetPlatformVersion
import org.jetbrains.org.objectweb.asm.Opcodes
enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_1_6("1.6"),
JVM_1_8("1.8"),
JVM_9("9"),
JVM_10("10"),
JVM_11("11"),
JVM_12("12"),
JVM_13("13"),
JVM_14("14"),
JVM_15("15"),
enum class JvmTarget(
override val description: String,
val majorVersion: Int,
) : TargetPlatformVersion {
JVM_1_6("1.6", Opcodes.V1_6),
JVM_1_8("1.8", Opcodes.V1_8),
JVM_9("9", Opcodes.V9),
JVM_10("10", Opcodes.V10),
JVM_11("11", Opcodes.V11),
JVM_12("12", Opcodes.V12),
JVM_13("13", Opcodes.V12 + 1),
JVM_14("14", Opcodes.V12 + 2),
JVM_15("15", Opcodes.V12 + 3),
;
val bytecodeVersion: Int by lazy {
when (this) {
JVM_1_6 -> Opcodes.V1_6
JVM_1_8 -> Opcodes.V1_8
JVM_9 -> Opcodes.V9
JVM_10 -> Opcodes.V10
JVM_11 -> Opcodes.V11
JVM_12 -> Opcodes.V12
JVM_13 -> Opcodes.V12 + 1
JVM_14 -> Opcodes.V12 + 2
JVM_15 -> Opcodes.V12 + 3
}
}
companion object {
@JvmField
val DEFAULT = JVM_1_6
@@ -52,14 +41,14 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
@JvmStatic
fun fromString(string: String) = values().find { it.description == string }
fun getDescription(bytecodeVersion: Int): String {
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?: when (bytecodeVersion) {
fun getDescription(majorVersion: Int): String {
val platformDescription = values().find { it.majorVersion == majorVersion }?.description ?: when (majorVersion) {
Opcodes.V1_7 -> "1.7"
else -> null
}
return if (platformDescription != null) "JVM target $platformDescription"
else "JVM bytecode version $bytecodeVersion"
else "JVM bytecode version $majorVersion"
}
}
}

View File

@@ -46,7 +46,7 @@ object AnalysisFlags {
val ideMode by AnalysisFlag.Delegates.Boolean
@JvmStatic
val reportErrorsOnIrDependencies by AnalysisFlag.Delegates.Boolean
val allowUnstableDependencies by AnalysisFlag.Delegates.Boolean
@JvmStatic
val libraryToSourceAnalysis by AnalysisFlag.Delegates.Boolean

View File

@@ -28,7 +28,7 @@ public final class Test : R|kotlin/Any| {
}
public final inline class Z : R|kotlin/Any| {
@R|kotlin/jvm/JvmInline|() public final inline class Z : R|kotlin/Any| {
public open operator fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean|
public open fun hashCode(): R|kotlin/Int|
@@ -41,3 +41,4 @@ public final inline class Z : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|test/Z|
}

View File

@@ -1,4 +1,4 @@
public final inline class Z : R|kotlin/Any| {
@R|kotlin/jvm/JvmInline|() public final inline class Z : R|kotlin/Any| {
public open operator fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean|
public open fun hashCode(): R|kotlin/Int|
@@ -11,3 +11,4 @@ public final inline class Z : R|kotlin/Any| {
@R|kotlin/PublishedApi|() internal constructor(value: R|kotlin/Int|): R|test/Z|
}

View File

@@ -7,5 +7,5 @@ FILE: definetelyNotNullForTypeParameter.kt
public final fun <F : R|kotlin/Any|> foo(computable: R|Out<F?>|): R|kotlin/Unit| {
}
public final fun <T : R|kotlin/Any|> bar(computable: R|Out<T?>|): R|kotlin/Unit| {
R|/foo|<R|T?!!|>(R|/id|<R|T?|>(R|<local>/computable|))
R|/foo|<R|T|>(R|/id|<R|T?|>(R|<local>/computable|))
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -1224,6 +1224,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
public void testParenthesizedAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/parenthesizedAnnotations.kt");
}
@TestMetadata("propagteAnyAnnotations.kt")
public void testPropagteAnyAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/propagteAnyAnnotations.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/annotations/options")
@@ -7892,6 +7897,24 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
}
}
@TestMetadata("compiler/testData/diagnostics/tests/exceptions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Exceptions extends AbstractFirOldFrontendDiagnosticsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInExceptions() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("kt24158.kt")
public void testKt24158() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/exposed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -10527,6 +10550,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
}
@TestMetadata("reportNotEnoughTypeInformationErrorsOnBlockExpressions.kt")
public void testReportNotEnoughTypeInformationErrorsOnBlockExpressions() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.kt");
}
@TestMetadata("resolveWithUnknownLambdaParameterType.kt")
public void testResolveWithUnknownLambdaParameterType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/resolveWithUnknownLambdaParameterType.kt");
@@ -10537,14 +10565,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
}
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt");
}
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
@TestMetadata("specialCallsWithCallableReferences.kt")
public void testSpecialCallsWithCallableReferences() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt");
}
@TestMetadata("starApproximation.kt")
@@ -10602,6 +10625,59 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt");
}
@TestMetadata("compiler/testData/diagnostics/tests/inference/builderInference")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class BuilderInference extends AbstractFirOldFrontendDiagnosticsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInBuilderInference() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt");
}
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
}
@TestMetadata("specialCallsWithCallableReferences.kt")
public void testSpecialCallsWithCallableReferences() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.kt");
}
@TestMetadata("specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt")
public void testSpecialCallsWithCallableReferencesDontCareTypeInBlockExression() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt");
}
@TestMetadata("specialCallsWithCallableReferencesDontRewriteAtSlice.kt")
public void testSpecialCallsWithCallableReferencesDontRewriteAtSlice() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.kt");
}
@TestMetadata("specialCallsWithCallableReferencesErrorType.kt")
public void testSpecialCallsWithCallableReferencesErrorType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt");
}
@TestMetadata("specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt")
public void testSpecialCallsWithCallableReferencesNonStrictOnlyInputTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt");
}
@TestMetadata("specialCallsWithLambdas.kt")
public void testSpecialCallsWithLambdas() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithLambdas.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -10659,6 +10735,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/captureTypeOnlyOnTopLevel.kt");
}
@TestMetadata("capturedFlexibleIntersectionTypesWithDifferentBounds.kt")
public void testCapturedFlexibleIntersectionTypesWithDifferentBounds() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt");
}
@TestMetadata("capturedFlexibleIntersectionTypesWithDifferentConstructors.kt")
public void testCapturedFlexibleIntersectionTypesWithDifferentConstructors() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentConstructors.kt");
}
@TestMetadata("capturedType.kt")
public void testCapturedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt");
@@ -10684,6 +10770,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithTypeVariableSubtyping.kt");
}
@TestMetadata("capturedTypesSubstitutionIntoAbbreviation.kt")
public void testCapturedTypesSubstitutionIntoAbbreviation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypesSubstitutionIntoAbbreviation.kt");
}
@TestMetadata("capturingFromArgumentOfFlexibleType.kt")
public void testCapturingFromArgumentOfFlexibleType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturingFromArgumentOfFlexibleType.kt");
@@ -12035,6 +12126,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
}
@TestMetadata("kt44440.kt")
public void testKt44440() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt44440.kt");
}
@TestMetadata("kt702.kt")
public void testKt702() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt702.kt");
@@ -12200,6 +12296,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
public void testSubstitutionIntoInnerClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/substitutions/substitutionIntoInnerClass.kt");
}
@TestMetadata("substitutionOfTypeEnhancement.kt")
public void testSubstitutionOfTypeEnhancement() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/substitutions/substitutionOfTypeEnhancement.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/inference/upperBounds")
@@ -12907,6 +13008,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inlineClasses/inlineClassesInsideAnnotations.kt");
}
@TestMetadata("innerClassInsideInlineClass.kt")
public void testInnerClassInsideInlineClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/inlineClasses/innerClassInsideInlineClass.kt");
}
@TestMetadata("lateinitInlineClasses.kt")
public void testLateinitInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/inlineClasses/lateinitInlineClasses.kt");
@@ -12942,6 +13048,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inlineClasses/unsignedLiteralsWithoutArtifactOnClasspath.kt");
}
@TestMetadata("varPropertyWithInlineClassReceiver.kt")
public void testVarPropertyWithInlineClassReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/inlineClasses/varPropertyWithInlineClassReceiver.kt");
}
@TestMetadata("varargsOnParametersOfInlineClassType.kt")
public void testVarargsOnParametersOfInlineClassType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inlineClasses/varargsOnParametersOfInlineClassType.kt");
@@ -17130,6 +17241,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/platformTypes/override.kt");
}
@TestMetadata("propagateFlexibilityFromOtherConstraints.kt")
public void testPropagateFlexibilityFromOtherConstraints() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/propagateFlexibilityFromOtherConstraints.kt");
}
@TestMetadata("rawOverrides.kt")
public void testRawOverrides() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawOverrides.kt");
@@ -17728,6 +17844,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("buildFlexibleEnhancement.kt")
public void testBuildFlexibleEnhancement() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/buildFlexibleEnhancement.kt");
}
@TestMetadata("overriddenExtensions.kt")
public void testOverriddenExtensions() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt");
@@ -19051,6 +19172,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt");
}
@TestMetadata("resolveCollectionLiteralInsideLambda.kt")
public void testResolveCollectionLiteralInsideLambda() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt");
}
@TestMetadata("resolveSubclassOfList.kt")
public void testResolveSubclassOfList() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");
@@ -19542,6 +19668,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt");
}
@TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt")
public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt");
}
@TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt")
public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt");
@@ -20743,6 +20874,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.kt");
}
@TestMetadata("ExhaustiveWithFreedom.kt")
public void testExhaustiveWithFreedom() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt");
}
@TestMetadata("inheritorInDifferentModule.kt")
public void testInheritorInDifferentModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt");
}
@TestMetadata("Local.kt")
public void testLocal() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/Local.kt");
@@ -20753,11 +20894,21 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/sealed/LocalSealed.kt");
}
@TestMetadata("MultipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt");
}
@TestMetadata("NestedSealed.kt")
public void testNestedSealed() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/NestedSealed.kt");
}
@TestMetadata("NestedSealedWithoutRestrictions.kt")
public void testNestedSealedWithoutRestrictions() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt");
}
@TestMetadata("NeverConstructed.kt")
public void testNeverConstructed() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/NeverConstructed.kt");
@@ -20857,6 +21008,34 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
public void testWithInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/WithInterface.kt");
}
@TestMetadata("compiler/testData/diagnostics/tests/sealed/interfaces")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Interfaces extends AbstractFirOldFrontendDiagnosticsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInInterfaces() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/sealed/interfaces"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("inheritorInDifferentModule.kt")
public void testInheritorInDifferentModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt");
}
@TestMetadata("sealedInterfacesDisabled.kt")
public void testSealedInterfacesDisabled() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt");
}
@TestMetadata("simpleSealedInterface.kt")
public void testSimpleSealedInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt");
}
}
}
@TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
@@ -24403,6 +24582,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasRHS.kt");
}
@TestMetadata("boundsViolationRecursive.kt")
public void testBoundsViolationRecursive() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationRecursive.kt");
}
@TestMetadata("capturingTypeParametersFromOuterClass.kt")
public void testCapturingTypeParametersFromOuterClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt");
@@ -24548,6 +24732,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/typealias/kt14518.kt");
}
@TestMetadata("kt14612.kt")
public void testKt14612() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/kt14612.kt");
}
@TestMetadata("kt14641.kt")
public void testKt14641() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/kt14641.kt");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -201,6 +201,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
}
@TestMetadata("jvmRecordWithoutJdk15.kt")
public void testJvmRecordWithoutJdk15() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmRecordWithoutJdk15.kt");
}
@TestMetadata("JvmSyntheticOnDelegate.kt")
public void testJvmSyntheticOnDelegate() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.backend.jvm
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmBackendExtension
import org.jetbrains.kotlin.backend.jvm.codegen.MetadataSerializer
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
import org.jetbrains.kotlin.config.JvmAbiStability
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.org.objectweb.asm.Type
class FirJvmBackendExtension(private val session: FirSession, private val components: Fir2IrComponents) : JvmBackendExtension {
override fun createSerializer(
context: JvmBackendContext,
klass: IrClass,
type: Type,
bindings: JvmSerializationBindings,
parentSerializer: MetadataSerializer?
): MetadataSerializer {
return FirMetadataSerializer(session, context, klass, bindings, parentSerializer)
}
override fun generateMetadataExtraFlags(abiStability: JvmAbiStability?): Int =
JvmAnnotationNames.METADATA_JVM_IR_FLAG or
JvmAnnotationNames.METADATA_FIR_FLAG or
(if (abiStability == JvmAbiStability.STABLE) JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG else 0)
}

View File

@@ -338,7 +338,8 @@ internal fun IrDeclarationParent.declareThisReceiverParameter(
symbolTable.irFactory.createValueParameter(
startOffset, endOffset, thisOrigin, symbol,
Name.special("<this>"), UNDEFINED_PARAMETER_INDEX, thisType,
varargElementType = null, isCrossinline = false, isNoinline = false, isAssignable = false
varargElementType = null, isCrossinline = false, isNoinline = false,
isHidden = false, isAssignable = false
).apply {
this.parent = this@declareThisReceiverParameter
receiverDescriptor.bind(this)

View File

@@ -269,7 +269,8 @@ class Fir2IrDeclarationStorage(
startOffset, endOffset, IrDeclarationOrigin.DEFINED, symbol,
Name.special("<set-?>"), 0, type,
varargElementType = null,
isCrossinline = false, isNoinline = false, isAssignable = false
isCrossinline = false, isNoinline = false,
isHidden = false, isAssignable = false
).apply {
this.parent = parent
descriptor.bind(this)
@@ -899,7 +900,8 @@ class Fir2IrDeclarationStorage(
valueParameter.name, index, type,
if (!valueParameter.isVararg) null
else valueParameter.returnTypeRef.coneType.arrayElementType()?.toIrType(typeContext),
valueParameter.isCrossinline, valueParameter.isNoinline
isCrossinline = valueParameter.isCrossinline, isNoinline = valueParameter.isNoinline,
isHidden = false, isAssignable = false
).apply {
descriptor.bind(this)
if (valueParameter.defaultValue.let {

View File

@@ -266,6 +266,7 @@ internal class AdapterGenerator(
varargElementType = null,
isCrossinline = false,
isNoinline = false,
isHidden = false,
isAssignable = false
).also { irAdapterValueParameter ->
descriptor.bind(irAdapterValueParameter)

View File

@@ -17,8 +17,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.fir.types.ConeStarProjection
@@ -37,7 +35,6 @@ import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.util.DataClassMembersGenerator
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
/**
@@ -84,11 +81,11 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
// TODO
}
override fun getBackingField(parameter: ValueParameterDescriptor?, irValueParameter: IrValueParameter?): IrField? =
override fun getProperty(parameter: ValueParameterDescriptor?, irValueParameter: IrValueParameter?): IrProperty? =
irValueParameter?.let {
irClass.properties.single { irProperty ->
irProperty.name == irValueParameter.name && irProperty.backingField?.type == irValueParameter.type
}.backingField
}
}
override fun transform(typeParameterDescriptor: TypeParameterDescriptor): IrType {
@@ -216,8 +213,8 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
fun generateComponentBody(irFunction: IrFunction) {
val index = getComponentIndex(irFunction)!!
val valueParameter = irClass.primaryConstructor!!.valueParameters[index - 1]
val backingField = irDataClassMembersGenerator.getBackingField(null, valueParameter)!!
irDataClassMembersGenerator.generateComponentFunction(irFunction, backingField)
val irProperty = irDataClassMembersGenerator.getProperty(null, valueParameter)!!
irDataClassMembersGenerator.generateComponentFunction(irFunction, irProperty)
}
fun generateCopyBody(irFunction: IrFunction) =
@@ -295,7 +292,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
) { symbol ->
components.irFactory.createValueParameter(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, symbol, name, index, type, null,
isCrossinline = false, isNoinline = false, isAssignable = false
isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false
)
}.apply {
parent = irFunction

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -53,6 +53,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/callDeserializedPropertyOnInlineClassType.kt");
}
@TestMetadata("callDeserializedPropertyOnInlineClassTypeOldMangling.kt")
public void testCallDeserializedPropertyOnInlineClassTypeOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/callDeserializedPropertyOnInlineClassTypeOldMangling.kt");
}
@TestMetadata("callsToMultifileClassFromOtherPackage.kt")
public void testCallsToMultifileClassFromOtherPackage() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt");
@@ -88,6 +93,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependencies.kt");
}
@TestMetadata("constructorWithInlineClassParametersInBinaryDependenciesOldMangling.kt")
public void testConstructorWithInlineClassParametersInBinaryDependenciesOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependenciesOldMangling.kt");
}
@TestMetadata("copySamOnInline.kt")
public void testCopySamOnInline() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/copySamOnInline.kt");
@@ -123,6 +133,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/defaultWithInlineClassAndReceivers.kt");
}
@TestMetadata("defaultWithInlineClassAndReceiversOldMangling.kt")
public void testDefaultWithInlineClassAndReceiversOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/defaultWithInlineClassAndReceiversOldMangling.kt");
}
@TestMetadata("delegatedDefault.kt")
public void testDelegatedDefault() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/delegatedDefault.kt");
@@ -148,16 +163,46 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/expectClassActualTypeAlias.kt");
}
@TestMetadata("inlineClassFakeOverrideMangling.kt")
public void testInlineClassFakeOverrideMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFakeOverrideMangling.kt");
}
@TestMetadata("inlineClassFakeOverrideManglingOldMangling.kt")
public void testInlineClassFakeOverrideManglingOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFakeOverrideManglingOldMangling.kt");
}
@TestMetadata("inlineClassFromBinaryDependencies.kt")
public void testInlineClassFromBinaryDependencies() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt");
}
@TestMetadata("inlineClassFromBinaryDependenciesOldMangling.kt")
public void testInlineClassFromBinaryDependenciesOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependenciesOldMangling.kt");
}
@TestMetadata("inlineClassInlineFunctionCall.kt")
public void testInlineClassInlineFunctionCall() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt");
}
@TestMetadata("inlineClassInlineFunctionCallOldMangling.kt")
public void testInlineClassInlineFunctionCallOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCallOldMangling.kt");
}
@TestMetadata("inlineClassInlineProperty.kt")
public void testInlineClassInlineProperty() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt");
}
@TestMetadata("inlineClassInlinePropertyOldMangling.kt")
public void testInlineClassInlinePropertyOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlinePropertyOldMangling.kt");
}
@TestMetadata("inlineClassesOldMangling.kt")
public void testInlineClassesOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt");
@@ -188,6 +233,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
}
@TestMetadata("internalWithInlineClass.kt")
public void testInternalWithInlineClass() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
}
@TestMetadata("internalWithOtherModuleName.kt")
public void testInternalWithOtherModuleName() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
@@ -328,11 +378,21 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/privateCompanionObjectValInDifferentModule.kt");
}
@TestMetadata("privateCompanionObjectValInDifferentModuleOldMangling.kt")
public void testPrivateCompanionObjectValInDifferentModuleOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/privateCompanionObjectValInDifferentModuleOldMangling.kt");
}
@TestMetadata("privateTopLevelValInDifferentModule.kt")
public void testPrivateTopLevelValInDifferentModule() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/privateTopLevelValInDifferentModule.kt");
}
@TestMetadata("privateTopLevelValInDifferentModuleOldMangling.kt")
public void testPrivateTopLevelValInDifferentModuleOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/privateTopLevelValInDifferentModuleOldMangling.kt");
}
@TestMetadata("propertyReference.kt")
public void testPropertyReference() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/propertyReference.kt");
@@ -383,6 +443,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
runTest("compiler/testData/compileKotlinAgainstKotlin/suspendFunWithDefaultMangling.kt");
}
@TestMetadata("suspendFunWithDefaultOldMangling.kt")
public void testSuspendFunWithDefaultOldMangling() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/suspendFunWithDefaultOldMangling.kt");
}
@TestMetadata("targetedJvmName.kt")
public void testTargetedJvmName() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/targetedJvmName.kt");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -1731,49 +1731,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
}
}
@TestMetadata("compiler/testData/codegen/box/builderInference")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class BuilderInference extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInBuilderInference() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("callableReferenceAndCoercionToUnit.kt")
public void testCallableReferenceAndCoercionToUnit() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/callableReferenceAndCoercionToUnit.kt");
}
@TestMetadata("kt41164.kt")
public void testKt41164() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/kt41164.kt");
}
@TestMetadata("lackOfNullCheckOnNullableInsideBuild.kt")
public void testLackOfNullCheckOnNullableInsideBuild() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/lackOfNullCheckOnNullableInsideBuild.kt");
}
@TestMetadata("substituteStubTypeIntoCR.kt")
public void testSubstituteStubTypeIntoCR() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/substituteStubTypeIntoCR.kt");
}
@TestMetadata("substituteStubTypeIntolambdaParameterDescriptor.kt")
public void testSubstituteStubTypeIntolambdaParameterDescriptor() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/substituteStubTypeIntolambdaParameterDescriptor.kt");
}
@TestMetadata("substituteTypeVariableIntolambdaParameterDescriptor.kt")
public void testSubstituteTypeVariableIntolambdaParameterDescriptor() throws Exception {
runTest("compiler/testData/codegen/box/builderInference/substituteTypeVariableIntolambdaParameterDescriptor.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/builtinStubMethods")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -3840,6 +3797,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
}
@TestMetadata("extensionFunWithDefaultParam.kt")
public void testExtensionFunWithDefaultParam() throws Exception {
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
}
@TestMetadata("extensionOnNamedClassObject.kt")
public void testExtensionOnNamedClassObject() throws Exception {
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
@@ -5018,6 +4980,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/collections/inheritFromHashtable.kt");
}
@TestMetadata("internalRemove.kt")
public void testInternalRemove() throws Exception {
runTest("compiler/testData/codegen/box/collections/internalRemove.kt");
}
@TestMetadata("internalRemoveFromJava.kt")
public void testInternalRemoveFromJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/internalRemoveFromJava.kt");
}
@TestMetadata("irrelevantImplCharSequence.kt")
public void testIrrelevantImplCharSequence() throws Exception {
runTest("compiler/testData/codegen/box/collections/irrelevantImplCharSequence.kt");
@@ -7341,6 +7313,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines");
}
@TestMetadata("defaultExpect.kt")
public void testDefaultExpect() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt");
}
@TestMetadata("delegate.kt")
public void testDelegate_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines");
@@ -9838,6 +9815,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/defaultArguments/function/covariantOverrideGeneric.kt");
}
@TestMetadata("defaultLambdaInline.kt")
public void testDefaultLambdaInline() throws Exception {
runTest("compiler/testData/codegen/box/defaultArguments/function/defaultLambdaInline.kt");
}
@TestMetadata("extensionFunctionManyArgs.kt")
public void testExtensionFunctionManyArgs() throws Exception {
runTest("compiler/testData/codegen/box/defaultArguments/function/extensionFunctionManyArgs.kt");
@@ -11140,6 +11122,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/enum/classForEnumEntry.kt");
}
@TestMetadata("companionAccessingEnumValue.kt")
public void testCompanionAccessingEnumValue() throws Exception {
runTest("compiler/testData/codegen/box/enum/companionAccessingEnumValue.kt");
}
@TestMetadata("companionObjectInEnum.kt")
public void testCompanionObjectInEnum() throws Exception {
runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt");
@@ -12572,6 +12559,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/functions/bigArity/javaLambda.kt");
}
@TestMetadata("nestedBigArityFunCalls.kt")
public void testNestedBigArityFunCalls() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/nestedBigArityFunCalls.kt");
}
@TestMetadata("subclass.kt")
public void testSubclass() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/subclass.kt");
@@ -13349,6 +13341,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
}
@TestMetadata("capturedTypesSubstitutionIntoAbbreviation.kt")
public void testCapturedTypesSubstitutionIntoAbbreviation() throws Exception {
runTest("compiler/testData/codegen/box/inference/capturedTypesSubstitutionIntoAbbreviation.kt");
}
@TestMetadata("coercionToUnitForLambdaReturnTypeWithFlexibleConstraint.kt")
public void testCoercionToUnitForLambdaReturnTypeWithFlexibleConstraint() throws Exception {
runTest("compiler/testData/codegen/box/inference/coercionToUnitForLambdaReturnTypeWithFlexibleConstraint.kt");
@@ -13469,6 +13466,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
}
@TestMetadata("specialCallsWithCallableReferences.kt")
public void testSpecialCallsWithCallableReferences() throws Exception {
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
}
@TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt")
public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception {
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");
@@ -13483,6 +13485,74 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testUnsafeVarianceCodegen() throws Exception {
runTest("compiler/testData/codegen/box/inference/unsafeVarianceCodegen.kt");
}
@TestMetadata("compiler/testData/codegen/box/inference/builderInference")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class BuilderInference extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInBuilderInference() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("callableReferenceAndCoercionToUnit.kt")
public void testCallableReferenceAndCoercionToUnit() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/callableReferenceAndCoercionToUnit.kt");
}
@TestMetadata("kt41164.kt")
public void testKt41164() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt");
}
@TestMetadata("lackOfNullCheckOnNullableInsideBuild.kt")
public void testLackOfNullCheckOnNullableInsideBuild() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt");
}
@TestMetadata("specialCallsWithCallableReferences.kt")
public void testSpecialCallsWithCallableReferences() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt");
}
@TestMetadata("specialCallsWithCallableReferencesDontCareTypeInBlockExpression.kt")
public void testSpecialCallsWithCallableReferencesDontCareTypeInBlockExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExpression.kt");
}
@TestMetadata("specialCallsWithCallableReferencesErrorType.kt")
public void testSpecialCallsWithCallableReferencesErrorType() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt");
}
@TestMetadata("specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt")
public void testSpecialCallsWithCallableReferencesNonStrictOnlyInputTypes() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt");
}
@TestMetadata("specialCallsWithLambdas.kt")
public void testSpecialCallsWithLambdas() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithLambdas.kt");
}
@TestMetadata("substituteStubTypeIntoCR.kt")
public void testSubstituteStubTypeIntoCR() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/substituteStubTypeIntoCR.kt");
}
@TestMetadata("substituteStubTypeIntolambdaParameterDescriptor.kt")
public void testSubstituteStubTypeIntolambdaParameterDescriptor() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/substituteStubTypeIntolambdaParameterDescriptor.kt");
}
@TestMetadata("substituteTypeVariableIntolambdaParameterDescriptor.kt")
public void testSubstituteTypeVariableIntolambdaParameterDescriptor() throws Exception {
runTest("compiler/testData/codegen/box/inference/builderInference/substituteTypeVariableIntolambdaParameterDescriptor.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses")
@@ -14142,6 +14212,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inlineClasses/multifileClass.kt");
}
@TestMetadata("nestedInlineClass.kt")
public void testNestedInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/nestedInlineClass.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
@@ -15154,6 +15229,59 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jvm8DefaultInterfaceMethods extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("javaDefaultMethod.kt")
public void testJavaDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt");
}
@TestMetadata("javaDefaultMethodOverriddenByKotlin.kt")
public void testJavaDefaultMethodOverriddenByKotlin() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt");
}
@TestMetadata("jvmDefaultAll.kt")
public void testJvmDefaultAll() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt");
}
@TestMetadata("jvmDefaultAllPrimaryProperty.kt")
public void testJvmDefaultAllPrimaryProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt");
}
@TestMetadata("jvmDefaultAllProperty.kt")
public void testJvmDefaultAllProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt");
}
@TestMetadata("jvmDefaultEnable.kt")
public void testJvmDefaultEnable() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt");
}
@TestMetadata("jvmDefaultEnablePrimaryProperty.kt")
public void testJvmDefaultEnablePrimaryProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt");
}
@TestMetadata("jvmDefaultEnableProperty.kt")
public void testJvmDefaultEnableProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -17914,6 +18042,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
}
@TestMetadata("kt31389.kt")
public void testKt31389() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt31389.kt");
}
@TestMetadata("kt35716.kt")
public void testKt35716() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
@@ -21463,6 +21596,31 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/properties/kt9603.kt");
}
@TestMetadata("lazyInitialization.kt")
public void testLazyInitialization() throws Exception {
runTest("compiler/testData/codegen/box/properties/lazyInitialization.kt");
}
@TestMetadata("lazyInitializationCyclicImports.kt")
public void testLazyInitializationCyclicImports() throws Exception {
runTest("compiler/testData/codegen/box/properties/lazyInitializationCyclicImports.kt");
}
@TestMetadata("lazyInitializationMultiModule.kt")
public void testLazyInitializationMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/lazyInitializationMultiModule.kt");
}
@TestMetadata("lazyInitializationOrder.kt")
public void testLazyInitializationOrder() throws Exception {
runTest("compiler/testData/codegen/box/properties/lazyInitializationOrder.kt");
}
@TestMetadata("lazyInitializationSplitPerModule.kt")
public void testLazyInitializationSplitPerModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/lazyInitializationSplitPerModule.kt");
}
@TestMetadata("primitiveOverrideDefaultAccessor.kt")
public void testPrimitiveOverrideDefaultAccessor() throws Exception {
runTest("compiler/testData/codegen/box/properties/primitiveOverrideDefaultAccessor.kt");
@@ -30117,6 +30275,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
}
@TestMetadata("objects.kt")
public void testObjects() throws Exception {
runTest("compiler/testData/codegen/box/sealed/objects.kt");
@@ -32036,6 +32199,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/unsignedTypes/equalsImplForInlineClassWrappingNullableInlineClass.kt");
}
@TestMetadata("evaluateConstructorOfUnsignedArrayType.kt")
public void testEvaluateConstructorOfUnsignedArrayType() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/evaluateConstructorOfUnsignedArrayType.kt");
}
@TestMetadata("evaluateConstructorOfUnsignedType.kt")
public void testEvaluateConstructorOfUnsignedType() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/evaluateConstructorOfUnsignedType.kt");
@@ -32215,6 +32383,59 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testWhenByUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/whenByUnsigned.kt");
}
@TestMetadata("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jvm8Intrinsics extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInJvm8Intrinsics() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("unsignedIntCompare_jvm8.kt")
public void testUnsignedIntCompare_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedIntCompare_jvm8.kt");
}
@TestMetadata("unsignedIntDivide_jvm8.kt")
public void testUnsignedIntDivide_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedIntDivide_jvm8.kt");
}
@TestMetadata("unsignedIntRemainder_jvm8.kt")
public void testUnsignedIntRemainder_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedIntRemainder_jvm8.kt");
}
@TestMetadata("unsignedIntToString_jvm8.kt")
public void testUnsignedIntToString_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedIntToString_jvm8.kt");
}
@TestMetadata("unsignedLongCompare_jvm8.kt")
public void testUnsignedLongCompare_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedLongCompare_jvm8.kt");
}
@TestMetadata("unsignedLongDivide_jvm8.kt")
public void testUnsignedLongDivide_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedLongDivide_jvm8.kt");
}
@TestMetadata("unsignedLongRemainder_jvm8.kt")
public void testUnsignedLongRemainder_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedLongRemainder_jvm8.kt");
}
@TestMetadata("unsignedLongToString_jvm8.kt")
public void testUnsignedLongToString_jvm8() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/jvm8Intrinsics/unsignedLongToString_jvm8.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/box/vararg")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -4210,6 +4210,16 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/properties"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("dataClass.kt")
public void testDataClass() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/properties/dataClass.kt");
}
@TestMetadata("openDataClass.kt")
public void testOpenDataClass() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/properties/openDataClass.kt");
}
@TestMetadata("compiler/testData/codegen/bytecodeText/properties/lateinit")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -221,6 +221,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/classes/objectWithInitializers.kt");
}
@TestMetadata("openDataClass.kt")
public void testOpenDataClass() throws Exception {
runTest("compiler/testData/ir/irText/classes/openDataClass.kt");
}
@TestMetadata("outerClassAccess.kt")
public void testOuterClassAccess() throws Exception {
runTest("compiler/testData/ir/irText/classes/outerClassAccess.kt");
@@ -2205,6 +2210,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/types/starProjection_OI.kt");
}
@TestMetadata("typeAliasWithUnsafeVariance.kt")
public void testTypeAliasWithUnsafeVariance() throws Exception {
runTest("compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.kt");
}
@TestMetadata("compiler/testData/ir/irText/types/nullChecks")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -58,7 +58,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
constructor: TypeConstructorMarker,
arguments: List<TypeArgumentMarker>,
nullable: Boolean,
isExtensionFunction: Boolean
isExtensionFunction: Boolean,
annotations: List<AnnotationMarker>? // TODO: process annotations
): SimpleTypeMarker {
val attributes = if (isExtensionFunction) // TODO: assert correct type constructor
ConeAttributes.create(listOf(CompilerConeAttributes.ExtensionFunctionType))
@@ -365,6 +366,10 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
return this is ConeCapturedTypeConstructor
}
override fun TypeConstructorMarker.isTypeParameterTypeConstructor(): Boolean {
return this.getTypeParameterClassifier() != null
}
override fun KotlinTypeMarker.removeExactAnnotation(): KotlinTypeMarker {
// TODO
return this

View File

@@ -402,6 +402,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
return false
}
override fun KotlinTypeMarker.getAnnotations(): List<AnnotationMarker> {
require(this is ConeKotlinType)
return emptyList() // TODO
}
override fun SimpleTypeMarker.isStubType(): Boolean {
return this is StubTypeMarker
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

Some files were not shown because too many files have changed in this diff Show More