Compare commits

...

889 Commits

Author SHA1 Message Date
Pavel Punegov
d48a7a55c6 Reduce signal usage 2021-06-03 13:23:24 +03:00
Pavel Punegov
30639af5a3 move to native 2021-06-03 13:07:16 +03:00
Pavel Punegov
3add3f091d remove 2021-06-03 00:35:08 +03:00
Pavel Punegov
4583e31991 add configure after evaluation 2021-06-02 23:20:44 +03:00
Pavel Punegov
f49fe26632 Use configureEach 2021-06-02 23:15:41 +03:00
Pavel Punegov
73ec5d27a6 Use interpreter for all 1.6 java tasks 2021-06-02 23:02:14 +03:00
Pavel Punegov
ac0dc94800 Since 1.5.30-dev-1466 a new archive naming schema was introduced
Support both names in NativeCompilerDownloader
2021-06-02 18:30:52 +03:00
Pavel Punegov
789799ac17 Revert simpleOsName in HostManager
Support old naming in simpleOsName.
Introduce new platformName method for the new archive naming.
2021-06-02 18:30:52 +03:00
Leonid Startsev
1f837134bb Support for @EncodeDefault annotation 2021-06-02 13:43:39 +00:00
Alexander Dudinsky
e6e3c9b236 Use master name for tests with snapshot version Kotlin Gradle Plugin 2021-06-02 15:23:31 +03:00
Roman Artemev
5f65b46dfc [JS IR] Unmute fixed tests 2021-06-02 13:42:35 +03:00
Roman Artemev
a36135baf1 [JS IR] Fix reflection generation 2021-06-02 13:42:35 +03:00
Roman Artemev
974779e91b [JS IR] Support function reference to array inline constructor 2021-06-02 13:42:34 +03:00
Tianyu Geng
84334b087c FIR checkers: report SMARTCAST_IMPOSSIBLE 2021-06-02 13:19:12 +03:00
Tianyu Geng
62f7e8f71f FIR DFA: store stability in RealVariable
As part of this change, we also extend the usage of RealVariable in more
places during DFA. Now mutable properties, property with custom getters,
delegated properties, etc are also treatd as a `RealVariable`. In
general this is needed in order to carry out smartcast computation in
order to report `SMARTCAST_IMPOSSIBLE`. It seems to also have side
effects that improves behavior of some test files.
2021-06-02 13:19:12 +03:00
Tianyu Geng
96bd2c54f0 FIR: add smartcast stability to FIR 2021-06-02 13:19:12 +03:00
Tianyu Geng
931a637bdd FIR: use isReal() and isSynthetic() helper consistently 2021-06-02 13:19:11 +03:00
Vladimir Ivanov
2165cc8f0d [Native] Fix test data for testObjCExportNoGeneric (#4424) 2021-06-02 11:13:07 +03:00
Vladimir Ivanov
e06a60bda5 [Native] Clean up nested comment when exporting kdoc to objc header (#4410)
* [Native] Clean up nested comment when exporting kdoc to objc header

* [kdoc-export] Add test witg nested comment block

* Remove redundant assert

Co-authored-by: Vladimir Ivanov <vladimir.d.ivanov@jetbrains.com>
2021-06-02 10:18:32 +03:00
Alexander Udalov
61d5595790 Remove dependency of ir.serialization.common on frontend 2021-06-01 20:28:23 +02:00
Alexander Udalov
dfea915f92 Remove dependency of frontend on compiler.common.jvm
Looks like it was added accidentally in 564d382b9d; common frontend
shouldn't depend on JVM-specific modules.

Since then, it has been accidentally used in two places in
ir.serialization.common to refer to JVM specifics, and that should be
abstracted away in the future.
2021-06-01 20:28:23 +02:00
Alexander Udalov
81ce1da352 Move PsiSourceElement to psi 2021-06-01 20:28:23 +02:00
Alexander Udalov
bcf47ddc94 Move optional annotation utilities to module 'resolution'
To avoid depending on a heavy module 'frontend' in parts of the compiler
where checking for optional annotations is needed, such as in
'ir.serialization.common'.
2021-06-01 20:28:22 +02:00
Alexander Udalov
e790fa8ac9 Remove dependency of serialization on frontend
Move ApplicationExtensionDescriptor and ProjectExtensionDescriptor to
:compiler:util.
2021-06-01 20:28:22 +02:00
Alexander Udalov
8b3769b88e Remove dependency of ir.serialization.common on ir.backend.common 2021-06-01 20:28:22 +02:00
Alexander Udalov
a3ad03d1ad Slightly refactor module dependencies of backend.js/serialization.js
The comment in serialization.js/build.gradle.kts is not needed because
such dependency cannot be introduced accidentally, since Gradle does not
support cycles in module dependencies.
2021-06-01 20:28:22 +02:00
Leonid Startsev
b43e5a5e7d fixup! Fix tests and review notes 2021-06-01 16:41:56 +00:00
Leonid Startsev
6a5cf00d7a Optimize serializer instantiation: use Companion.serializer() when possible
Add test for sealed hierarchy
2021-06-01 16:41:55 +00:00
Leonid Startsev
b61277df97 Support annotations in constructor signatures of special serializers 2021-06-01 16:41:55 +00:00
Leonid Startsev
229085f3d1 Support default parameter values in @SerialInfo annotations
#KT-46739 Fixed
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1461
2021-06-01 16:41:54 +00:00
Mads Ager
f846dd8ea2 [JVM_IR] Avoid using special names in static inline class replacements.
Fixes KT-46952
2021-06-01 16:22:14 +02:00
Aleksei.Cherepanov
b1ab597616 Fix FIR tests after ee45aa6b 2021-06-01 15:59:17 +03:00
Pavel Punegov
3293a888ca [native] Archive naming: use $os-$arch convention 2021-06-01 10:20:05 +00:00
Pavel Punegov
48ef739525 [native] Rename Apple MacOS targets in simpleOsName
Use Arm64 suffix for Apple Arm arch and X64 for Intel X86_64
2021-06-01 10:20:04 +00:00
Alexander Shabalin
825b77cc82 Remove unused ostream 2021-06-01 07:01:11 +00:00
Mikhael Bogdanov
b72aa76415 Support class type parameters annotation checking 2021-06-01 06:33:51 +02:00
Mikhael Bogdanov
a8186d19d6 Support annotations on class type parameters
#KT-43714
2021-06-01 06:33:50 +02:00
Dmitry Petrov
9091ca7b51 JVM_IR KT-46864 handle "unused" LDC instructions properly 2021-05-31 21:12:35 +03:00
Andrey Uskov
be097244d4 fixup synchronizations 2021-05-31 20:23:54 +03:00
Aleksei.Cherepanov
b0d721c9d0 Fix synchronization in translation-result map
#KT-27660 Fixed
2021-05-31 20:23:53 +03:00
Aleksei.Cherepanov
290d424111 Fix synchronization in source-to-classes table 2021-05-31 20:23:52 +03:00
Aleksei.Cherepanov
ee45aa6b08 Fixed closing of cache storage
#KTIJ-7680 Fixed
#KT-45843 Fixed
2021-05-31 20:23:51 +03:00
Mads Ager
886ce055f5 [JVM_IR] Do not use invoke-dynamic for targeting inline-only methods.
Fixes https://youtrack.jetbrains.com/issue/KT-46962
2021-05-31 18:11:50 +03:00
pyos
5c2753b5d1 JVM_IR: use substituted return type in function reference invoke
#KT-46982 Fixed
2021-05-31 16:01:22 +03:00
Vasily Levchenko
84c10079e4 [kotlin-native][tests] kt-42208 test added. 2021-05-31 11:45:32 +00:00
Vasily Levchenko
1ff6dc1275 [kotlin][tests][compiler/testData/debug/stepping] kt-42208 test added. 2021-05-31 11:45:31 +00:00
Vasily Levchenko
ecbae02f17 [IR][provisional function expression] another line information provider added for func_expression -> function_reference conversion 2021-05-31 11:45:31 +00:00
Dmitriy Novozhilov
c6a2d85c87 [Build] Remove incorrect dependency
`intellijDep()` includes jars with JUnit3 and JUnit4. JUnit5 runner
  which is used in compiler tests sees old junit on classpath and checks
  if this version can be ran using Vintage test engine. Looks like recent
  changes in platform changed order of this jars on classpath, so now
  jar with JUnit3 is closer than JUnit4 (and they have same classes inside),
  so version checker from JUnit5 observes JUnit3 and fails with error
  of incompatible versions. Since old JUnits are not needed at all in those
  modules now only required jars from intellijDep are included
2021-05-31 14:03:37 +03:00
Dmitriy Novozhilov
6121d156a1 [Build] Add workarounds for JPS build
Compilation of `:kotlin-gradle-statistics:test` is broken in gradle
  too, so this module is removed from JPS to allow build project with
  "Rebuild project" action

Dependency on `:kotlin-uast-base` changed to `implementation` because
  project import assumes `shadow` dependency as _Provided_ instead of
  _Compile_ in module structure which leads to problem that this
  dependency is missing during build (this is bug inside JPS itself)
2021-05-31 14:03:37 +03:00
Abduqodiri Qurbonzoda
d934c97bf5 Equivalize isLowerCase and isUpperCase behavior in all platforms #KT-46184 2021-05-31 13:42:46 +03:00
Yahor Berdnikau
0b10f255d7 Update 'kotlinOptions.jdkHome' deprecation message.
Also mention java toolchains approach.

^KT-43095 Fixed
2021-05-31 10:22:50 +00:00
Yahor Berdnikau
c5e6215d27 Set UsesKotlinJavaToolchain interface to extend Task interface.
Limit use-case of UsesKotlinJavaToolchain interface to only Gradle tasks
and allow to query all tasks using
 'taskContainer.withType(UsesKotlinJavaToolchain.class)'.

^KT-43095 In Progress
2021-05-31 10:22:50 +00:00
Yahor Berdnikau
4c943e7cd1 Allow to configure non-default JDK using toolchain via extension.
Add method into "kotlin" extension to set toolchain for all tasks.
This will also set toolchain for java compile tasks. Also user may
set toolchain via "java" extension and it will be applied to Kotlin
tasks as well.

^KT-43092 In Progress
2021-05-31 10:22:49 +00:00
Yahor Berdnikau
8e1c420c9f Allow to set non-default JDK for tasks via java toolchain.
Has to split jdk/toolchain setters, because, when toolchain setter is
in the 'UsesKotlinJavaToolchain', Groovy fails to create meta class
on <Gradle 6.7 with ClassNotFoundException.

^KT-43092 In Progress
2021-05-31 10:22:48 +00:00
Ilya Matveev
de5dcfcbd8 [K/N][Runtime] Support suspending mutators in the new MM 2021-05-31 09:48:46 +00:00
Alexander Likhachev
94a94a557d [Gradle, JS] Add test for KT-47045 2021-05-31 11:43:18 +03:00
Alexander Likhachev
89f8c5a651 [Gradle, JS] Prevent adding unintended implicit dependencies
The way JS compilations are mapped to task requirements were changed from `compilation` objects to compilations's `disambiguatedName` in order to support Gradle configuration cache. This may lead to implicitly adding unwanted dependencies in multi-module projects since compilation's `disambiguatedName` is unique within a module, not within a whole multi-module project.
#KT-47045 Fixed
2021-05-31 11:43:18 +03:00
Andrey Zinovyev
78e20c1098 [KAPT] Keep original expressions in annotations vararg
#KT-29929 Fixed
2021-05-31 08:08:37 +00:00
Dmitriy Dolovov
e927764aaf [IR][Native] Fix invalid IR return statement generation
^KT-46836
2021-05-29 19:31:13 +00:00
Victor Petukhov
15b6a3c88c Temporary don't fail fir tests if a test passes but *.fir.fail exists (needs for DiagnosisCompilerTestFE10TestdataTestGenerated) 2021-05-29 11:30:55 +03:00
Nikita Bobko
3e892d3184 'idea-fir-fe10-binding' move fir tests into subpackage 'org.jetbrains.kotlin.idea.fir'
In intellij infrastructure we run tests by matching package pattern.
So in order to be able run FIR tests we need to place them into unique package
2021-05-29 00:11:28 +03:00
Nikita Bobko
65972fa64c 'idea-frontend-fir' move fir tests into subpackage 'org.jetbrains.kotlin.idea.fir'
In intellij infrastructure we run tests by matching package pattern.
So in order to be able run FIR tests we need to place them into unique package
2021-05-29 00:11:27 +03:00
Nikita Bobko
1ba6845b59 'idea-fir' move fir tests into subpackage 'org.jetbrains.kotlin.idea.fir'
In intellij infrastructure we run tests by matching package pattern.
So in order to be able run FIR tests we need to place them into unique package
2021-05-29 00:11:26 +03:00
Alexander Udalov
e7275a7cb0 Revert "Enable JVM IR for stdlib/reflect/test libraries"
This reverts commit 15e978dbd3.

Together with the previous revert, this led to multiple failures in
Gradle integration tests:

    ConfigurationCacheIT.testIncrementalKaptProject
    ConfigurationCacheForAndroidIT.testAndroidKaptProject
    KotlinAndroid34GradleIT.testParcelize
    KotlinAndroid34GradleIT.testAndroidExtensionsManyVariants
    KotlinAndroid36GradleIT.testAndroidWithNewMppApp
    KotlinAndroid36GradleIT.testParcelize
    KotlinAndroid36GradleIT.testAndroidIcepickProject
2021-05-28 21:36:24 +02:00
Alexander Udalov
e0cc6d44a7 Revert "Remove obsolete kotlin.build.useIR flag"
This reverts commit 91e47f1fd7.
2021-05-28 21:35:57 +02:00
Victor Petukhov
67d48d0150 Fix failing test 2021-05-28 21:38:27 +03:00
Alexander Udalov
96f0b53761 IR: get overridden directly from IrProperty when resolving fake override
The previous way of getting them either via getter or setter failed on
Java properties which only have a backing field. Now that IrProperty has
overriddenSymbols (after 53c1de172f), it makes sense to use it directly
instead. Use it only in SyntheticAccessorLowering though to avoid
breaking Kotlin/Native (see KT-47019).

 #KT-46900 Fixed
2021-05-28 17:24:20 +02:00
Mark Punzalan
af35892007 FIR IDE: Enable RemoveUselessIsCheckFix and
RemoveUselessIsCheckFixForWhen.
2021-05-28 18:21:32 +03:00
Mark Punzalan
639b7537da FIR IDE: Enable RemoveUselessCastFix. 2021-05-28 18:21:31 +03:00
Pavel Kirpichenkov
f5a53c82c5 Don't write type arguments of types replaced with Any to metadata
Anonymous types are not approximated by frontend for private declarations.
Class IDs for such types are replaced by StringTable before being written
to metadata. JVM string table mangles such types and keeps them generic
for reflection. For other purposes the types are replaced with `Any`.
Type arguments of the replaced type should be ignored in the latter case.
Otherwise decompiled text builder crashes on an attempt to restore `Any`
type with non-zero number of type arguments.

The code pretending to replace a type with its first supertype was dropped
from ApproximatingStringTable for two reasons:
- the first type from `getAllSuperClassifiers` is the original type itself
which doens't provide a ClassId for anonymous type, so it was a noop
- tracking potential type arguments of the first anonymous type's supertype
would be a complication with almost no practical value (types in decompiled
text would be slightly closer to the real type of a private declaration).

^KT-46393 Fixed
2021-05-28 14:42:47 +00:00
sebastian.sellmair
fefc6f9b53 [Gradle] :kotlin-test-js-runner: Update nodejs to 16.2.0
^KT-45302
2021-05-28 14:27:36 +00:00
sebastian.sellmair
d3b1ee42be [Gradle] Test project 'commonizeHierarchically': Use new 'macos' target shortcut
^KT-45302
2021-05-28 14:27:36 +00:00
sebastian.sellmair
cc571a876a [Gradle] Implement AppleSiliconIT
^KT-45302
2021-05-28 14:27:35 +00:00
sebastian.sellmair
242d79ded6 [Gradle] :kotlin-gradle-plugin-integration-tests: Include Commonizer tests into 'native' tests
^KT-45302
2021-05-28 14:27:34 +00:00
sebastian.sellmair
b9018e8888 [Gradle] :kotlin-gradle-plugin-integration-tests: Add 'includeTestsWithPattern' util function
^KT-45302
2021-05-28 14:27:33 +00:00
sebastian.sellmair
5dcaaf47cb [Gradle] Support for Apple Silicon targets
^KT-45302 Verification Pending
2021-05-28 14:27:32 +00:00
Alexander Udalov
91e47f1fd7 Remove obsolete kotlin.build.useIR flag 2021-05-28 15:41:57 +02:00
Alexander Udalov
15e978dbd3 Enable JVM IR for stdlib/reflect/test libraries 2021-05-28 15:41:56 +02:00
Alexander Udalov
1dfcec3a93 Build: add temporary option to suppress jdkHome warning 2021-05-28 15:41:17 +02:00
Victor Petukhov
aaffd73feb Take into account FE exceptions built as FromFrontendHandler to proper mute corresponding tests for DiagnosisCompilerTestFE10TestdataTestGenerated 2021-05-28 15:48:59 +03:00
Victor Petukhov
54b9f39b3a Update tests after rebase 2021-05-28 15:36:24 +03:00
Victor Petukhov
f4788b479c Fix incorrect builder inference usage 2021-05-28 15:36:23 +03:00
Victor Petukhov
76c15e4444 Don't update null recorded type prematurely in ResolvedAtomCompleter 2021-05-28 15:36:23 +03:00
Victor Petukhov
bd7fb56a24 Fix builder inference tests 2021-05-28 15:36:23 +03:00
Victor Petukhov
4a767c597e Don't report the same diagnsotics several times 2021-05-28 15:36:23 +03:00
Victor Petukhov
e942052eb6 Substitute stub type variables in local variable descriptors 2021-05-28 15:36:22 +03:00
Victor Petukhov
758eb8f851 Fix builder inference tests 2021-05-28 15:36:22 +03:00
Victor Petukhov
be22078bd1 Return empty NotFixedToInferredTypesSubstitutor if the current substitutor is empty 2021-05-28 15:36:22 +03:00
Victor Petukhov
d8c68aacdd Split setting substitutor descriptor for entire resolved call into two parts: setting resulting substitutor and setting substitutor for resolved call's types 2021-05-28 15:36:22 +03:00
Victor Petukhov
fd5169186e Update test for the builder inference and add new ones 2021-05-28 15:36:21 +03:00
Victor Petukhov
31ed1ad5d9 Use recorded into descriptor inferred callable reference input/output types, to prevent leaking raw type parameter's types of reflectionCandidateType into the back-end 2021-05-28 15:36:21 +03:00
Victor Petukhov
84bd580f92 Complete block expressions to substitute stub type variables into last callable references there 2021-05-28 15:36:21 +03:00
Victor Petukhov
472ab09511 Do stub types substitution for property initializer's type 2021-05-28 15:36:20 +03:00
Victor Petukhov
ac222fdb41 Update type for both version of expression: parenthesis and not 2021-05-28 15:36:20 +03:00
Victor Petukhov
c0ad1c9b18 Do substitution of stub types inside smartcast types to further write it into trace and prevent dealing with that in the back-end 2021-05-28 15:36:20 +03:00
Victor Petukhov
26cbb020db Use resulting descriptor for old callable references to substitute stub type variables 2021-05-28 15:36:20 +03:00
Victor Petukhov
3ff22b67f7 Substitute type arguments of old callable references as well 2021-05-28 15:36:20 +03:00
Victor Petukhov
d5be258291 Do substitution for receivers of old (by passing though OI) callable references properly, with avoiding premature returning from the method 2021-05-28 15:36:19 +03:00
Victor Petukhov
9fd1cbd2e7 Inject stub type variables of a different builder inference call properly 2021-05-28 15:36:19 +03:00
Victor Petukhov
d486f7e188 Don't report TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE if unrestricted build inference was enabled 2021-05-28 15:36:19 +03:00
Victor Petukhov
0c427555cf Support definitely not null stub types and proper subtyping on them 2021-05-28 15:36:19 +03:00
Victor Petukhov
0f317b01b4 Rename language feature StableBuilderInference to UnrestrictedBuilderInference 2021-05-28 15:36:19 +03:00
Victor Petukhov
0b37b2be6a Add addtional tests for builder inference 2021-05-28 15:36:19 +03:00
Victor Petukhov
ecde5414dc Reuse error type constructor for stub types 2021-05-28 15:36:18 +03:00
Victor Petukhov
ee927a15a9 Compute nullability for stub types properly 2021-05-28 15:36:18 +03:00
Victor Petukhov
afbda75581 Set member scope for builder inference stub types equivalent to Any 2021-05-28 15:36:18 +03:00
Victor Petukhov
6356b9d501 Put removing builder inference restrictions under the compiler flag 2021-05-28 15:36:17 +03:00
Victor Petukhov
5a11450d77 Split stub types into stub type for subtyping and for builder inference and use them in the proper way 2021-05-28 15:36:17 +03:00
Victor Petukhov
703a353d2e Determine empty constraint system for a builder inference call by presense of not fixed type variables 2021-05-28 15:36:17 +03:00
Victor Petukhov
c5faf532f5 Allow builder inference calls with labeled lambda
^KT-24993 Fixed
2021-05-28 15:36:16 +03:00
Victor Petukhov
90066d7e50 Add expected type constraints in a builder inference call 2021-05-28 15:36:16 +03:00
Victor Petukhov
7da47dcde8 Add type variables into common system of a builder inference call properly 2021-05-28 15:36:15 +03:00
Victor Petukhov
ac7b459f2a Do subtyping with stub types properly
1) Return stub type if we are calculating super type between two same stub types
2) Return nullable Any if those stub types are different
2021-05-28 15:36:15 +03:00
Victor Petukhov
5d0461c722 Remove restrictions for builder inference internal calls 2021-05-28 15:36:14 +03:00
Victor Petukhov
26b8e86fe1 Render stub types properly 2021-05-28 15:36:14 +03:00
Nikita Bobko
af12b2fdf0 [imltogradle] Replace "Exported transitive dependency" with original module name reference 2021-05-28 14:03:07 +02:00
Nikita Bobko
6a7770573c [imltogradle] Support attaching 211 IDEA 2021-05-28 14:03:07 +02:00
Roman Artemev
8a856e440e [KLIB] Fix linker diagnostic message 2021-05-28 13:37:30 +03:00
Roman Artemev
720edfa6aa [IR] Fix branch offests
Seems logic that right bound of branch is result's right bound,
not condition's.
2021-05-28 13:23:52 +03:00
Andrey Zinovyev
ebf6ce133b [FIR] Fix kotlin version check in annotations
@RequireKotlin has more than one string parameter, so you need to check
 'version' only
2021-05-28 12:24:58 +03:00
Elena Lepilkina
3a22761d02 [K/N] Fix MutationCheck calls for inlined property accessors 2021-05-28 06:45:53 +00:00
Elena Lepilkina
b6f35ac44d [K/N] Fix inlining of property setters by replacing ReturnsInsertion lowering 2021-05-28 06:45:52 +00:00
Yahor Berdnikau
3387615d4a Fix test requires more later Gradle version. 2021-05-27 18:12:02 +00:00
Yahor Berdnikau
cdb04f9cd7 Add 'kgpSimpleTests' task.
This task run all JUnit5 tests with annotated with '@SimpleKGPTests`
annotation and also will be used in CI configuration.

^KT-45745 In Progress
2021-05-27 18:12:02 +00:00
Alexander Shabalin
af1f57007a https://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2 2021-05-27 17:18:55 +00:00
Nikolay Krasko
0b1884c994 Print memory consumption in the failure for GradleDaemonMemoryIT test 2021-05-27 20:13:10 +03:00
Nikolay Krasko
166f0a597b Run tests only for unique gradle versions 2021-05-27 20:13:09 +03:00
Nikolay Krasko
b5f71bacaf Never spam to log during the normal test execution in Gradle tests 2021-05-27 20:13:08 +03:00
Nikolay Krasko
9d1a6ebb18 Minor: narrow extracting functions scope 2021-05-27 20:13:07 +03:00
Mark Punzalan
d12a24418e FIR IDE: Remove multiple nested params in RemoveUselessElvisFix and
RemoveUselessCastFix.
2021-05-27 19:32:03 +03:00
Mark Punzalan
a778cc673e FIR IDE: Enable RemoveUselessElvisFix. 2021-05-27 19:32:01 +03:00
Ilya Goncharov
157046153f [Gradle, JS] Add test with dynamic webpack.config.d 2021-05-27 19:18:13 +03:00
Hung Nguyen
01c14a709a KotlinCompile: Add kotlin.incremental.useClasspathSnapshot flag
We are planning to improve incremental Kotlin compile with a new
approach using classpath snapshot (see
https://youtrack.jetbrains.com/issue/KT-45777 for more details).

The estimated steps will be as follows:
  [x] Add a flag for the new approach, disabled by default
  [ ] Add tests for the new approach, and update them as we go
  [ ] Add computation of classpath snapshot using artifact transforms
  [ ] Add computation of classpath snapshot changes
  [ ] Ensure incremental compile is fully functional with the new approach
  [ ] Measure performance + optimize: Repeat until we see evidence that
      the new approach is clearly better than the current approach
  [ ] Advertise the flag, and later on enable it by default

This commit is the first step. Although it's simple, it allows further
changes to be made safely without impacting the current approach.

Bug: KT-45777
Test: N/A (will be added in a subsequent change)
2021-05-27 19:05:26 +03:00
Nikita Bobko
1abf3a39d4 Fix kotlin-compiler-tests-for-ide. tests jars should be published 2021-05-27 17:23:46 +02:00
Nikita Bobko
2d015da1ea Make it possible to depend on the rest of :prepare:ide-plugin-dependencies modules
Those modules used as "aggregate" modules. kotlin-ide modules depend on them in coop-dev
2021-05-27 16:32:14 +02:00
Sergey Shanshin
961ee92c15 Fix bytecode for serializable enums in generated tests 2021-05-27 15:35:12 +03:00
Alexander Shabalin
e0c7cda1cf Adjust test expectations for the new MM 2021-05-27 11:39:56 +00:00
Ilya Goncharov
f2a067eda0 [Gradle, JS] In KotlinWebpack configDirectory as getter not lazy
It is useful to dynamically creating config directory during build execution

^KT-46976 fixed
2021-05-27 14:07:04 +03:00
Viacheslav Kormushkin
3709616baa Fixed failing cocoapods integration test 2021-05-27 10:47:45 +00:00
pyos
34878d17eb JVM: be more careful when removing unused constants
1. if an argument of a `pop` cannot be removed, then all other potential
   arguments of that `pop` can't be removed either, and the same applies
   to other `pop`s that touch them;
2. the same is true for primitive conversions, but this is even trickier
   to implement correctly, so I simply did the same thing as with
   boxing operators: replace the conversion itself with a `pop` and keep
   the argument as-is.

Somehow this actually removes *more* redundant primitive type conversions
than the old code in a couple bytecode text tests, so I've patched them
to kind of use the value, forcing the instructions to stay.

 #KT-46921 Fixed
2021-05-27 12:24:22 +02:00
pyos
2f60ce21a0 JVM: remove CHECKCAST handling from PopBackwardPropagationTransformer
Redundant CHECKCASTs should've been removed by a previous pass.
2021-05-27 12:24:22 +02:00
pyos
535934dc28 JVM: do not remove NOPs in PopBackwardPropagationTransformer
There is a pass that removes NOPs and runs afterwards anyway.
2021-05-27 12:24:22 +02:00
Aleksei.Cherepanov
5f4be07225 [JPS] Fix JS incremental compilation
Disable Idea JPS build mechanism for marking all sources of common output if one of them is dirty
Add source-to-outputs map for correctly removing Kotlin/JS outputs

#KT-45763 Fixed
#KT-44351 Fixed
2021-05-27 13:00:56 +03:00
Andrey Zinovyev
c2389a94fa [FIR] Resolve annotations in when expressions 2021-05-27 12:41:16 +03:00
Sergey Bogolepov
b541721a79 Deprecate Architecture.bitness property
There is no such thing as "bitness" of CPU achitecture.
Something more appropriate and correct (e.g. ABI) should be
introduced instead.
2021-05-27 10:09:25 +03:00
Sergey Bogolepov
bed42e9ab2 Revert "Drop useless bitness property from Architecture"
As it turn outs, `Architecture.bitness` leaks to public Gradle API and
we need to deprecate it gracefully.
This reverts commit 79bf2a1f.
2021-05-27 10:09:24 +03:00
sebastian.sellmair
14eca72913 Implement 'CommonizerTarget.fileName' and limit fileName length
^KT-46856 Fixed
2021-05-27 06:48:34 +00:00
sebastian.sellmair
0749443f7e Implement CommonizerIT.test KT-46856 filename too long - all native targets configured
Covers ^KT-46856
2021-05-27 06:48:33 +00:00
Abduqodiri Qurbonzoda
54994a289f Support all digit chars on JS and Native #KT-46002 2021-05-27 06:56:52 +03:00
Anton Lakotka
8481f4a9d2 Set kotlin-project-model as api dependency for kotlin-gradle-plugin-api
LanguageSettingsBuilder depends on LanguageSetting interface from KPM
which forces api dependency scope

^KT-46517 Fixed
2021-05-26 18:11:39 +00:00
Anton Lakotka
3e2b8a8898 Test Gradle buildSrc with kotlin-gradle-plugin-api dependency
For ^KT-46517
2021-05-26 18:11:39 +00:00
Anton Bannykh
b3bb033fe4 JS IR: fix plain module reference 2021-05-26 17:53:21 +03:00
Dmitriy Novozhilov
b63770bc7b Add workaround for KT-46902 2021-05-26 17:53:20 +03:00
Dmitriy Novozhilov
89e52cb780 Add workaround for KT-46900 2021-05-26 17:53:19 +03:00
Dmitriy Novozhilov
8eca31e867 Advance bootstrap to 1.5.30-dev-1023 2021-05-26 17:53:17 +03:00
pyos
d37ceb47be JVM_IR: use correct dispatch receiver type in more references
#KT-46902 Fixed
2021-05-26 15:23:19 +02:00
Sergey Shanshin
16dbafced1 Add .serializer() to enum companion and object with custom serializer
Fixes Kotlin/kotlinx.serialization#1386
2021-05-26 16:07:59 +03:00
Igor Chevdar
f431b4b171 [K/N][codegen] Escape analysis: increased a bit the number of iterations
This helps the algorithm to converge in more situations and increases
the number of stack allocated objects
2021-05-26 17:48:20 +05:00
Igor Chevdar
29584edcdd [K/N][codegen] Escape analysis: handled nulls more optimally
Helps with https://youtrack.jetbrains.com/issue/KT-44148
2021-05-26 17:46:22 +05:00
Igor Chevdar
426ac1281d [K/N][codegen] Removed square graph swelling during escape analysis
Helps with https://youtrack.jetbrains.com/issue/KT-44148
2021-05-26 17:46:15 +05:00
Konstantin Tskhovrebov
2129a762a5 Change assemble AppleFrameworkTask name to using framework name prefix
#KT-46892
2021-05-26 14:59:30 +03:00
Elena Lepilkina
a006f35df3 [K/N][build] Removed extra konanVersion variable as far as it's now same as kotlinVersion 2021-05-26 11:49:49 +00:00
Tianyu Geng
61475c48e2 FIR: fix VALUE_ARGUMENTS position strategy 2021-05-26 14:46:18 +03:00
Margarita Bobova
3bd6bf1432 Add changelog for 1.5.10 2021-05-26 13:51:48 +03:00
Margarita Bobova
e31173ca73 Add changelog for 1.5.0 2021-05-26 13:51:06 +03:00
pyos
33ddeffcfd JVM_IR: box inline class values returned by suspend inline lambdas
The call site inside the inline function expects them to return a boxed
value, like FunctionN.invoke would.

 #KT-46915 Fixed
2021-05-26 08:33:55 +02:00
pyos
117fad2018 JVM: refactor inline ExpressionLambda initialization 2021-05-26 08:33:55 +02:00
Mads Ager
d023966054 [JVM] Fix various undefined locals issues.
CoroutineTransformermethodVisitor attempts to extend the ranges
of local variables in various situations. Probably in an attempt
to give a better debugging experience. However, all of these
range extensions lead to invalid local variable tables where
something is in the local variable table where nothing is in the
corresponding slot.

The code that extends variables to the next suspension point
instead of ending them when they are no longer live has issues
with loops. When resuming and reentering the loop, the locals
table will mention a local that we did not spill and which
is therefore not restored when resuming.

The code that extends local variable table entries if there
are no suspension points between two entries doesn't work
for code such as:

```
var s: String
if (suspendHere() == "OK") {
  s = "OK"
} else {
  s = "FAIL"
}
```

If the local variable ranges are collapsed into one, one of
the branches will have the local defined in the local variable
table before the slot is initialized.
2021-05-26 08:33:34 +02:00
Nikita Bobko
14ed660f4f [cleanup] Remove unused AbstractFirMultiModuleResolveTest 2021-05-25 23:53:08 +03:00
Anton Lakotka
5d9915e133 Don't copy extendsFrom configs for resolvableMetadataConfiguration
Gradle's detached configurations doesn't respect extends from relation
to other configurations due to gradle bug.
In fact extendsFrom isn't required for resolvableMetadataConfiguration
business logic. It is enough to include all originalDependencies to
freshly created detached configuration.

^KT-46417 Fixed
2021-05-25 23:31:23 +03:00
sebastian.sellmair
e8bd8a938f Implement HierarchicalMppIT.testNativeLeafTestSourceSetsKt46417 to cover ^KT-46417 2021-05-25 23:31:22 +03:00
Ilya Goncharov
c62a965180 [IR] Not try Null constant in fold constant
^KT-46859 fixed
2021-05-25 22:29:58 +03:00
Ilya Kirillov
b18d4af37b fix fe1.0 plugin testdata 2021-05-25 20:39:37 +03:00
Mark Punzalan
2c18406632 IDE: Add test for message of VAL_OR_VAR_ON_*_PARAMETER diagnostic.
Also fall back to getting parameter descriptor if property descriptor
not found for `val/var` parameters.

^KTIJ-13030 Fixed
2021-05-25 20:39:36 +03:00
Mark Punzalan
23605e08be FIR IDE: Enable RemoveValVarFromParameterFix for
VAL_OR_VAR_ON_*_PARAMETER.
2021-05-25 20:39:35 +03:00
Mark Punzalan
af99ad0736 FIR checker: Report VAL_OR_VAR_ON_*_PARAMETER. 2021-05-25 20:39:34 +03:00
Tianyu Geng
71c5c9f6c5 FIR IDE: add quickfix to change function return type 2021-05-25 20:39:32 +03:00
Stanislav Erokhin
b5994fa3a9 Remove the Kotlin online event link 2021-05-25 19:19:26 +02:00
Andrey Zinovyev
ae079d9bdd [FIR] Move unsigned types constructor evaluation from intrinsics 2021-05-25 19:23:31 +03:00
Andrey Zinovyev
64b45e6d1b Add comments to skipped FIR tests 2021-05-25 19:23:30 +03:00
Andrey Zinovyev
dce8bd4e62 [FIR] Support constructor call of unsigned in checker 2021-05-25 19:23:29 +03:00
Andrey Zinovyev
7f2eaab02b [FIR] Support for constructor calls of unsigned types in constants 2021-05-25 19:23:27 +03:00
Dmitriy Novozhilov
f9eba6e842 [FIR] Fix determining dependencies for modular jdk in CLI 2021-05-25 15:08:47 +03:00
teamcityserver
d530344eda Merge branch 'push/zharkov-fixes-4' 2021-05-25 14:57:51 +03:00
Jinseong Jeon
5effbce363 UAST: cleanup plugin file to have only plugin definition 2021-05-25 13:09:57 +02:00
Jinseong Jeon
8b93727f64 UAST: split KotlinConverter into a separate file 2021-05-25 13:09:57 +02:00
Jinseong Jeon
0395294933 UAST: split KotlinUastResolveProviderService into a separate file 2021-05-25 13:09:57 +02:00
Jinseong Jeon
f16f9a13fd FIR/UAST: enforce the existence of BaseKotlinUastResolveProviderService 2021-05-25 13:09:57 +02:00
Jinseong Jeon
240f86b109 FIR UAST: use analyseWithCustomToken in lieu of analyse 2021-05-25 13:09:57 +02:00
Jinseong Jeon
741fdee59e FIR/UAST: commonize UnknownKotlinExpression 2021-05-25 13:09:57 +02:00
Jinseong Jeon
15a4649675 FIR/UAST: commonize UImportStatement 2021-05-25 13:09:57 +02:00
Jinseong Jeon
3c3b5aa4ac FIR/UAST: commonize abstract UElement and UExpression 2021-05-25 13:09:57 +02:00
Jinseong Jeon
a54a807dc9 FIR/UAST base: clarify what module we should not depend on
This should be part of commit bbe5cf0a
2021-05-25 13:09:57 +02:00
Denis.Zharkov
dac9d7b17a FIR: Mark a pack of tests (53) as FIR_IDENTICAL 2021-05-25 13:28:29 +03:00
Denis.Zharkov
ddbdfafa79 Remove OI/NI attributes from test data 2021-05-25 13:28:27 +03:00
Denis.Zharkov
2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00
Denis.Zharkov
d4586cefb4 FIR: Properly deserialize upper bounds of classes type parameters
^KT-46661 Fixed
2021-05-25 13:28:25 +03:00
Alexander Shabalin
858e3584a9 Disable escape analysis with the new MM 2021-05-25 10:06:40 +00:00
Ivan Gavrilovic
4f64431f10 KT-46820: Kotlin gradle plugin - prevent multiple threads from registering task
... as that is not supported by the underlying mechanism.
Build service that holds info about the incremnetal compilation
may be instantiated only during execution, and multiple tasks may
try to do that. Because the container which holds info about all
build services is not thread-safe, this change adds synchronization.

Fixes #KT-46820
2021-05-25 12:49:07 +03:00
Mikhail Glukhikh
1b7425f428 FIR mangler: handle situation with invisible type in f/o signature
Before this commit, FIR mangler effectively dropped f/o parameter with
invisible type from this module. It could lead to signature clashes.
Now we insert classId in mangler string instead.
This fixes FIR bootstrap.
2021-05-25 11:38:48 +03:00
Denis.Zharkov
924678a00d FIR: Mark a pack of tests (53) as FIR_IDENTICAL 2021-05-25 10:25:05 +03:00
Denis.Zharkov
26002a040f Remove OI/NI attributes from test data 2021-05-25 10:25:05 +03:00
Denis.Zharkov
fe1d540c95 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 10:25:04 +03:00
Denis.Zharkov
accd48de8c FIR: Properly deserialize upper bounds of classes type parameters
^KT-46661 Fixed
2021-05-25 10:25:04 +03:00
Ivan Kochurkin
cf531dbbe6 [FIR] Implement TYPE_VARIANCE_CONFLICT, TYPE_VARIANCE_CONFLICT_IN_EXPANDED_TYPE diagnostics, fix tests 2021-05-25 00:07:33 +03:00
Ivan Kochurkin
ef53f0e0b3 [FIR] Render diagnostics parameters instead of full text in debug messages (closer to old tests) 2021-05-25 00:07:32 +03:00
Ivan Kochurkin
6de97e17fe [FIR] Fix max parameters count in diagnostics from 3 to 4 2021-05-25 00:07:30 +03:00
Elena Lepilkina
7f591bcfd4 [K/N] Changed llvmInlineThreshold for new form of bitcode 2021-05-24 15:46:21 +00:00
Elena Lepilkina
2320eb8b44 [K/N] Replace invokes with combination of calls and branch instructions 2021-05-24 15:46:20 +00:00
Nikita Bobko
0be5602363 Move ':plugins:lombok:lombok-ide-plugin' module under 'attachedIntellijVersion' the flag 2021-05-24 17:02:46 +02:00
Dmitriy Dolovov
9ab764e9fd [Native] Disable debug mode in KonanLocalTest (-g) 2021-05-24 13:23:51 +00:00
nataliya.valtman
1db09d78b3 KT-46833: print correct message when history files are unavailable 2021-05-24 13:51:43 +03:00
Ilya Muradyan
23faacd21b [Scripting] Expose scripting-dependencies as API of Maven resolver 2021-05-22 04:10:39 +03:00
Ilya Muradyan
0e7d690923 [Scripting] Change compile to implementation in Maven resolver 2021-05-22 00:38:46 +03:00
Ilya Muradyan
bead0e3412 [Scripting] Fix Maven resolver dependencies 2021-05-22 00:38:44 +03:00
Dmitry Petrov
261b42f5c5 JVM_IR KT-46822 don't generate too deep StringBuilder.append trees 2021-05-21 22:28:54 +03:00
Dmitry Petrov
ba00709e4d JVM_IR KT-46839 lower varargs for *arrayOf function references 2021-05-21 22:06:52 +03:00
Alexander Udalov
6ca7b39f6a Psi2ir: do not load abbreviated types with not found classifier
This is not an ideal fix of the problem since the fact that
AbbreviatedType's classifier should be a TypeAliasDescriptor is a
reasonable assumption that might fail somewhere else, later in the
pipeline.

Previous attempts to fix this issue that were unsuccessful:

1) Do not load abbreviations for such types in deserialization at all.
   Unfortunately, it broke quite a few things like reflection and
   decompiler, where types frequently refer to symbols not reachable
   from the point where they're requested, yet we have the FQ name of
   the typealias, which is enough to render the abbreviation properly in
   both these use cases.

2) Load classifiers for unresolved abbreviations as
   MockTypeAliasDescriptor instead of MockClassDescriptor in
   NotFoundClasses. Technically this was a revert of
   e19c1b5364. But this failed because we
   don't have enough information about such typealias to correctly set
   its `expandedType`/`underlyingType` (just using nullable Any as
   before that commit is not good enough). We only know its underlying
   class (from one usage of such typealias), and even supporting that
   would involve a major refactoring of TypeDeserializer which is
   painful.

 #KT-45308 Fixed
2021-05-21 19:36:30 +02:00
Alexander Udalov
ceec451f3f Minor, slightly refactor TypeDeserializer.typeConstructor 2021-05-21 19:36:30 +02:00
Dmitriy Dolovov
ab6f577964 [Native] Support suspend functions as supertypes (remove debug code)
^KT-46777
2021-05-21 17:31:46 +00:00
Hung Nguyen
c0977dd638 Build report: Print task name instead of TaskRecord@hashCode
Previously when kotlin.build.report.enable=true, the build report
contained lines such as:
  org.jetbrains.kotlin.gradle.report.TaskRecord@2db49688 was skipped

This commit prints the task name instead of TaskRecord@hashCode so that
it is more readable, like this:
  Task ':app:compileDebugKotlin' was skipped

Bug: N/A (Clean up)
Test: Existing tests + manually checked the build report output
2021-05-21 19:35:25 +03:00
Dmitriy Novozhilov
478a512b24 [FIR] Expand type of const val in FirConstPropertyChecker 2021-05-21 17:38:26 +03:00
Vasily Levchenko
669985f853 [debug][stacktrace][mac] more tracing for stacktrace debugging 2021-05-21 11:52:08 +00:00
Dmitriy Dolovov
0be542fd33 [Native] Always enable assertions in KonanLocalTest 2021-05-21 14:37:30 +03:00
Dmitriy Novozhilov
a1ae108ce5 [FIR] Properly generate IDE diagnostics from multiple diagnostics lists 2021-05-21 14:18:58 +03:00
Dmitriy Novozhilov
09e3629d5d [FIR] Move common checkers container from :entrypoint to :checkers module 2021-05-21 14:18:57 +03:00
Dmitriy Novozhilov
a9838131ad [FIR] Move jvm specific checkers to checkers.jvm module 2021-05-21 14:18:56 +03:00
Dmitriy Novozhilov
f3c58a1df7 [FIR] Add separate diagnostic list for JVM specific diagnostics 2021-05-21 14:18:55 +03:00
Dmitriy Novozhilov
7f18d147c1 [FIR] Introduce new module for jvm specific checkers 2021-05-21 14:18:54 +03:00
Dmitriy Novozhilov
9825babc23 [FIR] Move model classes of diagnostics generation DSL to separate package 2021-05-21 14:18:52 +03:00
Denis.Zharkov
f0c85e0935 FIR: Add comments to freshly muted tests 2021-05-21 13:53:55 +03:00
Andrey Zinovyev
617d99faac [FIR] Don't keep ref to whole class proto
Store module name only
2021-05-21 12:49:59 +03:00
Andrey Zinovyev
a121061df7 [FIR] Get module name for deserialized fir2ir classes 2021-05-21 12:49:58 +03:00
Svyatoslav Scherbina
dc8934ab22 Native: fix crash in custom LLVM diagnostics handler
48a684c0 added custom LLVM diagnostic handler, using JvmCallbacks machinery,
thus triggered a bug in the latter: callbacks are cached and outlive the compilation session,
but rely on memory that is reclaimed at the end of the compilation session.
So during a subsequent compilation in the same process (e.g. when the compiler runs in the
Gradle daemon process), LLVM might call the callback which accesses the reclaimed memory, 
which in turn causes the crash.

Fix this by forcing JvmCallbacks to allocate memory that doesn't "expire" at the end of the compilation session.
2021-05-21 07:34:34 +00:00
Elena Lepilkina
573191251e [K/N] Remove redundant update of debug info 2021-05-21 06:55:07 +00:00
Alexander Shabalin
73533e4b19 Make NoOp GC support multiple mutators 2021-05-21 06:31:09 +00:00
Ilya Kirillov
792ac6ab63 FIR IDE: update resolve call testdata after adding targetFunction to KtFunctionalTypeVariableCall 2021-05-21 00:04:48 +02:00
Ilya Kirillov
c72b2caf3e Fix wrapWithSafeLetCall quickfix testdata 2021-05-21 00:01:20 +02:00
Ilya Kirillov
be4632c2fe FIR: add missing ArgumentTypeMismatch.isMismatchDueToNullability after rebase 2021-05-20 21:05:41 +02:00
Ilya Kirillov
acda71cc90 FIR IDE: restore test generator after rebase 2021-05-20 20:33:01 +02:00
Tianyu Geng
e1b542314a FIR IDE: quickfix for WrapWithSafeLetCall
There is some behavior change regarding the new WrapWithSafeLetCall quickfix

1. it now works correctly on binary expressions by wrapping it with `()`
2. it now looks for a nullable position upward and do the modification there,
   if possible. For example, consider the following code

   ```
   fun bar(s: String): String = s

   fun test(s: String?) {
     bar(bar(bar(<caret>s)))
   }
   ```

   After applying this fix, FE1.0 yields

   ```
   bar(bar(s?.let { bar(it) }))
   ```

   while the new implementation yields

   ```
   s?.let { bar(bar(bar(it))) }
   ```

   This behavior aligns with FE1.0 if `bar` accepts nullable values.
2021-05-20 20:33:00 +02:00
Tianyu Geng
0eaab6d8a2 FIR: extract common logic from KotlinNameSuggester and share 2021-05-20 20:33:00 +02:00
Tianyu Geng
00ffa69cb3 FIR: add receiver expression to UNSAFE_CALL diagnostic and its variances 2021-05-20 20:32:59 +02:00
Tianyu Geng
9106ae4f5f FIR: store in ARGUMENT_TYPE_MISMATCH whether it's due to nullability 2021-05-20 20:32:59 +02:00
Tianyu Geng
cceb7197a5 FIR: allow nullable types in diagnostic parameters 2021-05-20 20:32:59 +02:00
Tianyu Geng
594fbbb4ef FIR: Allow 4 parameters for diagnostics 2021-05-20 20:32:58 +02:00
Mark Punzalan
d2b8204fdc FIR/FIR IDE: Use entire FirVariableAssignment when reporting UNSAFE_CALL
(e.g., `nullable.a = b`), and use positioning strategies to locate the
dot in the LHS expression.

Without it, only the callee reference is reported on, which makes the
highlighting of the error and application of quickfixes incorrect in the
IDE.

Also fixed issue with annotated and/or labeled expressions on LHS of
assignment (e.g., `(@Ann label@ i) = 34`).
2021-05-20 20:32:58 +02:00
Mark Punzalan
1d9247ae0f FIR IDE: Offer AddExclExclCallFix for nullable types with an
`iterator()` function that does NOT have `operator` modifier.

This is different from FE1.0. Adding `!!` will then surface the error
that `operator` modifier needs to be added (with corresponding fix).
2021-05-20 20:32:58 +02:00
Mark Punzalan
9e01a608b2 FIR IDE: Add ability in test infra to have a "before" file different in
FIR vs FE1.0, and made file naming convention more consistent.
2021-05-20 20:32:57 +02:00
Mark Punzalan
efa3bf9c69 FIR IDE: Consolidate tests for AddExclExclFix in one directory.
I found these tests only _after_ the previous changes, so I needed to
merge and/or remove redundant tests.
2021-05-20 20:32:57 +02:00
Mark Punzalan
db82797f58 FIR IDE: Enable AddExclExclCallFix for UNSAFE_CALL,
UNSAFE_OPERATOR_CALL, UNSAFE_INFIX_CALL, ITERATOR_ON_NULLABLE,
ARGUMENT_TYPE_MISMATCH, RETURN_TYPE_MISMATCH.

TODO: Don't offer fix when target is known to be null (from data flow
analysis).
2021-05-20 20:32:56 +02:00
Mark Punzalan
71a8d9c0bb FIR quickfix: Enable addExclExclCall tests for FIR, move typeMismatch
tests for addExclExclCall to addExclExclCall directory.
2021-05-20 20:32:56 +02:00
Mark Punzalan
85cbea70bf IDE: Don't do any resolution in AddExclExclExclFix (i.e., in
isAvailable and in invoke) by moving computation of element to modify
to before instantiation (i.e., to the factories or equivalent).

This lets us to move it to idea-frontend-independent and re-use it FIR.
2021-05-20 20:32:56 +02:00
Mark Punzalan
c472c9facd IDE: Don't add this!! in AddExclExclCallFix for nullable member
access in extension function.

^KTIJ-10052 Fixed
2021-05-20 20:32:55 +02:00
Dmitry Petrov
c0fbdb1535 JVM_IR KT-46840 don't generate special function references with indy 2021-05-20 21:13:17 +03:00
Dmitriy Novozhilov
3fc7e0ed03 [FIR] Remove COMPARE_WITH_LIGHT_TREE from default directives of fir diagnostic tests 2021-05-20 20:20:40 +03:00
Nikita Bobko
f7aabf03f8 Fix kotlin-native compilation
This commit fixes:
```
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException:
Could not find method intellijDep() for arguments [] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
```
2021-05-20 17:02:00 +02:00
Viacheslav Kormushkin
d10910e553 Added support of custom Xcode configurations to cocoapods plugin
#KT-42023
2021-05-20 17:36:08 +03:00
Denis.Zharkov
a801eccf66 FIR: Report ARGUMENT_TYPE_MISMATCH instead of TYPE_MISMATCH for arguments 2021-05-20 17:24:51 +03:00
Denis.Zharkov
db500fab94 FIR: Avoid reporting redundant TYPE_MISMATCH (for assignments) 2021-05-20 17:24:50 +03:00
Denis.Zharkov
36c9418d55 FIR: Convert couple of methods to block-body 2021-05-20 17:24:49 +03:00
Denis.Zharkov
7c05c6420a FIR: Update test data (incorrect NEW_INFERENCE_ERROR with self types)
^KT-46661 Relates
2021-05-20 17:24:48 +03:00
Denis.Zharkov
4433dffbd3 FIR: Mute test that should be disabled since 1.6 2021-05-20 17:24:47 +03:00
Denis.Zharkov
8f41badf74 Minor. Regenerate tests 2021-05-20 17:24:46 +03:00
Denis.Zharkov
c3646b11ac FIR: Fix inference when unit value should be cast to Any 2021-05-20 17:24:44 +03:00
Denis.Zharkov
d3fc22fc6a FIR: Mute suspicious test relevant to safe-call and increment
See KT-46658
2021-05-20 17:24:43 +03:00
Denis.Zharkov
c4862fb124 FIR: Unwrap type aliases in type arguments 2021-05-20 17:24:42 +03:00
Denis.Zharkov
4f08e1550d FIR: Update test data (overload resolution by lambda return type) 2021-05-20 17:24:41 +03:00
Denis.Zharkov
be68dd5c11 FIR: Update test data (suspicious UPPER_BOUND_VIOLATED) 2021-05-20 17:24:40 +03:00
Denis.Zharkov
9265377d51 FIR: Update test data (SAM conversions)
See KT-46372
2021-05-20 17:24:39 +03:00
Denis.Zharkov
601500fd99 FIR: Update test data (extension function type -> function type)
See KT-46371
2021-05-20 17:24:38 +03:00
Denis.Zharkov
e46199d28b FIR: Update test data (nested type aliases)
It's not consistent with FE 1.0, but behavior
for nested type alias is undefined, yet.
2021-05-20 17:24:37 +03:00
Denis.Zharkov
da3233c47d FIR: Update test data (NEW_INFERENCE_ERROR)
Though these diagnostics look correct (the calls or constraint
systems indeed contain errors), more precise diagnostic kinds should be
chosen later.
2021-05-20 17:24:36 +03:00
Denis.Zharkov
010a0c6cdc FIR: Update test data (delegate inference)
Changed data looks correct
2021-05-20 17:24:35 +03:00
Denis.Zharkov
7c5c744e87 FIR: Update test data (suspicious diagnostic on return statement)
There should be errors, but different: cannot infer parameter type

^KT-46422 Relates
2021-05-20 17:24:34 +03:00
Denis.Zharkov
00821bbc63 FIR: Update test data (repeated diagnostics)
They are a bit redundant, but it needs additional work to be done
to avoid them
2021-05-20 17:24:33 +03:00
Denis.Zharkov
dbc0ebd861 FIR: Update test data
changed INAPPLICABLE_CANDIDATE -> ARGUMENT_TYPE_MISMATCH
2021-05-20 17:24:32 +03:00
Denis.Zharkov
b94335dd1c FIR: Update diagnostics test data
Green code correctly became red
2021-05-20 17:24:30 +03:00
Denis.Zharkov
829f80179c FIR: Update rendered tree in test data 2021-05-20 17:24:29 +03:00
Denis.Zharkov
faa5e46396 FIR: Fix inference case with flexible captured types
Previsously, errors have been ignored because we ignored errors raised
from the completion phase

See the comment above the createConstraintPartForLowerBoundAndFlexibleTypeVariable
2021-05-20 17:24:28 +03:00
Denis.Zharkov
c758069d7c FIR: Rework reporting COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH
Previously, it was reported via additional check on successful calls
But now it's contained within FirErrorNamedReference
2021-05-20 17:24:27 +03:00
Denis.Zharkov
c46d049394 FIR: Implement more precise reporting diagnostics from new inference 2021-05-20 17:24:26 +03:00
Denis.Zharkov
c67ae8a0a3 FIR: Replicate coercion-to-unit behavior from FE 1.0 2021-05-20 17:24:25 +03:00
Denis.Zharkov
dac5c31993 Minor. Simplify ConstraintSystemUtilContext::createArgumentConstraintPosition 2021-05-20 17:24:23 +03:00
Denis.Zharkov
9c7982673b FIR: Support substitution of inner class constructor capturing outer type parameters 2021-05-20 17:24:22 +03:00
Denis.Zharkov
91806c0a68 FIR: Refine diagnostics in case argument type mismatch on lambda
Report ArgumentTypeMismatch instead of imprecise NEW_INFERENCE_ERROR
2021-05-20 17:24:21 +03:00
Denis.Zharkov
2b806e717d FIR: Avoid adding new constraints when system already has contradictions 2021-05-20 17:24:20 +03:00
Denis.Zharkov
571c16be52 FIR: Fix computing dispatch receiver for property-delegation operators 2021-05-20 17:24:19 +03:00
Denis.Zharkov
35c754c27c FIR-DFA: Ignore FinallyBlockExitNode when computing return arguments 2021-05-20 17:24:17 +03:00
Denis.Zharkov
d0a0739d10 FIR: Mute builder-inference related tests
They started failing once we began reporting diagnostics from completion

^KT-46421 Relates
2021-05-20 17:24:16 +03:00
Denis.Zharkov
78ec4b5248 FIR: Mute property-delegation-inference related tests
They started failing once we began reporting diagnostics from completion
The main reason is that we resolve `delegate()` call
from `delegate().getValue()` in the independent context, while in FE 1.0
it's being resolved within the same system as getValue

^KT-46420 Relates
2021-05-20 17:24:15 +03:00
Denis.Zharkov
cd401b5b8a FIR: Update integer literal-related tests
They started failing once we began reporting diagnostics from completion

^KT-46419 Relates
2021-05-20 17:24:14 +03:00
Denis.Zharkov
42d387925d FIR: Refine makesSenseToBeDefinitelyNotNull
Make it work just the same as the analogue from FE 1.0
This change is necessary since many tests start failing after
we began reporting diagnostics after call completion
2021-05-20 17:24:12 +03:00
Denis.Zharkov
a700fdc312 FIR: Report diagnostics introduced during call completion 2021-05-20 17:24:10 +03:00
Nikita Bobko
09321e5e41 Implement ide-iml-to-gradle-generator
This module is used to generate build.gradle.kts files
of Kotlin IDE plugin
2021-05-20 16:09:14 +02:00
Nikita Bobko
61bf6bc447 Remove ':idea:idea-jps-common' from 'compiler-components-for-jps' artifact
It seems that it was added by mistake 'compiler-components-for-jps' artifact is used in IDE.
And in IDE we have our own jps-common module
2021-05-20 16:05:38 +02:00
Nikita Bobko
0fc31bc9c7 Disable IDE modules if 'attachedIntellijVersion' flag is specified 2021-05-20 16:05:37 +02:00
Nikita Bobko
897dafc7f3 GenerateTests: extract IDE part into separate module
It's refactoring-preparation commit. In later commits I will add possibility
to disable IDE modules with flags in gradle build (first step towards
removing IDE modules from kotlin repo). Thus, we need to extract IDE tests
generator in separate module for being possible to disable it with flags
2021-05-20 16:05:37 +02:00
Nikita Bobko
ac6c810d25 Make it possible to attach platforms with different versions to kotlin repo 2021-05-20 16:05:37 +02:00
Nikita Bobko
cc34f65392 [cleanup] Remove unused variable 2021-05-20 16:05:37 +02:00
Nikita Bobko
1fa4874426 Create 'installIdeArtifacts' task
This task is used for cooperative compilation with intellij.
See 'Install compiler-for-ide jars' run configuration in
intellij/kotlin-ide/intellij-kotlin repo
2021-05-20 16:05:37 +02:00
Nikita Bobko
8dec62de2b [kotlin + intellij combined] Add one more artifact url
This commit fixes:
```
* What went wrong:
Execution failed for task ':kotlin-ide.intellij.platform.testExtensions:compileKotlin'.
> Could not resolve all files for configuration ':kotlin-ide.intellij.platform.testExtensions:compileClasspath'.
   > Could not find intellij-core-analysis-deprecated-202.7660.26.jar (kotlin.build:ideaIC:202.7660.26).
     Searched in the following locations:
         file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/202.7660.26/artifacts/lib/intellij-core-analysis-deprecated.jar
         file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/202.7660.26/artifacts/intellij-core-analysis-deprecated.jar
         file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/202.7660.26/artifacts/plugins/ideaIC/lib/intellij-core-analysis-deprecated.jar
         file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/sources/intellij-core-analysis-deprecated-202.7660.26.jar
         file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/202.7660.26/intellij-core-analysis-deprecated.jar
```
2021-05-20 16:05:37 +02:00
Nikita Bobko
54f7633738 build.gradle.kts: exclude :kotlin-ide from allprojects
We don't need to setup compiler args and JDK version for kotlin-ide modules.
Generated build.gradle.kts will do it themselves
2021-05-20 16:05:37 +02:00
Nikita Bobko
6d125e0880 Initial implementation of kotlin + intellij combined repo 2021-05-20 16:05:36 +02:00
Nikita Bobko
cedafedfb0 Add kotlin-ide/ to .gitignore 2021-05-20 16:05:36 +02:00
Alexander Udalov
e0b0df01da Rename fields in KotlinIr.proto according to protobuf style guide
Field names should use snake_case, and names of repeated fields should
use the singular form: https://developers.google.com/protocol-buffers/docs/style#message_and_field_names
2021-05-20 15:59:42 +02:00
Alexander Udalov
8dee36d420 Tests: do not add transitive dependencies in multi-module tests
Prefer to have all module dependencies, including dependencies on
stdlib/reflect, declared explicitly. This allows to have tests on
situations like the one in KT-45308: three modules A<-B<-C, where C
doesn't depend on A, which was compiling correctly with the old JVM
backend before 1.5, but started to fail with JVM IR in 1.5.

Also simplify the code a bit, remove duplicated logic.
2021-05-20 15:58:05 +02:00
Alexander Shabalin
eac3f507b6 Make Kotlin_initRuntimeIfNeeded switch to native state 2021-05-20 13:48:49 +00:00
Ilya Goncharov
f40110eb83 [JS IR] Fixes after rebase 2021-05-20 16:37:52 +03:00
Ilya Goncharov
d65cbdf44d [JS IR] Fixes in tests
- Compilation of tests
- add arguments to extra help
2021-05-20 16:37:50 +03:00
Ilya Goncharov
b76f5547e4 [JS IR] Remove unnecessary overrides in IrNamer 2021-05-20 16:37:48 +03:00
Ilya Goncharov
0921235637 [JS IR] Remove redundant file after rebase 2021-05-20 16:37:47 +03:00
Ilya Goncharov
18cb8a1b9b [JS IR] Add flag with writing base class to metadata 2021-05-20 16:37:45 +03:00
Ilya Goncharov
228c6879f5 [JS IR] Add per-module output module name 2021-05-20 16:37:44 +03:00
Ilya Goncharov
4d7f7fc50f [Gradle, JS] Use jsOutputName as module name 2021-05-20 16:37:43 +03:00
Ilya Goncharov
eaf25b517d [JS IR] Use module name instead of output file wo extension 2021-05-20 16:37:41 +03:00
Ilya Goncharov
0e00186ca1 [JS IR] Fix compilation after rebase 2021-05-20 16:37:39 +03:00
Anton Bannykh
0182c09318 [JS IR] fix name clashes for imported external declarations 2021-05-20 16:37:38 +03:00
Anton Bannykh
6e40c814c8 [JS IR] add a flag which prepends a custom prefix to the per-module .js files 2021-05-20 16:37:37 +03:00
Anton Bannykh
7bd9462ffb [JS IR] save the desired JS output file name in the klib.
This is only usedful for code splitting. The output .js file name
is provided by the build system during the module compilation.
It is desirable to keep the .js output file names same as in old BE,
but calculating those name during the klib -> js phase is tricky.

Thus the desired names are saved in the klib, and used later on.
2021-05-20 16:37:35 +03:00
Anton Bannykh
6633a9edc0 [JS IR] add a flag which enable safe property access
If an accessor is not available at runtime we fall back
to the property access.

This is useful in cases when JS objects are casted to Kotlin
classes implicitly. This pattern did work in the old BE, which
lead to a significant amount of code which doesn't work anymore.
2021-05-20 16:37:34 +03:00
Anton Bannykh
8b18818bcc [JS IR] add base class to the $metadata$.interfaces list
This is needed for better compatibility with the old BE.
Some code in Space relies on the $metadata$ format.
2021-05-20 16:37:32 +03:00
Steven Schäfer
984e912f8d JVM IR: Do not unbox Results in suspend lambda invoke methods (KT-46813) 2021-05-20 14:40:00 +02:00
Dmitriy Novozhilov
ff3f3d2f9b [FIR] Properly setup search scope for IC symbol provider 2021-05-20 14:21:49 +03:00
Dmitriy Novozhilov
6e4cc49f1d [FIR] Cleanup IC provider creation in FirSessionFactory 2021-05-20 14:21:47 +03:00
Dmitriy Novozhilov
6d38a236c1 [FIR] Extract FIR related part of KotlinToJVMBytecodeCompiler to separate file 2021-05-20 14:21:46 +03:00
Jinseong Jeon
f0f1e2d945 FIR checker: report CAPTURED_VAL_INITIALIZATION 2021-05-20 13:59:13 +03:00
Andrey Zinovyev
d38effcbbe Use camel-case in FirFunctionCallOrigin
Also componentCall is operator call
2021-05-20 13:46:35 +03:00
Andrey Zinovyev
419aa65381 [FIR] Fix more tests because of modifier usage in resolution 2021-05-20 13:46:34 +03:00
Andrey Zinovyev
07a8ae7e71 [FIR] Mark more calls origin as OPERATOR 2021-05-20 13:46:32 +03:00
Andrey Zinovyev
0a45b3a50b [FIR] Set Function call origin to assign operators' functions 2021-05-20 13:46:31 +03:00
Andrey Zinovyev
cd22255ab7 [FIR] Set Function call origin in light tree too
Plus actualize some tests
2021-05-20 13:46:30 +03:00
Andrey Zinovyev
e021e25d6c [FIR] Resolve operator calls to operator functions only 2021-05-20 13:46:29 +03:00
Andrey Zinovyev
b1c8669b43 [FIR] Resolve infix calls to infix functions only
Implements INFIX_MODIFIER_REQUIRED diagnostics
2021-05-20 13:46:27 +03:00
Hung Nguyen
df14deb5a0 Organize integration tests for incremental Kotlin compile
Refactor common code into new abstract class
IncrementalCompilationBaseIT to make the code cleaner and easier to
evolve.

Also add a few missing key scenarios for ABI and non-ABI changes in
Kotlin files, and make it consistent with the test for changes in Java
files.

Bug: KT-45777
Test: Updating them
2021-05-20 12:59:07 +03:00
Mikhail Glukhikh
f3c9bd16ee Fix FIR IDE overrideImplement/androidxNotNull test 2021-05-20 12:22:23 +03:00
Mikhail Glukhikh
eac6da62d6 Fix FIR IDE highlighting tests 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh
6dd41b617a FIR: position INAPPLICABLE_FILE_TARGET on file use-site (when possible) 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh
6572010eed Introduce use-site annotation target checks for FIR 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh
9a13ec9b76 FIR: report WRONG_ANNOTATION_TARGET on types 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh
2a33a6927c FIR: report WRONG_ANNOTATION_TARGET(_WITH_USE_SITE_TARGET) on declarations 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh
95f2c52659 FirAnnotationHelpers: use KotlinTarget instead of AnnotationTarget 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh
7675ea3c23 Move AnnotationTargetLists & KotlinTarget to common compiler code 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh
d11092ae3c FIR: support WRONG_ANNOTATION_TARGET on expressions 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh
92ab600081 FIR: add check of SOURCE retention for EXPRESSION-targeted annotation 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh
4b00a43b22 FIR: add ANNOTATION_ON_SUPERCLASS diagnostic 2021-05-20 12:22:20 +03:00
Mikhail Glukhikh
0d6bc7e7b2 FIR: report ANNOTATION_CLASS_CONSTRUCTOR_CALL diagnostic 2021-05-20 12:22:20 +03:00
Mikhail Glukhikh
3663884db2 FIR: support CONDITION_TYPE_MISMATCH diagnostic
We report CONDITION_TYPE_MISMATCH on
- loop conditions
- when branch conditions
- binary logic arguments
2021-05-20 12:22:20 +03:00
Mikhail Glukhikh
e85d97b894 FIR: introduce separate THROWABLE_TYPE_MISMATCH 2021-05-20 12:22:20 +03:00
Mikhail Glukhikh
f0ce311fc6 Drop unused ConeTypeMismatchError 2021-05-20 12:22:19 +03:00
Toshiaki Kameyama
b9a4b60b93 Unnecessary local variable: highlight with INFORMATION level when initializer has any multi-line blocks (#3359)
#KT-26752 Fixed
2021-05-20 11:12:41 +02:00
Andrey Zinovyev
e82857996f [lombok] Resolve to absolute path when import from maven
#KT-46723 Fixed
2021-05-20 11:57:07 +03:00
Pavel Kunyavskiy
2680111125 [K/N] Fix order of lowerings to enable when on enum optimisation
EnumWhenLowering searches for pattern, which is destroyed by
BuiltinOperatorLowering, so first one should happen before second.
2021-05-20 08:34:15 +00:00
Pavel Kunyavskiy
43b91589a1 [K/N] Create lowering for optimising when, with lowered enums support 2021-05-20 08:34:14 +00:00
Pavel Kunyavskiy
1dd6dcdeef [K/N] Store ordinal value in lowered enum 2021-05-20 08:34:13 +00:00
Pavel Kunyavskiy
8a418161f6 [K/N] Support pre-creating for objects with only constant properties 2021-05-20 08:29:23 +00:00
Pavel Kunyavskiy
e4ecb3745b [K/N] Debug util for checking if object is global constant 2021-05-20 08:29:22 +00:00
Ilya Goncharov
5d36264660 Add Node.js 14.17.0 with verification metadata 2021-05-19 21:22:32 +03:00
Ilya Goncharov
f0044516d1 [Gradle, JS] Update Node.js version on latest stable (14.17.0)
^KT-46693 fixed
2021-05-19 21:22:31 +03:00
Igor Yakovlev
b0df70dbfe [ULC] Fix delegate field type resolve
Fixed #KT-46519
2021-05-19 20:49:55 +03:00
Alexander Shabalin
a02cecec20 Disable interop_cleaners_leak 2021-05-19 15:51:05 +00:00
Ilya Muradyan
9412fe094b [REPL] Copy findLabelAndCall to scripting-ide-services to fix problems with embeddable artifact 2021-05-19 18:32:50 +03:00
Ilya Muradyan
7caadd87a2 [Scripting] Get rid of unneeded dependencies in Maven resolver 2021-05-19 18:32:48 +03:00
Alexander Udalov
2fe498149e Psi2ir: add file name to exception when generating synthetic declarations 2021-05-19 17:12:12 +02:00
Alexander Udalov
6581d222cd Fix accidental usage of ASM from jdk.internal in jvm-debugger
Similarly to ee6586fe4f.
2021-05-19 17:11:08 +02:00
Dmitriy Novozhilov
99cdb86145 [FIR] Move createSessionWithDependencies to FirSessionFactory 2021-05-19 16:29:20 +03:00
Dmitriy Novozhilov
2ee54c2201 [FIR] Remove way to create FirSession using Module
The problem is that Module may not contain some default dependencies in
  classpath roots, so it's incorrect to take them from it
2021-05-19 16:29:19 +03:00
pyos
b2ef854aa1 JVM_IR: support @JvmStatic transformations in LateinitLowering
#KT-46759 Fixed
2021-05-19 16:23:01 +03:00
pyos
f1f13b6e97 JVM_IR: do not evaluate receiver of static calls if it is pure
#KT-46802 Fixed
2021-05-19 16:22:59 +03:00
Dmitriy Dolovov
ae1590d3cf [Native] Support multiple suspend lambdas as class supertypes
Drop the backend check. Eveything else is already fixed in
3b3318ab06

^KT-46775
2021-05-19 16:09:47 +03:00
Dmitriy Dolovov
896929cb21 [Native] Support suspend functions as supertypes
^KT-46777
2021-05-19 16:09:38 +03:00
Ilmir Usmanov
9fe503eeb3 Minor. Add regression test
#KT-45685 Fixed
2021-05-19 12:45:26 +02:00
Andrey Uskov
41dd6250d4 Implemented collecting use-old-backend flag from Gradle
#KT-46689 Fixed
2021-05-19 13:25:26 +03:00
Alexander Shabalin
3388ca2536 Support ObjC blocks in the new MM 2021-05-19 07:31:12 +00:00
Alexander Shabalin
94076300ec Implement a bit more of GC object interface 2021-05-19 07:29:27 +00:00
Jinseong Jeon
a3105da32e FIR checker: more specific type for CONFLICTIONG_PROJECTION 2021-05-19 01:04:21 +03:00
Jinseong Jeon
8d474c0e7e FIR checker: more specific type for containing class in diagnostics
about abstract members in non-abstract class
2021-05-19 01:04:20 +03:00
Jinseong Jeon
864ab2cadd FIR checker: clearer parameter names in diagnostics 2021-05-19 01:04:19 +03:00
Dmitriy Novozhilov
e08df2c530 [Test] Add diagnostics and codegen tests with hmpp module structure 2021-05-19 00:52:31 +03:00
Dmitriy Novozhilov
73a63359df [Test] Add new directive for specifying target platform for module 2021-05-19 00:52:28 +03:00
Dmitriy Novozhilov
06b2efe65f [Test] Introduce new syntax for dependsOn dependencies 2021-05-19 00:52:27 +03:00
Dmitriy Novozhilov
47e258ef6e [Test] Enable reporting errors from fronted to testdata of codegen tests 2021-05-19 00:52:25 +03:00
Dmitriy Novozhilov
df60e7368a [Test] Fix syntax errors in few boxInline tests 2021-05-19 00:52:24 +03:00
Dmitriy Novozhilov
27f0d938c9 [Test] Add wrapping of failures from different parts of test pipeline 2021-05-19 00:52:22 +03:00
Dmitriy Novozhilov
6aca0bb374 [Test] Add ability to disable DEBUG_INFO diagnostics except explicitly defined 2021-05-19 00:52:21 +03:00
Dmitriy Novozhilov
d44782f49f [Test] Allow to enable/disable all diagnostics with specific severity 2021-05-19 00:52:19 +03:00
Yahor Berdnikau
7fc23a1647 Deprecate 'kotlin.parallel.tasks.in.project' build property.
Default value will use Gradle parallel execution option value.

^KT-46401 Fixed
2021-05-18 21:02:02 +00:00
Dmitry Petrov
851980e36f JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs 2021-05-18 22:20:12 +03:00
pyos
bfb1a06f3d FIR: resolve conflicts between overloads with platform integer types 2021-05-18 22:11:33 +03:00
Victor Petukhov
a27d428573 Regenerate tests 2021-05-18 21:26:10 +03:00
Dmitriy Novozhilov
38fe917141 [FIR] Change order of IC symbol provider and dependency symbol provider
This is semantically incorrect, but current behavior leads to problems
  in FIR bootstrap due to incorrect setup of IC provider. So this ordering
  change is a workaround for now
2021-05-18 20:56:07 +03:00
Dmitriy Novozhilov
7d5fa2830d [FIR] Properly create source search scope in FIR CLI compiler 2021-05-18 20:56:05 +03:00
Dmitriy Novozhilov
dbccd4d459 [FIR] Properly acquire module data in FirSignatureEnhancement 2021-05-18 20:56:04 +03:00
Steven Schäfer
bf7db84451 Parcelize: Handle class hierarchies of Parcelers (KT-46567) 2021-05-18 18:52:15 +02:00
Andrey Zinovyev
709c127f1b [IR] Distinguish super calls from other calls
Otherwise super call and virtual call to the same method get the same
map key in case of Fir2Ir IR generation
2021-05-18 19:32:23 +03:00
Steven Schäfer
60bc0f4baf IR: Lower shared variables in enum entries (KT-46605) 2021-05-18 16:55:38 +02:00
Victor Petukhov
b78c645fb0 Report warnings by enhanced base types 2021-05-18 17:52:39 +03:00
Victor Petukhov
2239404085 Extract type preparation during type checking to a separate component 2021-05-18 17:52:23 +03:00
Victor Petukhov
cba221c18a Add test for enhancement in usages of annotated type parameter 2021-05-18 17:52:21 +03:00
Victor Petukhov
fd6475c804 Update tests 2021-05-18 17:52:19 +03:00
Victor Petukhov
8602d1fcf0 Merge foreign annotation tests for sources and binaries into single directory 2021-05-18 17:52:16 +03:00
Victor Petukhov
df2c95e444 [Jspecify] Use bounds of type parameters for warnings reporting as well 2021-05-18 17:52:14 +03:00
Victor Petukhov
0c4cba549d [Jspecify] Use arguments of enhancement of type instead of arguments of base type during getting enhancement of type deeply 2021-05-18 17:52:12 +03:00
Victor Petukhov
21dada4d2d [Jspecify] Use enhancement of type with enhancement if possible during substitution 2021-05-18 17:52:10 +03:00
Victor Petukhov
12f6146bdf [Jspecify] Substitute enhancement of type instead of type itself directly 2021-05-18 17:52:09 +03:00
Victor Petukhov
2479655708 [Jspecify] Do preserving flexibility when adding equality constraints by taking into account type with enhancement 2021-05-18 17:52:07 +03:00
Victor Petukhov
937e82db46 [Jspecify] Report warnings on violated bounds of method type parameters 2021-05-18 17:52:06 +03:00
Victor Petukhov
0d6764efc5 Process raw types during erasion properly
^KT-46670 Fixed
^KT-46476 Fixed
2021-05-18 17:38:52 +03:00
Svyatoslav Scherbina
570d860217 Native: deprecate SymbolName annotation 2021-05-18 17:29:00 +03:00
Igor Chevdar
3b3318ab06 [K/N][codegen] Refactored interface calls
Removed old impl for debug builds
Fixes https://youtrack.jetbrains.com/issue/KT-44547 as a side effect
2021-05-18 18:58:14 +05:00
Alexander Likhachev
3df45f9651 [Build] Bump kotlin-build-gradle-plugin version to 0.0.29 2021-05-18 16:37:36 +03:00
Alexander Likhachev
8a3a60caae [Build] Bump kotlinx-benchmark version to 0.3.1
kotlinx-benchmark Gradle plugin 0.3.1 now reads system property `idea.active` in compatible with configuration cache way
#KT-44611 In Progress
2021-05-18 16:37:36 +03:00
Alexander Likhachev
cf00bc8243 [Build] Remove outdated IDEA sync detection 2021-05-18 16:37:35 +03:00
Alexander Likhachev
b6670f5cc8 [Build] Replace build scan config script with plugin
See 129e82c556/common-custom-user-data-gradle-plugin
2021-05-18 16:37:35 +03:00
Alexander Likhachev
8ddbf542f3 [Gradle] Declare IDEA-related system properties reads
#KT-44611 In Progress
2021-05-18 16:37:34 +03:00
Alexander Likhachev
091b2129e7 [Build] Make GE build scan configuration compatible with conf cache
#KT-44611 In Progress
2021-05-18 16:37:34 +03:00
Alexander Likhachev
ca2051e1d4 [Build] Disable custom normalization when conf cache is enabled
Custom input normalizations currently isn't supported by Gracle configuration cache
#KT-44611 In Progress
2021-05-18 16:37:34 +03:00
Alexander Likhachev
cc183e96a4 [Build] Fix configuration cache undeclared system property read issues
#KT-44611 In Progress
2021-05-18 16:37:29 +03:00
Andrei Klunnyi
f0a6d9f33f VFS: reset KOTLIN_IS_COMPILED_FILE_ATTRIBUTE
This commit resets mentioned file attribute from Kotlin binary files.
It finalizes the fix 929b6dd9 - users might have mistakenly set 'false'
value left on their file systems.
2021-05-18 15:34:26 +03:00
Vladimir Ivanov
5a0f113e6d [cinterop] Fix type annotation for struct containing anonymous union … (#4289) 2021-05-18 14:34:56 +03:00
Vladimir Dolzhenko
b01478746c Cache all module dependencies to avoid O(n^2) calc complexity
Quite noticeable when there is a big module that has 100+ libraries and many modules depends on it

#KT-46622 Fixed
2021-05-18 09:20:18 +00:00
Andrey Zinovyev
82b7f589ad Add missing base-compiler-plugins-ide-support dependencies 2021-05-18 11:49:04 +03:00
pyos
21f2b3fa2b JVM: expect a continuation parameter in default suspend references 2021-05-18 10:48:31 +02:00
pyos
7eedcf75f9 Add tests for default inline suspend lambdas
Broken on JVM and JVM_IR
2021-05-18 10:48:31 +02:00
pyos
57c934987c JVM_IR: try to load mangled invoke from default lambdas
Old compiler versions still won't be able to load default lambdas
generated by JVM_IR, but this way we avoid incorrect behavior of
function references taking inline class types that unbox to Any.

 #KT-46601 Fixed
2021-05-18 10:48:31 +02:00
pyos
34ac232a82 Add a test for KT-46601 2021-05-18 10:48:31 +02:00
pyos
c32ccbb39a JVM: move descriptors from DefaultLambda to PsiDefaultLambda
Also, produce more correct results in IrDefaultLambda's
`invokeMethodParameters` and `invokeMethodReturnType`. This affects
whether the inliner inserts inline class boxings/unboxings around lambda
calls; while this doesn't matter now due to KT-46601, it would if the
naming was fixed.
2021-05-18 10:48:31 +02:00
pyos
7c168d663a JVM: move PSI-based LambdaInfo to PsiInlineCodegen 2021-05-18 10:48:31 +02:00
pyos
493b4e6c27 JVM: rearrange some LambdaInfo stuff 2021-05-18 10:48:31 +02:00
pyos
14e1417ea8 JVM: expect consistent signatures from LambdaInfo 2021-05-18 10:48:31 +02:00
Yahor Berdnikau
aae5cc5574 Update AGP versions to the latest stable one.
Kotlin Gradle Plugin should run against the latest stable one versions.
2021-05-18 10:37:41 +03:00
Ivan Kochurkin
73fb851864 [FIR] Commit incorrect test data that should be restored after fix of https://youtrack.jetbrains.com/issue/KT-41794 2021-05-17 22:33:19 +03:00
Ivan Kochurkin
c3b8f3e859 [FIR] Add lValueTypeRef to FirVariableAssignment, fix tests with ASSIGNMENT_TYPE_MISMATCH 2021-05-17 22:33:18 +03:00
Ivan Kochurkin
e57108d4e8 [FIR] Implement ASSIGNMENT_TYPE_MISMATCH, RESULT_TYPE_MISMATCH diagnostics, fix tests 2021-05-17 22:33:16 +03:00
Ilya Kirillov
aa70c952eb FIR IDE: fix SOE on opening project
Kotlin library may contain cycles which causes SOE in FirModuleInfoBasedModuleData.dependencies
2021-05-17 20:56:57 +02:00
Ilya Chernikov
d365d7c784 Fix IR compilation for empty script
#KT-46646 fixed
2021-05-17 20:15:14 +03:00
Dmitry Petrov
3a0e3798ec JVM_IR KT-46597 fix receiver type for inlined callable reference
Receiver type is used by SyntheticAccessorLowering to determine class in
which a synthetic accessor should be generated.
2021-05-17 20:12:58 +03:00
Konstantin Tskhovrebov
80ce3a5cf8 Delete umbrella Apple framework tasks and register concrete tasks.
#KT-46680
2021-05-17 19:45:02 +03:00
Ilya Muradyan
55a9f1a910 [Scripting] Make AetherResolveSession internal and do related refactorings 2021-05-17 18:22:29 +03:00
Ilya Muradyan
a0cc88ab5a [Scripting] Add transitive support for Maven Resolver 2021-05-17 18:22:28 +03:00
Ilya Muradyan
b77a822822 [Scripting] Add authorization for Maven Resolver 2021-05-17 18:22:26 +03:00
Ilya Muradyan
78c65ab802 [Scripting] Bump up Maven resolver JARs version 2021-05-17 18:22:25 +03:00
Yahor Berdnikau
800e382ba9 Warn on using 'jdkHome' option in Gradle builds.
User should instead use KotlinJavaToolchain that will take care of
tracking major java version and provide nicer API.

Gradle will still pass jdkHome value to the compiler, but it should
be changed in Kotlin 1.6 release.

^KT-45611 Fixed
2021-05-17 16:57:01 +03:00
Ilya Goncharov
74d1812461 [JS IR] Review remarks
- Move origin to common place
- Add comments and todo about solution
- Remove MODULE directive from tests
- Add test with in-place using of js function
2021-05-17 16:51:22 +03:00
Ilya Goncharov
507516e44d [JS IR] Add tests with reified generic and with KType on DCE to leave class 2021-05-17 16:51:20 +03:00
Ilya Goncharov
f0b3ee0e35 [JS IR] Add test with class reference using from js 2021-05-17 16:51:19 +03:00
Ilya Goncharov
137532bfa6 [JS IR] Use separate origin for class reference to preserve constructors 2021-05-17 16:51:17 +03:00
Leonid Startsev
796d2fd210 Respect explicit api mode state when generating actual declarations
#KT-44067 Fixed
2021-05-17 12:40:49 +00:00
Leonid Startsev
8cd704b6db Exclude public API symbols in explicit mode from unused symbol inspection
#KT-41659 Fixed
2021-05-17 12:40:48 +00:00
Leonid Startsev
19dece01f6 Add support of explicit API mode to 'Make public' intention
#KT-41902 Fixed

Do not check languageVersionSettings for fake elements
because this leads to an exception
2021-05-17 12:40:47 +00:00
Igor Yakovlev
d34c23914a [FIR IDE] Fix invalid designation collecting for local classes 2021-05-14 23:06:04 +03:00
Igor Yakovlev
207bad5d5f [FIR IDE] Implementation of KtUserType resolve 2021-05-14 23:06:03 +03:00
Igor Yakovlev
a5f701bac7 [FIR IDE] OnAir resolve for annotations with file site 2021-05-14 23:06:02 +03:00
Igor Yakovlev
dedcaf1eab [FIR IDE] Fixed annotation application completion 2021-05-14 23:06:00 +03:00
Igor Yakovlev
3275165619 [FIR IDE] Fix resolve for incomplete or invalid references 2021-05-14 23:05:59 +03:00
Igor Yakovlev
2bfacaaed2 [FIR IDE] Rename and move refactorings, codereview refactorings 2021-05-14 23:05:58 +03:00
Igor Yakovlev
c5372be267 [FIR IDE] Move and rename RawFirFragmentForLazyBodiesBuilder into Fir Ide module 2021-05-14 23:05:57 +03:00
Igor Yakovlev
0569f810cf [FIR IDE] Add OnAir resolve tests 2021-05-14 23:05:55 +03:00
Igor Yakovlev
633e03b710 [FIR IDE] LowLevel api refactoring 2021-05-14 23:05:54 +03:00
Igor Yakovlev
445f13d1bf [FIR IDE] Fix invalid body lazy resolve 2021-05-14 23:05:53 +03:00
Igor Yakovlev
cfc0bfd64a [FIR IDE] Refactoring of designated IDE transformers 2021-05-14 23:05:52 +03:00
Igor Yakovlev
384b2ad048 [FIR IDE] Rename refactoring and speed improvements 2021-05-14 23:05:50 +03:00
Igor Yakovlev
966743c704 [FIR IDE] Enable passing completion tests 2021-05-14 23:05:49 +03:00
Igor Yakovlev
37ccab4e23 [FIR] Fixed supertypes resolve for invalid code with class without ClassId 2021-05-14 23:05:48 +03:00
Igor Yakovlev
2e7eedd3f2 [FIR IDE] Correct in-body supertype resolve of fake nodes 2021-05-14 23:05:46 +03:00
Igor Yakovlev
959ff50fa7 [FIR IDE] Collect tower contexts for local declarations 2021-05-14 23:05:45 +03:00
Igor Yakovlev
ae63ad0b6d [FIR] Fix annotations invalid references diagnostics 2021-05-14 23:05:44 +03:00
Igor Yakovlev
261098a122 [FIR IDE] Implement on-air resolve of non-local declarations 2021-05-14 23:05:42 +03:00
Igor Yakovlev
779a06e86f [FIR IDE] Add types, supertypes and status lazy designated transformers 2021-05-14 23:05:41 +03:00
Igor Yakovlev
95acb6121b [FIR IDE] Fixed property and parameter creation/replacement and fixed invalid source on annotation type 2021-05-14 23:05:40 +03:00
Igor Yakovlev
38242bee75 [FIR] Fixed invalid real psi source fir fir annotation name reference 2021-05-14 23:05:38 +03:00
Igor Yakovlev
aaefe94763 [FIR IDE] Refactor low level resolve state for completion
Rename refactorings
Remove redundant methods and implementations
Increase code-logic locality
Removed redundant entities
2021-05-14 23:05:37 +03:00
Alexander Udalov
aa13936cb2 Move GenerateProtoBuf to separate source set with no dependencies
Also move GenerateProtoBufCompare to a new source set with a dependency
only on build-common.

 #KTI-79 Fixed
2021-05-14 21:08:56 +02:00
Ilya Kirillov
8b722cfc47 Separate uast-idea modules into fir and fe10 implementations 2021-05-14 20:57:20 +03:00
Svyatoslav Scherbina
ba6c3c7fe0 Add workaround for KT-35001
Just suppress the warning.
The accident it describes is generally harmless and totally expected.
2021-05-14 20:05:30 +03:00
Svyatoslav Scherbina
48a684c024 Native: implement custom handling for LLVM diagnostics
Apply it when linking LLVM modules, because otherwise LLVM would
terminate the entire compiler process on link errors, which isn't ok,
e.g. when embedding the compiler into Gradle daemon (see KT-46358).
2021-05-14 20:05:29 +03:00
Alexander Udalov
ee6586fe4f Fix accidental usage of ASM from jdk.internal
#KT-46402 Fixed
2021-05-14 15:23:08 +02:00
Dmitry Petrov
d1322280dd JVM_IR KT-46578 resolve fake overrides for fields 2021-05-14 16:20:22 +03:00
Mikhail Glukhikh
a255f44d6e FIR2IR KT-46578 add overridden properties generation 2021-05-14 16:20:20 +03:00
Dmitry Petrov
53c1de172f IR KT-46578 add IrProperty#overriddenSymbols 2021-05-14 16:20:18 +03:00
Andrey Zinovyev
dc9d5cdf35 [FIR] Handle of special getters when there is a kotlin super type
Special getter names (like Collection.size()) can be used only in Java
classes with all-java super-types
Because if there is a kotlin class (not interface) in
 the middle, we 'materialize' special getters to properties.
2021-05-14 15:38:09 +03:00
Dmitriy Novozhilov
7066a5b3dc [FIR-IDE] Questionable testdata update 2021-05-14 14:30:46 +03:00
Dmitriy Novozhilov
c652a9e7b1 [FIR-IDE] Use correct session in member scope provider 2021-05-14 14:30:45 +03:00
Dmitriy Novozhilov
194252e5a1 [FIR-IDE] Properly setup moduleDataProvider for ide library session 2021-05-14 14:30:44 +03:00
Dmitriy Novozhilov
43b075d452 [FIR] Add path normalization to LibraryPathFilter 2021-05-14 14:30:43 +03:00
Dmitriy Novozhilov
cf5af0f7ea [FIR] Add KDoc to FirModuleData 2021-05-14 14:30:42 +03:00
Dmitriy Novozhilov
f02a4a6b1f [FIR-IDE] Add workaround hack for building raw FIR with libraries session 2021-05-14 14:30:41 +03:00
Dmitriy Novozhilov
0427066558 [FIR-IDE] Fix compilation after changes in API of FirSessionFactory 2021-05-14 14:30:40 +03:00
Dmitriy Novozhilov
af307bd55d [FIR] Fix compilation of AbstractFirBaseDiagnosticsTest 2021-05-14 14:30:38 +03:00
Dmitriy Novozhilov
28be3a0dbc [FIR] Replace Path with String in KotlinJvmBinaryClass.containingLibrary
This is needed because :core:deserialization.common.jvm uses JDK 6
2021-05-14 14:30:37 +03:00
Dmitriy Novozhilov
2abed7161b [FIR] Get rid of FirJvmModuleInfo 2021-05-14 14:30:36 +03:00
Dmitriy Novozhilov
28e4721a89 [FIR] Check internal visibility in FirJvmModuleVisibilityChecker using module data 2021-05-14 14:30:35 +03:00
Dmitriy Novozhilov
02c58b7a8f [FIR] Refactor deserialized dependency providers and session factories with FirModuleData 2021-05-14 14:30:33 +03:00
Dmitriy Novozhilov
24f1f7b7b2 [FIR] Unify FirLibrarySession and FirJavaModuleBasedSession into single FirCliSession 2021-05-14 14:30:32 +03:00
Dmitriy Novozhilov
f16194e60d [FIR] Get rid of FirSession.moduleInfo 2021-05-14 14:30:31 +03:00
Dmitriy Novozhilov
57a8642f5a [FIR] Add analyzer services to FirModuleData 2021-05-14 14:30:29 +03:00
Dmitriy Novozhilov
92d6b39ffe [FIR] Add late initialization of session in FirModuleData 2021-05-14 14:30:28 +03:00
Dmitriy Novozhilov
5cfa8694d4 [FIR] Fix all usages of declarationSiteSession 2021-05-14 14:30:27 +03:00
Dmitriy Novozhilov
a15316de24 [FIR] Replace declarationSiteSession with moduleData 2021-05-14 14:30:26 +03:00
Dmitriy Novozhilov
fa8d8ad503 [FIR] Add cache for top-level functions and properties to AbstractFirDeserializedSymbolsProvider 2021-05-14 14:30:25 +03:00
Dmitriy Novozhilov
c523379e6a [FIR] Move out all JVM specific deserialization logic from AbstractFirDeserializedSymbolsProvider 2021-05-14 14:30:23 +03:00
Dmitriy Novozhilov
e8c4b0e947 [FIR] Rename KotlinScopeProvider to FirKotlinScopeProvider 2021-05-14 14:30:22 +03:00
Dmitriy Novozhilov
4ad7a4a2d1 [FIR] Split KotlinDeserializedJvmSymbolsProvider to common and JVM specific parts 2021-05-14 14:30:21 +03:00
Dmitriy Novozhilov
e5b7cf23d6 Drop min functions from addToStdlib.kt 2021-05-14 14:30:20 +03:00
Dmitriy Novozhilov
d114913cd2 Replace usages of addToStdlib.firstNotNullResult with firstNotNullOfOrNull 2021-05-14 14:30:19 +03:00
Dmitriy Novozhilov
24b6c5df56 Add regression test for KT-45905 2021-05-14 14:30:14 +03:00
Anton Yalyshev
c386b10f04 Add change notes for 1.5.20-M1 2021-05-14 14:05:44 +03:00
Tianyu Geng
3c4e3e8db6 FIR: remove obsolete DataFlowVariablev.isStable 2021-05-14 13:34:33 +03:00
Andrey Zinovyev
84a7bdffe5 [FIR] Don't report MUST_BE_INITIALIZED* on unreachable properties 2021-05-14 12:41:18 +03:00
Alexander Udalov
8308f5d7d3 Create array instances of correct types in reflection
Based on #4168.

 #KT-44977 Fixed

Co-authored-by: Arkady Bazhanov <arkady.bazhanov@gmail.com>
2021-05-14 11:16:29 +02:00
Roman Golyshev
ec6c25ef7e FIR IDE: Remove names duplicates in createImportTypeFix 2021-05-13 21:41:57 +03:00
Roman Golyshev
9504488acb FIR IDE: Do not show hint from ImportQuickFix if the PSI have changed
Without this check, the import hint will be available even after the
quickfix is applied; this happens because the element to which the
quickfix is attached is not invalidated by the quickfix execution

Since the quickfix is still considered as available some time after
the import have been added, the hint is also generated. And the hint
stays even after the quickfix itself is discarded

`isOutdated` function prevents this
2021-05-13 21:41:56 +03:00
Alexander Udalov
8991ce53f4 Regenerate tests 2021-05-13 19:16:09 +02:00
Steven Schäfer
b2378620c3 JVM IR: Fix handling of anonymous initializers in inline classes (#4372)
Fixes KT-46554
2021-05-13 18:40:26 +02:00
Yan Zhulanow
cc4c61d2b3 Remove dependency on parcelize-runtime in the Parcelize compiler plugin 2021-05-14 01:06:39 +09:00
Yan Zhulanow
e90cc30edb Remove CLI and some of daemon-related modules from compiler-for-ide
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-05-14 01:06:39 +09:00
Yan Zhulanow
26f71c33c0 IDE: Publish JS IR klib artifact 2021-05-14 01:06:39 +09:00
Andrey Zinovyev
58c7aa9937 [FIR] Don't replace custom compareTo with default one in primitives 2021-05-13 18:04:43 +03:00
Mikhail Glukhikh
1a3aa1bff0 FIR: report ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT 2021-05-13 16:13:44 +03:00
Mikhail Glukhikh
55104a594c FIR: fix WRONG_GETTER(SETTER)_RETURN_TYPE associated PSI types 2021-05-13 16:13:44 +03:00
Mikhail Glukhikh
0f9f63400e FirSupertypesChecker: implement six more diagnostics 2021-05-13 16:13:43 +03:00
Mikhail Glukhikh
db828a6aad Generalize FirInterfaceWithSuperclassChecker to FirSupertypesChecker 2021-05-13 16:13:43 +03:00
Mikhail Glukhikh
632a9d66d1 FIR: introduce isPrimitive / isPrimitiveOrNullablePrimitive helpers 2021-05-13 16:13:42 +03:00
Mikhail Glukhikh
6d82aa0bc9 Drop duplicating FirPropertyAccessorChecker 2021-05-13 16:13:08 +03:00
Mikhail Glukhikh
d2cbf941db Collect all accessor checks in FirPropertyAccessorChecker 2021-05-13 16:13:08 +03:00
Mikhail Glukhikh
243114ef29 FIR: add 'withSuppressedDiagnostics' call to property checkers 2021-05-13 16:13:08 +03:00
Mikhail Glukhikh
6618b4ea57 FirPropertyAccessorChecker: add three new diagnostics 2021-05-13 16:13:07 +03:00
Dmitriy Novozhilov
1a3b5657c7 [FIR] Fix overload conflicts resolution for callable references with defaults 2021-05-13 15:31:18 +03:00
Alexander Udalov
e3b92fd561 Update instructions to run protoc on Windows and Linux 2021-05-13 13:58:43 +02:00
Alexander Udalov
b5af93c8b4 Fix IR proto backward compatibility for InlineClassRepresentation
This is important only if any backend which uses IR serialization will
(accidentally or voluntarily) use `IrClass.inlineClassRepresentation`,
which is missing in IR of klibs serialized with 1.5.20 or earlier.

Note that at the moment only JVM IR is using
`IrClass.inlineClassRepresentation`, but ideally we'd like to change
that (if needed).
2021-05-13 13:58:43 +02:00
Alexander Udalov
0a18174165 IR: remove hack related to inline class representation in lazy IR
This commit effectively reverts changes from
b5f9b1dfc0, fixing the problem from
KT-44723 in a stabler way. It is possible because we now serialize
inline class representation to metadata and after previous changes, we
have that representation as a field in IrClass.
2021-05-13 13:56:59 +02:00
Alexander Udalov
da06faa57e JVM IR: use inlineClassRepresentation in more utilities
Remove any logic related to finding the single parameter of the primary
constructor, and use inlineClassRepresentaton from IrClass or
ClassDescriptor instead.
2021-05-13 13:56:59 +02:00
Alexander Udalov
54befa769f IR: add IrClass.getInlineClassRepresentation, serialize/deserialize it
The change in FirDeclarationUtil is needed because in case of unsigned
types loaded from the standard library, the primary constructor for some
reason is not the first, but the second in the list of constructors.
2021-05-13 13:56:59 +02:00
Alexander Udalov
4c7f207309 Use new getInlineClassRepresentation in some utilities 2021-05-13 13:54:02 +02:00
Alexander Udalov
7fb3f48c67 Add ClassDescriptor.getInlineClassRepresentation
This will be used at least in the JVM backend instead of the current
approach where we're loading the primary constructor's first parameter,
which isn't good enough since primary constructor can be private, and
we can't rely on private declarations in case they're declared in
another module.
2021-05-13 13:54:02 +02:00
Steven Schäfer
6aaff9dfb7 JVM IR: Handle overloaded values functions in MappedEnumWhenLowering
Fixes KT-46579.
2021-05-13 13:24:32 +02:00
Andrey Zinovyev
5d30576d28 [FIR] Report not-a-constant diagnostics inside function calls
When function calls are not fully resolved
2021-05-13 10:15:26 +03:00
Andrey Zinovyev
e74141ded6 [FIR] Properly check spread constant argument 2021-05-13 10:13:21 +03:00
Andrey Zinovyev
07e47140a6 [FIR] Treat unsigned numbers as primitives in constant checker 2021-05-13 10:11:59 +03:00
Roman Golyshev
9cadd1c8a7 Remove IGNORE_FIR from test data of already green test 2021-05-13 03:22:07 +03:00
Pavel Punegov
238ada04c0 Use newer version of Kotlin/Native in the testNativeCompilerDownloading 2021-05-13 03:19:23 +03:00
Yahor Berdnikau
13fd2a24ea Fix exposing provided by Gradle Kotlin dependencies.
Ensure that Gradle plugin dependencies do not include kotlin-stdlib,
kotlin-reflect and other dependencies that are provided by Gradle
runtime.

^KT-41142 Fixed
2021-05-12 23:28:37 +03:00
Steven Schäfer
1198b40c11 Parcelize: Port the fix for KT-41553 to android-extensions
Fixes KT-46590.
2021-05-12 21:18:15 +02:00
Ilya Kirillov
4ef81e93ef FIR IDE: properly implement FirKeywordCompletionContributor.keywordCompletion 2021-05-12 21:40:22 +03:00
Ilya Kirillov
ca320f2f8d FIR IDE: add this labels to keyword completion 2021-05-12 21:40:20 +03:00
Ilya Kirillov
47a596c214 FIR IDE: add return target to tail in keyword completion
The same do FE10 completion and we need it to have consistent tests
2021-05-12 21:40:19 +03:00
Ilya Kirillov
f8fc43f1e9 FIR IDE: add AbstractKeywordCompletionTest 2021-05-12 21:40:18 +03:00
Ilya Kirillov
96117fc1eb FIR IDE: cleanup FirPositionCompletionContextDetector.detect 2021-05-12 21:40:16 +03:00
Ilya Kirillov
597d64b81d FIR IDE: do not ignore passing tests from AbstractFirKeywordCompletionHandlerTest 2021-05-12 21:40:15 +03:00
Ilya Kirillov
f18bcdb88c FIR IDE: add AbstractFirKeywordCompletionHandlerTest 2021-05-12 21:40:14 +03:00
Ilya Kirillov
e5202f44d7 Refactor keyword completion handlers
- Separate completion keyword handlers stuff into files
- Introduce CompletionKeywordHandlerProvider as a common way to provide handlers
- Move CompletionKeywordHandler factory out of companion object
2021-05-12 21:40:12 +03:00
Ilya Kirillov
8983bde73e FIR IDE: implement override completion 2021-05-12 21:40:11 +03:00
Ilya Kirillov
ae212f36f5 FIR IDE: move addElementToCompletion to FirCompletionContributorBase 2021-05-12 21:40:10 +03:00
Ilya Kirillov
e624f2c136 FIR IDE: do not pass resultSet in KotlinWithNameReferenceCompletionProvider as it is already available 2021-05-12 21:40:09 +03:00
Ilya Kirillov
49aba39ae8 Make OverridesCompletionLookupElementDecorator available for FIR IDE 2021-05-12 21:40:07 +03:00
Ilya Kirillov
8f399652d7 FIR IDE: add expressions to return keyword completion
Also, adds return targets for return with labels while FE1.0 plugin don't
2021-05-12 21:40:06 +03:00
Ilya Kirillov
8cfa85df6b FIR IDE: make FirKeywordCompletion to be a completion contributor 2021-05-12 21:40:04 +03:00
Ilya Kirillov
ca1fd185dc FIR IDE: introduce base class for completion provider 2021-05-12 21:40:03 +03:00
Ilya Kirillov
81c6f38f79 FIR IDE: move context creation out of KotlinFirCompletionContributor 2021-05-12 21:40:02 +03:00
Ilya Kirillov
8eff865277 FIR IDE: encapsulate basic completion parameters into class 2021-05-12 21:40:01 +03:00
Ilya Kirillov
a08c267c37 FIR IDE: mute a few completion tests as they now fails because of unexpected keywords 2021-05-12 21:39:59 +03:00
Ilya Kirillov
98becc9a50 FIR IDE: remove FIR_IGNORE from passing completion test after implementing basic keyword completion 2021-05-12 21:39:58 +03:00
Ilya Kirillov
36068d0b94 FIR IDE: reuse keyword completion handlers which do not require resovle 2021-05-12 21:39:57 +03:00
Ilya Kirillov
1f93eb0841 FIR IDE: add basic keyword completion 2021-05-12 21:39:56 +03:00
Ilya Kirillov
62fe3930ff Move keyword completion stuff to frontend-independent module 2021-05-12 21:39:54 +03:00
Roman Golyshev
d7a91cb05e Remove IGNORE_FIR directive from already green tests 2021-05-12 16:28:31 +00:00
Roman Golyshev
4adb291a12 Mute failing AutoImportQuickFix tests 2021-05-12 16:28:30 +00:00
Roman Golyshev
03a1439cc0 Make IgnoreTests fail correctly when directive is outdated
`Outdated` means green test with `IGNORE_FIR` directive, or
red test with `FIR_COMPARISON` directive

Also, invoke directive insertion only when it is appropriate
2021-05-12 16:28:29 +00:00
Roman Golyshev
22db894076 FIR IDE: Add Add Import quickfix
This quickfix can import unresolved types and callables

It currently does not support Java types and is not as advanced as in
the old plugin

Also, enable tests that now pass
2021-05-12 16:28:28 +00:00
Roman Golyshev
3ad9e4cb5c Use Import instead of action FQN
This way test data can be used both in the old plugin and in the
FIR plugin
2021-05-12 16:28:27 +00:00
Roman Golyshev
eadd7ac034 Generate multi-file quickfix tests for FIR plugin
Currently generate only for `Import` quickfix
2021-05-12 16:28:27 +00:00
Roman Golyshev
24642a7c9f Add KtTypeElement.unwrapNullability() extension function
Replace similar functions with its usage
2021-05-12 16:28:26 +00:00
Roman Golyshev
cc41592969 Add possibility to compute additional files for IgnoreTests
It is more flexible then just passing additional prefixes, since in some
cases test data have some weird naming conventions
2021-05-12 16:28:25 +00:00
Roman Golyshev
e50d643213 Add possibility to use ModuleLibrariesSearchScope in other modules
The type is made private to avoid direct usage of it
2021-05-12 16:28:24 +00:00
Ivan Kochurkin
598501aaf0 [FIR] Improve locations for DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE and other diagnostics, refactor 2021-05-12 18:42:44 +03:00
Ivan Kochurkin
52c32d3d85 [FIR] Implement DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE, fix tests 2021-05-12 18:42:43 +03:00
Ivan Kochurkin
177394f6ef [FIR] Implement DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, fix tests 2021-05-12 18:42:42 +03:00
Ivan Kochurkin
77c137df22 [FIR] Add DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED diagnostics, fix tests 2021-05-12 18:42:41 +03:00
Ivan Kochurkin
3191e0b925 [FIR] Implement DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS diagnostics, fix tests, merge and refactor annotation checkers 2021-05-12 18:42:40 +03:00
Ivan Kochurkin
dc99a673a5 [FIR] Implement DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS diagnostics, fix tests 2021-05-12 18:42:38 +03:00
Ivan Kochurkin
5c086e2321 [FIR] Implement NEWER_VERSION_IN_SINCE_KOTLIN diagnostics, fix tests 2021-05-12 18:42:37 +03:00
Ivan Kochurkin
1be02e3ac4 [FIR] Implement ILLEGAL_KOTLIN_VERSION_STRING_VALUE diagnostics, fix tests 2021-05-12 18:42:36 +03:00
Jinseong Jeon
cb0b80253c FIR/UAST: make a fat jar with the base module 2021-05-12 17:36:35 +02:00
Ilya Muradyan
bab5d16001 [REPL] Stop old classpath calculation on the base classloader
The mechanism of the recursive classpath checking is intended
 for the "inner" scripting/REPL classloaders and should not touch
 anything beyond.
2021-05-12 18:30:43 +03:00
Mikhail Glukhikh
4608ca15eb FIR: don't allow SEALED callable modality anymore 2021-05-12 17:50:29 +03:00
Mikhail Glukhikh
67d1c35f19 FIR: report MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED also on interfaces 2021-05-12 17:50:27 +03:00
pyos
3fc2cc410c JVM_IR: propagate reified type parameter usages from inline lambdas
...to whichever class they are inlined into, not the class they are
declared in (which is not the same if the lambda is crossinline).

 #KT-46584 Fixed
2021-05-12 15:09:35 +03:00
Alexander Udalov
e079fb665e JVM IR: fix inheritance from mutable collections of Int
For subclasses of `AbstractMutableList<Int>` which are not inline
classes, the special bridge `remove` had a parameter of type `Int`
(mapped to JVM primitive int) before this fix. The hack in
`MethodSignatureMapper` changed this type to `Int?`, yet the body of the
special bridge still loaded it as non-nullable, which resulted in
incorrect bytecode.

It looks like a part of this hack in `BridgeLowering` was made only for
inline classes which are subclasses of mutable collections. Supposedly
it should be extended to non-inline classes, so that `remove` special
bridge would have consistent IR by the time it reaches codegen.

 #KT-46516 Fixed
2021-05-12 13:58:40 +02:00
Nikolay Krasko
f30980806f Read process streams to avoid hanging on Windows in parcelize tests
Could be reproduced with ParcelizeBoxTestGenerated.testKt36658 test.
2021-05-12 12:58:02 +03:00
Nikolay Krasko
818bbbbb83 Don't print to log in successful parcelize tests 2021-05-12 12:58:01 +03:00
Nikolay Krasko
b41fdd2705 Leave a clue about muted tests with directive for manual processing 2021-05-12 12:57:59 +03:00
Mads Ager
2c5a4dcb98 [JVM IR] Fix constant folding to use basic types always.
Fixes KT-46540.
2021-05-12 11:57:20 +02:00
Svyatoslav Scherbina
ad18d5984b Expand comment for unsupported nested generics when exporting to Swift
Add links to Swift and Kotlin issue trackers.
2021-05-12 09:06:28 +00:00
Elena Lepilkina
18462445b7 [K/N][stdlib] Fixed lookaround regexes (KT-45932) 2021-05-12 09:02:24 +00:00
Ilya Goncharov
d7a87a8552 [Gradle, JS] Fixes after rebase 2021-05-12 11:57:14 +03:00
Ilya Goncharov
9412b7236e [Gradle, JS] Refactor cacheBuilder to reuse one instance 2021-05-12 11:57:14 +03:00
Ilya Goncharov
19393948d7 [Gradle, JS] irBuildCache means ir compiler enabled 2021-05-12 11:57:14 +03:00
Ilya Goncharov
b9fc97b44f [Gradle, JS] Add arguments for building caches 2021-05-12 11:57:14 +03:00
Ilya Goncharov
c23376f040 [Gradle, JS] Use associated compilation's caches 2021-05-12 11:57:14 +03:00
Ilya Goncharov
9723d45d27 [Gradle, JS] Add associateWith compilations to CacheBuilder 2021-05-12 11:57:14 +03:00
Ilya Goncharov
194175d2d0 [Gradle, JS] Use multiple arguments for ignoring 2021-05-12 11:57:14 +03:00
Ilya Goncharov
2d3c13f8a2 [Gradle, JS] Everytime run compiler to build caches 2021-05-12 11:57:13 +03:00
Ilya Goncharov
d66d0fd4e4 [Gradle, JS] CacheBuilder before callCompiler 2021-05-12 11:57:13 +03:00
Ilya Goncharov
249fb8393c [Gradle, JS] Add compiler args serialization to consider in caching 2021-05-12 11:57:13 +03:00
Ilya Goncharov
c283c76130 [Gradle, JS] Add CacheBuilder for precache libraries 2021-05-12 11:57:13 +03:00
pyos
420bc6cbe8 JVM_IR: use correct types for generated inline reference wrappers
Doesn't change anything, but still.
2021-05-12 11:37:49 +03:00
pyos
d5d6736e67 PSI2IR/FIR2IR: do not approximate T!! before translation
This leads to weird effects when it's in a contravariant position,
because it's approximated by Nothing.
2021-05-12 11:37:48 +03:00
pyos
a37db99841 JVM_IR: remove a hack from InlineCallableReferenceToLambda
It breaks other things, the same problem is hit by FunctionReference,
and it's the translation layer's fault anyway.

 #KT-46555 Fixed
2021-05-12 11:37:47 +03:00
pyos
cff74b31d4 JVM_IR: get unbound property reference receiver type from KProperty1 2021-05-12 11:37:45 +03:00
Pavel Punegov
53bf0b1c42 Update Build gradle plugin to 0.0.28 2021-05-12 10:34:36 +03:00
Pavel Punegov
540c69ab89 [native] VersionGenerator: fix error string 2021-05-12 10:34:36 +03:00
Pavel Punegov
86041096fd Return milestone property back to support older versions of plugins
Older gradle plugin's NativeCompilerDownloader uses milestone property.
2021-05-12 10:34:36 +03:00
Pavel Punegov
f82c28bd79 Revert "[kotlin-gradle-plugin] workaround for old k/n artifacts"
This reverts commit 5c80dbfd
2021-05-12 10:34:36 +03:00
Pavel Punegov
a0d35e56a9 Revert "[tests][kotlin-gradle-plugin] workaround for old k/n artifacts"
This reverts commit f051119c to drop obsolete native version support
2021-05-12 10:34:35 +03:00
Pavel Punegov
fa525a8359 [native] Support milestones in meta versions
Add milestones to MetaVersion to replace standalone parameter in
compiler version generator. This makes native version match Kotlin one.
2021-05-12 10:34:35 +03:00
Ilmir Usmanov
c4ddf3530d Use GETFIELD instead of unbox-impl inside inline classes
#KT-36783 Fixed
2021-05-12 06:50:06 +00:00
Jinseong Jeon
e5f3091f2c FIR/UAST: commonize KotlinUFile
We can avoid explicit creation of UAnnotation and UImportStatement if we
use languagePlugin as a UAST element factory.
2021-05-11 21:43:02 +02:00
Jinseong Jeon
5dc0b52e38 FIR UAST: fix/test allCommentsInFile in UFile 2021-05-11 21:43:02 +02:00
Jinseong Jeon
03b5c14944 FIR UAST: enable remaining legacy test data
This should have been part of commit 7f627ab4
2021-05-11 21:43:02 +02:00
Tianyu Geng
302e0fa46b FIR IDE: add quickfix AddWhenElseBranchFix 2021-05-11 21:42:45 +02:00
Jinseong Jeon
8e10b5fdec FIR: introduce FirExpressionWithSmartcastToNull
This new kind of expression encompasses the nullability of the original
expression after null check (or equivalent `is Nothing?` check).

Unlike FirExpressionWithSmartcast, this expression won't be materialized
during conversion to backend IR. Also, Nothing? is discarded when
computing the intersection of possible types from smartcast info.
In that way, Nothing? is not used during resolution, while such
smartcast info is stored in it (and the expression kind itself).
2021-05-11 21:28:44 +03:00
Jinseong Jeon
8da183e4f4 FIR DFA: filter out unwanted implcations from processEqNull
^KT-41015 fixed
2021-05-11 21:28:43 +03:00
Xin Wang
b9209962cd CLI: Add documentation for -J argument in kotlinc -help 2021-05-11 19:50:24 +02:00
Dmitriy Novozhilov
1407af6301 [Test] Sort failed exceptions in JUnit5Assertions.assertAll
This is needed to throw FileComparisonFailure first, because idea
  test UI can not show multiple diff windows for multiple assertions
  and shows only first, which is not useful
2021-05-11 20:07:35 +03:00
Dmitriy Novozhilov
2530ae6b3d [Test] Split IR verification and IR dump to different handlers 2021-05-11 20:07:34 +03:00
Dmitriy Novozhilov
c9cd49d34f [Test] Temporary remove test for KT-22379
This is needed because this test breaks IDE when whit file is indexed.
This test will be returned after release of new kotlin plugins for IDEA
2021-05-11 19:45:43 +03:00
Andrey Zinovyev
89f0a790c9 [lombok] Map lombok MODULE to java PackageVisibility
Because that's what lombok does
#KT-46469 Fixed
2021-05-11 19:18:39 +03:00
Andrey Zinovyev
468fc86a3f [lombok] Fix fallback to config for array annotation's parameter
If annotation's parameter is not explicitly defined, it should be
taken from config
#KT-46529 Fixed
2021-05-11 19:18:37 +03:00
Andrey Zinovyev
57d3f98ece [lombok] Config keys are case-insensitive
#KT-46531 Fixed
2021-05-11 19:18:36 +03:00
Alexander Udalov
c898805ac5 CLI: improve path relativization for compiler messages
On Windows, the absolute file for the root of the drive is `"C:\"`,
which differs from the absolute file for any other directory, which
doesn't end with `\`. This resulted in incorrect trimming of the first
character of the path name in `descendantRelativeTo`.

Also, do not use canonicalPath because there is no point in expanding
symbolic links here.

 #KT-40979 Fixed
2021-05-11 18:44:14 +03:00
Alexander Udalov
f63dac26e6 Minor, extract ProgramWithDependencyOnCompiler for tests
Also use ProcessBuilder instead of GeneralCommandLine for simplicity.
2021-05-11 18:44:12 +03:00
Mads Ager
d397efb2bd [JVM IR] Copy attributes for JVM_STATIC_WRAPPERS. 2021-05-11 16:26:04 +02:00
Mads Ager
3db5ba98ad [JVM IR] Do not insert Nothing handling in JvmStatic wrapper.
Fixes KT-46568.
2021-05-11 16:26:04 +02:00
Dmitriy Novozhilov
3532ce7fbc [Parser] Fix OOM in parsing of incorrect string literals
^KT-46455 Fixed
KT-34410
KT-46564
2021-05-11 16:43:29 +03:00
Mikhail Glukhikh
c284eab2dd FIR / FE 1.0: fix exception for lambda with unresolved name
#KT-46515 Fixed
2021-05-11 15:41:06 +03:00
Stanislav Erokhin
eb4bb9554d Add ReplaceInvoke adn ReplaceCallWithUnaryOperator intention support
Surprisingly all test passed
2021-05-11 12:48:18 +02:00
Stanislav Erokhin
85d9e96632 Partially support call with errors
Cases with no candidates or with Ambiguity is not supported yet
2021-05-11 12:48:17 +02:00
Stanislav Erokhin
080a832605 Fix argument mapping for lambda arguments and default arguments
Maybe for other elements ValueArgument itself used as SourceElement
2021-05-11 12:48:17 +02:00
Stanislav Erokhin
335c5a03b6 Add correct equals/hashCode to KtSymbolBasedAbstractTypeConstructor
Previously there were no equals/hashCode implementation.
Because of that subtyping not working properly. That is because in
subtyping we have checks that type constructors are equals

Also toString was added so now it is a bit easier to debug code
involving the KtSymbolBasedAbstractTypeConstructor
2021-05-11 12:48:16 +02:00
Stanislav Erokhin
dc1ce19db9 Extract some logic from AbstractTypeConstructor to reuse it later
In FE10-binding I would like to re-use equal and hashCode mechanics
that was implemented in AbstractTypeConstructor, but I don't need
the supertype implementation, because it already there in FIR
2021-05-11 12:48:16 +02:00
Nikita Bobko
bee8c0bb90 Publish :compiler:test-infrastructure for ide 2021-05-11 12:36:59 +02:00
Vasily Levchenko
c2a46baa77 [build][kotlin-native][test] fix dist dependencies for test targets 2021-05-11 05:47:17 +00:00
Ilmir Usmanov
640d263ae1 Do not unbox nullable Result, since before usage it is coerced
#KT-46505
2021-05-11 05:49:24 +02:00
pyos
656c2496a6 JVM_IR: omit bound receiver in IrExpressionLambdaImpl parameters
and remove a hack intended to replace the missing type conversions this
caused.

 #KT-46505 Fixed
2021-05-11 05:49:20 +02:00
pyos
614d529168 JVM: remove LambdaInfo.invokeMethodDescriptor 2021-05-11 05:49:17 +02:00
Ilya Kirillov
47dc524763 FIR IDE: remove KtUnsubstitutedScope/KtSubstitutedScope as it designed wrong 2021-05-11 01:36:13 +03:00
Ilya Kirillov
90798d8857 FIR IDE: add KDoc for KtScope, choose better names for KtScope members 2021-05-11 01:36:11 +03:00
Ilya Kirillov
f9087a8ab1 FIR IDE: update testdata after changes in symbols 2021-05-11 01:36:10 +03:00
Ilya Kirillov
accc0e3761 FIR IDE: make KtCallableSymbol to be always KtPossiblyExtensionSymbol 2021-05-11 01:36:09 +03:00
Ilya Kirillov
0ba6412f96 FIR IDE: remove KtTypedSymbol interface as all its inheritors are KtCallableSymbol 2021-05-11 01:36:07 +03:00
Jinseong Jeon
bbe5cf0a70 FIR/UAST: clarify what module we should not depend on 2021-05-10 20:23:19 +02:00
Ilya Kirillov
e14848740a FIR IDE: forbid executing write action inside analyse call 2021-05-10 20:44:23 +03:00
Ilya Muradyan
626c1d3b48 [Scripting] Fix repository ID generation for Maven resolver 2021-05-10 19:40:32 +03:00
Ilya Muradyan
7cea639209 chore: fix typo in comment 2021-05-10 19:40:31 +03:00
Dmitry Petrov
ac0aaff611 JVM_IR KT-46562 don't use LambdaMetafactory for Serializable SAMs
TODO support serializable lambdas creation with LambdaMetafactory
2021-05-10 14:54:14 +03:00
Jinseong Jeon
bdfc879f00 FIR checker: report UNINITIALIZED_PARAMETER 2021-05-10 14:26:14 +03:00
Stanislav Erokhin
d2f831b635 Handle exception during intention background computation in tests
Our test infrastructure (in particular, muting mechanics) rely on
thrown exception during doTestFor function call. But if the
exception happened on background thread, then here we'll get only
TimeOutException but the actual exception won't be reported during
doTestFor call. It would be reported later by the common IDEA test
framework and bypass our mute mechanics
2021-05-10 14:04:04 +03:00
Stanislav Erokhin
7ac599520e Add first prototype of BindingContext implementation by FIR
Add ImportMemberIntention intention as a test.
In this commit all failed test were disabled, necessary fixes will be
added in the following commits
2021-05-10 14:04:03 +03:00
Stanislav Erokhin
6919f3dbb5 Move KotlinCacheServiceImpl to plugin-common.xml
This was done to prevent fir plugin from loading FE 1.0 services
2021-05-10 14:04:02 +03:00
Jinseong Jeon
bf85b110da FIR DFA: remove updatedAliasDiff from PersistentFlow
It is no longer used after element-wise join (a5389b06)
2021-05-10 12:16:04 +03:00
Mikhael Bogdanov
cd7841ceed Generate type annotations on class type parameters bounds
#KT-13228
 #KT-46539 Fixed
2021-05-10 12:12:21 +03:00
Mikhael Bogdanov
f574f89f78 Generate class annotation in AbstractAsmLikeInstructionListingTest 2021-05-10 12:12:20 +03:00
Mikhael Bogdanov
40eeee48b6 Extract generation of type parameters annotations and annotation on their bounds into utils 2021-05-10 12:12:19 +03:00
Mikhael Bogdanov
cbe3c66156 Generate function type parameter annotations and type annotations on their bounds into bytecode
Generate type parameter annotation by default for `-Xjvm-target 1.8` and above

 #KT-46539
 #KT-13228
 #KT-46545 Fixed
2021-05-10 12:12:18 +03:00
Mikhael Bogdanov
209ec68591 Make copy for disabled ir tests 2021-05-10 12:12:16 +03:00
Mikhael Bogdanov
5ff4d648f4 Render generic signature in type parameters tests 2021-05-10 12:12:15 +03:00
Mikhael Bogdanov
6182228de8 Render all annotations in type parameters tests 2021-05-10 12:12:14 +03:00
Vladimir Dolzhenko
c98dba6aea Do not set diagnostics callback if it is already set
Relates to #KT-37702
2021-05-10 09:59:16 +02:00
Vladimir Dolzhenko
cf5e6b242b Wrap exception with file details
Relates to #KT-39776
2021-05-07 23:48:12 +02:00
Ilya Muradyan
e9af2849ef Add Kotlin DeprecationLevel into the REPL completion 2021-05-07 19:56:21 +03:00
Mads Ager
6bc4e124fb [JVM_IR] Guard against infinite recursion in JvmIrCodegenFactory.
Fixed KTIJ-11580.
2021-05-07 17:58:49 +02:00
n-p-s
d70b889004 Update declarations to be searchable by their JvmName annotation
Relates to #KT-23653
2021-05-07 17:43:26 +03:00
pyos
36a25353e9 JVM_IR: permit @NoArg if super constructor is already zero-argument
#KT-46537 Fixed
2021-05-07 16:22:30 +02:00
Mikhail Glukhikh
ac9e8f667d Simplify code in Fir2IrConversionScope.returnTarget 2021-05-07 17:06:34 +03:00
Mikhail Glukhikh
05872fc6a8 Support captured types in ConeTypeCompatibilityChecker 2021-05-07 17:06:34 +03:00
Mikhail Glukhikh
df815a64cf FirEqualityCompatibilityChecker: rename file 2021-05-07 17:06:34 +03:00
Mikhail Glukhikh
6a51ddf755 FirEqualityCompatibilityChecker: add exception wrapper 2021-05-07 17:06:34 +03:00
Andrei Klunnyi
b7eded6e48 KT-46146 no 'protected' for final classes
Intention to change final class constructor visibility to 'protected'
was erroneous. This commit removes it.
2021-05-07 12:47:40 +00:00
Andrei Klunnyi
e56a3b3c30 KT-46146 'protected' and 'private' only for sealed constructors
Prior to this commit we suggested two invalid intentions for sealed
class constructors: change visibility to 'public' and 'internal'.

^KT-46146 Fixed
2021-05-07 12:47:39 +00:00
Andrei Klunnyi
686368749a KT-46146 'protected' is unavailable for primary constructors
Prior to this commit intention to change primary constructor visibility
to 'protected' was filtered out.
2021-05-07 12:47:38 +00:00
Alina Dolgikh
7388e60869 Add link to Kotlin 1.5 Event registration
As an experiment, we would like to try promotion in the Github repository.
2021-05-07 14:40:14 +02:00
Ilya Muradyan
042ac5555c Merge pull request #4342 from JetBrains/rr/ileasile/completion-for-function-params
[REPL] Add completion for the call named parameters
2021-05-07 15:11:12 +03:00
Mikhail Glukhikh
27903b4cd6 Configuration fix: make fir2ir tests depend on 'dist' 2021-05-07 10:32:47 +03:00
Alexander Udalov
d306d8a90e JVM IR: cast indy-SAM receiver type from KFunctionN to FunctionN
#KT-46512 Fixed
2021-05-07 00:53:31 +03:00
Ilya Kirillov
124bd559de FIR IDE: fix failing AbstractOverrideImplementTest tests on Windows
Before the System.lineSeparator() was used for splitting KtFile.text into lines.
In IJ all lines has UNIX file endings, so it failed on Windows TC agent
2021-05-07 00:40:52 +03:00
Mikhail Glukhikh
f83841a34f Cleanup FirHelpers (inline / remove / reduce visibility) 2021-05-07 00:40:51 +03:00
Tianyu Geng
9273c6326e FIR IDE: workaround deadlock when resolving class members
When listing members in a class, we need to resolve super types. But if
a super type is defined in another file, this file may not have been
resolved. In this case, listing the members would require resolving the
unresolved file, which can only be done in a write lock.

Before this change, KtFirScopeProvider only acquire the read lock, which
then causes read/write deadlock when the logic tries to further resolve
super types defined in other files. This change makes KtFirScopeProvider
acquire a write lock in the beginning so resolving can happen correctly
later.
2021-05-07 00:40:50 +03:00
Tianyu Geng
7a745cfe5c FIR IDE: Remove unnecessary renderAnnotations option 2021-05-07 00:40:48 +03:00
Tianyu Geng
417c841f77 FIR IDE: Move write actions out of analyze block 2021-05-07 00:40:47 +03:00
Tianyu Geng
e56b39bbd8 FIR IDE: fix typo in package name 2021-05-07 00:40:46 +03:00
Tianyu Geng
d09be811f0 FIR: make class delegation field a fake source
Previously, the FirFieldImpl generated from class delegation has a real
source. This causes troubles in the IDE. This change adds a new fake
source kind for class delegation fields.
2021-05-07 00:40:44 +03:00
Tianyu Geng
0b8b20eda0 FIR IDE: fix KtFirScopeProvider
Currently FIR IDE throws exceptions when enumerating members in this
scope if the class has delegate super types.

java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl Tjava.lang.IllegalStateException: java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl T
	at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestWithThrowable$3(KotlinTestUtils.java:498)
	at org.jetbrains.kotlin.test.MuteWithDatabaseKt.runTest(muteWithDatabase.kt:96)
	at org.jetbrains.kotlin.test.KotlinTestUtils.runTestWithThrowable(KotlinTestUtils.java:493)
	at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase.runTest(KotlinLightCodeInsightFixtureTestCaseBase.java:93)
	at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:394)
	at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
	at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
	at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$1.run(EdtTestUtil.kt:50)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$8(ApplicationImpl.java:475)
	at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:126)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:132)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:188)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:971)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:841)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:452)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:451)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:499)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl T
	at org.jetbrains.kotlin.fir.types.FirTypeUtilsKt.getConeType(FirTypeUtils.kt:33)
	at org.jetbrains.kotlin.fir.scopes.KotlinScopeProviderKt.scopeForSupertype(KotlinScopeProvider.kt:111)
	at org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider.getUseSiteMemberScope(KotlinScopeProvider.kt:42)
	at org.jetbrains.kotlin.fir.scopes.KotlinScopeProviderKt.unsubstitutedScope(KotlinScopeProvider.kt:83)
	at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider$getMemberScope$lambda-3$lambda-2$$inlined$withFirForScope$1.invoke(FirRefWithValidityCheck.kt:83)
	at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider$getMemberScope$lambda-3$lambda-2$$inlined$withFirForScope$1.invoke(FirRefWithValidityCheck.kt:41)
	at org.jetbrains.kotlin.idea.fir.low.level.api.api.LowLevelFirApiFacadeKt.withFirDeclaration(LowLevelFirApiFacade.kt:209)
	at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider.getMemberScope(KtFirScopeProvider.kt:323)
	at org.jetbrains.kotlin.idea.frontend.api.components.KtScopeProviderMixIn$DefaultImpls.getMemberScope(KtScopeProvider.kt:34)
	at org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession.getMemberScope(KtAnalysisSession.kt:26)
	at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.getOverridableMembers(KtOverrideMembersHandler.kt:54)
	at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.collectMembers(KtOverrideMembersHandler.kt:35)
	at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.collectMembersToGenerate(KtOverrideMembersHandler.kt:28)
	at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiOverrideImplement(AbstractOverrideImplementTest.kt:141)
	at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiFileTest(AbstractOverrideImplementTest.kt:98)
	at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiOverrideFileTest(AbstractOverrideImplementTest.kt:54)
	at org.jetbrains.kotlin.idea.codeInsight.OverrideImplementTest.testDelegatedMembers(OverrideImplementTest.kt:121)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at com.intellij.testFramework.UsefulTestCase.lambda$runTest$9(UsefulTestCase.java:331)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:462)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:480)
	at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:378)
	at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:350)
	at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase.lambda$runTest$0(KotlinLightCodeInsightFixtureTestCaseBase.java:93)
	at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestWithThrowable$3(KotlinTestUtils.java:495)
	... 36 more
.. 112 more
2021-05-07 00:40:42 +03:00
Tianyu Geng
53aafbd7d9 FIR IDE: enable override implement test for FIR 2021-05-07 00:40:41 +03:00
Tianyu Geng
00031c8eb1 FIR IDE: add action to override/implement missing members
This commit adds the following actions:

- quickfix to implement missing members
- quickfix to implement missing members as constructor parameters
- action to implement members (Code - Generate - Implement)
- action to override members (Code - Generate - Override)

The current implementation is still missing some pieces, which will be
addressed in future changes.

- fully qualified names are not shorten
- some Kotlin types are not rendered correctly
2021-05-07 00:40:40 +03:00
Tianyu Geng
34387e228f FIR IDE: extract common logic idea.core.overrideImplement
Also rename OverrideImplementMemberHandler to GenerateMemberHandler to
align with the naming of its member functions.
2021-05-07 00:40:38 +03:00
Tianyu Geng
06ba143afe FIR IDE: quickfix to make class abstract if member not implemented 2021-05-07 00:40:37 +03:00
Alexander Udalov
6e3009b82e JVM IR: generate adapted callable references as synthetic
As well as suspend conversion adapters, which are unsupported by default
right now.

 #KT-46259 Fixed
2021-05-06 22:58:18 +03:00
Leonid Startsev
d60a8f9baa Use correct type in KClassReference
Make sure that writeSelf function remains static
2021-05-06 19:53:21 +00:00
Leonid Startsev
a58f29aa06 Remove unnecessary ignoreIndexTo outside writeSelf
It never worked: descriptor.declaresDefaultValue used by property.isOptional
works only for current module
(since it looks up psi), so we never access default value initializers
outside current module
2021-05-06 19:53:21 +00:00
Leonid Startsev
66f39ca185 Use SerializerFactory interface and generate function
for sealed and abstract serializable classes.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1116
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1078
2021-05-06 19:53:20 +00:00
Jinseong Jeon
ebbef484ad FIR UAST: add utils to clean up identical render/log files 2021-05-06 20:19:29 +02:00
Jinseong Jeon
1385a4690e Revert "UAST Kotlin: update test data"
This reverts commit 291cd842

A directive to ignore FIR UAST is removed after facade support.
2021-05-06 20:19:29 +02:00
Jinseong Jeon
7f627ab480 FIR UAST: track all legacy test data since facade class is converted
These are mostly mechanical changes.
2021-05-06 20:19:29 +02:00
Jinseong Jeon
939740d26e FIR UAST: convert (light) class for facade 2021-05-06 20:19:29 +02:00
Ilya Goncharov
9baa24e626 [Gradle, JS] Fix with beta version of webpack-dev-server to work with webpack 5
^KT-46162 fixed
^KT-46331 fixed
2021-05-06 18:45:45 +03:00
Mads Ager
b6fa28ea81 [JVM_IR] Deal with inline-class arguments in large arity lambdas.
FunctionNVarargBridgeLowering checked the name of the method instead
of whether the method overrides an invoke method. That doesn't work
when the name of the function gets mangled because of inline class
arguments.

Fixed KT-45084.
2021-05-06 17:27:59 +02:00
pyos
1181854bd6 Add a couple more tests for array constructors and references 2021-05-06 18:25:56 +03:00
pyos
a30cfc332d JVM_IR: remove JvmArrayConstructorLowering
ExpressionCodegen already spills the stack before any loop, so it has
no effect.
2021-05-06 18:25:55 +03:00
pyos
9f53d70109 JVM_IR: move ArrayConstructor below function reference phases
This allows taking function references to inline array constructors.

Also, redundant classes are no longer generated when function references
are passed as arguments to the array constructors.

 #KT-46426 Fixed
2021-05-06 18:25:53 +03:00
Mikhail Glukhikh
776920f77d Cleanup code in FirAnnotationArgumentChecker 2021-05-06 17:51:24 +03:00
Mark Punzalan
18f617a582 FIR: Make FirAnnotationArgumentChecker a FirAnnotationCallChecker, to
run on all annotation calls, including those inside type annotations.
2021-05-06 17:51:22 +03:00
Mikhail Glukhikh
87d05bcf83 Fix spec test data after rebase 2021-05-06 17:50:37 +03:00
Mikhail Glukhikh
e451ecf000 Regenerate FIR IDE tests 2021-05-06 17:50:36 +03:00
Mikhail Glukhikh
1936a815e2 ConeTypeCompatibilityChecker: add temporary workaround for KT-46383 2021-05-06 17:50:35 +03:00
Tianyu Geng
db55a973d4 FIR: fix infinite recursion with equality operator checker 2021-05-06 17:50:34 +03:00
Tianyu Geng
d4717569b9 Fix inferred type of FirGetClassCall
The inferred type should be `KClass<out Blah>` for `FirGetClassCall`
invoked on expressions.
2021-05-06 17:50:33 +03:00
Tianyu Geng
7bb81ef157 FIR: add equality call checker
Added checker for FirEqualityOperatorCall. It's surfaced as one of the
following diagnostics depending on the PSI structure and types under
comparison:

* INCOMPATIBLE_TYPES(_WARNING)
* EQUALITY_NOT_APPLICABLE(_WARNING)
* INCOMPATIBLE_ENUM_COMPARISON_ERROR

Comparing with FE1.0, the current implementation is more conservative
and only highlights error if the types are known to follow certain
contracts with `equals` method. Otherwise, the checker reports warnings
instead.

However, the current checker is more strict in the following situations:
1. it now rejects incompatible enum types like `Enum<E1>` and
  `Enum<E2>`, which was previously accepted
2. it now rejects incompatible class types like `Class<String>` and
  `Class<Int>`, which was previously accepted
3. the check now takes smart cast into consideration, so
  `if (x is String) x == 3` is now rejected
2021-05-06 17:50:32 +03:00
Andrey Zinovyev
787c743333 [FIR] Syntax checkers
Introduce base class for checkers that dive into source trees.
2021-05-06 17:38:04 +03:00
Ilya Matveev
1be39cb505 [K/N] Replace thread_local with THREAD_LOCAL_VARIABLE
For some reason using C++'s thread_local modifier
causes crashes during TLS access on runtime initialization
Kotlin dlls on Windows. This patch replaces the thread_local
modifier with __thread which doesn't have this problem
2021-05-06 14:10:22 +00:00
Ilya Matveev
e2e173b92c [K/N][New MM] Disable tests for ObjC interop 2021-05-06 14:10:22 +00:00
Ilya Matveev
4d346d3735 [K/N][New MM] Support thread state switching
Including

* Support thread state switching in codegen
* Introduce and use GCUnsafeCall annotation
* Switch thread state in C++ runtime code

Also

* Register current thread in Mark&Sweep tests
* Store MemoryState in Worker instance
* Set worker tid in WorkerInit
2021-05-06 14:10:21 +00:00
Ilya Matveev
0b46ed3cde [K/N][New MM] Add thread state asserts to reference updates 2021-05-06 14:10:20 +00:00
Ilya Matveev
08688670b1 [K/N] Adjust repository root in K/N's .idea directory 2021-05-06 14:10:19 +00:00
Yahor Berdnikau
c6fc393417 Enable kotlin java toolchain support for kapt task.
With this change 'KaptWithoutKotlincTask' will also support overriding
default Gradle JDK to run kapt. In such case only 'in-process' kapt
 worker isolation mode is supported.

If user does not provide custom JDK, kapt worker isolation mode will
be 'no-isolation' as before.

^KT-45611 In Progress
2021-05-06 16:04:23 +02:00
Mads Ager
afa1b8bfdc [JVM] Extend boxing/unboxing optimizations to coroutine boxing. 2021-05-06 15:35:49 +02:00
Ivan Gavrilovic
4994cb3774 [Gradle] Create kotlinOptions during task init and keep outputFile for js
This is so that existing build scripts using
withType() do not break. Also, fix the failing
test.

It was necessary to keep outputFile for the js compile task
as it was accessed from the build scripts. Instead, a new
property is introduced which uses Gradle lazy properties.
2021-05-06 13:54:18 +03:00
Ivan Gavrilovic
80181c1091 [Gradle] Add Android bootclasspath lazily 2021-05-06 13:54:17 +03:00
Ivan Gavrilovic
1c0d40055e [Gradle] Support getting the sourceSet name from tasks when...
...Gradle property is being used, instead of the direct String
value.
2021-05-06 13:54:16 +03:00
Ivan Gavrilovic
98cc99e36b [Gradle] Fix adding KAPT generated classess to the compilation classes output 2021-05-06 13:54:15 +03:00
Ivan Gavrilovic
f5caa49c31 [Gradle] Use Gradle properties for KAPT tasks
Use lazy properties to configure KAPT tasks and in the model builder.
Also, avoid eager dependency resolution of the kaptExternalClasspath
file collection.
2021-05-06 13:54:14 +03:00
Ivan Gavrilovic
0882da1788 [Gradle] Introduce classes to configure KAPT tasks
Avoid storing references to KotlinCompile task and use lazy properties
to configure task. Values are kept in-sync with the
Kotlin compile task (for the stub generation) using this mechanism.
2021-05-06 13:54:13 +03:00
Ivan Gavrilovic
01dd15cc3e [Gradle] Use task properties to modify task configuration
This change migrates to using properties of KGP tasks and Gradle
built-in tasks. Also, in TaskProvider class, Configurator instances are
created to configure KGP tasks.
2021-05-06 13:54:12 +03:00
Ivan Gavrilovic
ad9f6e63b6 [Gradle] Extract configuration of KotlinJsIrLink to a class
Migrate KotlinJsIrLink to properties create Configurator class
to configure the task properties.
2021-05-06 13:54:11 +03:00
Ivan Gavrilovic
5eed9a4e6e [Gradle] Extract configuration of KotlinCompileCommon to a class
Migrate KotlinCompileCommon to properties create Configurator class
to configure the task properties.
2021-05-06 13:54:10 +03:00
Ivan Gavrilovic
ff27a61252 [Gradle] Use ConfigurableFileCollection for task local state
Use ConfigurableFileCollection so that tasks can simply append to the
file collection and tasks that do not need this, can simply do nothing.
2021-05-06 13:54:09 +03:00
Ivan Gavrilovic
571c9c10d4 [Gradle] Update compile tasks to use properties and clean up code
Update AbstractKotlinCompile, KotlinCompile, and Kotlin2JsCompile to
use Gradle properties, and introduce Configurator classes that are
using configuration-time data to configure task. Also, introduce
TaskConfigurator interface that should be implemented by classes that
are used to configure tasks.
2021-05-06 13:54:08 +03:00
Ivan Gavrilovic
56cad96718 [Gradle] Remove KotlinCompileTaskData
When getting the incremental compilation information use the
task graph which processes all tasks present in it. Tasks have
all information that is needed to get IncrementalModuleInfo for all
compilations.
2021-05-06 13:54:06 +03:00
Ivan Gavrilovic
b3d8187df4 [Gradle] Remove deprecated ways to specify compiler classpath
This change removes options to specify compiler classpath using
deprecated properties that were deprecated for more than 2 years.
2021-05-06 13:54:05 +03:00
Jinseong Jeon
61e21ef6a2 FIR: ensure the absence of FirResolvedTypeRef with erroneous type 2021-05-06 12:22:40 +03:00
Andrey Zinovyev
cba21c68a3 [lombok] Actualize README 2021-05-06 11:27:51 +03:00
Jinseong Jeon
e2dc21da90 FIR checker: warn useless as and is 2021-05-05 18:20:51 +03:00
Jinseong Jeon
19d939c36e TEST: remove redundant diagnostic directive (w/ syntax error) 2021-05-05 18:20:50 +03:00
Mikhail Glukhikh
7ee6597873 FIR: make inference context mandatory in withNullability() etc. 2021-05-05 17:35:50 +03:00
Jinseong Jeon
bb37728e4f FIR: use withNullability with type context whenever possible
It could simplify flexible type cases.
2021-05-05 17:35:48 +03:00
Anton Lakotka
f94ed1a00c Fail only when KotlinPm20ProjectExtension is passed
to buildKotlinProjectStructureMetadata
#Fixes KTIJ-11586
2021-05-05 16:53:20 +03:00
Jinseong Jeon
291cd842b9 UAST Kotlin: update test data
Addition of directive IGNORE_FIR alters synthetic local variable names.
2021-05-05 14:22:40 +02:00
Jinseong Jeon
dad198cb67 UAST Kotlin: make super type lookup test robust
Newly added directive IGNORE_FIR bothers lookup for object "O".
2021-05-05 14:22:40 +02:00
Jinseong Jeon
03d4cb0dfa FIR UAST: use uast-kotlin/testData for legecy tests 2021-05-05 14:22:40 +02:00
Jinseong Jeon
eac875b5d6 FIR UAST: commonize utils from UAST Kotlin 2021-05-05 14:22:40 +02:00
Jinseong Jeon
f37c722c76 UAST Kotlin: fix typos 2021-05-05 14:22:40 +02:00
Jinseong Jeon
40eaabdbb5 FIR UAST: prototype plugin entrypoint, declarations, test infra 2021-05-05 14:22:40 +02:00
Jinseong Jeon
225e3a747c LC: introduce light class interface for facade
so that FIR-based light class for facade can work well in LC utils
2021-05-05 14:11:48 +02:00
Jinseong Jeon
efba90c6f1 LC: rename KtLightClassForFacade to ...Impl
before introducing a common interface for light class for facade

This is a mechanical refactoring.
2021-05-05 14:11:48 +02:00
Alexander Udalov
c14a890e7e IR: fix capturing of type parameters in local functions
collectPotentiallyCapturedTypeParameters no longer stops on the first
class when going through parents. This is needed because otherwise type
parameters of the containing class, and its outer classes, were never
considered "captured", and thus not duplicated/remapped later in
LocalDeclarationsLowering.

This led to the IR where a local function referenced generic type
parameters of the outer class. On JVM, local function is generated into
a private static function in that container class, and static functions
can't use generic type parameters, which crashed some bytecode
processing tools.

Also, add another explicit call to `seeType` to cover references to
generic type parameters in function return types.

 #KT-45941 Fixed
2021-05-04 21:10:56 +02:00
Vasily Levchenko
b389fd6667 [performance][build][kotlin-build-gradle-plugin] version 0.0.27 (fix) 2021-05-04 15:44:19 +00:00
Stanislav Erokhin
d9be05fea8 Support getContainer for the synthetic it value parameter
Also fixed incorrect KtSymbolOrigin:
it was SOURCE instead of SOURCE_MEMBER_GENERATED
2021-05-04 17:25:34 +02:00
Stanislav Erokhin
c24ad0ba51 Use KtFunctionLiteral as key for KtAnonymousFunctionSymbol retrieving
It seems logical to do, because KtFunctionLiteral is KtDeclaration
and KtLambdaExpression is not. Also FirAnonymousFunction use it as
realPsi reference
2021-05-04 14:01:30 +02:00
Dmitriy Dolovov
75d2e415e1 [K/N][IR] Generate missing return statement, p. 2
^KT-42832
2021-05-04 13:26:02 +03:00
Alexander Shabalin
5e456ed82b Put GC implementations into separate modules.
The mm module now compiles separately for each GC implementation.
2021-05-04 10:23:16 +00:00
Ilya Kirillov
41ab97ff1f FIR IDE: introduce single function for checking if declaration can be lazily resolved 2021-05-04 08:19:50 +02:00
Ilya Kirillov
babf079c31 FIR IDE: fix resolving of inner type aliases 2021-05-04 08:19:50 +02:00
Ilya Kirillov
9e1bc5680d FIR IDE: do not consider KtEnumEntry as ktClassOrObject 2021-05-04 08:19:50 +02:00
Ilya Kirillov
ef5f0e77ec FIR IDE: use KtClassLikeDeclaration.classId instead of hacks 2021-05-04 08:19:50 +02:00
Ilya Kirillov
aff807e3af Stubs: bump stubs version 2021-05-04 08:19:50 +02:00
Ilya Kirillov
4942f5eb66 Stubs: add classId to KtTypeAlias stubs 2021-05-04 08:19:50 +02:00
Ilya Kirillov
fdb091d98e Stubs: add classId to KtClassOrObject stubs 2021-05-04 08:19:49 +02:00
Ilya Kirillov
09a94f3200 FIR IDE: ignore non-passing tests in compiler based tests 2021-05-04 08:19:49 +02:00
Ilya Kirillov
3503a54437 FIR IDE: run tests in parallel in module idea-fir-low-level-api 2021-05-04 08:19:49 +02:00
Ilya Kirillov
65ce641b22 FIR IDE: introduce diagnostics tests bases on FIR diagnostics tests 2021-05-04 08:19:49 +02:00
Ilya Muradyan
b771f9eea4 [REPL] Add completion for the call named parameters 2021-05-04 04:40:00 +03:00
Mads Ager
0c77565104 JVM_IR: Add more local variable tests for finally code. 2021-05-03 07:43:38 +02:00
Mads Ager
6095d8a7fa [JVM] Split the variable range for external finally blocks in inliner
When external finally blocks are inlined none of the current locals
are in scope of the finally block.
2021-05-03 07:43:37 +02:00
Mads Ager
6d9f02cfc6 [JVM_IR] Fix range of locals in connection with finally blocks.
For code such as:

```
try {
  var y = "y"
  for (i in 0 until 1) {
    return y
  }
} finally {
  println("finally")
}
```

The local variables `y` and `i` ended up covering the finally block as
well in the debugger.

This change splits the range of the locals so that they do
not cover the finally block.

This change does not change the inliner to do similar transformations,
so the range of locals is still wrong win finally blocks when inlined
into an inline function. Added a failing test to that effect.
2021-05-03 07:43:37 +02:00
Mikhail Glukhikh
0764a0601c Fix FIR IDE test data broken by 80a44986 2021-05-01 19:12:05 +03:00
sebastian.sellmair
a1ed81146e [Commonizer] Logging: NativeDistributionCommonizationCache: Log in level 'quite' on cache misses
^KT-36679 Verification Pending
2021-05-01 14:36:18 +03:00
sebastian.sellmair
b48850c993 [Commonizer] Logging: Implement CommonizerLogLevel and hide verbose output by default
^KT-36679 Fixed
2021-05-01 14:36:18 +03:00
sebastian.sellmair
7349ec8f2f [Commonizer] Logging: Implement ProgressLogger.fork
^KT-36679
2021-05-01 14:36:16 +03:00
sebastian.sellmair
ec440aecf6 [Commonizer] Logging: Remove 'COMMONIZATION' prologue
^KT-36679
2021-05-01 14:36:15 +03:00
sebastian.sellmair
9d9e11d6d8 [Commonizer] Logging: 'Preparing commonized Kotlin/Native libraries': show outputTarget instead of flat list of targets
^KT-36679
2021-05-01 14:36:14 +03:00
sebastian.sellmair
0d9e32f963 [Commonizer] Logging: Show [Step x of y] only when more than one task is scheduled
^KT-36679
2021-05-01 14:36:13 +03:00
Victor Petukhov
9eaec8d919 Use platform-independent line separator in jspecify tests handler 2021-05-01 13:39:28 +03:00
Nikolay Krasko
2a2fa31577 Allow emulate sonatype publishing when publishing to folder (KTI-552) 2021-05-01 01:41:30 +03:00
Nikolay Krasko
624740a80a Force usage of passed deploy url for sonatype publication (KTI-552) 2021-05-01 01:41:28 +03:00
Nikolay Krasko
2eda82f178 Allow in memory signing (KTI-552) 2021-05-01 01:41:27 +03:00
Nikolay Krasko
8f97d8a78e Drop legacy publishing 2021-05-01 01:37:09 +03:00
Mads Ager
df225c0c7f [JVM] Fix uninitialized locals after coroutine transformation.
The coroutine transformation would leave locals in the local
variable table across the code that reloads local variables from
the continuation on reentry. However, when reentering the function
the local has no value until after the reloads from the
continuation.

This change splits the locals in the local variable table to
avoid such uninitialized locals. A local alive across a
suspension point has its range split in two. One that goes
from the original start to the state label for the restart
after the suspension. The other goes from after the local
has been reloaded from the continuation until the previous
end of the local.
2021-04-30 22:24:03 +02:00
Dmitry Petrov
83e3a702c5 JVM_IR KT-46408 properly map fake overrides in method handles 2021-04-30 22:24:02 +03:00
Vasily Levchenko
ef2c2c2c9e [kotlin][tests][compiler/testData/debug/stepping] kt-42208 test added. 2021-04-30 18:44:55 +00:00
Vasily Levchenko
3160fc84fa [kotlin-native][tests] kt-42208 test added. 2021-04-30 18:44:54 +00:00
Vasily Levchenko
a6a7da31c9 [IR][provisional function expression] do generate function reference with offset of call site. 2021-04-30 18:44:54 +00:00
Tianyu Geng
b6bd4ae8e6 FIR: check DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH 2021-04-30 19:58:50 +03:00
Mikhael Bogdanov
84e67da2af Mute test on JDK 6 2021-04-30 18:24:10 +02:00
Mikhael Bogdanov
95d95f9a9b Put reification markers came from super object signature
#KT-44770 Fixed
  #KT-30696 Open
2021-04-30 17:34:16 +02:00
Sergey Shanshin
8dd307573a Fix IR compilation of external serializers in native 2021-04-30 18:17:08 +03:00
Mikhail Glukhikh
80a449862e FIR: implement diagnostics for qualifier as stand-alone expression case 2021-04-30 17:59:45 +03:00
Mikhail Glukhikh
84ccf7bbb1 FIR: use Java 8 rules in not implemented checker 2021-04-30 17:59:38 +03:00
Mikhail Glukhikh
5de8401494 Reset FirQualifiedNameResolver properly 2021-04-30 17:59:32 +03:00
Victor Petukhov
4fb78fab93 Temporary disable failing jspecify tests on Windows 2021-04-30 17:50:56 +03:00
Victor Petukhov
c9568c0744 Fix FIR tests 2021-04-30 16:49:56 +03:00
Victor Petukhov
7c62e9aecd Introduce warnings reporting by missed constraints because of incorrect optimization in the constraints processor 2021-04-30 15:46:04 +03:00
Victor Petukhov
e110b49cab Revert "Don't stop constraints processing if all type variables have proper equality constraints"
This reverts commit b87c2a15
2021-04-30 15:46:03 +03:00
Andrey Zinovyev
287ff3ed55 [FIR] Fix for AugmentedArraySetCall expression type
Hacky fix so it's type is Unit and not error
2021-04-30 15:25:44 +03:00
Simon Ogorodnik
6365164c21 FIR: Fix gradle integration tests broken by c6fa3634 2021-04-30 15:19:58 +03:00
Sergey Bogolepov
13464cce68 [Native] Adapt Skia interop to ClangArgs refactoring. 2021-04-30 12:07:46 +00:00
Victor Petukhov
f330d67740 Mute foreign annotations tests with compiled java through psi class files reading 2021-04-30 14:43:28 +03:00
Victor Petukhov
78ffefe107 Add jspecify license 2021-04-30 14:43:27 +03:00
Victor Petukhov
909f0d8bdb Implement caching module annotations per class id 2021-04-30 14:43:27 +03:00
Victor Petukhov
2e57ff25ee Leave KotlinCliJavaFileManager::findClass only passing JavaClassFinder.Request 2021-04-30 14:43:27 +03:00
Victor Petukhov
072bba109f Move foreign annotations logic into the corresponding configurator for the tests 2021-04-30 14:43:27 +03:00
Victor Petukhov
e93133a28f Implement jspecify marks processing in the tests properly, by adding specific handler and cleanuper 2021-04-30 14:43:27 +03:00
Victor Petukhov
b9536a25d6 Support type enhancement on freshly supported module level annotations
^KT-45189 Fixed
2021-04-30 14:43:27 +03:00
Victor Petukhov
bc5e92033b Support reading annotations on java 9 module on sources and binaries 2021-04-30 14:43:27 +03:00
Victor Petukhov
24685ee9d6 Add directive ALL_JAVA_AS_BINARIES and use it explicitly for foreign annotations tests with compiled java 2021-04-30 14:43:27 +03:00
Victor Petukhov
89270399db Update some third-party annotations 2021-04-30 14:43:26 +03:00
Victor Petukhov
cdcde634e8 Add basic Java 9 module tests 2021-04-30 14:43:26 +03:00
Victor Petukhov
757fdb2b32 Add Java 9 jspecify annotations including module level ones 2021-04-30 14:43:26 +03:00
Victor Petukhov
71755b7a5e Support java 9 modules in the diagnostic tests both in sources and binaries 2021-04-30 14:43:26 +03:00
Victor Petukhov
1f0616439c Introduce special common directives for tests based on foreign annotation tests 2021-04-30 14:43:26 +03:00
Victor Petukhov
6065f0e2d0 [Jspecify] Move diagnostic tests against compiled java under the new tests infrastructure 2021-04-30 14:43:26 +03:00
Victor Petukhov
8f097b14cc [Jspecify] Move jspecify test runner under the new tests infrastructure 2021-04-30 14:43:26 +03:00
Victor Petukhov
6f9694174f Move foreign annotation tests into diagnostics folder 2021-04-30 14:43:25 +03:00
Victor Petukhov
57bd4d3a98 [Jspecify] Remove Kotlin use sites generator: consider manually picking changes from the jspecify repo 2021-04-30 14:43:25 +03:00
Victor Petukhov
49e838781c Clean-up JavaModuleInfo.kt 2021-04-30 14:43:25 +03:00
Vasily Levchenko
788d3c022a [build][kotlin-build-gradle-plugin] version 0.0.27
- reading konanVersion and konanMetaVersion from project properties
2021-04-30 10:26:36 +00:00
Vasily Levchenko
9cbcafa8d1 [dependencies][kotlin-build-gradle-plugin] version 0.0.27
- reading konanVersion and konanMetaVersion from project properties
2021-04-30 10:26:35 +00:00
Dmitry Petrov
72804d2e8c JVM_IR KT-45779 don't generate intrinsic method refs via invokedynamic 2021-04-30 12:45:11 +03:00
Sergey Bogolepov
f3a935adb9 Support explicit C++ flags in run_konan tool 2021-04-30 08:39:27 +00:00
Sergey Bogolepov
25ebb3fa75 Remove obsolete Gradle native plugin configuration 2021-04-30 08:39:27 +00:00
Sergey Bogolepov
274d18a141 [Kotlin/Native] Add a workaround for Xcode 12.5
SDKs from Xcode 12.5 contain C++ stdlib and it
breaks compilation of C++ parts of compiler.
Mitigate this problem by explicitly specifying
path to C++ stdlib.
2021-04-30 08:39:26 +00:00
Victor Petukhov
8dd71ec5c8 Build recursive raw types and raw types which contain type parameters properly
1) Substitute erasure of other type parameters
2) Use star projection at top level for recursive raw types

^KT-46126 Fixed
2021-04-30 10:49:47 +03:00
Andi Wenger
f9d2ca68ce KJS IR: Fix KT-45738 - Consider recursive checkForPrimitiveOrPattern
Recursive results from checkForPrimitiveOrPattern were ignored. If it found a case/condition that could not be optimized the resulting "false" was not propagated. This would lead to a "optimized" when without all conditions.
- see KT-45738
- The return is now lifted out of the when to make it more obvious what is going on.
- New test for mixed multiple conditions in when
2021-04-29 23:52:01 +03:00
Ilya Kirillov
caff279255 FIR IDE: add missing binary extensions
This also reveals and error in find usages for fir: it does not work for library source files
So, corresponding tests are muted
2021-04-29 23:31:05 +03:00
Andrey Zinovyev
e4a5775570 Remove duplicated code in annotation-based-compiler-plugins-ide-support 2021-04-29 23:14:16 +03:00
Andrey Zinovyev
8afb6d2761 [lombok] Support import from gradle to IDE
Introduce base module for ide compiler plugins
2021-04-29 23:14:15 +03:00
Andrey Zinovyev
b58bea6fa1 [lombok] IDE plugin with maven import handler 2021-04-29 23:14:14 +03:00
Andrey Zinovyev
07daf2165a [lombok] Rename maven subplugin to 'lombok' 2021-04-29 23:14:13 +03:00
Andrey Zinovyev
b88f54b31a [lombok] Add maven plugin integration test with kapt 2021-04-29 23:14:12 +03:00
Andrey Zinovyev
3e883120dd [lombok] Simple maven plugin to enable lombok support 2021-04-29 23:14:11 +03:00
Ivan Kochurkin
7ec709cf46 FIR: fix incorrect reporting of underscores, simplify code, fix test data file 2021-04-29 22:31:39 +03:00
Jinseong Jeon
9b39a8abc2 FIR: avoid wrapping an erroneous type as FirResolvedTypeRef
Instead, use FirErrorTypeRef, a subtype of FirResolvedTypeRef
2021-04-29 22:31:38 +03:00
Alexander Gorshenev
887032667d [Kotlin/Native][Interop] Skia interop plugin for cinterop 2021-04-29 21:43:26 +03:00
Vladimir Ivanov
5f582ad28a [Kotlin/Native][Interop] Provide pure c wrappers over cpp for skia interop 2021-04-29 21:43:25 +03:00
Yahor Berdnikau
61825e9aec Made GradleCompileTaskProvder compative with configuration cache.
After moving compilerRunner() method evaluation into execution phase,
creation of GradleCompileTaskProvider class started to violate
configuration cache.

^KT-45611 In Progress
2021-04-29 20:43:59 +03:00
Yahor Berdnikau
816e955c61 Introduce KotlinJavaToolchain compile tasks input.
This task input provides a way to set different from current Gradle
JDK and use it for Kotlin files compilation. By default it provides
current Gradle JDK.

Provided JDK major version is used as task input, so on providing
different JDK user will see cache miss.

All required interfaces are located inside api module.

^KT-45611 In Progress
2021-04-29 20:43:58 +03:00
Yahor Berdnikau
201b6dfa60 Print path to java executable Kotlin daemon was started with.
Useful for tests to validate toolchain correct behaviour.

^KT-45611 In Progress
2021-04-29 20:43:57 +03:00
Yahor Berdnikau
85456bd6d8 Add helper methods simplifying working with lazy properties from Kotlin.
Just allow to write Kotlin code easier and nicer when using Gradle
lazy properties.

^KT-45611 In Progress
2021-04-29 20:43:55 +03:00
Yahor Berdnikau
007f11e22e Add initial test setup to enable and test Gradle build cache.
This will allow to write JUnit5 tests to verify tasks are re-using
build cache on rebuilding same project from clean state.

^KT-45611 In Progress
2021-04-29 20:43:54 +03:00
Ilya Kirillov
ddf451739b FIR IDE: add member type-alias test for FileStructureTest 2021-04-29 17:51:28 +02:00
Ilya Kirillov
d438d2db40 FIR IDE: do not remove duplicated diagnostics
This hides the real problem why diagnostics are duplicated
2021-04-29 17:51:28 +02:00
Ilya Kirillov
77ae1fa1f2 FIR IDE: run lazy resolve phases in ContextIndependent ResolutionMode 2021-04-29 17:51:28 +02:00
Ilya Kirillov
663c0d975d FIR IDE: add cases for diagnostics traversal test 2021-04-29 17:51:27 +02:00
Ilya Kirillov
602be42b24 FIR IDE: fix lazy resolve for generated synthetic accessors 2021-04-29 17:51:27 +02:00
Nikolay Krasko
66683d2952 Unwrap both parts of light element in KtLightElementBase.isEquivalentTo
Even if origins are same, wrapped light elements are not equivalent.

Revealed by running bunch of JavaAgainstKotlinBinariesCheckerTestGenerated
tests.

com.intellij.testFramework.LoggedErrorProcessor$TestLoggerAssertionError: Non-idempotent computation:
it returns different results when invoked multiple times or on different threads:

  KtLightMethodForDecompiledDeclaration of KtLightClassForDecompiledDeclaration of PsiFile:A.class != KtLightMethodForDecompiledDeclaration of KtLightClassForDecompiledDeclaration of PsiFile:A.class
2021-04-29 18:20:38 +03:00
Andrey Zinovyev
c8a81911c0 [lombok] Add message about experimental status of the plugin 2021-04-29 18:05:27 +03:00
Ivan Gavrilovic
f0199d7277 [Gradle] Simplify Parcelize Gradle plugin
Do not iterate over all configurations, just
add the dependency to the compile and runtime classpath.
2021-04-29 17:26:36 +03:00
Ilmir Usmanov
cb89bd0e13 Generate SuspendFunction marker interface if supertype is suspend
Otherwise, is/as checks will not work.
 #KT-18707
2021-04-29 17:11:31 +03:00
Margarita Bobova
5d296a01c2 Add changelog for 1.4.31 and 1.4.32 2021-04-29 16:13:13 +03:00
Dmitriy Novozhilov
dbaaf081d7 Fix warning in Kotlin/Native build 2021-04-29 16:07:24 +03:00
Dmitriy Novozhilov
df51856e65 Advance bootstrap to 1.5.20-dev-5753 2021-04-29 16:07:22 +03:00
Mikhail Glukhikh
8147a88353 Cleanup: OverrideResolver.kt 2021-04-29 15:24:57 +03:00
Mikhail Glukhikh
cc05d91bda FE 1.0: add deprecation ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED_WARNING
#KT-45508 Fixed
2021-04-29 15:24:49 +03:00
Svyatoslav Scherbina
59b5475350 Fix WITH_COROUTINES tests compilation on Native after 5617d83c 2021-04-29 11:16:02 +00:00
Steven Schäfer
84d78035e4 JVM IR: Avoid double mangling of function reference invoke methods 2021-04-29 13:10:43 +02:00
Alexander Udalov
276ffd5a4b JVM IR: fix ::class reference and type mapping for scripts
#KT-46284 Fixed
2021-04-29 00:33:34 +03:00
Alexander Udalov
d10f734594 Fix warnings after making getKotlinPluginVersion non-null
See 4cb6303fa8.
2021-04-29 00:18:07 +03:00
Ilya Kirillov
7149d08995 FIR IDE: resolve supertypes before retrieving them 2021-04-28 22:11:05 +03:00
Ilya Kirillov
cccf9b7d54 FIR IDE: add JVM checkers 2021-04-28 17:57:45 +02:00
Ilya Kirillov
81a7271009 FIR: Decouple AbstractDiagnosticCollectorComponent and AbstractDiagnosticCollector 2021-04-28 17:57:45 +02:00
Nikolay Krasko
e43835c9f5 Bump konanVersion: 1.5.30 2021-04-28 17:58:40 +03:00
Ivan Kochurkin
525cc6df97 [FIR] Implement MANY_LAMBDA_EXPRESSION_ARGUMENTS diagnostics, fix tests 2021-04-28 16:21:48 +03:00
Udi Cohen
b8002cb54f [Kapt] Support dumping processors stats to a file
Using the option -Kapt-dump-processor-timings
2021-04-28 11:48:19 +03:00
sebastian.sellmair
beba85a848 [Commonizer] Calculate 'commonModuleNames' in hierarchical context
^KT-46330 Verification Pending
2021-04-28 02:03:20 +03:00
Nikolay Krasko
f7fdffefd6 Add an explicit dependency on dist for UAST tests 2021-04-27 22:00:18 +03:00
Dmitry Petrov
b34e2c1474 JVM_IR KT-36646 fuze primitive equality with safe call 2021-04-27 19:41:31 +03:00
Dmitry Petrov
72849a3dc3 JVM_IR update test for KT-36637 2021-04-27 19:41:29 +03:00
Dmitry Petrov
bdf914e8d5 JVM_IR use static 'hashCode' for boxed primitives on JVM 1.8+ 2021-04-27 19:41:28 +03:00
Dmitriy Novozhilov
07b15f9de6 [FIR] Support effective visibility with @PublishedApi
#KT-46270 Fixed
2021-04-27 18:39:10 +03:00
Dmitriy Novozhilov
32c3f85679 [FIR] Add inline checker for bodies of inline functions
This checker doesn't support `@PublishedAPI` yet, so some BB tests for it
 were muted. #KT-46270
2021-04-27 18:39:09 +03:00
Dmitriy Novozhilov
7e052c1eb1 [FIR] Fix suppressing diagnostics for some expressions 2021-04-27 18:39:07 +03:00
Dmitriy Novozhilov
2a08923c51 [FIR] Add more utilities for builtin functional types 2021-04-27 18:39:06 +03:00
Dmitriy Novozhilov
8925b8c922 [FIR] Fix leaking mutable map type of resolved argument mapping 2021-04-27 18:39:05 +03:00
Dmitriy Novozhilov
1afb844e1a [FIR] Fix FirExpressionWithSmartcastImpl.acceptChildren 2021-04-27 18:39:03 +03:00
Dmitriy Novozhilov
12331cb10c [FIR] Build resolved declaration status for all non-raw declarations 2021-04-27 18:39:02 +03:00
Ivan Kochurkin
d54808e33f [FIR] Implement CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS diagnostics, fix tests 2021-04-27 18:27:39 +03:00
Alexander Likhachev
f2f2df90aa [Gradle] Prevent early resolve of compiler classpath
#KT-45834 Fixed
2021-04-27 18:21:19 +03:00
Dmitry Petrov
660208740e PSI2IR KT-44013 WA: function interface constructor call accepted by FE 2021-04-27 17:35:37 +03:00
Ivan Kochurkin
704b5a0e13 [FIR] Implement UNDERSCORE_IS_RESERVED, UNDERSCORE_USAGE_WITHOUT_BACKTICKS diagnostics (lighttree) 2021-04-27 17:03:53 +03:00
Ivan Kochurkin
ea2d9f7c0c [FIR] Implement UNDERSCORE_IS_RESERVED, UNDERSCORE_USAGE_WITHOUT_BACKTICKS diagnostics (psi only) 2021-04-27 17:03:52 +03:00
Sergey Bogolepov
cc4adb798f Add cacheable targets for macos_arm64 host. 2021-04-27 13:47:20 +00:00
6883 changed files with 133731 additions and 33172 deletions

1
.gitignore vendored
View File

@@ -12,6 +12,7 @@
/android-studio/sdk
out/
/tmp
kotlin-ide/
workspace.xml
*.versionsBackup
/idea/testData/debugger/tinyApp/classes*

View File

@@ -1,5 +1,677 @@
# CHANGELOG
## 1.5.10
### Compiler
#### Fixes
- [`KT-41078`](https://youtrack.jetbrains.com/issue/KT-41078) Incorrect type substitution in contracts with type parameters
- [`KT-44770`](https://youtrack.jetbrains.com/issue/KT-44770) JVM / IR: "IllegalArgumentException: Unrecognized Type: [null]" Jackson doesn't recognize type
- [`KT-45084`](https://youtrack.jetbrains.com/issue/KT-45084) JVM IR: "NoSuchElementException: Sequence contains no element matching the predicate" when inline class is passed to lambda with >22 parameters
- [`KT-45779`](https://youtrack.jetbrains.com/issue/KT-45779) JVM / IR: java.lang.NoSuchMethodError: 'int java.lang.Integer.plus(int)' caused by function reference
- [`KT-45941`](https://youtrack.jetbrains.com/issue/KT-45941) JVM IR: local functions use generic type parameters of the outer class in the bytecode, which breaks Bytebuddy and MockK
- [`KT-46149`](https://youtrack.jetbrains.com/issue/KT-46149) Generate synthetic classes for SAM adapters with erased instead of generic supertype
- [`KT-46189`](https://youtrack.jetbrains.com/issue/KT-46189) JVM IR: tailrec function with capturing lambda in default parameter value leads to NoSuchMethodError at runtime
- [`KT-46214`](https://youtrack.jetbrains.com/issue/KT-46214) JVM / IR: "IllegalStateException: No mapping for symbol: VALUE_PARAMETER INSTANCE_RECEIVER" on a suspend function in an inner class
- [`KT-46238`](https://youtrack.jetbrains.com/issue/KT-46238) JVM IR: BootstrapMethodError in JDK 11+ on intersection type passed in arguments of SAM adapter where SAM interface's type parameter has a non-trivial upper bound
- [`KT-46259`](https://youtrack.jetbrains.com/issue/KT-46259) JVM IR: local function for adapted function reference is not declared as ACC_SYNTHETIC
- [`KT-46284`](https://youtrack.jetbrains.com/issue/KT-46284) JVM IR: "Unbound private symbol IrClassSymbol" on class reference to script class
- [`KT-46402`](https://youtrack.jetbrains.com/issue/KT-46402) IllegalAccessError: "CapturedLambdaInterpreter (in unnamed module @0x71b06418) cannot access class jdk.internal.org.objectweb.asm.Type" caused by inline function with a suspend parameter in Maven project
- [`KT-46408`](https://youtrack.jetbrains.com/issue/KT-46408) JVM IR: BootstrapMethodError due to missing bridge for subclass of generic Java interface
- [`KT-46426`](https://youtrack.jetbrains.com/issue/KT-46426) JVM IR: Corrupted .class file when passing Array constructor reference as (inline) lambda
- [`KT-46455`](https://youtrack.jetbrains.com/issue/KT-46455) OOM on parsing invalid code with string interpolation
- [`KT-46503`](https://youtrack.jetbrains.com/issue/KT-46503) JVM IR: "AssertionError: Unexpected variance in super type argument: out @1"
- [`KT-46505`](https://youtrack.jetbrains.com/issue/KT-46505) JVM IR: NullPointerException caused by a callable reference with nullable inline value class parameter
- [`KT-46512`](https://youtrack.jetbrains.com/issue/KT-46512) JVM / IR: NoSuchMethodError on SAM conversion of a function reference
- [`KT-46515`](https://youtrack.jetbrains.com/issue/KT-46515) IndexOutOfBoundsException: "Empty list doesn't contain element at index 0." on bad variable name in 1.5.0
- [`KT-46516`](https://youtrack.jetbrains.com/issue/KT-46516) JVM IR: "AnalyzerException: Expected I, but found R" on subclassing AbstractMutableList<Int>
- [`KT-46524`](https://youtrack.jetbrains.com/issue/KT-46524) Cannot use unsigned literals with api-version < 1.5 even with opt-in
- [`KT-46537`](https://youtrack.jetbrains.com/issue/KT-46537) JVM / IR: "IllegalStateException: No noarg super constructor for CLASS" caused by "No-arg" plugin with annotation on child class
- [`KT-46540`](https://youtrack.jetbrains.com/issue/KT-46540) JVM / IR: AnalyzerException: Expected an object reference, but found J caused by java.function.Supplier
- [`KT-46554`](https://youtrack.jetbrains.com/issue/KT-46554) JVM IR: "IllegalStateException: No mapping for symbol: VAR IR_TEMPORARY_VARIABLE" with value class constructor delegation call
- [`KT-46555`](https://youtrack.jetbrains.com/issue/KT-46555) JVM IR: IllegalAccessError when using Java method reference
- [`KT-46562`](https://youtrack.jetbrains.com/issue/KT-46562) Kotlin 1.5.0 generates non-serializable lambdas when they should be serializable
- [`KT-46568`](https://youtrack.jetbrains.com/issue/KT-46568) JVM IR: "AssertionError: IrCall expected inside JvmStatic wrapper" on compiling protected static function with return type Nothing inside companion object of abstract class
- [`KT-46574`](https://youtrack.jetbrains.com/issue/KT-46574) JVM / IR: ClassCastException caused by runBlocking awaiting call while returning Kotlin.Result type.
- [`KT-46579`](https://youtrack.jetbrains.com/issue/KT-46579) JVM IR: "IllegalArgumentException: Sequence contains more than one matching element" for Java enum with overloaded values() static method
- [`KT-46584`](https://youtrack.jetbrains.com/issue/KT-46584) JVM IR: Intrinsics.needClassReification (UnsupportedOperationException thrown). Property delegate provider crossinline lambda inlining/reification issue
- [`KT-46751`](https://youtrack.jetbrains.com/issue/KT-46751) JVM / IR:"ClassCastException: java.lang.String cannot be cast to java.lang.Void" in extension function in Kotlin 1.5
### IDE
- [`KT-45981`](https://youtrack.jetbrains.com/issue/KT-45981) failed to analyze: java.lang.AssertionError: diagnostic callback has been already registered: Code analysis get stuck in AS 2020.3.1.14 & Kotlin v1.5.0-M2
- [`KT-46622`](https://youtrack.jetbrains.com/issue/KT-46622) 60+ second freezes with Kotlin plugin 1.5.0: GetModuleInfoKt.findJvmStdlibAcrossDependencies
### IDE. Gradle Integration
- [`KT-46417`](https://youtrack.jetbrains.com/issue/KT-46417) [UNRESOLVED_REFERENCE] For project to project dependencies of native platform test source sets
### Libraries
- [`KT-46280`](https://youtrack.jetbrains.com/issue/KT-46280) JvmRecord annotation missing constructor in common
### Middle-end. IR
- [`KT-44013`](https://youtrack.jetbrains.com/issue/KT-44013) NPE: When calling constructor of a function type while inheriting from it, despite it's an interface
### Tools. Android Extensions
- [`KT-46590`](https://youtrack.jetbrains.com/issue/KT-46590) Kotlin Android Extensions 1.5.0 generates bad writeToParcel() method for nullable Array types
### Tools. Gradle
- [`KT-41142`](https://youtrack.jetbrains.com/issue/KT-41142) Kotlin version conflict when using Kotlin Gradle plugins in pre-compiled script plugin
- [`KT-46353`](https://youtrack.jetbrains.com/issue/KT-46353) Optimizations disabled in Gradle 7 for KAPT when generating sources
- [`KT-46368`](https://youtrack.jetbrains.com/issue/KT-46368) Memory leak with 1.5.0-RC when building with Gradle
- [`KT-46689`](https://youtrack.jetbrains.com/issue/KT-46689) Track -Xuse-old-backend flag usage
### Tools. Gradle. JS
- [`KT-46006`](https://youtrack.jetbrains.com/issue/KT-46006) KJS \ Gradle: Task without declaring an explicit or implicit dependency on `jsGenerateExternalsIntegrated` in Gradle 7
- [`KT-46162`](https://youtrack.jetbrains.com/issue/KT-46162) KJS: Exported items unavailable on dev server
- [`KT-46331`](https://youtrack.jetbrains.com/issue/KT-46331) KJS: With `kotlin.js.webpack.major.version=4` browserXRun tasks fail
### Tools. Parcelize
- [`KT-46567`](https://youtrack.jetbrains.com/issue/KT-46567) Kotlin 1.5.0 parcelize compilation fails in new backend when using TypeParceller with nested generics
### Tools. kapt
- [`KT-45532`](https://youtrack.jetbrains.com/issue/KT-45532) Do not create Kapt stubs directory during configuration time
## 1.5.0
### Backend. Native
- [`KT-42053`](https://youtrack.jetbrains.com/issue/KT-42053) Support compiler caches for linux_x64
- [`KT-43690`](https://youtrack.jetbrains.com/issue/KT-43690) Support compiler caches for ios_arm64
### Backend. IR
- [`KT-42684`](https://youtrack.jetbrains.com/issue/KT-42684) StackOverflowError on recursive inline arguments in inline fun
### Compiler
#### New Features
- [`KT-28791`](https://youtrack.jetbrains.com/issue/KT-28791) Kotlin serialization with inline classes
- [`KT-30222`](https://youtrack.jetbrains.com/issue/KT-30222) Support JVM target version selection in Kotlin bytecode tool window
- [`KT-41884`](https://youtrack.jetbrains.com/issue/KT-41884) Support 'file' target for JvmSynthetic annotation
- [`KT-43677`](https://youtrack.jetbrains.com/issue/KT-43677) Support for Java records
- [`KT-43920`](https://youtrack.jetbrains.com/issue/KT-43920) Support loading binary Java annotations on fields
- [`KT-44278`](https://youtrack.jetbrains.com/issue/KT-44278) Generate SAM-converted lambdas and function references using 'invokedynamic' on JDK 1.8+
- [`KT-44650`](https://youtrack.jetbrains.com/issue/KT-44650) Deprecate JVM target version 1.6
- [`KT-44787`](https://youtrack.jetbrains.com/issue/KT-44787) Suspend functions in fun interfaces
- [`KT-44865`](https://youtrack.jetbrains.com/issue/KT-44865) Allow to declare protected constructors in sealed classes
- [`KT-44869`](https://youtrack.jetbrains.com/issue/KT-44869) Compiling sealed interface with version less than 1.5: error message from future could be provided
#### Performance Improvements
- [`KT-6336`](https://youtrack.jetbrains.com/issue/KT-6336) Optimize generation of local functions
- [`KT-7307`](https://youtrack.jetbrains.com/issue/KT-7307) Optimize infix call of String.plus
- [`KT-18692`](https://youtrack.jetbrains.com/issue/KT-18692) Optimize '<optimizable_range> step x' for-in loop
- [`KT-19978`](https://youtrack.jetbrains.com/issue/KT-19978) Inefficient bytecode generated for function references undergoing Java SAM conversion
- [`KT-23565`](https://youtrack.jetbrains.com/issue/KT-23565) OperationsMapGenerated.kt generates unreasonable amount of bytecode
- [`KT-23825`](https://youtrack.jetbrains.com/issue/KT-23825) Tail suspend call utilizing elvis operator does not take advantage of suspend tail call optimization
- [`KT-23826`](https://youtrack.jetbrains.com/issue/KT-23826) A suspend function on the right side of a returned || condition is not tail call optimized
- [`KT-25348`](https://youtrack.jetbrains.com/issue/KT-25348) No compile time unsigned integer conversion when using hex literal
- [`KT-26060`](https://youtrack.jetbrains.com/issue/KT-26060) Support a compiler mode to compile lambda expressions using `invokedynamic` instruction
- [`KT-26590`](https://youtrack.jetbrains.com/issue/KT-26590) Do not generate create method for suspend lambdas if its arity >= 2
- [`KT-27427`](https://youtrack.jetbrains.com/issue/KT-27427) Optimize nullable check introduced with 'as' cast
- [`KT-28246`](https://youtrack.jetbrains.com/issue/KT-28246) Redundant boxing/unboxing isn't eliminated by the compiler in case of inline classes and javaClass intrinsic
- [`KT-30605`](https://youtrack.jetbrains.com/issue/KT-30605) Constant folding doesn't evaluate inv() function
- [`KT-36845`](https://youtrack.jetbrains.com/issue/KT-36845) Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR
- [`KT-39585`](https://youtrack.jetbrains.com/issue/KT-39585) JVM BE generates redundant accessor calls when accessing static final field lifted from companion
- [`KT-40886`](https://youtrack.jetbrains.com/issue/KT-40886) Old JVM BE unspills ACONST_NULL from continuation
- [`KT-42621`](https://youtrack.jetbrains.com/issue/KT-42621) Kotlin binary size considerably larger for code extensively using stream API
- [`KT-44153`](https://youtrack.jetbrains.com/issue/KT-44153) NI: Low Memory and IntelliJ hangs when quotes in split() are missed
- [`KT-45410`](https://youtrack.jetbrains.com/issue/KT-45410) JVM / IR: Extreme performance regression on arithmetic operations inside a loop
#### Fixes
- [`KT-6007`](https://youtrack.jetbrains.com/issue/KT-6007) Support changed return type of inlined generic function when lambda returns anonymous object
- [`KT-6055`](https://youtrack.jetbrains.com/issue/KT-6055) Failed invoke plus assign on array element accessed via several args through local get/set convention extensions
- [`KT-6879`](https://youtrack.jetbrains.com/issue/KT-6879) CompilationException when local classes hierarchy is placed within other local or inner declaration
- [`KT-8120`](https://youtrack.jetbrains.com/issue/KT-8120) NoSuchMethodError on local class constructor call inside a local class
- [`KT-8199`](https://youtrack.jetbrains.com/issue/KT-8199) "Cannot pop operand off an empty stack" for local class using a captured variable as default value for constructor parameter
- [`KT-10835`](https://youtrack.jetbrains.com/issue/KT-10835) "AssertionError: Non-outer parameter incorrectly mapped to outer" when inlining object literal extending inner class
- [`KT-12790`](https://youtrack.jetbrains.com/issue/KT-12790) Don't generate synthetic accessors for private inline function/properties
- [`KT-13213`](https://youtrack.jetbrains.com/issue/KT-13213) IllegalArgumentException in ByteVector.putUTF8 on attempt to compile file with moderately long string literal
- [`KT-14628`](https://youtrack.jetbrains.com/issue/KT-14628) "UnsupportedOperationException: Don't know how to generate outer expression" for nested class inheriting from inner class with a companion object
- [`KT-14833`](https://youtrack.jetbrains.com/issue/KT-14833) JVM internal error: Augment assignment and increment are not supported for local delegated properties and inline properties
- [`KT-15403`](https://youtrack.jetbrains.com/issue/KT-15403) Suspend operator get wrong code generated by BE (NoSuchMethodError)
- [`KT-15404`](https://youtrack.jetbrains.com/issue/KT-15404) Suspend operator set wrong code generated
- [`KT-16084`](https://youtrack.jetbrains.com/issue/KT-16084) Proguard can't find enclosing class of let closure inside apply closure
- [`KT-16151`](https://youtrack.jetbrains.com/issue/KT-16151) Internal compiler error when using plusAssign operator with mutable map
- [`KT-16221`](https://youtrack.jetbrains.com/issue/KT-16221) Support in/!in suspend operators
- [`KT-16282`](https://youtrack.jetbrains.com/issue/KT-16282) "Cannot pop operand off an empty stack" for plusAssign with default parameters in setter operator
- [`KT-16445`](https://youtrack.jetbrains.com/issue/KT-16445) `java.lang.VerifyError: Bad type on operand stack` when delegating an interface through a private reified function inside an object
- [`KT-16520`](https://youtrack.jetbrains.com/issue/KT-16520) Invalid bytecode semantics for set call by convention with default parameters
- [`KT-16567`](https://youtrack.jetbrains.com/issue/KT-16567) Inliner creates redundant objects on source inlining
- [`KT-16752`](https://youtrack.jetbrains.com/issue/KT-16752) Delegating function interface to function reference does not work
- [`KT-17554`](https://youtrack.jetbrains.com/issue/KT-17554) Incorrect cast to Unit generated on annotated when-expression with a single-branch if inside
- [`KT-17738`](https://youtrack.jetbrains.com/issue/KT-17738) Java cannot extend class implementing kotlin.collections.Map
- [`KT-17753`](https://youtrack.jetbrains.com/issue/KT-17753) Strange behavior of if and return statements
- [`KT-18583`](https://youtrack.jetbrains.com/issue/KT-18583) "ISE: Recursive call in a lazy value" for generic sealed class with nested subclass in a `when(this)` with inferred return type
- [`KT-19861`](https://youtrack.jetbrains.com/issue/KT-19861) "IllegalStateException: Label wasn't found during iterating through instructions" for `plusAssign` with safe call
- [`KT-20306`](https://youtrack.jetbrains.com/issue/KT-20306) Make 'when' over an 'expect' enum class non-exhaustive
- [`KT-20869`](https://youtrack.jetbrains.com/issue/KT-20869) kotlin.jvm.internal.DefaultConstructorMarker should be public
- [`KT-20996`](https://youtrack.jetbrains.com/issue/KT-20996) IllegalStateException: Cannot get FQ name of local class: class <no name provided> in metadata serialization for common code
- [`KT-21014`](https://youtrack.jetbrains.com/issue/KT-21014) Incorrect bytecode generated for 'PrimitiveArray::size'
- [`KT-21092`](https://youtrack.jetbrains.com/issue/KT-21092) Reference `javaClass` for generic property: "couldn't transform method node: get()"
- [`KT-21778`](https://youtrack.jetbrains.com/issue/KT-21778) "IllegalStateException: Couldn't build context" for inline function inside an anonymous object
- [`KT-21900`](https://youtrack.jetbrains.com/issue/KT-21900) VerifyError on equals on generic primitive type
- [`KT-22098`](https://youtrack.jetbrains.com/issue/KT-22098) "UnsupportedOperationException: Don't know how to generate outer expression" on extension function call inside lambda in anonymous object super constructor call
- [`KT-22488`](https://youtrack.jetbrains.com/issue/KT-22488) Bad line numbers generated for '&&' expression
- [`KT-22972`](https://youtrack.jetbrains.com/issue/KT-22972) A compiler bug(?) in Number class descendants
- [`KT-23619`](https://youtrack.jetbrains.com/issue/KT-23619) Transform stateless singleton lambda during inline
- [`KT-23881`](https://youtrack.jetbrains.com/issue/KT-23881) Declaration of lambda in inlined apply block holds reference to superfluous references causing leak
- [`KT-24135`](https://youtrack.jetbrains.com/issue/KT-24135) Calling invoke on crossinline suspend lambda leads to no state-machine
- [`KT-24193`](https://youtrack.jetbrains.com/issue/KT-24193) NoClassDefFoundError: java/lang/Cloneable$DefaultImpls on inheritance from Cloneable through an interface
- [`KT-24305`](https://youtrack.jetbrains.com/issue/KT-24305) ClassNotFoundException when using Java reflection on local class in an inlined lambda
- [`KT-24564`](https://youtrack.jetbrains.com/issue/KT-24564) Custom operator fun set on ByteArray resolves properly but is miscompiled
- [`KT-25400`](https://youtrack.jetbrains.com/issue/KT-25400) "NoClassDefFoundError: kotlin/KotlinPackage" with Turkish system locale on macOS
- [`KT-26130`](https://youtrack.jetbrains.com/issue/KT-26130) Incorrect method signature for a generic function with inline class as a type parameter upper bound
- [`KT-26360`](https://youtrack.jetbrains.com/issue/KT-26360) "Method from super interface has a different signature" for Interface that extends both interfaces with and without @JvmDefault
- [`KT-26473`](https://youtrack.jetbrains.com/issue/KT-26473) Error on compiling inline class with calls of super methods equals(), hashCode(), toString()
- [`KT-26474`](https://youtrack.jetbrains.com/issue/KT-26474) VE “Bad type on operand stack” at runtime on calling toString() method of inline class with calls of super methods (toString(), equals(), hashCode()) inside
- [`KT-26592`](https://youtrack.jetbrains.com/issue/KT-26592) Do not generate private suspend functions as synthetic package-private
- [`KT-27449`](https://youtrack.jetbrains.com/issue/KT-27449) NoSuchMethodError for local suspend function with suspend lambda parameter with default value
- [`KT-27469`](https://youtrack.jetbrains.com/issue/KT-27469) "Cannot pop operand off an empty stack" for compound assignment (plusAssign) with a `vararg` operator get
- [`KT-27825`](https://youtrack.jetbrains.com/issue/KT-27825) Gradually prohibit non-abstract classes containing abstract members invisible from that classes (internal/package-private)
- [`KT-27830`](https://youtrack.jetbrains.com/issue/KT-27830) "Incompatible stack heights" with suspend inline function in do while loop that executes suspend lambda
- [`KT-28042`](https://youtrack.jetbrains.com/issue/KT-28042) "Cannot pop operand off an empty stack" for a bound callable reference of lambda inside inline function
- [`KT-28166`](https://youtrack.jetbrains.com/issue/KT-28166) "Argument 1: expected I, but found R" for generic method with generic parameter or receiver with inline class upper bound
- [`KT-28331`](https://youtrack.jetbrains.com/issue/KT-28331) Consider generating accessors for lateinit properties to avoid assertion on each call
- [`KT-28573`](https://youtrack.jetbrains.com/issue/KT-28573) Inliner does not update references to transformed object
- [`KT-29331`](https://youtrack.jetbrains.com/issue/KT-29331) "AnalyzerException: Argument 1: expected R, but found I" with local generic extension property called on `Int` receiver
- [`KT-29595`](https://youtrack.jetbrains.com/issue/KT-29595) NoClassDefFoundError with inline reified function with lambda argument returning anonymous object
- [`KT-29802`](https://youtrack.jetbrains.com/issue/KT-29802) Incorrect reification when the same type parameter name is used for different reified types
- [`KT-30041`](https://youtrack.jetbrains.com/issue/KT-30041) "AnalyzerException: Expected an object reference, but found ." on nested suspend function calls outer suspend function
- [`KT-30066`](https://youtrack.jetbrains.com/issue/KT-30066) Consider adding annotations to ConeKotlinType
- [`KT-30280`](https://youtrack.jetbrains.com/issue/KT-30280) Inline class class literal gets unwrapped in annotation arguments
- [`KT-30402`](https://youtrack.jetbrains.com/issue/KT-30402) Constant folding works incorrectly with unsigned arithmetics
- [`KT-30548`](https://youtrack.jetbrains.com/issue/KT-30548) "java.lang.IndexOutOfBoundsException: Cannot pop operand off an empty stack" while compiling access to a private lateinit companion field
- [`KT-30629`](https://youtrack.jetbrains.com/issue/KT-30629) `java.lang.VerifyError: Bad type on operand stack` when using a function reference to a generic property
- [`KT-30933`](https://youtrack.jetbrains.com/issue/KT-30933) Inline function produces IllegalAccessError on property reference from different package
- [`KT-31136`](https://youtrack.jetbrains.com/issue/KT-31136) "AnalyzerException: Argument 1: expected R, but found I" on x::javaClass when x is inline class object built around primitive type
- [`KT-31227`](https://youtrack.jetbrains.com/issue/KT-31227) Prohibit using array based on non-reified type parameters as reified type arguments on JVM
- [`KT-31592`](https://youtrack.jetbrains.com/issue/KT-31592) NoSuchMethodException when inlining public function accessing a protected static Java class member
- [`KT-31727`](https://youtrack.jetbrains.com/issue/KT-31727) Object expression captures all variables used in constructor
- [`KT-32023`](https://youtrack.jetbrains.com/issue/KT-32023) "AnalyzerException: Expected I, but found R" with inline suspend function used with callable reference
- [`KT-32115`](https://youtrack.jetbrains.com/issue/KT-32115) NPE during initialization of enum class with delegated property
- [`KT-32153`](https://youtrack.jetbrains.com/issue/KT-32153) "AnalyzerException: Expected an object reference, but found ." with recursive suspend local function
- [`KT-32351`](https://youtrack.jetbrains.com/issue/KT-32351) ClassNotFoundException for anonymous object implementing interface inside a lambda with data class and inline methods
- [`KT-32384`](https://youtrack.jetbrains.com/issue/KT-32384) Safe cast to generic type argument with inline class upper-bound throws NPE instead of ClassCastException
- [`KT-32579`](https://youtrack.jetbrains.com/issue/KT-32579) java.lang.VerifyError: Bad type on operand stack on calling inner class of inherited class in super class when casting to inherited class
- [`KT-32749`](https://youtrack.jetbrains.com/issue/KT-32749) "VerifyError: Call to wrong <init> method" with inline function and accessing class field from anonymous object
- [`KT-32793`](https://youtrack.jetbrains.com/issue/KT-32793) Generated code crashes by ClassCastException with local suspend function and inline class
- [`KT-32812`](https://youtrack.jetbrains.com/issue/KT-32812) "AnalyzerException: Argument 1: expected R, but found I" invoking function with default parameter inherited by inline class
- [`KT-32821`](https://youtrack.jetbrains.com/issue/KT-32821) Missing unboxing of inline class for complex hierarchy of suspend calls
- [`KT-33155`](https://youtrack.jetbrains.com/issue/KT-33155) ClassNotFoundException for qualified this in anonymous object and as a result of inline function call
- [`KT-33173`](https://youtrack.jetbrains.com/issue/KT-33173) Internal error: "AnalyzerException: Expected I, but found R" for supercall inside inline lambda from HashSet.remove implementation
- [`KT-33577`](https://youtrack.jetbrains.com/issue/KT-33577) NoSuchFieldError with nested anonymous objects accessing outer instance property
- [`KT-33836`](https://youtrack.jetbrains.com/issue/KT-33836) Wrong code generated for a local tailrec suspend function.
- [`KT-33873`](https://youtrack.jetbrains.com/issue/KT-33873) ClassCastException invoking UByte setter function via reflection
- [`KT-34018`](https://youtrack.jetbrains.com/issue/KT-34018) "Cannot pop operand off an empty stack" with inline lambda with callable reference
- [`KT-34186`](https://youtrack.jetbrains.com/issue/KT-34186) JDK11: class file contains malformed variable arity method for vararg sealed class constructor
- [`KT-34202`](https://youtrack.jetbrains.com/issue/KT-34202) IllegalAccessError on callable reference of function from multifile facade from standard library
- [`KT-34255`](https://youtrack.jetbrains.com/issue/KT-34255) @JvmStatic tailrec function: "Cannot pop operand off an empty stack"
- [`KT-34507`](https://youtrack.jetbrains.com/issue/KT-34507) Incorrect generated code for mutable collection stub methods in case of presence of functions with similar signature
- [`KT-34665`](https://youtrack.jetbrains.com/issue/KT-34665) Possible index overflow in optimized "for" loop over withIndex()
- [`KT-34754`](https://youtrack.jetbrains.com/issue/KT-34754) Flow builder: "AnalyzerException: Expected an object reference, but found ." with recursive suspend local function
- [`KT-34816`](https://youtrack.jetbrains.com/issue/KT-34816) "AnalyzerException: Expected an object reference, but found I" on "this" in inline class member extension suspend function
- [`KT-34841`](https://youtrack.jetbrains.com/issue/KT-34841) ClassNotFoundException when invoke param function inside anonymous object method
- [`KT-35008`](https://youtrack.jetbrains.com/issue/KT-35008) "AnalyzerException: Expected an object reference, but found I" in inline class companion calling private constructor
- [`KT-35166`](https://youtrack.jetbrains.com/issue/KT-35166) `NoSuchMethodError` at runtime with local property delegate on anonymous object referencing another anonymous object
- [`KT-35224`](https://youtrack.jetbrains.com/issue/KT-35224) It's possible to pass non-spread arrays after arguments with SAM-conversion
- [`KT-35301`](https://youtrack.jetbrains.com/issue/KT-35301) MethodInliner fails with "AssertionError: <init> call doesn't correspond to object transformation info" for qualified this in SAM constructor used as parameter of anonymous object inside inline lambda
- [`KT-35419`](https://youtrack.jetbrains.com/issue/KT-35419) `Failed to generate expression: KtNamedFunction` for local suspend tailrec function with receiver
- [`KT-35511`](https://youtrack.jetbrains.com/issue/KT-35511) VerifyError: "Bad type on operand stack" after reification
- [`KT-35553`](https://youtrack.jetbrains.com/issue/KT-35553) Kotlin compiler generates methods that always have line number 1 for Inline Classes
- [`KT-35725`](https://youtrack.jetbrains.com/issue/KT-35725) "AssertionError: Couldn't find a context for a super-call" for `super` member call in property initializer of companion object
- [`KT-36420`](https://youtrack.jetbrains.com/issue/KT-36420) ClassCastException with inline class Foo extending generic Comparable<Foo>
- [`KT-36713`](https://youtrack.jetbrains.com/issue/KT-36713) AnalyzerException: "Incompatible stack heights" with suspend and inline suspend functions
- [`KT-36794`](https://youtrack.jetbrains.com/issue/KT-36794) Move $assertionsDisabled field to the top-level class
- [`KT-36853`](https://youtrack.jetbrains.com/issue/KT-36853) IR: UninitializedPropertyAccessException on tailrec with object expression in default argument
- [`KT-36875`](https://youtrack.jetbrains.com/issue/KT-36875) "RuntimeException: Trying to access skipped parameter" on synthetic local variable access from inline function
- [`KT-36916`](https://youtrack.jetbrains.com/issue/KT-36916) AnalyzerException: Argument 1: expected I, but found R when using inline class with rxjava
- [`KT-36957`](https://youtrack.jetbrains.com/issue/KT-36957) Exception during codegen: cannot pop operand off an empty stack (Nothing variable in string interpolation)
- [`KT-36984`](https://youtrack.jetbrains.com/issue/KT-36984) SAM adapter classes should be generated as anonymous inner classes in JVM_IR
- [`KT-37704`](https://youtrack.jetbrains.com/issue/KT-37704) Incorrect SMAP syntax
- [`KT-37716`](https://youtrack.jetbrains.com/issue/KT-37716) "AssertionError: <init> call doesn't correspond to object transformation info" with inline reified type parameter, anonymous object and lambda in constructor call
- [`KT-37972`](https://youtrack.jetbrains.com/issue/KT-37972) IllegalAccessError on initializing property reference for a property declared in JvmMultifileClass with -Xmultifile-parts-inherit
- [`KT-38100`](https://youtrack.jetbrains.com/issue/KT-38100) Support local delegated properties (not inlined) in new JVM default modes
- [`KT-38833`](https://youtrack.jetbrains.com/issue/KT-38833) JVM: java.lang.ClassCastException when loop variable is nullable in for loop over unsigned progression
- [`KT-38849`](https://youtrack.jetbrains.com/issue/KT-38849) Read-only variable initialized in non-inline lambda using contract callsInPlace EXACTLY_ONCE is not captured correctly in nested lambdas
- [`KT-38869`](https://youtrack.jetbrains.com/issue/KT-38869) JVM BE produces invalid bytecode when inheriting from AbstractList and declaring methods that look like MutableList implementors (but they aren't)
- [`KT-38965`](https://youtrack.jetbrains.com/issue/KT-38965) "UnsupportedOperationException: Don't know how to generate outer expression: Closure" with reference to local variable in block argument of anonymous object `by` delegation
- [`KT-39289`](https://youtrack.jetbrains.com/issue/KT-39289) CCE in if-else inside annotated 'if' statement
- [`KT-39425`](https://youtrack.jetbrains.com/issue/KT-39425) AbstractMethodError: "Receiver class does not define or inherit an implementation of the resolved method" using classes with complex Java and Kotlin inheritance hierarchies.
- [`KT-39434`](https://youtrack.jetbrains.com/issue/KT-39434) IllegalAccessError with local delegated property in lambda in inlined function
- [`KT-39687`](https://youtrack.jetbrains.com/issue/KT-39687) "Couldn't find captured this" when more than 3 inline functions are nested
- [`KT-39784`](https://youtrack.jetbrains.com/issue/KT-39784) "IndexOutOfBoundsException: Cannot pop operand off an empty stack" caused by JvmOverloads annotation inside an inline class
- [`KT-40165`](https://youtrack.jetbrains.com/issue/KT-40165) ClassCastException caused by SAM conversion used on a functional interface with suspended function
- [`KT-40179`](https://youtrack.jetbrains.com/issue/KT-40179) "VerifyError: Bad type on operand stack" with parent class `get` extension function and child class `set` extension function which used inside child class `plusAssign` extension function
- [`KT-40277`](https://youtrack.jetbrains.com/issue/KT-40277) Fix generic types in special bridge methods
- [`KT-40308`](https://youtrack.jetbrains.com/issue/KT-40308) NoSuchFieldError for multiple delegated extension properties with the same name in a companion object
- [`KT-40338`](https://youtrack.jetbrains.com/issue/KT-40338) NoSuchFieldError on property without backing field that is called as function reference
- [`KT-40392`](https://youtrack.jetbrains.com/issue/KT-40392) Deprecate JvmDefault annotation and old -Xjvm-default modes
- [`KT-40396`](https://youtrack.jetbrains.com/issue/KT-40396) NI: Exceptions when ambiguous type argument and generic invoke
- [`KT-40510`](https://youtrack.jetbrains.com/issue/KT-40510) "AssertionError: DELEGATION slice must override something" for ByteBuffer delegation
- [`KT-40601`](https://youtrack.jetbrains.com/issue/KT-40601) VerifyError: "interface method reference is in an indirect superinterface" when calling @JvmDefault suspend method
- [`KT-40809`](https://youtrack.jetbrains.com/issue/KT-40809) "Couldn't find captured field" compiler error with local function with recursive call through method reference
- [`KT-41056`](https://youtrack.jetbrains.com/issue/KT-41056) Increase stub version due to new "contract" keyword
- [`KT-41105`](https://youtrack.jetbrains.com/issue/KT-41105) IllegalStateException: 'Couldn't find declaration file <class name>' with inline delegate declared in another file
- [`KT-41165`](https://youtrack.jetbrains.com/issue/KT-41165) "IllegalStateException: Concrete fake override public final fun" when an enum class inherits an interface with a variable 'name' or 'ordinal'
- [`KT-41222`](https://youtrack.jetbrains.com/issue/KT-41222) "IllegalStateException: Concrete fake override public final fun" when a class property is inherited as merged 'var' from 'val' and 'var' from parent abstract class and interface properties
- [`KT-41255`](https://youtrack.jetbrains.com/issue/KT-41255) JDK 11: "VerifyError: Bad type on operand stack" with long function body with annotated `when` expression
- [`KT-41427`](https://youtrack.jetbrains.com/issue/KT-41427) NoSuchMethodError caused by implementation by delegation to function reference
- [`KT-41508`](https://youtrack.jetbrains.com/issue/KT-41508) ClassNotFoundException caused by object with overridden function inside a lambda with safe cast receiver
- [`KT-41750`](https://youtrack.jetbrains.com/issue/KT-41750) Inline classes: ClassCastExceptionError when calling .withIndex() on Iterator over Array
- [`KT-41758`](https://youtrack.jetbrains.com/issue/KT-41758) Deprecate kotlin.Metadata.bytecodeVersion and avoid using it in the compiler
- [`KT-41770`](https://youtrack.jetbrains.com/issue/KT-41770) AssertionError: "Asm parameter types should be the same length as Kotlin parameter types" cause by fun interface
- [`KT-41874`](https://youtrack.jetbrains.com/issue/KT-41874) "IllegalStateException: Couldn't obtain compiled function body" on extension delegated property with inline operator getValue in a different file
- [`KT-41917`](https://youtrack.jetbrains.com/issue/KT-41917) [FIR] Incorrect calculating property type for override from intersection scope
- [`KT-42012`](https://youtrack.jetbrains.com/issue/KT-42012) IllegalAccess to protected field instead of getter
- [`KT-42017`](https://youtrack.jetbrains.com/issue/KT-42017) "AssertionError: Unsigned type expected: UInt?" during codegen when a variable of nullable unsigned type is checking for presence in the range
- [`KT-42032`](https://youtrack.jetbrains.com/issue/KT-42032) "AnalyzerException: Expected I, but found R" while using Flow.reduce() with suspend function reference
- [`KT-42034`](https://youtrack.jetbrains.com/issue/KT-42034) ArrayIndexOutOfBoundsException in PopBackwardPropagationTransformer on external override of function in inline class
- [`KT-42064`](https://youtrack.jetbrains.com/issue/KT-42064) "Parameter specified as non-null is null" with default value of the parameter in operator fun
- [`KT-42069`](https://youtrack.jetbrains.com/issue/KT-42069) JVM IR: -Xreport-output-files doesn't report any source files for META-INF/*.kotlin_module files
- [`KT-42083`](https://youtrack.jetbrains.com/issue/KT-42083) AbstractMethodError when 'remove' with irrelevant generic parameter but matching JVM signature is present in Kotlin collection class
- [`KT-42092`](https://youtrack.jetbrains.com/issue/KT-42092) JVM / IR: "AnalyzerException: Argument 1: expected R, but found J" when trying to add to ArrayList the result of a function applied to int
- [`KT-42175`](https://youtrack.jetbrains.com/issue/KT-42175) Psi2ir: "AssertionError: Undefined parameter referenced: <this>" on augmented assignment on this in a BuilderInference lambda
- [`KT-42179`](https://youtrack.jetbrains.com/issue/KT-42179) Platform declaration clash when extending abstract Java class implementing 'java.util.Collection' by abstract Kotlin class implementing Kotlin Set or List
- [`KT-42321`](https://youtrack.jetbrains.com/issue/KT-42321) JVM IR: do not cast integer value based on the type of a literal receiver of an operator call
- [`KT-42337`](https://youtrack.jetbrains.com/issue/KT-42337) NoSuchMethodError in JVM backend with inheritance of private functions in the interface
- [`KT-42404`](https://youtrack.jetbrains.com/issue/KT-42404) "Supertypes of the following classes cannot be resolved" in Rider project
- [`KT-42472`](https://youtrack.jetbrains.com/issue/KT-42472) No TYPE_INFERENCE_UPPER_BOUND_VIOLATED for Delegated Properties do not check types (in Kotlin 1.4.10)
- [`KT-42487`](https://youtrack.jetbrains.com/issue/KT-42487) "IndexOutOfBoundsException: Cannot pop operand off an empty stack" caused by USELESS_IS_CHECK of Double type
- [`KT-42533`](https://youtrack.jetbrains.com/issue/KT-42533) `(N until MIN_VALUE).reversed()` should be an empty progression in for loops
- [`KT-42588`](https://youtrack.jetbrains.com/issue/KT-42588) "IllegalStateException: Concrete fake override public open fun" caused by `val` override with `var` with delegation.
- [`KT-42634`](https://youtrack.jetbrains.com/issue/KT-42634) Different bridges and abstract stubs behavior in abstract class implementing Map<K, String> in JVM and JVM_IR
- [`KT-42635`](https://youtrack.jetbrains.com/issue/KT-42635) ClassCastException with inline class in for loop
- [`KT-42662`](https://youtrack.jetbrains.com/issue/KT-42662) AbstractMethodError when using partially specialized generic Map class
- [`KT-42694`](https://youtrack.jetbrains.com/issue/KT-42694) @get:Synchronized causes the JVM getter method not to be generated
- [`KT-42753`](https://youtrack.jetbrains.com/issue/KT-42753) "VerifyError: Bad invokespecial instruction: interface method reference is in an indirect superinterface" with `jvm-default=all`
- [`KT-42879`](https://youtrack.jetbrains.com/issue/KT-42879) JVM: Declaration clash in fun interface implementation returning an inline class
- [`KT-42900`](https://youtrack.jetbrains.com/issue/KT-42900) "VerifyError: Bad return type" incorrect bytecode when a property and an extension property in inline class have the same names
- [`KT-42946`](https://youtrack.jetbrains.com/issue/KT-42946) FIR2IR: Fix super-calls to Java overrides of special built-in
- [`KT-42971`](https://youtrack.jetbrains.com/issue/KT-42971) JVM: "AssertionError: Unsigned type expected: T" with UInt loop range
- [`KT-42990`](https://youtrack.jetbrains.com/issue/KT-42990) "AssertionError: Next value after NEW should be one generated by DUP" caused by extension properties with accessors annotataed as @JvmStatic
- [`KT-43034`](https://youtrack.jetbrains.com/issue/KT-43034) AssertionError: Compiler fails with complicated tailrec + inline case
- [`KT-43048`](https://youtrack.jetbrains.com/issue/KT-43048) JVM_IR: Implement coroutines state clearing
- [`KT-43050`](https://youtrack.jetbrains.com/issue/KT-43050) JVM IR: incorrect mangling for method with type parameter with inline class bound in the signature
- [`KT-43059`](https://youtrack.jetbrains.com/issue/KT-43059) Different bridges behavior in class implementing Map<String, String> in JVM and JVM_IR
- [`KT-43063`](https://youtrack.jetbrains.com/issue/KT-43063) Redundant DefaultImpls delegate is generated in old JVM backend on explicit "duplicate" inheritance from interface
- [`KT-43069`](https://youtrack.jetbrains.com/issue/KT-43069) JVM: incorrect generic signature for method with implicit return type Nothing overriding a method from Collection
- [`KT-43099`](https://youtrack.jetbrains.com/issue/KT-43099) Tailrec call in not tail-call position leads to internal compiler error
- [`KT-43106`](https://youtrack.jetbrains.com/issue/KT-43106) JVM: custom `remove` in Iterator subclass results in a synthetic bridge
- [`KT-43120`](https://youtrack.jetbrains.com/issue/KT-43120) JVM: "Expected an object reference, but found ." caused by function which is passed as reference to suspend parameter
- [`KT-43167`](https://youtrack.jetbrains.com/issue/KT-43167) JVM IR, serialization: "No mapping for symbol: VALUE_PARAMETER INSTANCE_RECEIVER" with data class containing property defined in body
- [`KT-43255`](https://youtrack.jetbrains.com/issue/KT-43255) Verify error when inheriting from an abstract class implementing Collection with stub-like method in superclass
- [`KT-43303`](https://youtrack.jetbrains.com/issue/KT-43303) NI: False negative TYPE_INFERENCE_UPPER_BOUND_VIOLATED when inferred type argument is not a subtype of type parameter upper bound
- [`KT-43333`](https://youtrack.jetbrains.com/issue/KT-43333) AbstractMethodError when calling 'toArray' from Java on a Kotlin Collection with custom internal 'toArray'
- [`KT-43334`](https://youtrack.jetbrains.com/issue/KT-43334) AbstractMethodError when calling 'remove' from Java on a Kotlin Collection with custom internal 'remove'
- [`KT-43342`](https://youtrack.jetbrains.com/issue/KT-43342) [FIR2IR] No getter or backing field found for delegated member call
- [`KT-43347`](https://youtrack.jetbrains.com/issue/KT-43347) [FIR] Synthetic setter with unmatched parameter type isn't found
- [`KT-43401`](https://youtrack.jetbrains.com/issue/KT-43401) JVM_IR. Additional `synchronized` flag on JvmOverloads-generated adapter for Synchronized function
- [`KT-43405`](https://youtrack.jetbrains.com/issue/KT-43405) Turkish locale, Linux Mint: "NoSuchMethodError: 'int[] kotlin.jvm.internal.Intrinsics$Kotlin.intArrayOf(int[])'" with `intArrayOf` function call
- [`KT-43460`](https://youtrack.jetbrains.com/issue/KT-43460) JVM: redundant private setter is generated in case of multifile facade
- [`KT-43473`](https://youtrack.jetbrains.com/issue/KT-43473) "VerifyError: Bad type on operand stack" caused by operator `get` with optional argument in superclass when called via square brackets on subclass
- [`KT-43518`](https://youtrack.jetbrains.com/issue/KT-43518) JVM_IR. Additional `strictfp` flag on JvmOverloads-generated adapter for Strictfp function
- [`KT-43569`](https://youtrack.jetbrains.com/issue/KT-43569) FIR: inapplicable candidate(s): kotlin/collections/set
- [`KT-43616`](https://youtrack.jetbrains.com/issue/KT-43616) [FIR] Nullable type parameter-based type after merge in if
- [`KT-43669`](https://youtrack.jetbrains.com/issue/KT-43669) FIR: No real overrides for FUN IR_EXTERNAL_DECLARATION_STUB
- [`KT-43682`](https://youtrack.jetbrains.com/issue/KT-43682) Inline extension method of a multifile library inline class not found
- [`KT-43687`](https://youtrack.jetbrains.com/issue/KT-43687) FIR: UnusedChecker does not take annotation arguments into account
- [`KT-43688`](https://youtrack.jetbrains.com/issue/KT-43688) FIR: unused checker doesn't handle invokes properly
- [`KT-43749`](https://youtrack.jetbrains.com/issue/KT-43749) "UnsupportedOperationException: Don't know how to generate outer expression: Closure" caused by Flow and collect method with function reference as a parameter
- [`KT-43812`](https://youtrack.jetbrains.com/issue/KT-43812) JVM IR: SAM wrapper class with generic supertype mentions missing type parameter in the signature
- [`KT-43832`](https://youtrack.jetbrains.com/issue/KT-43832) JVM IR: missing bridges for inheritance of class from interface in a complex generic diamond hierarchy
- [`KT-43851`](https://youtrack.jetbrains.com/issue/KT-43851) JVM IR: function call returning object instance is removed during constant propagation
- [`KT-43864`](https://youtrack.jetbrains.com/issue/KT-43864) JVM: "Assertion error after mandatory stack transformations: incorrect bytecode" with lateinit property of type T, which has a primitive type upperbound
- [`KT-43887`](https://youtrack.jetbrains.com/issue/KT-43887) Problem with FunctionReferenceLowering$FunctionReferenceBuilder in kotlin native
- [`KT-43912`](https://youtrack.jetbrains.com/issue/KT-43912) JVM internal error: Augment assignment and increment are not supported for local delegated properties and inline properties
- [`KT-43915`](https://youtrack.jetbrains.com/issue/KT-43915) Back-end (JVM) Internal error: wrong bytecode generated for default method
- [`KT-43938`](https://youtrack.jetbrains.com/issue/KT-43938) NSME when calling 'kotlin.Number' methods on instance of Java class extending Kolin abstract class extending 'kotlin.Number'
- [`KT-43942`](https://youtrack.jetbrains.com/issue/KT-43942) org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate function
- [`KT-43949`](https://youtrack.jetbrains.com/issue/KT-43949) FIR: unresolved callable reference as lambda return
- [`KT-43983`](https://youtrack.jetbrains.com/issue/KT-43983) IllegalStateException: "Couldn't obtain compiled function body for public final suspend inline fun" after moving inline extension function to library
- [`KT-43984`](https://youtrack.jetbrains.com/issue/KT-43984) FIR: recursion in overridden symbols
- [`KT-43984`](https://youtrack.jetbrains.com/issue/KT-43984) FIR: recursion in overridden symbols
- [`KT-44010`](https://youtrack.jetbrains.com/issue/KT-44010) FIR: Inapplicable constructor due to an unresolved reference
- [`KT-44030`](https://youtrack.jetbrains.com/issue/KT-44030) FIR2IR: uncached type parameters in delegated property
- [`KT-44032`](https://youtrack.jetbrains.com/issue/KT-44032) FIR2IR: uncached type parameters in Java field
- [`KT-44050`](https://youtrack.jetbrains.com/issue/KT-44050) FIR: anonymous object as IR parent
- [`KT-44054`](https://youtrack.jetbrains.com/issue/KT-44054) FIR2IR: incorrect IR origin for substituted override function
- [`KT-44058`](https://youtrack.jetbrains.com/issue/KT-44058) CompilationException: open suspend fun with @JvmStatic in open class companion
- [`KT-44069`](https://youtrack.jetbrains.com/issue/KT-44069) please remove deprecated usages
- [`KT-44066`](https://youtrack.jetbrains.com/issue/KT-44066) FIR Java: override ambiguity with vararg value type
- [`KT-44114`](https://youtrack.jetbrains.com/issue/KT-44114) CompilationException when inlining a extension suspend function declared in interface companion with 'this' reference to extension receiver
- [`KT-44131`](https://youtrack.jetbrains.com/issue/KT-44131) "UnsupportedOperationException: Don't know how to generate outer expression: Closure" when using suspend lambda and a function reference
- [`KT-44140`](https://youtrack.jetbrains.com/issue/KT-44140) JVM IR: compilation of kotlin.Result crashes with IOOBE while generating toString-impl
- [`KT-44141`](https://youtrack.jetbrains.com/issue/KT-44141) JVM IR: "ISE: There should be underlying type for inline class type" on usage of type parameter with Result upper bound inside a lambda
- [`KT-44192`](https://youtrack.jetbrains.com/issue/KT-44192) Allow a greater number of constants in an enum class
- [`KT-44202`](https://youtrack.jetbrains.com/issue/KT-44202) "ClassCastException" when getting delegated property with inline class and Any/Any? type
- [`KT-44210`](https://youtrack.jetbrains.com/issue/KT-44210) KJS / IR: "AssertionError: Undefined parameter referenced: <this> defined" caused by plus assign operators in build blocks
- [`KT-44233`](https://youtrack.jetbrains.com/issue/KT-44233) [IR] Collection Stub generation not correctly considering java.util Collection iterators
- [`KT-44234`](https://youtrack.jetbrains.com/issue/KT-44234) Private companion property with explicit setter generates invalid bytecode
- [`KT-44269`](https://youtrack.jetbrains.com/issue/KT-44269) "[TAILREC_ON_VIRTUAL_MEMBER_ERROR] Tailrec is not allowed on open members" with Spring annotation and private tailrec function
- [`KT-44284`](https://youtrack.jetbrains.com/issue/KT-44284) Make Kotlin binaries publicly unavailable (set KotlinCompilerVersion.IS_PRE_RELEASE = true)
- [`KT-44316`](https://youtrack.jetbrains.com/issue/KT-44316) ReenteringLazyValueComputationException when analyzing complex lazy delegate
- [`KT-44347`](https://youtrack.jetbrains.com/issue/KT-44347) Back-end (JVM) Internal error: Couldn't transform method node for suspend function with wrong local for Continuation
- [`KT-44368`](https://youtrack.jetbrains.com/issue/KT-44368) "IllegalStateException: Error type encountered" when inlining 'invoke' operator without enough information on type variable
- [`KT-44412`](https://youtrack.jetbrains.com/issue/KT-44412) JVM IR backend fails to compile break in condition of do while
- [`KT-44420`](https://youtrack.jetbrains.com/issue/KT-44420) False NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATION with 1.4.30-RC
- [`KT-44429`](https://youtrack.jetbrains.com/issue/KT-44429) JVM IR: unnecessary integer unboxing leads to NPE when using mockito-kotlin
- [`KT-44439`](https://youtrack.jetbrains.com/issue/KT-44439) Type inference of generic types failing java interop
- [`KT-44440`](https://youtrack.jetbrains.com/issue/KT-44440) Too many Nothings in inferred type
- [`KT-44471`](https://youtrack.jetbrains.com/issue/KT-44471) Fix failing script tests after switching to 1.5
- [`KT-44474`](https://youtrack.jetbrains.com/issue/KT-44474) Compiler expects sealed type inheritors from platform specific source-sets in when expression in common source-set
- [`KT-44483`](https://youtrack.jetbrains.com/issue/KT-44483) JVM IR: CCE on calling generic vararg function reference with Array expected type
- [`KT-44527`](https://youtrack.jetbrains.com/issue/KT-44527) Suspend function with kotlin.Result: ClassCastException class kotlin.Result cannot be cast to class ...
- [`KT-44529`](https://youtrack.jetbrains.com/issue/KT-44529) Inline class calls wrong iterator method in for loop
- [`KT-44533`](https://youtrack.jetbrains.com/issue/KT-44533) JVM IR: ClassFormatError on synthetic $suspendImpl method generated in interface for a @JvmDefault function
- [`KT-44540`](https://youtrack.jetbrains.com/issue/KT-44540) Regression in 1.4.30 in intellij-community: type mismatch for generic function call with generic Java class
- [`KT-44546`](https://youtrack.jetbrains.com/issue/KT-44546) NI: changed variable fixation order (that can lead to changed resolution)
- [`KT-44550`](https://youtrack.jetbrains.com/issue/KT-44550) KotlinBinaryClassCache leaks Kotlin plugin classloader on plugin unload
- [`KT-44563`](https://youtrack.jetbrains.com/issue/KT-44563) Type Inference loosing type annotations in lambda type expectation for function calls with block parameters
- [`KT-44583`](https://youtrack.jetbrains.com/issue/KT-44583) "Supertypes of the following classes cannot be resolved" error message gives no context
- [`KT-44627`](https://youtrack.jetbrains.com/issue/KT-44627) JVM IR: ACCIDENTAL_OVERRIDE when overriding a generic field where the type parameter has a primitive bound
- [`KT-44631`](https://youtrack.jetbrains.com/issue/KT-44631) "IndexOutOfBoundsException: Cannot pop operand off an empty stack" caused by a default param in inner class constructor which uses method or field from receiver
- [`KT-44647`](https://youtrack.jetbrains.com/issue/KT-44647) "IllegalAccessError: class TestKt tried to access private method" with String Builder `get` and `inc` operator
- [`KT-44651`](https://youtrack.jetbrains.com/issue/KT-44651) JVM / IR: "IllegalStateException: Illegal type substitutor" with if-else inside class constructor argument inside another if-else
- [`KT-44660`](https://youtrack.jetbrains.com/issue/KT-44660) Internal inline functions in companion object with inline class return type fails compilation
- [`KT-44671`](https://youtrack.jetbrains.com/issue/KT-44671) JVM_IR: ClassCastException: Result$Failure cannot be cast to Result with multithreaded coroutines
- [`KT-44703`](https://youtrack.jetbrains.com/issue/KT-44703) JVM / IR: "IllegalStateException: Unhandled special name in mangledNameFor" caused by a reference to inline class inside interface's companion with lazy initialization
- [`KT-44712`](https://youtrack.jetbrains.com/issue/KT-44712) JVM / IR: Behavior change after enabling with Mockito
- [`KT-44714`](https://youtrack.jetbrains.com/issue/KT-44714) Debugger / Coroutines: Local variables are trimmed out too aggressively
- [`KT-44722`](https://youtrack.jetbrains.com/issue/KT-44722) JVM IR: ClassCastException with inline class, let and bound function reference
- [`KT-44726`](https://youtrack.jetbrains.com/issue/KT-44726) JVM IR: Incorrect KType nullability for platform type reified as non-null
- [`KT-44781`](https://youtrack.jetbrains.com/issue/KT-44781) JVM IR: java.lang.NoSuchFieldError: $noName_0 when calling a crossinline lambda within a suspending lambda
- [`KT-44798`](https://youtrack.jetbrains.com/issue/KT-44798) JVM IR: Inherited platform declarations clash for class implementing both List and Set
- [`KT-44801`](https://youtrack.jetbrains.com/issue/KT-44801) 1.4.30 JVM IR: Unbound symbols not allowed with anonymous object
- [`KT-44803`](https://youtrack.jetbrains.com/issue/KT-44803) FIR bootstrap: incorrect nullability is set for type alias-based type
- [`KT-44827`](https://youtrack.jetbrains.com/issue/KT-44827) Non-existing outer class is written in anonymous class for SAM wrapper in inline lambda with capture
- [`KT-44837`](https://youtrack.jetbrains.com/issue/KT-44837) JVM / IR: ClassCastException with Result object when it is used by a generic method in a suspend call
- [`KT-44875`](https://youtrack.jetbrains.com/issue/KT-44875) JVM_IR. `hashCode` call is generated on interface target in fun interface equality
- [`KT-44878`](https://youtrack.jetbrains.com/issue/KT-44878) JVM_IR: "IllegalStateException: Unexpected types" when checking non-nullable variable is `in` range between nullable ones with smart-cast
- [`KT-44926`](https://youtrack.jetbrains.com/issue/KT-44926) MPP: Actual typealias to compiled inline class incompatible with expect inline class
- [`KT-44947`](https://youtrack.jetbrains.com/issue/KT-44947) Sealed interfaces: Sealed fun interface leads to "NoWhenBranchMatchedException"
- [`KT-44993`](https://youtrack.jetbrains.com/issue/KT-44993) JVM IR: VerifyError on getfield with Kotlin generic field and elvis operator
- [`KT-45008`](https://youtrack.jetbrains.com/issue/KT-45008) JVM IR: hashCode is generated as invokeinterface if smart cast to interface is present
- [`KT-45011`](https://youtrack.jetbrains.com/issue/KT-45011) JVM / IR: "AssertionError: Unbound symbols not allowed"
- [`KT-45022`](https://youtrack.jetbrains.com/issue/KT-45022) IR: "AssertionError: Undefined variable referenced" from psi2ir caused by plusAssign operator of object
- [`KT-45064`](https://youtrack.jetbrains.com/issue/KT-45064) JVM IR: "java.lang.AssertionError: SyntheticAccessorLowering should not attempt to modify other files!" with member reference to property in another file with private setter
- [`KT-45067`](https://youtrack.jetbrains.com/issue/KT-45067) "IllegalArgumentException: Wildcard mast have a bound for annotation of WILDCARD_BOUND position" with BEAM SDK 2.27
- [`KT-45069`](https://youtrack.jetbrains.com/issue/KT-45069) JVM / IR: New SAM conversions mode fails when converting from Unit to Any
- [`KT-45131`](https://youtrack.jetbrains.com/issue/KT-45131) JVM / IR: "RuntimeException: Lambda, SAM or anonymous object should have only one constructor" caused by inline class that type cast to reified type parameter inside lambda in inline function
- [`KT-45139`](https://youtrack.jetbrains.com/issue/KT-45139) Inline class: AssertionError: Expected top level inline class
- [`KT-45166`](https://youtrack.jetbrains.com/issue/KT-45166) JVM / IR: "AbstractMethodError: Receiver class does not define or inherit an implementation of the resolved method of interface" caused by interface with suspend function
- [`KT-45187`](https://youtrack.jetbrains.com/issue/KT-45187) JVM / IR: ClassCastException caused by substituting generic type of vararg parameter with java.lang.Void
- [`KT-45195`](https://youtrack.jetbrains.com/issue/KT-45195) JVM IR: annotation methods are generated as default interface methods if `allopen` is used
- [`KT-45243`](https://youtrack.jetbrains.com/issue/KT-45243) "IllegalStateException: Lambdas shouldn't be visited by ESExpressionVisitor" caused by lambda inside `kotlin.test.assertNotNull`
- [`KT-45259`](https://youtrack.jetbrains.com/issue/KT-45259) JVM: ClassCastException caused by Result as lambda parameter type
- [`KT-45292`](https://youtrack.jetbrains.com/issue/KT-45292) AssertionError with recursive inline extension property
- [`KT-45300`](https://youtrack.jetbrains.com/issue/KT-45300) Deprecate super calls in public-api inline functions
- [`KT-45409`](https://youtrack.jetbrains.com/issue/KT-45409) Rename jspecify annotations package and default not null annotation
- [`KT-45446`](https://youtrack.jetbrains.com/issue/KT-45446) JVM / IR: NullPointerException caused by unreachable code and comparison
- [`KT-45721`](https://youtrack.jetbrains.com/issue/KT-45721) JVM / IR: "Unbound symbols not allowed" caused by class reference in sequence lambda
- [`KT-45853`](https://youtrack.jetbrains.com/issue/KT-45853) JVM / IR: "Accidental override" caused by inheriting Throwable.getCause from Java interface
- [`KT-45861`](https://youtrack.jetbrains.com/issue/KT-45861) Turning warnings into errors for calls with type parameters annotated by @OnlyInputTypes
- [`KT-45865`](https://youtrack.jetbrains.com/issue/KT-45865) JVM IR: "VerifyError: Bad type on operand stack" with `enumValueOf` on a value from a list of strings
- [`KT-45868`](https://youtrack.jetbrains.com/issue/KT-45868) JVM IR: ClassCastException with SAM function in init block when SAM is generated via invokedynamic
- [`KT-45920`](https://youtrack.jetbrains.com/issue/KT-45920) JVM IR: "Accidental override" on redefining `get()` in custom Map class
- [`KT-45934`](https://youtrack.jetbrains.com/issue/KT-45934) JVM IR: "java.lang.IllegalStateException: Function has no body" for class implementing interface by delegation
- [`KT-45945`](https://youtrack.jetbrains.com/issue/KT-45945) JVM / IR: "AssertionError: Unexpected variance in super type argument" with contravariance and intersection types
- [`KT-45963`](https://youtrack.jetbrains.com/issue/KT-45963) JVM / IR: "AbstractMethodError: Receiver class does not define or inherit an implementation of the resolved method" in Dokka tests
- [`KT-45967`](https://youtrack.jetbrains.com/issue/KT-45967) JVM IR: "IllegalAccessError" with invokedynamic to Java SAM over callable reference to private function
- [`KT-45982`](https://youtrack.jetbrains.com/issue/KT-45982) Wrong subtyping result on captured types with postponed type variables
- [`KT-46007`](https://youtrack.jetbrains.com/issue/KT-46007) JVM / IR: "ClassCastException: kotlin.Unit cannot be cast to java.lang.String" caused by default suspend function in interface
- [`KT-46060`](https://youtrack.jetbrains.com/issue/KT-46060) JVM IR: NullPointerException from RangeContainsLowering when `contains` is a @JvmStatic function in object
- [`KT-46069`](https://youtrack.jetbrains.com/issue/KT-46069) JVM IR: unbound type parameter on generic bound adapted function reference
- [`KT-46092`](https://youtrack.jetbrains.com/issue/KT-46092) JVM IR: AssertionError "Array type expected: @[FlexibleNullability] kotlin.CharArray?" on super call to Java constructor with primitive vararg
- [`KT-46104`](https://youtrack.jetbrains.com/issue/KT-46104) The message on inline -> value class migration should not say that inline classes are deprecated
- [`KT-46131`](https://youtrack.jetbrains.com/issue/KT-46131) Kotlin 1.5.0-RC errors when reading class file
- [`KT-46160`](https://youtrack.jetbrains.com/issue/KT-46160) JVM IR: IllegalAccessException at runtime for member reference to JvmMultifileClass member from stdlib
- [`KT-46186`](https://youtrack.jetbrains.com/issue/KT-46186) Type inference regression in Kotlin 1.5 with constrained generic return types
### Docs & Examples
- [`KT-45884`](https://youtrack.jetbrains.com/issue/KT-45884) Incorrect description for JVM `toUpperCase` method
### IDE
- [`KT-33233`](https://youtrack.jetbrains.com/issue/KT-33233) Use dependency of library to build built-ins in IDE, instead of loading them from the current classloader
- [`KT-34023`](https://youtrack.jetbrains.com/issue/KT-34023) kotlin.KotlinNullPointerException at org.jetbrains.kotlin.backend.common.FunctionsFromAnyGenerator.getPrimaryConstructorProperties(FunctionsFromAnyGenerator.kt:66)
- [`KT-35947`](https://youtrack.jetbrains.com/issue/KT-35947) KFunctionN.call is unresolved in IDE in Kotlin/JVM project
- [`KT-37702`](https://youtrack.jetbrains.com/issue/KT-37702) Code analysis speed: on-the-fly analysis diagnostics reporting
- [`KT-41048`](https://youtrack.jetbrains.com/issue/KT-41048) [FIR-IDE] Properly implement methods in KtFirPackageScope
- [`KT-41671`](https://youtrack.jetbrains.com/issue/KT-41671) Missing nullability information in properties using type inference from get()
- [`KT-43824`](https://youtrack.jetbrains.com/issue/KT-43824) KtLightClassForSourceDeclaration#isInheritor works in a different way than java implementation
- [`KT-44128`](https://youtrack.jetbrains.com/issue/KT-44128) IDE: Kotlin JVM record has incorrect property accessors as seen from Java
- [`KT-44487`](https://youtrack.jetbrains.com/issue/KT-44487) MPP, IDE: No error in IDE when sealed class inheritor from common source-set is not used in exhaustive when expression in platform source-set
- [`KT-45254`](https://youtrack.jetbrains.com/issue/KT-45254) Highlighting for files with certain errors appears only on second opening
- [`KT-46097`](https://youtrack.jetbrains.com/issue/KT-46097) Light classes: Incomplete nullability information for a getter method of a kotlin property defined in private constructor
### IDE. Decompiler, Indexing, Stubs
- [`KT-43699`](https://youtrack.jetbrains.com/issue/KT-43699) IDE: Unresolved extension method from Java code for simple class with typealias and generics (IllegalStateException: Unknown type parameter)
- [`KT-44756`](https://youtrack.jetbrains.com/issue/KT-44756) Infinite "UpToDateStubIndexMismatch: PSI and index do not match." with IDEA 2021.1 EAP upon attempt to open "org.gradle.configurationcache" even they seem to be the same
### IDE. Gradle Integration
- [`KT-37127`](https://youtrack.jetbrains.com/issue/KT-37127) Implement precise importing of platforms of root source sets (commonMain/commonTest) when hierarchical multiplatform support is enabled
- [`KT-42048`](https://youtrack.jetbrains.com/issue/KT-42048) KJS / Gradle integration: Could not determine the dependencies of task ':webApp:testPackageJson' in Android Studio 4.2 Canary 11
### IDE. Gradle. Script
- [`KT-46215`](https://youtrack.jetbrains.com/issue/KT-46215) Dead lock on closing project during the import in IJ211 through ScriptDefinitionsManager
### IDE. Inspections and Intentions
- [`KT-23824`](https://youtrack.jetbrains.com/issue/KT-23824) Return lifted out of if condition causes suspend tail call optimization to no longer apply
- [`KT-38155`](https://youtrack.jetbrains.com/issue/KT-38155) Lift assignment out of 'if' produces type mismatch without manually adding a semicolon
- [`KT-44821`](https://youtrack.jetbrains.com/issue/KT-44821) IDE: False positive NO_ELSE_IN_WHEN caused by sealed class and when in another module
- [`KT-46088`](https://youtrack.jetbrains.com/issue/KT-46088) [IDEA] Incorrect behavior of replace inline class with value class intention
### IDE. Misc
- [`KT-44675`](https://youtrack.jetbrains.com/issue/KT-44675) Incorrect reference to resource into 202 plugin
### IDE. Refactorings
- [`KT-44079`](https://youtrack.jetbrains.com/issue/KT-44079) Sealed Interfaces: Move refactoring should warn about violation of hierarchy restrictions
- [`KT-44839`](https://youtrack.jetbrains.com/issue/KT-44839) Sealed interfaces: move refactoring warnings works with "more freedom for sealed classes" rules for language level < 1.5
### IDE. Script
- [`KT-43288`](https://youtrack.jetbrains.com/issue/KT-43288) Allow push notifications about script configuration /dependencies changes via the `ScriptDefinitionsProvider` EP
### JavaScript
- [`KT-39272`](https://youtrack.jetbrains.com/issue/KT-39272) KJS / IR: Can't use javascript keywords as JsName
- [`KT-41650`](https://youtrack.jetbrains.com/issue/KT-41650) JS IR BE: `default` should be a reserved identifier
- [`KT-42176`](https://youtrack.jetbrains.com/issue/KT-42176) KJS / IR: Interface default method in sub-interface not resolved correctly from extension on super-interface
- [`KT-44103`](https://youtrack.jetbrains.com/issue/KT-44103) [JSIR] TypeError when bumping from 1.4.20 to 1.4.30-M1
- [`KT-44180`](https://youtrack.jetbrains.com/issue/KT-44180) KJS / IR: NPE in ConstTransformer of compileDevelopmentExecutableKotlinJs/compileProductionExecutableKotlinJs tasks
- [`KT-44415`](https://youtrack.jetbrains.com/issue/KT-44415) Kotlin/JS with IR and kotlin-react: "too much recursion" error in runtime in browser
- [`KT-44433`](https://youtrack.jetbrains.com/issue/KT-44433) KJS IR: support function interfaces with suspend member
- [`KT-44469`](https://youtrack.jetbrains.com/issue/KT-44469) KJS / IR: Incorrect export functions with bridges
- [`KT-44718`](https://youtrack.jetbrains.com/issue/KT-44718) MPP/ KJS: "IllegalStateException: Unsupported operation" with serialization plugin and incremental compilation
- [`KT-44796`](https://youtrack.jetbrains.com/issue/KT-44796) KJS / IR: default parameter of function with @JsName leads to "RangeError: Maximum call stack size exceeded"
- [`KT-45059`](https://youtrack.jetbrains.com/issue/KT-45059) KJS / IR: Add possibility for runtime diagnostics of DCE result
### Libraries
- [`KT-12109`](https://youtrack.jetbrains.com/issue/KT-12109) Add stdlib method that combines mapNotNull() and first/firstOrNull()
- [`KT-25571`](https://youtrack.jetbrains.com/issue/KT-25571) Make random implementations serializable
- [`KT-26234`](https://youtrack.jetbrains.com/issue/KT-26234) Floored division and remainder function for numeric types
- [`KT-32996`](https://youtrack.jetbrains.com/issue/KT-32996) kotlin.test: add assertContentEquals for comparing content of arrays, iterables, sequences
- [`KT-39177`](https://youtrack.jetbrains.com/issue/KT-39177) Make CharCategory available in common multiplatform code
- [`KT-40225`](https://youtrack.jetbrains.com/issue/KT-40225) Support adding kotlin-test as a single dependency, as it should be with a multiplatform library
- [`KT-42071`](https://youtrack.jetbrains.com/issue/KT-42071) Strict version of String.toBoolean()
- [`KT-42720`](https://youtrack.jetbrains.com/issue/KT-42720) Kotlin ArrayDeque on JVM: provide optimized toArray method
- [`KT-42840`](https://youtrack.jetbrains.com/issue/KT-42840) Commonize and generalize String.contentEquals that is currently JVM-only
- [`KT-43772`](https://youtrack.jetbrains.com/issue/KT-43772) Kotlin/Native unfinished workers detected.
- [`KT-44168`](https://youtrack.jetbrains.com/issue/KT-44168) Prevent storing NaN and negative zero in kotlin.time.Duration
- [`KT-44369`](https://youtrack.jetbrains.com/issue/KT-44369) Commonize Char.titlecaseChar() and Char.titlecase() that are currently JVM-only
- [`KT-44783`](https://youtrack.jetbrains.com/issue/KT-44783) Add IS_VALUE flag for value classes to kotlinx-metadata-jvm
- [`KT-44815`](https://youtrack.jetbrains.com/issue/KT-44815) Remove kotlin-annotations-android and JVM compiler support for @ParameterName/@DefaultValue/@DefaultNull
- [`KT-45213`](https://youtrack.jetbrains.com/issue/KT-45213) Update Unicode version used in K/N for Char and String case conversion functions
### Middle-end. IR
- [`KT-43831`](https://youtrack.jetbrains.com/issue/KT-43831) Compilation failed, IrSimpleFunctionPublicSymbolImpl is already bound
- [`KT-44100`](https://youtrack.jetbrains.com/issue/KT-44100) KJS / IR: Top level declarations added in IR plugin are not referenceable from other modules
- [`KT-45170`](https://youtrack.jetbrains.com/issue/KT-45170) IR: "AssertionError: Single expression value for GET_OBJECT" caused by inc operator of field inside scope function inside object
### Native
- [`KT-42446`](https://youtrack.jetbrains.com/issue/KT-42446) Native: SIGSEGV in Kotlin_Array_get on linuxArm64
- [`KT-43502`](https://youtrack.jetbrains.com/issue/KT-43502) [K/N] relocation R_X86_64_PC32 cannot be used against symbol __environ; recompile with -fPIC
- [`KT-44295`](https://youtrack.jetbrains.com/issue/KT-44295) 1.4.21 Kotlin native ndk compiler crash
- [`KT-44774`](https://youtrack.jetbrains.com/issue/KT-44774) ld fails with CALL16 reloc at 0x48f00 not against global symbol (Linux MIPS)
- [`KT-44746`](https://youtrack.jetbrains.com/issue/KT-44746) Different hashCode() results for Kotlin/Native stdlib
### Native. C and ObjC Import
- [`KT-44824`](https://youtrack.jetbrains.com/issue/KT-44824) cinterop tool no longer appends .klib to produced klibs
### Native. C Export
- [`KT-36639`](https://youtrack.jetbrains.com/issue/KT-36639) MPP: Build ios "staticLib" or "sharedLib" binary failed if interface contains member extension function
- [`KT-41725`](https://youtrack.jetbrains.com/issue/KT-41725) Dynamic library doesn't load on raspberrypi
### Native. ObjC Export
- [`KT-44549`](https://youtrack.jetbrains.com/issue/KT-44549) In the Xcode debug session, call stack is missing a frame when the iOS app fails
### Native. Platforms
- [`KT-45094`](https://youtrack.jetbrains.com/issue/KT-45094) Fail to compile Kotlin Native sources under Oracle Linux 7
### Reflection
- [`KT-44594`](https://youtrack.jetbrains.com/issue/KT-44594) Avoid using unnecessary array types reflection in kotlin-reflect
- [`KT-44782`](https://youtrack.jetbrains.com/issue/KT-44782) Add KClass.isValue to kotlin-reflect
### Tools. Ant
- [`KT-16227`](https://youtrack.jetbrains.com/issue/KT-16227) Ant task: do not include runtime by default if destination is a jar
- [`KT-44293`](https://youtrack.jetbrains.com/issue/KT-44293) Support fork mode in kotlinc Ant task
### Tools. CLI
- [`KT-17344`](https://youtrack.jetbrains.com/issue/KT-17344) Include kotlin-reflect to resulting jar if "-include-runtime" is specified
- [`KT-43220`](https://youtrack.jetbrains.com/issue/KT-43220) -include-runtime should add .kotlin_builtins to the output
- [`KT-43704`](https://youtrack.jetbrains.com/issue/KT-43704) Illegal reflective access by com.intellij.util.ReflectionUtil to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
- [`KT-44078`](https://youtrack.jetbrains.com/issue/KT-44078) Do not include module-info.class of kotlin-stdlib.jar to the resulting jar with -include-runtime
- [`KT-44232`](https://youtrack.jetbrains.com/issue/KT-44232) CLI: do not pass -noverify to java process starting from JDK 13
- [`KT-45566`](https://youtrack.jetbrains.com/issue/KT-45566) JDK 16 - e: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
### Tools. CLI. Native
- [`KT-43874`](https://youtrack.jetbrains.com/issue/KT-43874) Native / CLI: provide a way to show difference between Jvm and Native compilers
### Tools. Compiler Plugins
- [`KT-45783`](https://youtrack.jetbrains.com/issue/KT-45783) Serialization: "AnalyzerException: Expected an object reference, but found I" caused by `JvmInline` and `Serializable` annotations
### Tools. Gradle
- [`KT-31027`](https://youtrack.jetbrains.com/issue/KT-31027) java.lang.NoSuchMethodError: No static method hashCode(Z)I in class Ljava/lang/Boolean; or its super classes (declaration of 'java.lang.Boolean' appears in /system/framework/core-libart.jar)
- [`KT-43605`](https://youtrack.jetbrains.com/issue/KT-43605) Kotlin Gradle Plugin 1.4.20 undeclared system property reads cause problems with Gradle configuration cache enabled
- [`KT-44204`](https://youtrack.jetbrains.com/issue/KT-44204) Kotlin Gradle Plugin 1.4.21 makes impossible to use ANTLR in other plugins
- [`KT-44361`](https://youtrack.jetbrains.com/issue/KT-44361) Gradle: deprecate options includeRuntime, noStdlib, noReflect
- [`KT-44462`](https://youtrack.jetbrains.com/issue/KT-44462) Kotlin Gradle plugin creates `compile` configuration with Gradle 7.0
- [`KT-44834`](https://youtrack.jetbrains.com/issue/KT-44834) Gradle Kotlin DSL: Add `languageSettings` configuration lambda without `apply` call
- [`KT-44949`](https://youtrack.jetbrains.com/issue/KT-44949) Compatibility with Gradle 7.0
- [`KT-44957`](https://youtrack.jetbrains.com/issue/KT-44957) gradle - target.compilations seems to be deprecated
- [`KT-45340`](https://youtrack.jetbrains.com/issue/KT-45340) Update minimal supported version of Kotlin Gradle Plugin to 6.1
### Tools. Gradle. JS
- [`KT-43237`](https://youtrack.jetbrains.com/issue/KT-43237) KJS: `-jsLegacy` Naming Convention is incompatible with NPM
- [`KT-43869`](https://youtrack.jetbrains.com/issue/KT-43869) Error in webpack configuration not displayed
- [`KT-44614`](https://youtrack.jetbrains.com/issue/KT-44614) Update Node.JS and Yarn versions
- [`KT-44616`](https://youtrack.jetbrains.com/issue/KT-44616) Kotlin/JS: IR backend with React: "Uncaught TypeError: _this__0 is undefined" runtime error in browser
- [`KT-45574`](https://youtrack.jetbrains.com/issue/KT-45574) Sync Kotlin/JS compile tasks into one folder (build/js/packages/<package>/kotlin)
### Tools. Gradle. Multiplatform
- [`KT-42098`](https://youtrack.jetbrains.com/issue/KT-42098) Commonizer is re-launched for every included Gradle build
- [`KT-43116`](https://youtrack.jetbrains.com/issue/KT-43116) Merge together MultiplatformHighlightingTest and MultiplatformAnalysisTest
- [`KT-44322`](https://youtrack.jetbrains.com/issue/KT-44322) KotlinTargetComponent maintenance for -sources.jar
- [`KT-44900`](https://youtrack.jetbrains.com/issue/KT-44900) Support gradle configuration cache with kotlin.multiplatform plugin
### Tools. Gradle. Native
- [`KT-46122`](https://youtrack.jetbrains.com/issue/KT-46122) kotlinx-serialization and kotlinx-datetime can't be built with 1.5.0-RC
### Tools. JPS
- [`KT-13631`](https://youtrack.jetbrains.com/issue/KT-13631) Compilation fails on Turkish locale because of locale-sensitive uppercasing
- [`KT-44644`](https://youtrack.jetbrains.com/issue/KT-44644) Mark all `@JvmMultifileClass` parts compiled in the previous round as dirty in the JPS plugin, similarly to how its done in the Gradle plugin
### Tools. Scripts
- [`KT-45194`](https://youtrack.jetbrains.com/issue/KT-45194) KT: Generate Kotlin Entities script: it doesn't work
- [`KT-44580`](https://youtrack.jetbrains.com/issue/KT-44580) Scripts: Unable to set new file annotation hooks after first snippet compilation
### Tools. kapt
- [`KT-43686`](https://youtrack.jetbrains.com/issue/KT-43686) KaptWithoutKotlincTask should use `@CompileClasspath` for `kotlinStdlibClasspath` for cache relocateability.
- [`KT-44130`](https://youtrack.jetbrains.com/issue/KT-44130) KAPT changes field order in 1.4.30-M1
- [`KT-44909`](https://youtrack.jetbrains.com/issue/KT-44909) Kapt: ReenteringLazyValueComputationException without stacktrace caused by `when` expression with sealed class function without explicit return type
- [`KT-45168`](https://youtrack.jetbrains.com/issue/KT-45168) KAPT: Java stubs generated for Kotlin files generated by annotation processors
## 1.4.32
### IDE
- [`KT-43824`](https://youtrack.jetbrains.com/issue/KT-43824) KtLightClassForSourceDeclaration#isInheritor works in a different way than java implementation
- [`KT-45287`](https://youtrack.jetbrains.com/issue/KT-45287) LightClasses: `KtLightSimpleModifierList` is no more a parent of `KtLightAnnotationForSourceEntry`
- [`KT-45291`](https://youtrack.jetbrains.com/issue/KT-45291) LightClasses: can't get annotations for constructor val-parameter
- [`KT-45417`](https://youtrack.jetbrains.com/issue/KT-45417) ULC leakage of primitive type annotations
### Tools. CLI
- [`KT-44758`](https://youtrack.jetbrains.com/issue/KT-44758) kotlin-compiler-embeddable dependency includes unshaded `fastutil` package
- [`KT-45007`](https://youtrack.jetbrains.com/issue/KT-45007) Concurrent Kotlin script compilation/execution results in NullPointerException in KeyedExtensionCollector.getPoint()
## 1.4.31
### Compiler
- [`KT-39776`](https://youtrack.jetbrains.com/issue/KT-39776) 2020.3+: Unresolved reference to Kotlin stdlib function
### IDE. Gradle Integration
- [`KT-44845`](https://youtrack.jetbrains.com/issue/KT-44845) After update to Kotlin 1.4.30 all external dependencies is unresolved in IDE with kotlin.mpp.enableGranularSourceSetsMetadata=true
### IDE. Gradle. Script
- [`KTIJ-11137`](https://youtrack.jetbrains.com/issue/KTIJ-1137) build.gradle.kts: Fatal error during save/load standalone scripts settings
- [`KTIJ-898`](https://youtrack.jetbrains.com/issue/KTIJ-898) Unable to import with Kotlin DSL buildscript - NullPointerException in KotlinDslScriptModelProcessorKt.toListOfScriptModels
### IDE. Multiplatform
- [`KTIJ-1200`](https://youtrack.jetbrains.com/issue/KTIJ-1200) KotlinIconProviderKt.addExpectActualMarker takes up to 180+ seconds
### IDE
#### Fixes
- [`KT-44697`](https://youtrack.jetbrains.com/issue/KT-44697) New JVM IR backend notification - narrow its triggering to Kotlin projects
- [`KT-44523`](https://youtrack.jetbrains.com/issue/KT-44523) IDE notification for trying new JVM backend
- [`KTIJ-696`](https://youtrack.jetbrains.com/issue/KTIJ-696) Freeze during startup of IDEA with intellij project with Kotlin (211-1.4.10-release-IJ1440)
## 1.4.30

View File

@@ -1,11 +1,11 @@
import kotlinx.benchmark.gradle.benchmark
val benchmarks_version = "0.3.0"
val benchmarks_version = "0.3.1"
plugins {
java
kotlin("jvm")
id("org.jetbrains.kotlinx.benchmark") version "0.3.0"
id("org.jetbrains.kotlinx.benchmark") version "0.3.1"
}
dependencies {

View File

@@ -12,6 +12,7 @@ import com.intellij.psi.PsiFileFactory
import com.intellij.psi.impl.PsiFileFactoryImpl
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.LightVirtualFile
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
@@ -147,6 +148,7 @@ abstract class AbstractSimpleFileBenchmark {
bh.consume(result.shouldGenerateCode)
}
@OptIn(ObsoleteTestInfrastructure::class)
private fun analyzeGreenFileIr(bh: Blackhole) {
val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))

View File

@@ -39,4 +39,4 @@ class GeneratedJvmClass(
}
}
fun File.isModuleMappingFile() = extension == ModuleMapping.MAPPING_FILE_EXT && parentFile.name == "META-INF"
fun File.isModuleMappingFile() = extension == ModuleMapping.MAPPING_FILE_EXT && parentFile.name == "META-INF"

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.incremental
import com.intellij.util.io.DataExternalizer
import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
import org.jetbrains.kotlin.incremental.js.IrTranslationResultValue
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
@@ -48,6 +49,7 @@ open class IncrementalJsCache(
private const val INLINE_FUNCTIONS = "inline-functions"
private const val HEADER_FILE_NAME = "header.meta"
private const val PACKAGE_META_FILE = "packages-meta"
private const val SOURCE_TO_JS_OUTPUT = "source-to-js-output"
fun hasHeaderFile(cachesDir: File) = File(cachesDir, HEADER_FILE_NAME).exists()
}
@@ -60,6 +62,7 @@ open class IncrementalJsCache(
private val irTranslationResults = registerMap(IrTranslationResultMap(IR_TRANSLATION_RESULT_MAP.storageFile, pathConverter))
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile, pathConverter))
private val packageMetadata = registerMap(PackageMetadataMap(PACKAGE_META_FILE.storageFile))
private val sourceToJsOutputsMap = registerMap(SourceToJsOutputMap(SOURCE_TO_JS_OUTPUT.storageFile, pathConverter))
private val dirtySources = hashSetOf<File>()
@@ -75,6 +78,7 @@ open class IncrementalJsCache(
override fun markDirty(removedAndCompiledSources: Collection<File>) {
removedAndCompiledSources.forEach { sourceFile ->
sourceToJsOutputsMap.remove(sourceFile)
// The common prefix of all FQN parents has to be the file package
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minByOrNull { it.length }?.let {
packageMetadata.remove(it)
@@ -95,6 +99,10 @@ open class IncrementalJsCache(
}
}
fun getOutputsBySource(sourceFile: File): Collection<File> {
return sourceToJsOutputsMap.get(sourceFile)
}
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
val translatedFiles = incrementalResults.packageParts
@@ -175,6 +183,17 @@ open class IncrementalJsCache(
}
}
}
fun updateSourceToOutputMap(
generatedFiles: Iterable<GeneratedFile>,
) {
for (generatedFile in generatedFiles) {
for (source in generatedFile.sourceFiles) {
if (dirtySources.contains(source))
sourceToJsOutputsMap.add(source, generatedFile.outputFile)
}
}
}
}
private object TranslationResultValueExternalizer : DataExternalizer<TranslationResultValue> {
@@ -215,17 +234,20 @@ private class TranslationResultMap(
override fun dumpValue(value: TranslationResultValue): String =
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, InlineData: ${value.inlineData.md5()}"
@Synchronized
fun put(sourceFile: File, newMetadata: ByteArray, newBinaryAst: ByteArray, newInlineData: ByteArray) {
storage[pathConverter.toPath(sourceFile)] =
TranslationResultValue(metadata = newMetadata, binaryAst = newBinaryAst, inlineData = newInlineData)
}
@Synchronized
operator fun get(sourceFile: File): TranslationResultValue? =
storage[pathConverter.toPath(sourceFile)]
fun keys(): Collection<File> =
storage.keys.map { pathConverter.toFile(it) }
@Synchronized
fun remove(sourceFile: File, changesCollector: ChangesCollector) {
val path = pathConverter.toPath(sourceFile)
val protoBytes = storage[path]!!.metadata
@@ -359,6 +381,7 @@ private class InlineFunctionsMap(
storageFile: File,
private val pathConverter: FileToPathConverter
) : BasicStringMap<Map<String, Long>>(storageFile, StringToLongMapExternalizer) {
@Synchronized
fun process(srcFile: File, newMap: Map<String, Long>, changesCollector: ChangesCollector) {
val key = pathConverter.toPath(srcFile)
val oldMap = storage[key] ?: emptyMap()
@@ -376,6 +399,7 @@ private class InlineFunctionsMap(
}
}
@Synchronized
fun remove(sourceFile: File) {
storage.remove(pathConverter.toPath(sourceFile))
}

View File

@@ -47,10 +47,16 @@ abstract class BasicMap<K : Comparable<K>, V>(
storage.flush(memoryCachesOnly)
}
// avoid unsynchronized close
fun close() {
storage.close()
}
@TestOnly
fun closeForTest() {
close()
}
@TestOnly
fun dump(): String {
return with(StringBuilder()) {

View File

@@ -34,7 +34,6 @@ class CachingLazyStorage<K, V>(
) : LazyStorage<K, V> {
private var storage: PersistentHashMap<K, V>? = null
@Synchronized
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
if (storage != null) return storage
@@ -46,32 +45,36 @@ class CachingLazyStorage<K, V>(
return null
}
@Synchronized
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
if (storage == null) {
storage = createMap()
}
return storage!!
}
override val keys: Collection<K>
@Synchronized
get() = getStorageIfExists()?.allKeysWithExistingMapping ?: listOf()
@Synchronized
override operator fun contains(key: K): Boolean =
getStorageIfExists()?.containsMapping(key) ?: false
@Synchronized
override operator fun get(key: K): V? =
getStorageIfExists()?.get(key)
@Synchronized
override operator fun set(key: K, value: V) {
getStorageOrCreateNew().put(key, value)
}
@Synchronized
override fun remove(key: K) {
getStorageIfExists()?.remove(key)
}
@Synchronized
override fun append(key: K, value: V) {
getStorageOrCreateNew().appendData(key, { valueExternalizer.save(it, value) })
}
@@ -103,7 +106,11 @@ class CachingLazyStorage<K, V>(
@Synchronized
override fun close() {
storage?.close()
try {
storage?.close()
} finally {
storage = null
}
}
private fun createMap(): PersistentHashMap<K, V> = PersistentHashMap(storageFile, keyDescriptor, valueExternalizer)

View File

@@ -28,6 +28,7 @@ internal open class ClassOneToManyMap(storageFile: File) : BasicStringMap<Collec
storage.append(key.asString(), listOf(value.asString()))
}
@Synchronized
operator fun get(key: FqName): Collection<FqName> =
storage[key.asString()]?.map(::FqName) ?: setOf()

View File

@@ -31,7 +31,6 @@ class NonCachingLazyStorage<K, V>(
) : LazyStorage<K, V> {
private var storage: PersistentHashMap<K, V>? = null
@Synchronized
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
if (storage != null) return storage
@@ -43,7 +42,6 @@ class NonCachingLazyStorage<K, V>(
return null
}
@Synchronized
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
if (storage == null) {
storage = createMap()
@@ -53,22 +51,28 @@ class NonCachingLazyStorage<K, V>(
}
override val keys: Collection<K>
@Synchronized
get() = getStorageIfExists()?.allKeysWithExistingMapping ?: listOf()
@Synchronized
override operator fun contains(key: K): Boolean =
getStorageIfExists()?.containsMapping(key) ?: false
@Synchronized
override operator fun get(key: K): V? =
getStorageIfExists()?.get(key)
@Synchronized
override operator fun set(key: K, value: V) {
getStorageOrCreateNew().put(key, value)
}
@Synchronized
override fun remove(key: K) {
getStorageIfExists()?.remove(key)
}
@Synchronized
override fun append(key: K, value: V) {
getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) }
}
@@ -100,7 +104,11 @@ class NonCachingLazyStorage<K, V>(
@Synchronized
override fun close() {
storage?.close()
try {
storage?.close()
} finally {
storage = null
}
}
private fun createMap(): PersistentHashMap<K, V> =

View File

@@ -0,0 +1,43 @@
/*
* 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.
*/
package org.jetbrains.kotlin.incremental.storage
import org.jetbrains.kotlin.incremental.dumpCollection
import java.io.File
class SourceToJsOutputMap(storageFile: File, private val pathConverter: FileToPathConverter) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
override fun dumpValue(value: Collection<String>): String = value.dumpCollection()
@Synchronized
fun add(key: File, value: File) {
storage.append(pathConverter.toPath(key), listOf(pathConverter.toPath(value)))
}
operator fun get(sourceFile: File): Collection<File> =
storage[pathConverter.toPath(sourceFile)]?.map { pathConverter.toFile(it) } ?: setOf()
@Synchronized
operator fun set(key: File, values: Collection<File>) {
if (values.isEmpty()) {
remove(key)
return
}
storage[pathConverter.toPath(key)] = values.map { pathConverter.toPath(it) }
}
@Synchronized
fun remove(key: File) {
storage.remove(pathConverter.toPath(key))
}
@Synchronized
fun removeValues(key: File, removed: Set<File>) {
val notRemoved = this[key].filter { it !in removed }
this[key] = notRemoved
}
}

View File

@@ -14,8 +14,11 @@ buildscript {
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/plugins.gradle.org/m2")
maven("https://cache-redirector.jetbrains.com/repo.maven.apache.org/maven2")
} else {
maven("https://plugins.gradle.org/m2")
mavenCentral()
}
}
@@ -27,7 +30,7 @@ buildscript {
dependencies {
bootstrapCompilerClasspath(kotlin("compiler-embeddable", bootstrapKotlinVersion))
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.29")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath(kotlin("serialization", bootstrapKotlinVersion))
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
@@ -35,10 +38,6 @@ buildscript {
}
}
if (kotlinBuildProperties.buildScanServer != null) {
apply(from = "gradle/buildScanUserData.gradle")
}
plugins {
base
idea
@@ -183,7 +182,7 @@ extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.1.3"
extra["versions.r8"] = "2.1.96"
extra["versions.r8"] = "2.2.64"
val immutablesVersion = "0.3.1"
extra["versions.kotlinx-collections-immutable"] = immutablesVersion
extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
@@ -298,6 +297,7 @@ extra["compilerModules"] = arrayOf(
":compiler:fir:java",
":compiler:fir:jvm",
":compiler:fir:checkers",
":compiler:fir:checkers:checkers.jvm",
":compiler:fir:entrypoint",
":compiler:fir:analysis-tests",
":compiler:fir:analysis-tests:legacy-fir-tests",
@@ -317,7 +317,6 @@ extra["compilerModulesForJps"] = listOf(
":core:compiler.common.jvm",
":core:descriptors",
":core:descriptors.jvm",
":idea:idea-jps-common",
":kotlin-preloader",
":compiler:util",
":compiler:config",
@@ -327,13 +326,47 @@ extra["compilerModulesForJps"] = listOf(
":compiler:compiler.version"
)
extra["compilerArtifactsForIde"] = listOf(
":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide",
":prepare:ide-plugin-dependencies:js-ir-runtime-for-ide",
":prepare:ide-plugin-dependencies:kotlin-build-common-tests-for-ide",
":prepare:ide-plugin-dependencies:kotlin-compiler-for-ide",
":prepare:ide-plugin-dependencies:kotlin-compiler-cli-for-ide",
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide",
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:compiler-components-for-jps",
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide",
":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide",
":kotlin-script-runtime",
":kotlin-script-util",
":kotlin-scripting-common",
":kotlin-scripting-jvm",
":kotlin-scripting-compiler",
":kotlin-scripting-compiler-impl",
":kotlin-android-extensions-runtime",
":kotlin-stdlib-common",
":kotlin-stdlib",
":kotlin-stdlib-jdk7",
":kotlin-stdlib-jdk8",
":kotlin-reflect",
":kotlin-main-kts"
)
// TODO: fix remaining warnings and remove this property.
extra["tasksWithWarnings"] = listOf(
":kotlin-stdlib:compileTestKotlin",
":kotlin-stdlib-jdk7:compileTestKotlin",
":kotlin-stdlib-jdk8:compileTestKotlin",
":plugins:uast-kotlin-base:compileKotlin",
":plugins:uast-kotlin:compileKotlin",
":plugins:uast-kotlin:compileTestKotlin"
":plugins:uast-kotlin:compileTestKotlin",
":plugins:uast-kotlin-fir:compileKotlin",
":plugins:uast-kotlin-fir:compileTestKotlin"
)
val tasksWithWarnings: List<String> by extra
@@ -378,7 +411,7 @@ apply {
}
apply {
if (extra["isSonatypeRelease"] as? Boolean == true) {
if (extra["isDeployStagingRepoGenerationRequired"] as? Boolean == true) {
logger.info("Applying configuration for sonatype release")
from("libraries/prepareSonatypeStaging.gradle")
}
@@ -397,6 +430,29 @@ val defaultJavaHome = jdkPath(if (Platform[203].orHigher()) "11" else defaultJvm
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
allprojects {
val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString()
repositories {
kotlinBuildLocalRepo(project)
mirrorRepo?.let(::maven)
internalBootstrapRepo?.let(::maven)
bootstrapKotlinRepo?.let(::maven)
maven(protobufRepo)
maven(intellijRepo)
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://dl.google.com/dl/android/maven2")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
jcenter()
}
if (path.startsWith(":kotlin-ide.")) {
return@allprojects
}
configurations.maybeCreate("embedded").apply {
isCanBeConsumed = false
@@ -425,25 +481,6 @@ allprojects {
// therefore it is disabled by default
// buildDir = File(commonBuildDir, project.name)
val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString()
repositories {
kotlinBuildLocalRepo(project)
mirrorRepo?.let(::maven)
internalBootstrapRepo?.let(::maven)
bootstrapKotlinRepo?.let(::maven)
maven(protobufRepo)
maven(intellijRepo)
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://dl.google.com/dl/android/maven2")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
jcenter()
}
configureJvmProject(javaHome!!, jvmTarget!!)
@@ -519,12 +556,16 @@ allprojects {
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { true }
}
normalization {
runtimeClasspath {
ignore("META-INF/MANIFEST.MF")
ignore("META-INF/compiler.version")
ignore("META-INF/plugin.xml")
ignore("kotlin/KotlinVersionCurrentValue.class")
if (isConfigurationCacheDisabled) {
// Custom input normolization isn't supported by configuration cache at the moment
// See https://github.com/gradle/gradle/issues/13706
normalization {
runtimeClasspath {
ignore("META-INF/MANIFEST.MF")
ignore("META-INF/compiler.version")
ignore("META-INF/plugin.xml")
ignore("kotlin/KotlinVersionCurrentValue.class")
}
}
}
@@ -844,11 +885,12 @@ tasks {
":idea:idea-fir:test",
":idea:idea-frontend-api:test",
":idea:idea-frontend-fir:test",
":idea:idea-frontend-fir:idea-fir-low-level-api:test"
":idea:idea-frontend-fir:idea-fir-low-level-api:test",
":plugins:uast-kotlin-fir:test",
":idea:idea-fir-fe10-binding:test"
)
}
register("android-ide-tests") {
dependsOn("dist")
dependsOn(
@@ -894,7 +936,6 @@ tasks {
}
}
register("kaptIdeTest") {
dependsOn(":kotlin-annotation-processing:test")
dependsOn(":kotlin-annotation-processing-base:test")
@@ -950,32 +991,13 @@ tasks {
register("publishIdeArtifacts") {
idePluginDependency {
dependsOn(
":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-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-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",
":kotlin-script-runtime:publish",
":kotlin-script-util:publish",
":kotlin-scripting-common:publish",
":kotlin-scripting-jvm:publish",
":kotlin-scripting-compiler:publish",
":kotlin-scripting-compiler-impl:publish",
":kotlin-android-extensions-runtime:publish",
":kotlin-stdlib-common:publish",
":kotlin-stdlib:publish",
":kotlin-stdlib-jdk7:publish",
":kotlin-stdlib-jdk8:publish",
":kotlin-reflect:publish",
":kotlin-main-kts:publish"
)
dependsOn((rootProject.extra["compilerArtifactsForIde"] as List<String>).map { "$it:publish" })
}
}
register("installIdeArtifacts") {
idePluginDependency {
dependsOn((rootProject.extra["compilerArtifactsForIde"] as List<String>).map { "$it:install" })
}
}
}
@@ -1113,7 +1135,7 @@ fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
}
tasks.withType<KotlinCompile> {
kotlinOptions.jdkHome = javaHome
kotlinOptions.jdkHome = javaHome.takeUnless { kotlinBuildProperties.suppressJdkHomeWarning }
kotlinOptions.jvmTarget = javaVersion
kotlinOptions.freeCompilerArgs += "-Xjvm-default=compatibility"
}

View File

@@ -22,7 +22,7 @@ buildscript {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.29")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.bootstrapKotlinVersion}")
}
@@ -144,7 +144,7 @@ java {
dependencies {
implementation(kotlin("stdlib", embeddedKotlinVersion))
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.29")
implementation("com.gradle.publish:plugin-publish-plugin:0.14.0")
implementation("net.rubygrapefruit:native-platform:${property("versions.native-platform")}")

View File

@@ -18,6 +18,7 @@ plugins {
val intellijUltimateEnabled: Boolean by rootProject.extra
val intellijReleaseType: String by rootProject.extra
val intellijVersion = rootProject.extra["versions.intellijSdk"] as String
val intellijVersionForIde = rootProject.intellijSdkVersionForIde()
val asmVersion = rootProject.findProperty("versions.jar.asm-all") as String?
val androidStudioRelease = rootProject.findProperty("versions.androidStudioRelease") as String?
val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String?
@@ -25,15 +26,18 @@ val intellijSeparateSdks: Boolean by rootProject.extra
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
val installIntellijUltimate = intellijUltimateEnabled && androidStudioRelease == null
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
if (intellijVersionDelimiterIndex == -1) {
error("Invalid IDEA version $intellijVersion")
fun checkIntellijVersion(intellijVersion: String) {
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
if (intellijVersionDelimiterIndex == -1) {
error("Invalid IDEA version $intellijVersion")
}
}
val platformBaseVersion = intellijVersion.substring(0, intellijVersionDelimiterIndex)
checkIntellijVersion(intellijVersion)
intellijVersionForIde?.let { checkIntellijVersion(it) }
logger.info("intellijUltimateEnabled: $intellijUltimateEnabled")
logger.info("intellijVersion: $intellijVersion")
logger.info("intellijVersionForIde: $intellijVersionForIde")
logger.info("androidStudioRelease: $androidStudioRelease")
logger.info("androidStudioBuild: $androidStudioBuild")
logger.info("intellijSeparateSdks: $intellijSeparateSdks")
@@ -73,11 +77,16 @@ repositories {
}
val intellij by configurations.creating
val intellijForIde by configurations.creating
val intellijUltimate by configurations.creating
val intellijUltimateForIde by configurations.creating
val androidStudio by configurations.creating
val sources by configurations.creating
val sourcesForIde by configurations.creating
val jpsStandalone by configurations.creating
val jpsStandaloneForIde by configurations.creating
val intellijCore by configurations.creating
val intellijCoreForIde by configurations.creating
val nodeJSPlugin by configurations.creating
/**
@@ -93,7 +102,6 @@ val dependenciesDir = (findProperty("kotlin.build.dependencies.dir") as String?)
val customDepsRepoDir = dependenciesDir.resolve("repo")
val customDepsOrg: String by rootProject.extra
val customDepsRevision = intellijVersion
val repoDir = File(customDepsRepoDir, customDepsOrg)
dependencies {
@@ -107,9 +115,11 @@ dependencies {
} else {
if (installIntellijCommunity) {
intellij("com.jetbrains.intellij.idea:ideaIC:$intellijVersion")
intellijVersionForIde?.let { intellijForIde("com.jetbrains.intellij.idea:ideaIC:$it") }
}
if (installIntellijUltimate) {
intellijUltimate("com.jetbrains.intellij.idea:ideaIU:$intellijVersion")
intellijVersionForIde.let { intellijUltimateForIde("com.jetbrains.intellij.idea:ideaIU:$it") }
}
}
@@ -118,102 +128,111 @@ dependencies {
}
sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar")
intellijVersionForIde?.let { sourcesForIde("com.jetbrains.intellij.idea:ideaIC:$it:sources@jar") }
jpsStandalone("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion")
intellijVersionForIde?.let { jpsStandaloneForIde("com.jetbrains.intellij.idea:jps-standalone:$it") }
intellijCore("com.jetbrains.intellij.idea:intellij-core:$intellijVersion")
intellijVersionForIde?.let { intellijCoreForIde("com.jetbrains.intellij.idea:intellij-core:$it") }
if (intellijUltimateEnabled) {
nodeJSPlugin("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
}
}
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
fun prepareDeps(intellij: Configuration, intellijCore: Configuration, sources: Configuration, intellijUltimate: Configuration, jpsStandalone: Configuration, intellijVersion: String) {
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
val makeIntellijAnnotations by tasks.registering(Copy::class) {
dependsOn(makeIntellijCore)
val makeIntellijAnnotations = tasks.register("makeIntellijAnnotations${intellij.name.capitalize()}", Copy::class) {
dependsOn(makeIntellijCore)
val intellijCoreRepo = CleanableStore[repoDir.resolve("intellij-core").absolutePath][intellijVersion].use()
from(intellijCoreRepo.resolve("artifacts/annotations.jar"))
val intellijCoreRepo = CleanableStore[repoDir.resolve("intellij-core").absolutePath][intellijVersion].use()
from(intellijCoreRepo.resolve("artifacts/annotations.jar"))
val annotationsStore = CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath]
val targetDir = annotationsStore[intellijVersion].use()
into(targetDir)
val annotationsStore = CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath]
val targetDir = annotationsStore[intellijVersion].use()
into(targetDir)
val ivyFile = File(targetDir, "$intellijRuntimeAnnotations.ivy.xml")
outputs.files(ivyFile)
val ivyFile = File(targetDir, "$intellijRuntimeAnnotations.ivy.xml")
outputs.files(ivyFile)
doFirst {
annotationsStore.cleanStore()
doFirst {
annotationsStore.cleanStore()
}
doLast {
writeIvyXml(
customDepsOrg,
intellijRuntimeAnnotations,
intellijVersion,
intellijRuntimeAnnotations,
targetDir,
targetDir,
targetDir,
allowAnnotations = true
)
}
}
doLast {
writeIvyXml(
val mergeSources = tasks.create("mergeSources${intellij.name.capitalize()}", Jar::class.java) {
dependsOn(sources)
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
isZip64 = true
if (!kotlinBuildProperties.isTeamcityBuild) {
from(provider { sources.map(::zipTree) })
}
destinationDirectory.set(File(repoDir, sources.name))
archiveBaseName.set("intellij")
archiveClassifier.set("sources")
archiveVersion.set(intellijVersion)
}
val sourcesFile = mergeSources.outputs.files.singleFile
val makeIde = if (androidStudioBuild != null) {
buildIvyRepositoryTask(
androidStudio,
customDepsOrg,
intellijRuntimeAnnotations,
intellijVersion,
intellijRuntimeAnnotations,
targetDir,
targetDir,
targetDir,
allowAnnotations = true
customDepsRepoDir,
if (androidStudioOs == "mac")
::skipContentsDirectory
else
::skipToplevelDirectory
)
} else {
val task = if (installIntellijUltimate) {
buildIvyRepositoryTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
} else {
buildIvyRepositoryTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
}
task.configure {
dependsOn(mergeSources)
}
task
}
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
tasks.named("build") {
dependsOn(
makeIntellijCore,
makeIde,
buildJpsStandalone,
makeIntellijAnnotations
)
}
}
val mergeSources by tasks.creating(Jar::class.java) {
dependsOn(sources)
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
isZip64 = true
if (!kotlinBuildProperties.isTeamcityBuild) {
from(provider { sources.map(::zipTree) })
if (installIntellijUltimate) {
val buildNodeJsPlugin =
buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
tasks.named("build") { dependsOn(buildNodeJsPlugin) }
}
destinationDirectory.set(File(repoDir, sources.name))
archiveBaseName.set("intellij")
archiveClassifier.set("sources")
archiveVersion.set(intellijVersion)
}
val sourcesFile = mergeSources.outputs.files.singleFile
val makeIde = if (androidStudioBuild != null) {
buildIvyRepositoryTask(
androidStudio,
customDepsOrg,
customDepsRepoDir,
if (androidStudioOs == "mac")
::skipContentsDirectory
else
::skipToplevelDirectory
)
} else {
val task = if (installIntellijUltimate) {
buildIvyRepositoryTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
} else {
buildIvyRepositoryTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
}
task.configure {
dependsOn(mergeSources)
}
task
}
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
tasks.named("build") {
dependsOn(
makeIntellijCore,
makeIde,
buildJpsStandalone,
makeIntellijAnnotations
)
}
if (installIntellijUltimate) {
val buildNodeJsPlugin =
buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
tasks.named("build") { dependsOn(buildNodeJsPlugin) }
prepareDeps(intellij, intellijCore, sources, intellijUltimate, jpsStandalone, intellijVersion)
if (intellijVersionForIde != null) {
prepareDeps(intellijForIde, intellijCoreForIde, sourcesForIde, intellijUltimateForIde, jpsStandaloneForIde, intellijVersionForIde)
}
tasks.named<Delete>("clean") {
@@ -400,6 +419,11 @@ fun skipToplevelDirectory(path: String) = path.substringAfter('/')
fun skipContentsDirectory(path: String) = path.substringAfter("Contents/")
fun Project.intellijSdkVersionForIde(): String? {
val majorVersion = kotlinBuildProperties.getOrNull("attachedIntellijVersion") as? String ?: return null
return rootProject.findProperty("versions.intellijSdk.forIde.$majorVersion") as? String
}
class XMLWriter(private val outputStreamWriter: OutputStreamWriter) : Closeable {
private val xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStreamWriter)

View File

@@ -18,9 +18,10 @@ buildscript {
} else {
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" }
}
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.29")
}
}

View File

@@ -20,3 +20,5 @@ val KotlinBuildProperties.jarCompression: Boolean get() = getBoolean("kotlin.bui
val KotlinBuildProperties.ignoreTestFailures: Boolean get() = getBoolean("ignoreTestFailures", isTeamcityBuild)
val KotlinBuildProperties.disableWerror: Boolean get() = getBoolean("kotlin.build.disable.werror", false)
val KotlinBuildProperties.suppressJdkHomeWarning: Boolean get() = getBoolean("kotlin.suppress.jdkHome.warning", false)

View File

@@ -81,3 +81,9 @@ fun Task.singleOutputFile(): File = when (this) {
is ProGuardTask -> project.file(outJarFiles.single()!!)
else -> outputs.files.singleFile
}
val Project.isConfigurationCacheDisabled
get() = (gradle.startParameter as? org.gradle.api.internal.StartParameterInternal)?.isConfigurationCache != true
val Project.isIdeaActive
get() = providers.systemProperty("idea.active").forUseAtConfigurationTime().isPresent

View File

@@ -229,23 +229,6 @@ fun Project.publish(moduleMetadata: Boolean = false, configure: MavenPublication
publication.configure()
}
fun Project.publishWithLegacyMavenPlugin(body: Upload.() -> Unit = {}): Upload {
apply<plugins.PublishedKotlinModule>()
if (artifactsRemovedDiagnosticFlag) {
error("`publish()` should be called before removing artifacts typically done in `noDefaultJar()` or `runtimeJar()` call")
}
afterEvaluate {
if (configurations.findByName("classes-dirs") != null)
throw GradleException("classesDirsArtifact() is incompatible with publish(), see sources comments for details")
}
return (tasks.getByName("uploadArchives") as Upload).apply {
body()
}
}
fun Project.idePluginDependency(block: () -> Unit) {
val shouldActivate = rootProject.findProperty("publish.ide.plugin.dependencies")?.toString()?.toBoolean() == true
if (shouldActivate) {
@@ -253,6 +236,31 @@ fun Project.idePluginDependency(block: () -> Unit) {
}
}
fun Project.publishJarsForIde(projects: List<String>, libraryDependencies: List<String> = emptyList()) {
idePluginDependency {
publishProjectJars(projects, libraryDependencies)
}
dependencies {
projects.forEach {
jpsLikeJarDependency(project(it), JpsDepScope.COMPILE, { isTransitive = false }, exported = true)
}
libraryDependencies.forEach {
jpsLikeJarDependency(it, JpsDepScope.COMPILE, exported = true)
}
}
}
fun Project.publishTestJarsForIde(projectNames: List<String>) {
idePluginDependency {
publishTestJar(projectNames)
}
dependencies {
for (projectName in projectNames) {
jpsLikeJarDependency(projectTests(projectName), JpsDepScope.COMPILE, exported = true)
}
}
}
fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List<String> = emptyList()) {
apply<JavaPlugin>()
@@ -291,13 +299,15 @@ fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List
javadocJar()
}
fun Project.publishTestJar(projectName: String) {
fun Project.publishTestJar(projects: List<String>) {
apply<JavaPlugin>()
val fatJarContents by configurations.creating
dependencies {
fatJarContents(project(projectName, configuration = "tests-jar")) { isTransitive = false }
for (projectName in projects) {
fatJarContents(project(projectName, configuration = "tests-jar")) { isTransitive = false }
}
}
publish()
@@ -314,7 +324,7 @@ fun Project.publishTestJar(projectName: String) {
sourcesJar {
from {
project(projectName).testSourceSet.allSource
projects.map { project(it).testSourceSet.allSource }
}
}

View File

@@ -11,11 +11,13 @@ import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
import org.gradle.kotlin.dsl.closureOf
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import java.io.File
@@ -115,6 +117,87 @@ fun DependencyHandler.projectTests(name: String): ProjectDependency = project(na
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives")
enum class JpsDepScope {
COMPILE, TEST, RUNTIME, PROVIDED
}
fun DependencyHandler.add(configurationName: String, dependencyNotation: Any, configure: (ModuleDependency.() -> Unit)?) {
// Avoid `dependencyNotation` to `ModuleDependency` class cast exception if possible
if (configure != null) {
add(configurationName, dependencyNotation, closureOf(configure))
} else {
add(configurationName, dependencyNotation)
}
}
fun DependencyHandler.jpsLikeJarDependency(
dependencyNotation: Any,
scope: JpsDepScope,
dependencyConfiguration: (ModuleDependency.() -> Unit)? = null,
exported: Boolean = false
) {
when (scope) {
JpsDepScope.COMPILE -> {
if (exported) {
add("api", dependencyNotation, dependencyConfiguration)
add("testCompile", dependencyNotation, dependencyConfiguration)
} else {
add("implementation", dependencyNotation, dependencyConfiguration)
}
}
JpsDepScope.TEST -> {
if (exported) {
add("testCompile", dependencyNotation, dependencyConfiguration)
} else {
add("testImplementation", dependencyNotation, dependencyConfiguration)
}
}
JpsDepScope.RUNTIME -> {
add("testRuntimeOnly", dependencyNotation, dependencyConfiguration)
}
JpsDepScope.PROVIDED -> {
if (exported) {
add("compileOnlyApi", dependencyNotation, dependencyConfiguration)
add("testCompile", dependencyNotation, dependencyConfiguration)
} else {
add("compileOnly", dependencyNotation, dependencyConfiguration)
add("testImplementation", dependencyNotation, dependencyConfiguration)
}
}
}
}
fun DependencyHandler.jpsLikeModuleDependency(moduleName: String, scope: JpsDepScope, exported: Boolean = false) {
jpsLikeJarDependency(project(moduleName), scope, exported = exported)
when (scope) {
JpsDepScope.COMPILE -> {
if (exported) {
add("testCompile", projectTests(moduleName))
} else {
add("testImplementation", projectTests(moduleName))
}
}
JpsDepScope.TEST -> {
if (exported) {
add("testCompile", projectTests(moduleName))
} else {
add("testImplementation", projectTests(moduleName))
}
}
JpsDepScope.RUNTIME -> {
add("runtimeOnly", projectTests(moduleName))
}
JpsDepScope.PROVIDED -> {
if (exported) {
add("testCompile", projectTests(moduleName))
} else {
add("testImplementation", projectTests(moduleName))
}
}
}
}
fun Project.testApiJUnit5(
vintageEngine: Boolean = false,
runner: Boolean = false,

View File

@@ -0,0 +1,51 @@
/*
* 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.
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
}
publish()
standardPublicJars()
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
dependencies {
compileOnly(kotlinStdlib())
compileOnly(gradleApi())
}
// These dependencies will be provided by Gradle and we should prevent version conflict
fun Configuration.excludeGradleCommonDependencies() {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
}
configurations {
"implementation" {
excludeGradleCommonDependencies()
}
"api" {
excludeGradleCommonDependencies()
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.languageVersion = "1.3"
kotlinOptions.apiVersion = "1.3"
kotlinOptions.freeCompilerArgs += listOf(
"-Xskip-prerelease-check",
"-Xskip-runtime-version-check",
"-Xsuppress-version-warnings"
)
}
tasks.named<Jar>("jar") {
callGroovy("manifestAttributes", manifest, project)
}

View File

@@ -42,9 +42,21 @@ private fun Project.ideModuleName() = when (IdeVersionConfigurator.currentIde.ki
}
}
private fun Project.ideModuleVersion() = when (IdeVersionConfigurator.currentIde.kind) {
private fun Project.ideModuleVersion(forIde: Boolean) = when (IdeVersionConfigurator.currentIde.kind) {
Ide.Kind.AndroidStudio -> rootProject.findProperty("versions.androidStudioBuild")
Ide.Kind.IntelliJ -> rootProject.findProperty("versions.intellijSdk")
Ide.Kind.IntelliJ -> {
if (forIde) {
intellijSdkVersionForIde()
?: error("Please specify 'attachedIntellijVersion' in your local.properties")
} else {
rootProject.findProperty("versions.intellijSdk")
}
}
}
fun Project.intellijSdkVersionForIde(): String? {
val majorVersion = kotlinBuildProperties.getOrNull("attachedIntellijVersion") as? String ?: return null
return rootProject.findProperty("versions.intellijSdk.forIde.$majorVersion") as? String
}
fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactRepository = ivy {
@@ -58,6 +70,7 @@ fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactReposit
artifact("[organisation]/[module]/[revision]/artifacts/lib/[artifact](-[classifier]).[ext]")
artifact("[organisation]/[module]/[revision]/artifacts/[artifact](-[classifier]).[ext]")
artifact("[organisation]/intellij-core/[revision]/artifacts/[artifact](-[classifier]).[ext]")
artifact("[organisation]/${project.ideModuleName()}/[revision]/artifacts/plugins/[module]/lib/[artifact](-[classifier]).[ext]") // bundled plugins
artifact("[organisation]/sources/[artifact]-[revision](-[classifier]).[ext]")
artifact("[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]")
@@ -68,7 +81,9 @@ fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactReposit
}
}
fun Project.intellijDep(module: String? = null) = "kotlin.build:${module ?: ideModuleName()}:${ideModuleVersion()}"
@JvmOverloads
fun Project.intellijDep(module: String? = null, forIde: Boolean = false) =
"kotlin.build:${module ?: ideModuleName()}:${ideModuleVersion(forIde)}"
fun Project.intellijCoreDep() = "kotlin.build:intellij-core:${rootProject.extra["versions.intellijSdk"]}"
@@ -93,7 +108,7 @@ fun Project.kotlinxCollectionsImmutable() = "org.jetbrains.kotlinx:kotlinx-colle
*/
fun Project.intellijRuntimeAnnotations() = "kotlin.build:intellij-runtime-annotations:${rootProject.extra["versions.intellijSdk"]}"
fun Project.intellijPluginDep(plugin: String) = intellijDep(plugin)
fun Project.intellijPluginDep(plugin: String, forIde: Boolean = false) = intellijDep(plugin, forIde)
fun Project.intellijUltimateDep() = intellijDep("ideaIU")
@@ -125,7 +140,7 @@ object IntellijRootUtils {
fun getIntellijRootDir(project: Project): File = with(project.rootProject) {
return File(
getRepositoryRootDir(this),
"${ideModuleName()}/${ideModuleVersion()}/artifacts"
"${ideModuleName()}/${ideModuleVersion(forIde = false)}/artifacts"
)
}
}

View File

@@ -164,7 +164,17 @@ fun Project.configureDefaultPublishing() {
private fun Project.configureSigning() {
configure<SigningExtension> {
sign(extensions.getByType<PublishingExtension>().publications) // all publications
useGpgCmd()
val signKeyId = project.findProperty("signKeyId") as? String
if (!signKeyId.isNullOrBlank()) {
val signKeyPrivate = project.findProperty("signKeyPrivate") as? String
?: error("Parameter `signKeyPrivate` not found")
val signKeyPassphrase = project.findProperty("signKeyPassphrase") as? String
?: error("Parameter `signKeyPassphrase` not found")
useInMemoryPgpKeys(signKeyId, signKeyPrivate, signKeyPassphrase)
} else {
useGpgCmd()
}
}
}

View File

@@ -1,173 +0,0 @@
@file:Suppress("DEPRECATION")
package plugins
import org.codehaus.groovy.runtime.InvokerHelper
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer
import org.gradle.api.artifacts.maven.MavenDeployment
import org.gradle.api.artifacts.maven.MavenResolver
import org.gradle.api.plugins.MavenPluginConvention
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
import org.gradle.api.publication.maven.internal.deployer.MavenRemoteRepository
import org.gradle.api.tasks.Upload
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import kotlin.properties.Delegates
/**
* Configures a Kotlin module for publication.
*/
open class PublishedKotlinModule : Plugin<Project> {
private fun String.toBooleanOrNull() = listOf(true, false).firstOrNull { it.toString().equals(this, ignoreCase = true) }
override fun apply(project: Project) {
project.run {
plugins.apply("maven")
configurations.maybeCreate("publishedRuntime").apply {
the<MavenPluginConvention>()
.conf2ScopeMappings
.addMapping(0, this, Conf2ScopeMappingContainer.RUNTIME)
}
configurations.maybeCreate("publishedCompile").apply {
the<MavenPluginConvention>()
.conf2ScopeMappings
.addMapping(0, this, Conf2ScopeMappingContainer.COMPILE)
}
if (!project.hasProperty("prebuiltJar")) {
plugins.apply("signing")
val signingRequired = project.findProperty("signingRequired")?.toString()?.toBooleanOrNull()
?: project.property("isSonatypeRelease") as Boolean
configure<SigningExtension> {
isRequired = signingRequired
sign(configurations["archives"])
useGpgCmd()
}
tasks.named<Sign>("signArchives").configure {
enabled = signingRequired
}
}
fun MavenResolver.configurePom() {
pom.project {
withGroovyBuilder {
"licenses" {
"license" {
"name"("The Apache Software License, Version 2.0")
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
"distribution"("repo")
}
}
"name"("${project.group}:${project.name}")
"packaging"("jar")
// optionally artifactId can be defined here
"description"(project.description)
"url"("https://kotlinlang.org/")
"licenses" {
"license" {
"name"("The Apache License, Version 2.0")
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
"scm" {
"url"("https://github.com/JetBrains/kotlin")
"connection"("scm:git:https://github.com/JetBrains/kotlin.git")
"developerConnection"("scm:git:https://github.com/JetBrains/kotlin.git")
}
"developers" {
"developer" {
"name"("Kotlin Team")
setProperty("organization", "JetBrains")
"organizationUrl"("https://www.jetbrains.com")
}
}
}
}
pom.whenConfigured {
dependencies.removeIf {
InvokerHelper.getMetaClass(it).getProperty(it, "scope") == "test"
}
dependencies
.find {
InvokerHelper.getMetaClass(it).getProperty(it, "groupId") == "org.jetbrains.kotlin"
&& InvokerHelper.getMetaClass(it).getProperty(it, "artifactId") == "kotlin-stdlib"
}
?.also {
InvokerHelper.getMetaClass(it).setProperty(it, "exclusions", emptyList<Any>())
logger.warn("WARNING! Removed exclusions from kotlin-stdlib dependency of ${this.artifactId} artifact's maven metadata, check kotlin-stdlib dependency of ${project.path} project")
}
}
}
tasks.named<Upload>("uploadArchives").configure {
val preparePublication = project.rootProject.tasks.named("preparePublication").get()
dependsOn(preparePublication)
val username: String? by preparePublication.extra
val password: String? by preparePublication.extra
val repoUrl: String by preparePublication.extra
var repository by Delegates.notNull<MavenRemoteRepository>()
repositories {
withConvention(MavenRepositoryHandlerConvention::class) {
mavenDeployer {
withGroovyBuilder {
"beforeDeployment" {
val signing = project.the<SigningExtension>()
if (signing.isRequired)
signing.signPom(delegate as MavenDeployment)
}
"repository"("url" to repoUrl)!!.also { repository = it as MavenRemoteRepository }.withGroovyBuilder {
if (username != null && password != null) {
"authentication"("userName" to username, "password" to password)
}
}
}
configurePom()
}
}
}
doFirst {
repository.url = repoUrl
}
}
val install = if (tasks.names.contains("install")) tasks.getByName("install") as Upload
else tasks.create("install", Upload::class.java)
install.apply {
configuration = project.configurations.getByName(Dependency.ARCHIVES_CONFIGURATION)
description = "Installs the 'archives' artifacts into the local Maven repository."
repositories {
withConvention(MavenRepositoryHandlerConvention::class) {
mavenInstaller {
configurePom()
}
}
}
}
tasks.register("publish") {
dependsOn(tasks.named("uploadArchives"))
}
}
}
}

View File

@@ -354,8 +354,8 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
extractor.provideConfigurationKeys()
extractor.configure(keyConfiguration, module.directives)
}
val kind = configuratorForFlags.extractConfigurationKind(module.directives)
val jdkKind = configuratorForFlags.extractJdkKind(module.directives)
val kind = JvmEnvironmentConfigurator.extractConfigurationKind(module.directives)
val jdkKind = JvmEnvironmentConfigurator.extractJdkKind(module.directives)
keyConfiguration.languageVersionSettings = module.languageVersionSettings

View File

@@ -18,6 +18,7 @@ interface TypeMappingContext<Writer : JvmDescriptorTypeWriter<Type>> {
val typeContext: TypeSystemCommonBackendContextForTypeMapping
fun getClassInternalName(typeConstructor: TypeConstructorMarker): String
fun getScriptInternalName(typeConstructor: TypeConstructorMarker): String
fun Writer.writeGenericType(type: SimpleTypeMarker, asmType: Type, mode: TypeMappingMode)
}
@@ -117,9 +118,7 @@ object AbstractTypeMapper {
}
typeConstructor.isScript() -> {
val asmType = AsmTypes.JAVA_CLASS_TYPE
with(context) { sw?.writeGenericType(type, asmType, mode) }
return asmType
return Type.getObjectType(context.getScriptInternalName(typeConstructor))
}
typeConstructor.isTypeParameter() -> {

View File

@@ -34,10 +34,10 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.AnnotationChecker;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker;
import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt;
import org.jetbrains.kotlin.resolve.multiplatform.OptionalAnnotationUtil;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType;
@@ -376,7 +376,7 @@ public abstract class AnnotationCodegen {
// We do not generate annotations whose classes are optional (annotated with `@OptionalExpectation`) because if an annotation entry
// is resolved to the expected declaration, this means that annotation has no actual class, and thus should not be generated.
// (Otherwise we would've resolved the entry to the actual annotation class.)
if (ExpectedActualDeclarationChecker.isOptionalAnnotationClass(classDescriptor)) {
if (OptionalAnnotationUtil.isOptionalAnnotationClass(classDescriptor)) {
return null;
}

View File

@@ -12,6 +12,7 @@ import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.context.ClosureContext;
@@ -31,7 +32,6 @@ import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
import org.jetbrains.kotlin.metadata.ProtoBuf;
import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.SimpleType;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -376,10 +376,12 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
value = StackValue.local(slot, type, bridgeParameterKotlinTypes.get(i));
slot += type.getSize();
}
if (InlineClassesCodegenUtilKt.isInlineClassWithUnderlyingTypeAnyOrAnyN(parameterType) &&
functionReferenceCall == null
) {
parameterType = InlineClassesUtilsKt.unsubstitutedUnderlyingParameter(parameterType).getType();
if (InlineClassesCodegenUtilKt.isInlineClassWithUnderlyingTypeAnyOrAnyN(parameterType) && functionReferenceCall == null) {
ClassDescriptor descriptor = TypeUtils.getClassDescriptor(parameterType);
InlineClassRepresentation<SimpleType> representation =
descriptor != null ? descriptor.getInlineClassRepresentation() : null;
assert representation != null : "Not an inline class type: " + parameterType;
parameterType = representation.getUnderlyingType();
}
value.put(typeMapper.mapType(calleeParameter), parameterType, iv);
}

View File

@@ -72,7 +72,7 @@ class ErasedInlineClassBodyCodegen(
}
private fun generateUnboxMethod() {
val boxMethodDescriptor = InlineClassDescriptorResolver.createBoxFunctionDescriptor(descriptor) ?: return
val boxMethodDescriptor = InlineClassDescriptorResolver.createBoxFunctionDescriptor(descriptor)
functionCodegen.generateMethod(
Synthetic(null, boxMethodDescriptor), boxMethodDescriptor, object : FunctionGenerationStrategy.CodegenBased(state) {
@@ -103,7 +103,7 @@ class ErasedInlineClassBodyCodegen(
}
private fun generateSpecializedEqualsStub() {
val specializedEqualsDescriptor = InlineClassDescriptorResolver.createSpecializedEqualsDescriptor(descriptor) ?: return
val specializedEqualsDescriptor = InlineClassDescriptorResolver.createSpecializedEqualsDescriptor(descriptor)
functionCodegen.generateMethod(
Synthetic(null, specializedEqualsDescriptor), specializedEqualsDescriptor, object : FunctionGenerationStrategy.CodegenBased(state) {

View File

@@ -20,6 +20,7 @@ import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
@@ -92,7 +93,6 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker;
import org.jetbrains.kotlin.types.model.TypeParameterMarker;
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Opcodes;
@@ -265,13 +265,23 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
);
}
private static void addReifiedParametersFromSignature(@NotNull MemberCodegen member, @NotNull ClassDescriptor descriptor) {
private static void addReifiedParametersFromSignature(@NotNull MemberCodegen<?> member, @NotNull ClassDescriptor descriptor) {
for (KotlinType type : descriptor.getTypeConstructor().getSupertypes()) {
for (TypeProjection supertypeArgument : type.getArguments()) {
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
if (parameterDescriptor != null && parameterDescriptor.isReified()) {
processTypeArguments(member, type);
}
}
private static void processTypeArguments(@NotNull MemberCodegen<?> member, KotlinType type) {
for (TypeProjection supertypeArgument : type.getArguments()) {
if (supertypeArgument.isStarProjection()) continue;
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
if (parameterDescriptor != null) {
if (parameterDescriptor.isReified()) {
member.getReifiedTypeParametersUsages().addUsedReifiedParameter(parameterDescriptor.getName().asString());
}
} else {
processTypeArguments(member, supertypeArgument.getType());
}
}
}
@@ -2014,10 +2024,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// Do not unbox parameters of suspend lambda, they are unboxed in `invoke` method
!CoroutineCodegenUtilKt.isInvokeSuspendOfLambda(context.getFunctionDescriptor())
) {
KotlinType underlyingType = InlineClassesUtilsKt.underlyingRepresentation(
(ClassDescriptor) inlineClassType.getConstructor().getDeclarationDescriptor()).getType();
return StackValue.underlyingValueOfInlineClass(
typeMapper.mapType(underlyingType), underlyingType, localOrCaptured);
ClassDescriptor inlineClass = (ClassDescriptor) inlineClassType.getConstructor().getDeclarationDescriptor();
InlineClassRepresentation<SimpleType> representation =
inlineClass != null ? inlineClass.getInlineClassRepresentation() : null;
assert representation != null : "Not an inline class: " + inlineClassType;
KotlinType underlyingType = representation.getUnderlyingType();
return StackValue.underlyingValueOfInlineClass(typeMapper.mapType(underlyingType), underlyingType, localOrCaptured);
}
}
return localOrCaptured;

View File

@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.SimpleType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -369,23 +370,22 @@ public class FunctionCodegen {
public static void generateMethodInsideInlineClassWrapper(
@NotNull JvmDeclarationOrigin origin,
@NotNull FunctionDescriptor functionDescriptor,
@NotNull ClassDescriptor containingDeclaration,
@NotNull ClassDescriptor inlineClass,
@NotNull MethodVisitor mv,
@NotNull KotlinTypeMapper typeMapper
) {
mv.visitCode();
Type fieldOwnerType = typeMapper.mapClass(containingDeclaration);
Type fieldOwnerType = typeMapper.mapClass(inlineClass);
Method erasedMethodImpl = typeMapper.mapAsmMethod(functionDescriptor.getOriginal(), OwnerKind.ERASED_INLINE_CLASS);
ValueParameterDescriptor valueRepresentation = InlineClassesUtilsKt.underlyingRepresentation(containingDeclaration);
if (valueRepresentation == null) return;
Type fieldType = typeMapper.mapType(valueRepresentation);
InlineClassRepresentation<SimpleType> representation = inlineClass.getInlineClassRepresentation();
assert representation != null : "Not an inline class: " + inlineClass;
generateDelegateToStaticErasedVersion(
mv, erasedMethodImpl,
fieldOwnerType, valueRepresentation.getName().asString(), fieldType
mv, erasedMethodImpl, fieldOwnerType,
representation.getUnderlyingPropertyName().asString(),
typeMapper.mapType(representation.getUnderlyingType())
);
endVisit(mv, null, origin.getElement());

View File

@@ -55,6 +55,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.SimpleType;
import org.jetbrains.org.objectweb.asm.FieldVisitor;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Type;
@@ -274,26 +275,25 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
protected void generateUnboxMethodForInlineClass() {
if (!(myClass instanceof KtClass)) return;
if (!InlineClassesUtilsKt.isInlineClass(descriptor)) return;
InlineClassRepresentation<SimpleType> inlineClassRepresentation = descriptor.getInlineClassRepresentation();
if (inlineClassRepresentation == null) return;
Type ownerType = typeMapper.mapClass(descriptor);
ValueParameterDescriptor inlinedValue = InlineClassesUtilsKt.underlyingRepresentation(this.descriptor);
if (inlinedValue == null) return;
Type valueType = typeMapper.mapType(inlinedValue.getType());
Type valueType = typeMapper.mapType(inlineClassRepresentation.getUnderlyingType());
SimpleFunctionDescriptor functionDescriptor = InlineClassDescriptorResolver.createUnboxFunctionDescriptor(this.descriptor);
assert functionDescriptor != null : "FunctionDescriptor for unbox method should be not null during codegen";
functionCodegen.generateMethod(
JvmDeclarationOriginKt.UnboxMethodOfInlineClass(functionDescriptor), functionDescriptor,
new FunctionGenerationStrategy.CodegenBased(state) {
@Override
public void doGenerateBody(
@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature
) {
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
InstructionAdapter iv = codegen.v;
iv.load(0, OBJECT_TYPE);
iv.getfield(ownerType.getInternalName(), inlinedValue.getName().asString(), valueType.getDescriptor());
iv.getfield(
ownerType.getInternalName(),
inlineClassRepresentation.getUnderlyingPropertyName().asString(),
valueType.getDescriptor()
);
iv.areturn(valueType);
}
}

View File

@@ -35,9 +35,9 @@ import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStat
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.lazy.descriptors.PackageDescriptorUtilKt;
import org.jetbrains.kotlin.resolve.multiplatform.OptionalAnnotationUtil;
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments;
import org.jetbrains.org.objectweb.asm.Type;
@@ -91,8 +91,8 @@ public class PackageCodegenImpl implements PackageCodegen {
if (declaration instanceof KtClassOrObject) {
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, declaration);
if (PsiUtilsKt.hasExpectModifier(declaration)) {
if (descriptor != null && ExpectedActualDeclarationChecker.shouldGenerateExpectClass(descriptor)) {
assert ExpectedActualDeclarationChecker.isOptionalAnnotationClass(descriptor) :
if (descriptor != null && OptionalAnnotationUtil.shouldGenerateExpectClass(descriptor)) {
assert OptionalAnnotationUtil.isOptionalAnnotationClass(descriptor) :
"Expect class should be generated only if it's an optional annotation: " + descriptor;
state.getFactory().getPackagePartRegistry().getOptionalAnnotations().add(descriptor);
}

View File

@@ -7,9 +7,7 @@ package org.jetbrains.kotlin.codegen.coroutines
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.builtins.isSuspendFunctionTypeOrSubtype
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.CAPTURES_CROSSINLINE_LAMBDA
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.CLOSURE
@@ -601,21 +599,6 @@ class CoroutineCodegenForLambda private constructor(
}
}
fun isCapturedSuspendLambda(closure: CalculatedClosure, name: String, bindingContext: BindingContext): Boolean {
for ((param, value) in closure.captureVariables) {
if (param !is ValueParameterDescriptor) continue
if (value.fieldName != name) continue
return param.type.isSuspendFunctionTypeOrSubtype
}
val classDescriptor = closure.capturedOuterClassDescriptor ?: return false
return isCapturedSuspendLambda(classDescriptor, name, bindingContext)
}
fun isCapturedSuspendLambda(classDescriptor: ClassDescriptor, name: String, bindingContext: BindingContext): Boolean {
val closure = bindingContext[CLOSURE, classDescriptor] ?: return false
return isCapturedSuspendLambda(closure, name, bindingContext)
}
private class AddEndLabelMethodVisitor(
delegate: MethodVisitor,
access: Int,

View File

@@ -650,7 +650,7 @@ class CoroutineTransformerMethodVisitor(
val livenessFrames = analyzeLiveness(methodNode)
// References shall be cleaned up after uspill (during spill in next suspension point) to prevent memory leaks,
// References shall be cleaned up after unspill (during spill in next suspension point) to prevent memory leaks,
val referencesToSpillBySuspensionPointIndex = arrayListOf<List<ReferenceToSpill>>()
// while primitives shall not
val primitivesToSpillBySuspensionPointIndex = arrayListOf<List<PrimitiveToSpill>>()
@@ -759,6 +759,35 @@ class CoroutineTransformerMethodVisitor(
referencesToCleanBySuspensionPointIndex += currentSpilledReferencesCount to predSpilledReferencesCount
}
// Calculate debug metadata mapping before modifying method node to make it easier to locate
// locals alive across suspension points.
fun calculateSpilledVariableAndField(
suspension: SuspensionPoint,
slot: Int,
spillableVariable: SpillableVariable?
): SpilledVariableAndField? {
if (spillableVariable == null) return null
val name = localVariableName(methodNode, slot, suspension.suspensionCallBegin.index()) ?: return null
return SpilledVariableAndField(spillableVariable.fieldName, name)
}
val spilledToVariableMapping = arrayListOf<List<SpilledVariableAndField>>()
for (suspensionPointIndex in suspensionPoints.indices) {
val suspension = suspensionPoints[suspensionPointIndex]
val spilledToVariable = arrayListOf<SpilledVariableAndField>()
referencesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
primitivesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
spilledToVariableMapping += spilledToVariable
}
// Mutate method node
fun generateSpillAndUnspill(suspension: SuspensionPoint, slot: Int, spillableVariable: SpillableVariable?) {
@@ -772,6 +801,22 @@ class CoroutineTransformerMethodVisitor(
return
}
// Find and remove the local variable node, if any, in the local variable table corresponding to the slot that is spilled.
var local: LocalVariableNode? = null
val localRestart = LabelNode().linkWithLabel()
val iterator = methodNode.localVariables.listIterator()
while (iterator.hasNext()) {
val node = iterator.next()
if (node.index == slot &&
methodNode.instructions.indexOf(node.start) <= methodNode.instructions.indexOf(suspension.suspensionCallBegin) &&
methodNode.instructions.indexOf(node.end) > methodNode.instructions.indexOf(suspension.tryCatchBlockEndLabelAfterSuspensionCall)
) {
local = node
iterator.remove()
break
}
}
with(instructions) {
// store variable before suspension call
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
@@ -795,8 +840,31 @@ class CoroutineTransformerMethodVisitor(
)
StackValue.coerce(spillableVariable.normalizedType, spillableVariable.type, this)
store(slot, spillableVariable.type)
if (local != null) {
visitLabel(localRestart.label)
}
})
}
// Split the local variable range for the local so that it is visible until the next state label, but is
// not visible until it has been unspilled from the continuation on the reentry path.
if (local != null) {
val previousEnd = local.end
local.end = suspension.stateLabel
// Add the local back, but end it at the next state label.
methodNode.localVariables.add(local)
// Add a new entry that starts after the local variable is restored from the continuation.
methodNode.localVariables.add(
LocalVariableNode(
local.name,
local.desc,
local.signature,
localRestart,
previousEnd,
local.index
)
)
}
}
fun cleanUpField(suspension: SuspensionPoint, fieldIndex: Int) {
@@ -839,33 +907,6 @@ class CoroutineTransformerMethodVisitor(
}
}
// Calculate debug metadata mapping
fun calculateSpilledVariableAndField(
suspension: SuspensionPoint,
slot: Int,
spillableVariable: SpillableVariable?
): SpilledVariableAndField? {
if (spillableVariable == null) return null
val name = localVariableName(methodNode, slot, suspension.suspensionCallEnd.next.index()) ?: return null
return SpilledVariableAndField(spillableVariable.fieldName, name)
}
val spilledToVariableMapping = arrayListOf<List<SpilledVariableAndField>>()
for (suspensionPointIndex in suspensionPoints.indices) {
val suspension = suspensionPoints[suspensionPointIndex]
val spilledToVariable = arrayListOf<SpilledVariableAndField>()
referencesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
primitivesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
spilledToVariableMapping += spilledToVariable
}
return spilledToVariableMapping
}
@@ -901,7 +942,6 @@ class CoroutineTransformerMethodVisitor(
suspendMarkerVarIndex: Int,
suspendPointLineNumber: LineNumberNode?
): LabelNode {
val stateLabel = LabelNode().linkWithLabel()
val continuationLabelAfterLoadedResult = LabelNode()
val suspendElementLineNumber = lineNumber
var nextLineNumberNode = nextDefinitelyHitLineNumber(suspension)
@@ -929,7 +969,7 @@ class CoroutineTransformerMethodVisitor(
load(suspendMarkerVarIndex, AsmTypes.OBJECT_TYPE)
areturn(AsmTypes.OBJECT_TYPE)
// Mark place for continuation
visitLabel(stateLabel.label)
visitLabel(suspension.stateLabel.label)
})
// After suspension point there is always three nodes: L1, NOP, L2
@@ -985,7 +1025,7 @@ class CoroutineTransformerMethodVisitor(
}
}
return stateLabel
return suspension.stateLabel
}
// Find the next line number instruction that is defintely hit. That is, a line number
@@ -1154,6 +1194,7 @@ internal class SuspensionPoint(
) {
lateinit var tryCatchBlocksContinuationLabel: LabelNode
val stateLabel = LabelNode().linkWithLabel()
val unboxInlineClassInstructions: List<AbstractInsnNode> = findUnboxInlineClassInstructions()
private fun findUnboxInlineClassInstructions(): List<AbstractInsnNode> {
@@ -1235,16 +1276,13 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
fun isAlive(insnIndex: Int, variableIndex: Int): Boolean =
liveness[insnIndex].isAlive(variableIndex)
fun nextSuspensionPointEndLabel(insn: AbstractInsnNode): LabelNode {
val suspensionPoint =
InsnSequence(insn, method.instructions.last).firstOrNull { isAfterSuspendMarker(it) } ?: method.instructions.last
return suspensionPoint as? LabelNode ?: suspensionPoint.findNextOrNull { it is LabelNode } as LabelNode
}
fun nextSuspensionPointStartLabel(insn: AbstractInsnNode): LabelNode {
val suspensionPoint =
InsnSequence(insn, method.instructions.last).firstOrNull { isBeforeSuspendMarker(it) } ?: method.instructions.last
return suspensionPoint as? LabelNode ?: suspensionPoint.findPreviousOrNull { it is LabelNode } as LabelNode
fun nextLabel(node: AbstractInsnNode?): LabelNode? {
var current = node
while (current != null) {
if (current is LabelNode) return current
current = current.next
}
return null
}
fun min(a: LabelNode, b: LabelNode): LabelNode =
@@ -1253,9 +1291,6 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
fun max(a: LabelNode, b: LabelNode): LabelNode =
if (method.instructions.indexOf(a) < method.instructions.indexOf(b)) b else a
fun containsSuspensionPoint(a: LabelNode, b: LabelNode): Boolean =
InsnSequence(min(a, b), max(a, b)).none { isBeforeSuspendMarker(it) }
val oldLvt = arrayListOf<LocalVariableNode>()
for (record in method.localVariables) {
oldLvt += record
@@ -1276,35 +1311,40 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
// No variable in LVT -> do not add one
val lvtRecord = oldLvt.findRecord(insnIndex, variableIndex) ?: continue
if (lvtRecord.name == CONTINUATION_VARIABLE_NAME) continue
// Extend lvt record to the next suspension point
val endLabel = min(lvtRecord.end, nextSuspensionPointEndLabel(insn))
// End the local when it is no longer live. Since it is not live, we will not spill and unspill it across
// suspension points. It is tempting to keep it alive until the next suspension point to leave it visible in
// the debugger for as long as possible. However, in the case of loops, the resumption after suspension can
// have a backwards edge targeting instruction between the point of death and the next suspension point.
//
// For example, code such as the following:
//
// listOf<String>.forEach {
// yield(it)
// }
//
// Generates code of this form with a back edge after resumption that will lead to invalid locals tables
// if the local range is extended to the next suspension point.
//
// iterator = iterable.iterator()
// L1: (iterable dies here)
// load iterator.next if there
// yield suspension point
//
// L2: (resumption point)
// restore live variables (not including iterable)
// goto L1 (iterator not restored here, so we cannot not have iterator live at L1)
val endLabel = nextLabel(insn.next)?.let { min(lvtRecord.end, it) } ?: lvtRecord.end
// startLabel can be null in case of parameters
@Suppress("NAME_SHADOWING") val startLabel = startLabel ?: lvtRecord.start
// Attempt to extend existing local variable node corresponding to the record in
// the original local variable table.
val recordToExtend: LocalVariableNode? = oldLvtNodeToLatestNewLvtNode[lvtRecord]
if (recordToExtend != null && containsSuspensionPoint(recordToExtend.end, startLabel)) {
recordToExtend.end = endLabel
} else {
val node = LocalVariableNode(lvtRecord.name, lvtRecord.desc, lvtRecord.signature, startLabel, endLabel, lvtRecord.index)
if (lvtRecord !in oldLvtNodeToLatestNewLvtNode) {
method.localVariables.add(node)
}
oldLvtNodeToLatestNewLvtNode[lvtRecord] = node
val node = LocalVariableNode(lvtRecord.name, lvtRecord.desc, lvtRecord.signature, startLabel, endLabel, lvtRecord.index)
if (lvtRecord !in oldLvtNodeToLatestNewLvtNode) {
method.localVariables.add(node)
}
oldLvtNodeToLatestNewLvtNode[lvtRecord] = node
}
}
}
val deadVariables = arrayListOf<Int>()
outer@for (variableIndex in start until method.maxLocals) {
if (oldLvt.none { it.index == variableIndex }) continue
for (insnIndex in 0 until (method.instructions.size() - 1)) {
if (isAlive(insnIndex, variableIndex)) continue@outer
}
deadVariables += variableIndex
}
for (variable in oldLvt) {
// $continuation and $result are dead, but they are used by debugger, as well as fake inliner variables
// For example, $continuation is used to create async stack trace
@@ -1320,19 +1360,5 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
method.localVariables.add(variable)
continue
}
// Shrink LVT records of dead variables to the next suspension point
if (variable.index in deadVariables) {
method.localVariables.add(
LocalVariableNode(
variable.name,
variable.desc,
variable.signature,
variable.start,
min(variable.end, nextSuspensionPointStartLabel(variable.start)),
variable.index
)
)
}
}
}

View File

@@ -189,7 +189,7 @@ fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
Pair(it, typeArguments[candidateDescriptor.typeParameters[it.index]]!!.asTypeProjection())
}.toMap()
newCall.setResultingSubstitutor(
newCall.setSubstitutor(
TypeConstructorSubstitution.createByParametersMap(newTypeArguments).buildSubstitutor()
)

View File

@@ -547,7 +547,7 @@ class AnonymousObjectTransformer(
capturedParamBuilder.addCapturedParam(desc, desc.fieldName, !capturedOuterThisTypes.add(desc.type.className))
else
capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false)
if (info is ExpressionLambda && info.isCapturedSuspend(desc)) {
if (desc.isSuspend) {
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
}
val composed = StackValue.field(

View File

@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.org.objectweb.asm.Type
class CapturedParamDesc(private val containingLambdaType: Type, val fieldName: String, val type: Type) {
val containingLambdaName: String
get() = containingLambdaType.internalName
class CapturedParamDesc(containingLambdaType: Type, val fieldName: String, val type: Type, val isSuspend: Boolean = false) {
val containingLambdaName: String = containingLambdaType.internalName
}

View File

@@ -320,8 +320,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
val splitBy = SimpleInterval(start.info as LabelNode, extension.finallyIntervalEnd)
processor.tryBlocksMetaInfo.splitAndRemoveCurrentIntervals(splitBy, true)
//processor.getLocalVarsMetaInfo().splitAndRemoveIntervalsFromCurrents(splitBy);
processor.localVarsMetaInfo.splitAndRemoveCurrentIntervals(splitBy, true);
mark.dropTo()
}
@@ -330,8 +329,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
}
processor.substituteTryBlockNodes(intoNode)
//processor.substituteLocalVarTable(intoNode);
processor.substituteLocalVarTable(intoNode);
}
protected abstract fun generateAssertFieldIfNeeded(info: RootInliningContext)

View File

@@ -5,32 +5,13 @@
package org.jetbrains.kotlin.codegen.inline
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil
import org.jetbrains.kotlin.codegen.PropertyReferenceCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.*
import org.jetbrains.kotlin.codegen.binding.MutableClosure
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
import org.jetbrains.kotlin.codegen.coroutines.isCapturedSuspendLambda
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.coroutines.isSuspendLambda
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.*
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.*
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode
import kotlin.properties.Delegates
@@ -47,7 +28,9 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
abstract val invokeMethod: Method
abstract val invokeMethodDescriptor: FunctionDescriptor
abstract val invokeMethodParameters: List<KotlinType?>
abstract val invokeMethodReturnType: KotlinType?
abstract val capturedVars: List<CapturedParamDesc>
@@ -56,6 +39,8 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
lateinit var node: SMAPAndMethodNode
val reifiedTypeParametersUsages = ReifiedTypeParametersUsages()
abstract fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>)
open val hasDispatchReceiver = true
@@ -67,7 +52,7 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
val field = remapper.findField(FieldInsnNode(0, info.containingLambdaName, info.fieldName, ""))
?: error("Captured field not found: " + info.containingLambdaName + "." + info.fieldName)
val recapturedParamInfo = builder.addCapturedParam(field, info.fieldName)
if (this is ExpressionLambda && isCapturedSuspend(info)) {
if (info.isSuspend) {
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
}
}
@@ -75,14 +60,9 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
return builder.buildParameters()
}
companion object {
fun LambdaInfo.getCapturedParamInfo(descriptor: EnclosedValueDescriptor): CapturedParamDesc {
return capturedParamDesc(descriptor.fieldName, descriptor.type)
}
fun LambdaInfo.capturedParamDesc(fieldName: String, fieldType: Type): CapturedParamDesc {
return CapturedParamDesc(lambdaClassType, fieldName, fieldType)
fun LambdaInfo.capturedParamDesc(fieldName: String, fieldType: Type, isSuspend: Boolean): CapturedParamDesc {
return CapturedParamDesc(lambdaClassType, fieldName, fieldType, isSuspend)
}
}
}
@@ -90,31 +70,19 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
object NonInlineableArgumentForInlineableParameterCalledInSuspend : FunctionalArgument
object NonInlineableArgumentForInlineableSuspendParameter : FunctionalArgument
class PsiDefaultLambda(
lambdaClassType: Type,
capturedArgs: Array<Type>,
parameterDescriptor: ValueParameterDescriptor,
offset: Int,
needReification: Boolean
) : DefaultLambda(lambdaClassType, capturedArgs, parameterDescriptor, offset, needReification) {
override fun mapAsmSignature(sourceCompiler: SourceCompilerForInline): Method {
return sourceCompiler.state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor).asmMethod
abstract class ExpressionLambda(isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
node = sourceCompiler.generateLambdaBody(this, reifiedTypeParametersUsages)
node.node.preprocessSuspendMarkers(forInline = true, keepFakeContinuation = false)
}
override fun findInvokeMethodDescriptor(): FunctionDescriptor =
parameterDescriptor.type.memberScope
.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND)
.single()
}
abstract class DefaultLambda(
override val lambdaClassType: Type,
private val capturedArgs: Array<Type>,
val parameterDescriptor: ValueParameterDescriptor,
isCrossinline: Boolean,
val offset: Int,
val needReification: Boolean
) : LambdaInfo(parameterDescriptor.isCrossinline) {
) : LambdaInfo(isCrossinline) {
final override var isBoundCallableReference by Delegates.notNull<Boolean>()
private set
@@ -124,80 +92,52 @@ abstract class DefaultLambda(
final override lateinit var invokeMethod: Method
private set
override lateinit var invokeMethodDescriptor: FunctionDescriptor
final override lateinit var capturedVars: List<CapturedParamDesc>
private set
var originalBoundReceiverType: Type? = null
private set
override val isSuspend = parameterDescriptor.isSuspendLambda
override val isSuspend = false // TODO: it should probably be true sometimes, but it never was
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
val classBytes = loadClassBytesByInternalName(sourceCompiler.state, lambdaClassType.internalName)
val classReader = ClassReader(classBytes)
var isPropertyReference = false
var isFunctionReference = false
classReader.accept(object : ClassVisitor(Opcodes.API_VERSION) {
override fun visit(
version: Int,
access: Int,
name: String,
signature: String?,
superName: String?,
interfaces: Array<out String>?
) {
isPropertyReference = superName in PROPERTY_REFERENCE_SUPER_CLASSES
isFunctionReference = superName == FUNCTION_REFERENCE.internalName || superName == FUNCTION_REFERENCE_IMPL.internalName
super.visit(version, access, name, signature, superName, interfaces)
}
}, ClassReader.SKIP_CODE or ClassReader.SKIP_FRAMES or ClassReader.SKIP_DEBUG)
invokeMethodDescriptor = findInvokeMethodDescriptor().let {
//property reference generates erased 'get' method
if (isPropertyReference) it.original else it
}
val descriptor = Type.getMethodDescriptor(Type.VOID_TYPE, *capturedArgs)
val constructor = getMethodNode(classBytes, "<init>", descriptor, lambdaClassType)?.node
val superName = ClassReader(classBytes).superName
val isPropertyReference = superName in PROPERTY_REFERENCE_SUPER_CLASSES
val isFunctionReference = superName == FUNCTION_REFERENCE.internalName || superName == FUNCTION_REFERENCE_IMPL.internalName
val constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, *capturedArgs)
val constructor = getMethodNode(classBytes, "<init>", constructorDescriptor, lambdaClassType)?.node
assert(constructor != null || capturedArgs.isEmpty()) {
"Can't find non-default constructor <init>$descriptor for default lambda $lambdaClassType"
"Can't find non-default constructor <init>$constructorDescriptor for default lambda $lambdaClassType"
}
capturedVars =
if (isFunctionReference || isPropertyReference)
constructor?.desc?.let { Type.getArgumentTypes(it) }?.singleOrNull()?.let {
originalBoundReceiverType = it
listOf(capturedParamDesc(AsmUtil.RECEIVER_PARAMETER_NAME, it.boxReceiverForBoundReference()))
listOf(capturedParamDesc(AsmUtil.RECEIVER_PARAMETER_NAME, AsmUtil.boxType(it), isSuspend = false))
} ?: emptyList()
else
constructor?.findCapturedFieldAssignmentInstructions()?.map { fieldNode ->
capturedParamDesc(fieldNode.name, Type.getType(fieldNode.desc))
capturedParamDesc(fieldNode.name, Type.getType(fieldNode.desc), isSuspend = false)
}?.toList() ?: emptyList()
isBoundCallableReference = (isFunctionReference || isPropertyReference) && capturedVars.isNotEmpty()
val methodName = (if (isPropertyReference) OperatorNameConventions.GET else OperatorNameConventions.INVOKE).asString()
val signature = mapAsmSignature(sourceCompiler)
node = getMethodNode(classBytes, methodName, signature.descriptor, lambdaClassType, signatureAmbiguity = true)
?: error("Can't find method '$methodName$signature' in '${classReader.className}'")
invokeMethod = Method(node.node.name, node.node.desc)
val invokeNameFallback = (if (isPropertyReference) OperatorNameConventions.GET else OperatorNameConventions.INVOKE).asString()
val invokeMethod = mapAsmMethod(sourceCompiler, isPropertyReference)
// TODO: `signatureAmbiguity = true` ignores the argument types from `invokeDescriptor` and only looks at the count.
// This effectively masks incorrect results from `mapAsmDescriptor`, which hopefully won't manifest in another way.
node = getMethodNode(classBytes, invokeMethod.name, invokeMethod.descriptor, lambdaClassType, signatureAmbiguity = true)
?: getMethodNode(classBytes, invokeNameFallback, invokeMethod.descriptor, lambdaClassType, signatureAmbiguity = true)
?: error("Can't find method '$invokeMethod' in '${lambdaClassType.internalName}'")
this.invokeMethod = Method(node.node.name, node.node.desc)
if (needReification) {
//nested classes could also require reification
reifiedTypeInliner.reifyInstructions(node.node)
reifiedTypeParametersUsages.mergeAll(reifiedTypeInliner.reifyInstructions(node.node))
}
}
protected abstract fun mapAsmSignature(sourceCompiler: SourceCompilerForInline): Method
protected abstract fun findInvokeMethodDescriptor(): FunctionDescriptor
protected abstract fun mapAsmMethod(sourceCompiler: SourceCompilerForInline, isPropertyReference: Boolean): Method
private companion object {
val PROPERTY_REFERENCE_SUPER_CLASSES =
@@ -208,131 +148,3 @@ abstract class DefaultLambda(
.mapTo(HashSet(), Type::getInternalName)
}
}
internal fun Type.boxReceiverForBoundReference() =
AsmUtil.boxType(this)
internal fun Type.boxReceiverForBoundReference(kotlinType: KotlinType, typeMapper: KotlinTypeMapper) =
DescriptorAsmUtil.boxType(this, kotlinType, typeMapper)
abstract class ExpressionLambda(isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
node = sourceCompiler.generateLambdaBody(this)
node.node.preprocessSuspendMarkers(forInline = true, keepFakeContinuation = false)
}
abstract fun getInlineSuspendLambdaViewDescriptor(): FunctionDescriptor
abstract fun isCapturedSuspend(desc: CapturedParamDesc): Boolean
}
class PsiExpressionLambda(
expression: KtExpression,
private val typeMapper: KotlinTypeMapper,
private val languageVersionSettings: LanguageVersionSettings,
isCrossInline: Boolean,
override val isBoundCallableReference: Boolean
) : ExpressionLambda(isCrossInline) {
override val lambdaClassType: Type
override val invokeMethod: Method
override val invokeMethodDescriptor: FunctionDescriptor
val classDescriptor: ClassDescriptor
val propertyReferenceInfo: PropertyReferenceInfo?
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
override val returnLabels: Map<String, Label?>
override val isSuspend: Boolean
var closure: CalculatedClosure
private set
init {
val bindingContext = typeMapper.bindingContext
val function =
bindingContext.get<PsiElement, SimpleFunctionDescriptor>(BindingContext.FUNCTION, functionWithBodyOrCallableReference)
if (function == null && expression is KtCallableReferenceExpression) {
val variableDescriptor =
bindingContext.get(BindingContext.VARIABLE, functionWithBodyOrCallableReference) as? VariableDescriptorWithAccessors
?: throw AssertionError("Reference expression not resolved to variable descriptor with accessors: ${expression.getText()}")
classDescriptor = bindingContext.get(CLASS_FOR_CALLABLE, variableDescriptor)
?: throw IllegalStateException("Class for callable not found: $variableDescriptor\n${expression.text}")
lambdaClassType = typeMapper.mapClass(classDescriptor)
val getFunction = PropertyReferenceCodegen.findGetFunction(variableDescriptor)
invokeMethodDescriptor = PropertyReferenceCodegen.createFakeOpenDescriptor(getFunction, classDescriptor)
val resolvedCall = expression.callableReference.getResolvedCallWithAssert(bindingContext)
propertyReferenceInfo = PropertyReferenceInfo(
resolvedCall.resultingDescriptor as VariableDescriptor, getFunction
)
} else {
propertyReferenceInfo = null
invokeMethodDescriptor = function ?: throw AssertionError("Function is not resolved to descriptor: " + expression.text)
classDescriptor = bindingContext.get(CLASS_FOR_CALLABLE, invokeMethodDescriptor)
?: throw IllegalStateException("Class for invoke method not found: $invokeMethodDescriptor\n${expression.text}")
lambdaClassType = asmTypeForAnonymousClass(bindingContext, invokeMethodDescriptor)
}
bindingContext.get<ClassDescriptor, MutableClosure>(CLOSURE, classDescriptor).let {
assert(it != null) { "Closure for lambda should be not null " + expression.text }
closure = it!!
}
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
isSuspend = invokeMethodDescriptor.isSuspend
}
override val capturedVars: List<CapturedParamDesc> by lazy {
arrayListOf<CapturedParamDesc>().apply {
val captureThis = closure.capturedOuterClassDescriptor
if (captureThis != null) {
val kotlinType = captureThis.defaultType
val type = typeMapper.mapType(kotlinType)
val descriptor = EnclosedValueDescriptor(
AsmUtil.CAPTURED_THIS_FIELD, null,
StackValue.field(type, lambdaClassType, AsmUtil.CAPTURED_THIS_FIELD, false, StackValue.LOCAL_0),
type, kotlinType
)
add(getCapturedParamInfo(descriptor))
}
val capturedReceiver = closure.capturedReceiverFromOuterContext
if (capturedReceiver != null) {
val type = typeMapper.mapType(capturedReceiver).let {
if (isBoundCallableReference) it.boxReceiverForBoundReference() else it
}
val fieldName = closure.getCapturedReceiverFieldName(typeMapper.bindingContext, languageVersionSettings)
val descriptor = EnclosedValueDescriptor(
fieldName, null,
StackValue.field(type, capturedReceiver, lambdaClassType, fieldName, false, StackValue.LOCAL_0),
type, capturedReceiver
)
add(getCapturedParamInfo(descriptor))
}
closure.captureVariables.values.forEach { descriptor ->
add(getCapturedParamInfo(descriptor))
}
}
}
val isPropertyReference: Boolean
get() = propertyReferenceInfo != null
override fun getInlineSuspendLambdaViewDescriptor(): FunctionDescriptor {
return getOrCreateJvmSuspendFunctionView(
invokeMethodDescriptor,
languageVersionSettings.isReleaseCoroutines(),
typeMapper.bindingContext
)
}
override fun isCapturedSuspend(desc: CapturedParamDesc): Boolean =
isCapturedSuspendLambda(closure, desc.fieldName, typeMapper.bindingContext)
}

View File

@@ -23,13 +23,10 @@ import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.nullCheck.isCheckParameterIsNotNull
import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.SmartSet
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -233,52 +230,34 @@ class MethodInliner(
return
}
// in case of inlining suspend lambda reference as ordinary parameter of inline function:
// suspend fun foo (...) ...
// inline fun inlineMe(c: (...) -> ...) ...
// builder {
// inlineMe(::foo)
// }
// we should create additional parameter for continuation.
var coroutineDesc = desc
val actualInvokeDescriptor: FunctionDescriptor
if (info.isSuspend) {
actualInvokeDescriptor = (info as ExpressionLambda).getInlineSuspendLambdaViewDescriptor()
val parametersSize = actualInvokeDescriptor.valueParameters.size +
(if (actualInvokeDescriptor.extensionReceiverParameter != null) 1 else 0)
// And here we expect invoke(...Ljava/lang/Object;) be replaced with invoke(...Lkotlin/coroutines/Continuation;)
// if this does not happen, insert fake continuation, since we could not have one yet.
val argumentTypes = Type.getArgumentTypes(desc)
if (argumentTypes.size != parametersSize &&
// But do not add it in IR. In IR we already have lowered lambdas with additional parameter, while in Old BE we don't.
!inliningContext.root.state.isIrBackend
) {
val nullableAnyType = inliningContext.root.sourceCompilerForInline.compilationContextDescriptor.builtIns.nullableAnyType
val expectedParameters = info.invokeMethod.argumentTypes
val expectedKotlinParameters = info.invokeMethodParameters
val argumentCount = Type.getArgumentTypes(desc).size.let {
if (!inliningContext.root.state.isIrBackend && info.isSuspend && it < expectedParameters.size) {
// Inlining suspend lambda into a function that takes a non-suspend lambda.
// In the IR backend, this cannot happen as inline lambdas are not lowered.
addFakeContinuationMarker(this)
coroutineDesc = Type.getMethodDescriptor(Type.getReturnType(desc), *argumentTypes, AsmTypes.OBJECT_TYPE)
}
} else {
actualInvokeDescriptor = info.invokeMethodDescriptor
it + 1
} else it
}
assert(argumentCount == expectedParameters.size && argumentCount == expectedKotlinParameters.size) {
"inconsistent lambda arguments: $argumentCount on stack, ${expectedParameters.size} expected, " +
"${expectedKotlinParameters.size} Kotlin types"
}
val valueParameters =
listOfNotNull(actualInvokeDescriptor.extensionReceiverParameter) + actualInvokeDescriptor.valueParameters
val erasedInvokeFunction = ClosureCodegen.getErasedInvokeFunction(actualInvokeDescriptor)
val invokeParameters = erasedInvokeFunction.valueParameters
val valueParamShift = max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
val parameterTypesFromDesc = info.invokeMethod.argumentTypes
putStackValuesIntoLocalsForLambdaOnInvoke(
listOf(*parameterTypesFromDesc), valueParameters, invokeParameters, valueParamShift, this, coroutineDesc
)
if (parameterTypesFromDesc.isEmpty()) {
// There won't be no parameters processing and line call can be left without actual instructions.
// Note: if function is called on the line with other instructions like 1 + foo(), 'nop' will still be generated.
visitInsn(Opcodes.NOP)
var valueParamShift = max(nextLocalIndex, markerShift) + expectedParameters.sumOf { it.size }
for (index in argumentCount - 1 downTo 0) {
val type = expectedParameters[index]
StackValue.coerce(AsmTypes.OBJECT_TYPE, nullableAnyType, type, expectedKotlinParameters[index], this)
valueParamShift -= type.size
store(valueParamShift, type)
}
if (expectedParameters.isEmpty()) {
nop() // add something for a line number to bind onto
}
inlineOnlySmapSkipper?.onInlineLambdaStart(remappingMethodAdapter, info, sourceMapper.parent)
inlineOnlySmapSkipper?.onInlineLambdaStart(remappingMethodAdapter, info.node.node, sourceMapper.parent)
addInlineMarker(this, true)
val lambdaParameters = info.addAllParameters(nodeRemapper)
@@ -303,10 +282,9 @@ class MethodInliner(
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info.returnLabels, invokeCall.finallyDepthShift)
result.mergeWithNotChangeInfo(lambdaResult)
result.reifiedTypeParametersUsages.mergeAll(lambdaResult.reifiedTypeParametersUsages)
result.reifiedTypeParametersUsages.mergeAll(info.reifiedTypeParametersUsages)
StackValue
.onStack(info.invokeMethod.returnType, info.invokeMethodDescriptor.returnType)
.put(OBJECT_TYPE, erasedInvokeFunction.returnType, this)
StackValue.coerce(info.invokeMethod.returnType, info.invokeMethodReturnType, OBJECT_TYPE, nullableAnyType, this)
setLambdaInlining(false)
addInlineMarker(this, false)
inlineOnlySmapSkipper?.onInlineLambdaEnd(remappingMethodAdapter)
@@ -1073,46 +1051,6 @@ class MethodInliner(
}
}
private fun putStackValuesIntoLocalsForLambdaOnInvoke(
directOrder: List<Type>,
directOrderOfArguments: List<ParameterDescriptor>,
directOrderOfInvokeParameters: List<ValueParameterDescriptor>,
shift: Int,
iv: InstructionAdapter,
descriptor: String
) {
val actualParams = Type.getArgumentTypes(descriptor)
assert(actualParams.size == directOrder.size) {
"Number of expected and actual parameters should be equal, but ${actualParams.size} != ${directOrder.size}!"
}
var currentShift = shift + directOrder.sumOf { it.size }
val safeToUseArgumentKotlinType =
directOrder.size == directOrderOfArguments.size && directOrderOfArguments.size == directOrderOfInvokeParameters.size
for (index in directOrder.lastIndex downTo 0) {
val type = directOrder[index]
currentShift -= type.size
val typeOnStack = actualParams[index]
val argumentKotlinType: KotlinType?
val invokeParameterKotlinType: KotlinType?
if (safeToUseArgumentKotlinType) {
argumentKotlinType = directOrderOfArguments[index].type
invokeParameterKotlinType = directOrderOfInvokeParameters[index].type
} else {
argumentKotlinType = null
invokeParameterKotlinType = null
}
if (typeOnStack != type || invokeParameterKotlinType != argumentKotlinType) {
StackValue.onStack(typeOnStack, invokeParameterKotlinType).put(type, argumentKotlinType, iv)
}
iv.store(currentShift, type)
}
}
//process local and global returns (local substituted with goto end-label global kept unchanged)
@JvmStatic
fun processReturns(

View File

@@ -5,20 +5,23 @@
package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
import org.jetbrains.kotlin.builtins.isSuspendFunctionTypeOrSubtype
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil.getMethodAsmFlags
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtIfExpression
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
@@ -28,8 +31,11 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.MethodNode
class PsiInlineCodegen(
@@ -140,9 +146,9 @@ class PsiInlineCodegen(
val receiverKotlinType = receiver.kotlinType
val boxedReceiver =
if (receiverKotlinType != null)
receiver.type.boxReceiverForBoundReference(receiverKotlinType, state.typeMapper)
DescriptorAsmUtil.boxType(receiver.type, receiverKotlinType, state.typeMapper)
else
receiver.type.boxReceiverForBoundReference()
AsmUtil.boxType(receiver.type)
putClosureParametersOnStack(
lambdaInfo,
@@ -214,3 +220,139 @@ class PsiInlineCodegen(
override fun descriptorIsDeserialized(memberDescriptor: CallableMemberDescriptor): Boolean =
memberDescriptor is DescriptorWithContainerSource
}
private val FunctionDescriptor.explicitParameters
get() = listOfNotNull(extensionReceiverParameter) + valueParameters
class PsiExpressionLambda(
expression: KtExpression,
private val typeMapper: KotlinTypeMapper,
private val languageVersionSettings: LanguageVersionSettings,
isCrossInline: Boolean,
override val isBoundCallableReference: Boolean
) : ExpressionLambda(isCrossInline) {
override val lambdaClassType: Type
override val invokeMethod: Method
val invokeMethodDescriptor: FunctionDescriptor
override val invokeMethodParameters: List<KotlinType?>
get() {
val actualInvokeDescriptor = if (isSuspend)
getOrCreateJvmSuspendFunctionView(
invokeMethodDescriptor, languageVersionSettings.isReleaseCoroutines(), typeMapper.bindingContext
)
else
invokeMethodDescriptor
return actualInvokeDescriptor.explicitParameters.map { it.returnType }
}
override val invokeMethodReturnType: KotlinType?
get() = invokeMethodDescriptor.returnType
val classDescriptor: ClassDescriptor
val propertyReferenceInfo: PropertyReferenceInfo?
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
override val returnLabels: Map<String, Label?>
override val isSuspend: Boolean
val closure: CalculatedClosure
init {
val bindingContext = typeMapper.bindingContext
val function = bindingContext.get(BindingContext.FUNCTION, functionWithBodyOrCallableReference)
if (function == null && expression is KtCallableReferenceExpression) {
val variableDescriptor =
bindingContext.get(BindingContext.VARIABLE, functionWithBodyOrCallableReference) as? VariableDescriptorWithAccessors
?: throw AssertionError("Reference expression not resolved to variable descriptor with accessors: ${expression.getText()}")
classDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, variableDescriptor)
?: throw IllegalStateException("Class for callable not found: $variableDescriptor\n${expression.text}")
lambdaClassType = typeMapper.mapClass(classDescriptor)
val getFunction = PropertyReferenceCodegen.findGetFunction(variableDescriptor)
invokeMethodDescriptor = PropertyReferenceCodegen.createFakeOpenDescriptor(getFunction, classDescriptor)
val resolvedCall = expression.callableReference.getResolvedCallWithAssert(bindingContext)
propertyReferenceInfo = PropertyReferenceInfo(resolvedCall.resultingDescriptor as VariableDescriptor, getFunction)
} else {
propertyReferenceInfo = null
invokeMethodDescriptor = function ?: throw AssertionError("Function is not resolved to descriptor: " + expression.text)
classDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, invokeMethodDescriptor)
?: throw IllegalStateException("Class for invoke method not found: $invokeMethodDescriptor\n${expression.text}")
lambdaClassType = CodegenBinding.asmTypeForAnonymousClass(bindingContext, invokeMethodDescriptor)
}
closure = bindingContext.get(CodegenBinding.CLOSURE, classDescriptor)
?: throw AssertionError("null closure for lambda ${expression.text}")
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
isSuspend = invokeMethodDescriptor.isSuspend
}
override val capturedVars: List<CapturedParamDesc> by lazy {
arrayListOf<CapturedParamDesc>().apply {
val captureThis = closure.capturedOuterClassDescriptor
if (captureThis != null) {
add(capturedParamDesc(AsmUtil.CAPTURED_THIS_FIELD, typeMapper.mapType(captureThis.defaultType), isSuspend = false))
}
val capturedReceiver = closure.capturedReceiverFromOuterContext
if (capturedReceiver != null) {
val fieldName = closure.getCapturedReceiverFieldName(typeMapper.bindingContext, languageVersionSettings)
val type = typeMapper.mapType(capturedReceiver).let {
if (isBoundCallableReference) AsmUtil.boxType(it) else it
}
add(capturedParamDesc(fieldName, type, isSuspend = false))
}
closure.captureVariables.forEach { (parameter, value) ->
val isSuspend = parameter is ValueParameterDescriptor && parameter.type.isSuspendFunctionTypeOrSubtype
add(capturedParamDesc(value.fieldName, value.type, isSuspend))
}
}
}
val isPropertyReference: Boolean
get() = propertyReferenceInfo != null
}
class PsiDefaultLambda(
override val lambdaClassType: Type,
capturedArgs: Array<Type>,
private val parameterDescriptor: ValueParameterDescriptor,
offset: Int,
needReification: Boolean
) : DefaultLambda(capturedArgs, parameterDescriptor.isCrossinline, offset, needReification) {
private lateinit var invokeMethodDescriptor: FunctionDescriptor
override val invokeMethodParameters: List<KotlinType?>
get() = invokeMethodDescriptor.explicitParameters.map { it.returnType }
override val invokeMethodReturnType: KotlinType?
get() = invokeMethodDescriptor.returnType
override fun mapAsmMethod(sourceCompiler: SourceCompilerForInline, isPropertyReference: Boolean): Method {
val substitutedDescriptor = parameterDescriptor.type.memberScope
.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND)
.single()
invokeMethodDescriptor = when {
// Property references: `(A) -> B` => `get(Any?): Any?`
isPropertyReference -> substitutedDescriptor.original
// Suspend function references: `suspend (A) -> B` => `invoke(A, Continuation<B>): Any?`
// TODO: default suspend lambdas are currently uninlinable
parameterDescriptor.type.isSuspendFunctionType ->
getOrCreateJvmSuspendFunctionView(
substitutedDescriptor,
sourceCompiler.state.languageVersionSettings.isReleaseCoroutines(),
sourceCompiler.state.bindingContext
)
// Non-suspend function references and lambdas: `(A) -> B` => `invoke(A): B`
else -> substitutedDescriptor
}
return sourceCompiler.state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor).asmMethod
}
}

View File

@@ -48,7 +48,7 @@ interface SourceCompilerForInline {
val lazySourceMapper: SourceMapper
fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode
fun generateLambdaBody(lambdaInfo: ExpressionLambda, reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode
fun doCreateMethodNodeFromSource(
callableDescriptor: FunctionDescriptor,
@@ -130,7 +130,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
override val lazySourceMapper
get() = codegen.parentCodegen.orCreateSourceMapper
override fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode {
override fun generateLambdaBody(lambdaInfo: ExpressionLambda, reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode {
lambdaInfo as? PsiExpressionLambda ?: error("TODO")
val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor
val jvmMethodSignature = state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor)

View File

@@ -2,12 +2,13 @@
* Copyright 2010-2019 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.
*/
@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
package org.jetbrains.kotlin.codegen.inline.coroutines
import com.intellij.util.ArrayUtil
import jdk.internal.org.objectweb.asm.Type
import org.jetbrains.kotlin.builtins.isSuspendFunctionTypeOrSubtype
import org.jetbrains.kotlin.codegen.ClassBuilder
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.coroutines.*
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.optimization.common.asSequence
@@ -16,10 +17,12 @@ import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
@@ -250,7 +253,18 @@ fun FieldInsnNode.isSuspendLambdaCapturedByOuterObjectOrLambda(inliningContext:
while (container !is ClassDescriptor) {
container = container.containingDeclaration ?: return false
}
return isCapturedSuspendLambda(container, name, inliningContext.state.bindingContext)
val bindingContext = inliningContext.state.bindingContext
var classDescriptor: ClassDescriptor? = container
while (classDescriptor != null) {
val closure = bindingContext[CodegenBinding.CLOSURE, classDescriptor] ?: return false
for ((param, value) in closure.captureVariables) {
if (param is ValueParameterDescriptor && value.fieldName == name) {
return param.type.isSuspendFunctionTypeOrSubtype
}
}
classDescriptor = closure.capturedOuterClassDescriptor
}
return false
}
// Interpreter, that keeps track of captured functional arguments
@@ -287,4 +301,4 @@ private class CapturedLambdaInterpreter : BasicInterpreter(Opcodes.API_VERSION)
override fun merge(v: BasicValue?, w: BasicValue?): BasicValue? =
if (v is PossibleLambdaLoad && w is PossibleLambdaLoad && v.insn == w.insn) v else super.merge(v, w)
}
}

View File

@@ -579,8 +579,8 @@ class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
const val LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER = 1
}
fun onInlineLambdaStart(mv: MethodVisitor, info: LambdaInfo, smap: SourceMapper) {
val firstLine = info.node.node.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
fun onInlineLambdaStart(mv: MethodVisitor, lambda: MethodNode, smap: SourceMapper) {
val firstLine = lambda.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
if (callLineNumber >= 0 && firstLine == callLineNumber) {
// We want the debugger to be able to break both on the inline call itself, plus on each
// invocation of the inline lambda passed to it. For that to happen there needs to be at least

View File

@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.isInlineClassType
import org.jetbrains.kotlin.resolve.underlyingRepresentation
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
import org.jetbrains.kotlin.types.KotlinType
@@ -26,9 +24,8 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.commons.Method
fun KotlinType.isInlineClassWithUnderlyingTypeAnyOrAnyN(): Boolean {
if (!isInlineClassType()) return false
val classDescriptor = constructor.declarationDescriptor as? ClassDescriptor ?: return false
return classDescriptor.underlyingRepresentation()?.type?.isAnyOrNullableAny() == true
val classDescriptor = constructor.declarationDescriptor
return classDescriptor is ClassDescriptor && classDescriptor.inlineClassRepresentation?.underlyingType?.isAnyOrNullableAny() == true
}
fun CallableDescriptor.isGenericParameter(): Boolean {
@@ -79,4 +76,4 @@ fun classFileContainsMethod(classId: ClassId, state: GenerationState, method: Me
}
}, ClassReader.SKIP_FRAMES)
return found
}
}

View File

@@ -18,12 +18,16 @@ package org.jetbrains.kotlin.codegen.optimization.boxing
import com.google.common.collect.ImmutableSet
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.coroutines.RELEASE_COROUTINES_VERSION_SETTINGS
import org.jetbrains.kotlin.codegen.coroutines.coroutinesJvmInternalPackageFqName
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter
import org.jetbrains.kotlin.codegen.optimization.common.StrictBasicValue
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.codegen.topLevelClassInternalName
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
import org.jetbrains.org.objectweb.asm.Opcodes
@@ -174,7 +178,7 @@ fun AbstractInsnNode.isUnboxing(state: GenerationState) =
isPrimitiveUnboxing() || isJavaLangClassUnboxing() || isInlineClassUnboxing(state)
fun AbstractInsnNode.isBoxing(state: GenerationState) =
isPrimitiveBoxing() || isJavaLangClassBoxing() || isInlineClassBoxing(state)
isPrimitiveBoxing() || isJavaLangClassBoxing() || isInlineClassBoxing(state) || isCoroutinePrimitiveBoxing()
fun AbstractInsnNode.isPrimitiveUnboxing() =
isMethodInsnWith(Opcodes.INVOKEVIRTUAL) {
@@ -211,6 +215,19 @@ fun AbstractInsnNode.isPrimitiveBoxing() =
isBoxingMethodDescriptor()
}
private val BOXING_CLASS_INTERNAL_NAME =
RELEASE_COROUTINES_VERSION_SETTINGS.coroutinesJvmInternalPackageFqName().child(Name.identifier("Boxing")).topLevelClassInternalName()
private fun isJvmPrimitiveName(name: String) = JvmPrimitiveType.values().any { it.javaKeywordName == name }
fun AbstractInsnNode.isCoroutinePrimitiveBoxing(): Boolean {
return isMethodInsnWith(Opcodes.INVOKESTATIC) {
owner == BOXING_CLASS_INTERNAL_NAME &&
name.startsWith("box") &&
isJvmPrimitiveName(name.substring(3).lowercase())
}
}
private fun MethodInsnNode.isBoxingMethodDescriptor(): Boolean {
val ownerType = Type.getObjectType(owner)
return desc == Type.getMethodDescriptor(ownerType, AsmUtil.unboxType(ownerType))

View File

@@ -17,12 +17,9 @@
package org.jetbrains.kotlin.codegen.optimization.boxing
import org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor
import org.jetbrains.kotlin.codegen.optimization.common.debugText
import org.jetbrains.kotlin.codegen.optimization.common.isLoadOperation
import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
import org.jetbrains.kotlin.codegen.optimization.fixStack.peekWords
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.removeNodeGetNext
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.tree.*
@@ -32,91 +29,66 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
import java.util.*
private typealias Transformation = (AbstractInsnNode) -> Unit
class PopBackwardPropagationTransformer : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
if (!OptimizationMethodVisitor.canBeOptimizedUsingSourceInterpreter(methodNode)) return
Transformer(methodNode).transform()
if (methodNode.instructions.any { it.isPop() || it.isPurePush() }) {
Transformer(methodNode).transform()
}
}
private class Transformer(val methodNode: MethodNode) {
private interface Transformation {
fun apply(insn: AbstractInsnNode)
}
private inline fun Transformation(crossinline body: (AbstractInsnNode) -> Unit): Transformation =
object : Transformation {
override fun apply(insn: AbstractInsnNode) {
body(insn)
}
}
private val REPLACE_WITH_NOP = Transformation { insnList.set(it, createRemovableNopInsn()) }
private val REPLACE_WITH_POP1 = Transformation { insnList.set(it, InsnNode(Opcodes.POP)) }
private val REPLACE_WITH_POP2 = Transformation { insnList.set(it, InsnNode(Opcodes.POP2)) }
private val INSERT_POP1_AFTER = Transformation { insnList.insert(it, InsnNode(Opcodes.POP)) }
private val INSERT_POP2_AFTER = Transformation { insnList.insert(it, InsnNode(Opcodes.POP2)) }
private val REPLACE_WITH_NOP: Transformation = { insnList.set(it, InsnNode(Opcodes.NOP)) }
private val REPLACE_WITH_POP1: Transformation = { insnList.set(it, InsnNode(Opcodes.POP)) }
private val REPLACE_WITH_POP2: Transformation = { insnList.set(it, InsnNode(Opcodes.POP2)) }
private val INSERT_POP1_AFTER: Transformation = { insnList.insert(it, InsnNode(Opcodes.POP)) }
private val INSERT_POP2_AFTER: Transformation = { insnList.insert(it, InsnNode(Opcodes.POP2)) }
private val insnList = methodNode.instructions
private val insns = insnList.toArray()
private val dontTouchInsnIndices = BitSet(insns.size)
private val transformations = hashMapOf<AbstractInsnNode, Transformation>()
private val removableNops = hashSetOf<InsnNode>()
private val frames by lazy { analyzeMethodBody() }
fun transform() {
if (insns.none { it.isPop() || it.isPurePush() }) return
computeTransformations()
for ((insn, transformation) in transformations.entries) {
transformation.apply(insn)
}
postprocessNops()
}
private fun analyzeMethodBody(): Array<out Frame<SourceValue>?> {
val frames = Analyzer<SourceValue>(HazardsTrackingInterpreter()).analyze("fake", methodNode)
postprocessStackHazards(frames)
return frames
}
private fun postprocessStackHazards(frames: Array<out Frame<SourceValue>?>) {
val insns = methodNode.instructions.toArray()
for (i in frames.indices) {
val frames = Analyzer(HazardsTrackingInterpreter()).analyze("fake", methodNode)
for ((i, insn) in insns.withIndex()) {
val frame = frames[i] ?: continue
val insn = insns[i]
when (insn.opcode) {
Opcodes.POP2 -> {
val top2 = frame.peekWords(2) ?: throwIncorrectBytecode(insn, frame)
top2.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP_X1 -> {
val top2 = frame.peekWords(1, 1) ?: throwIncorrectBytecode(insn, frame)
top2.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP2_X1 -> {
val top3 = frame.peekWords(2, 1) ?: throwIncorrectBytecode(insn, frame)
top3.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP_X2 -> {
val top3 = frame.peekWords(1, 2) ?: throwIncorrectBytecode(insn, frame)
top3.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP2_X2 -> {
val top4 = frame.peekWords(2, 2) ?: throwIncorrectBytecode(insn, frame)
top4.forEach { it.insns.markAsDontTouch() }
Opcodes.POP ->
frame.top()?.let { input ->
// If this POP won't be removed, other POPs that touch the same values have to stay as well.
if (input.insns.any { it.shouldKeep() } || input.longerWhenFusedWithPop()) {
input.insns.markAsDontTouch()
}
}
Opcodes.POP2 -> frame.peekWords(2)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP_X1 -> frame.peekWords(1, 1)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP2_X1 -> frame.peekWords(2, 1)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP_X2 -> frame.peekWords(1, 2)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP2_X2 -> frame.peekWords(2, 2)?.forEach { it.insns.markAsDontTouch() }
}
}
val transformations = hashMapOf<AbstractInsnNode, Transformation>()
for ((i, insn) in insns.withIndex()) {
val frame = frames[i] ?: continue
if (insn.opcode == Opcodes.POP) {
val input = frame.top() ?: continue
if (input.insns.none { it.shouldKeep() }) {
transformations[insn] = REPLACE_WITH_NOP
input.insns.forEach {
if (it !in transformations) {
transformations[it] = it.combineWithPop(frames, input.size)
}
}
}
}
}
}
private fun throwIncorrectBytecode(insn: AbstractInsnNode?, frame: Frame<SourceValue>): Nothing {
throw AssertionError("Incorrect bytecode at ${methodNode.instructions.indexOf(insn)}: ${insn.debugText} $frame")
for ((insn, transformation) in transformations.entries) {
transformation(insn)
}
}
private inner class HazardsTrackingInterpreter : SourceInterpreter(Opcodes.API_VERSION) {
@@ -133,9 +105,7 @@ class PopBackwardPropagationTransformer : MethodTransformer() {
}
override fun unaryOperation(insn: AbstractInsnNode, value: SourceValue): SourceValue {
if (insn.opcode != Opcodes.CHECKCAST && !insn.isPrimitiveTypeConversion()) {
value.insns.markAsDontTouch()
}
value.insns.markAsDontTouch()
return super.unaryOperation(insn, value)
}
@@ -164,153 +134,48 @@ class PopBackwardPropagationTransformer : MethodTransformer() {
}
}
private fun computeTransformations() {
transformations.clear()
for (i in insns.indices) {
if (frames[i] == null) continue
val insn = insns[i]
if (insn.opcode == Opcodes.POP) {
propagatePopBackwards(insn, 0)
}
}
}
private fun propagatePopBackwards(insn: AbstractInsnNode, poppedValueSize: Int) {
if (transformations.containsKey(insn)) return
private fun SourceValue.longerWhenFusedWithPop() = insns.fold(0) { x, insn ->
when {
insn.opcode == Opcodes.POP -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
if (sources.all { !isDontTouch(it) } && sources.any { isTransformablePopOperand(it) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
insn.isPurePush() -> x - 1
insn.isPrimitiveBoxing() || insn.isPrimitiveTypeConversion() -> x
else -> x + 1
}
} > 0
private fun AbstractInsnNode.combineWithPop(frames: Array<out Frame<SourceValue>?>, resultSize: Int): Transformation =
when {
isPurePush() -> REPLACE_WITH_NOP
isPrimitiveBoxing() || isPrimitiveTypeConversion() -> {
val index = insnList.indexOf(this)
val frame = frames[index] ?: throw AssertionError("dead instruction #$index used by non-dead instruction")
val input = frame.top() ?: throw AssertionError("coercion instruction at #$index has no input")
when (input.size) {
1 -> REPLACE_WITH_POP1
2 -> REPLACE_WITH_POP2
else -> throw AssertionError("Unexpected pop value size: ${input.size}")
}
}
insn.opcode == Opcodes.CHECKCAST -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
val resultType = (insn as TypeInsnNode).desc
if (sources.all { !isDontTouch(it) } && sources.any { isTransformableCheckcastOperand(it, resultType) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
} else {
transformations[insn] = insertPopAfterTransformation(poppedValueSize)
else ->
when (resultSize) {
1 -> INSERT_POP1_AFTER
2 -> INSERT_POP2_AFTER
else -> throw AssertionError("Unexpected pop value size: $resultSize")
}
}
insn.isPrimitiveBoxing() -> {
val boxedValueSize = getInputTop(insn).size
transformations[insn] = replaceWithPopTransformation(boxedValueSize)
}
insn.isPurePush() -> {
transformations[insn] = replaceWithNopTransformation()
}
insn.isPrimitiveTypeConversion() -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
if (sources.all { !isDontTouch(it) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
} else {
transformations[insn] = replaceWithPopTransformation(poppedValueSize)
}
}
else -> {
transformations[insn] = insertPopAfterTransformation(poppedValueSize)
}
}
}
private fun postprocessNops() {
var node: AbstractInsnNode? = insnList.first
var hasRemovableNops = false
while (node != null) {
node = node.next
val begin = node ?: break
while (node != null && node !is LabelNode) {
if (node in removableNops) {
hasRemovableNops = true
}
node = node.next
}
val end = node
if (hasRemovableNops) {
removeUnneededNopsInRange(begin, end)
}
hasRemovableNops = false
}
}
private fun removeUnneededNopsInRange(begin: AbstractInsnNode, end: AbstractInsnNode?) {
var node: AbstractInsnNode? = begin
var keepNop = true
while (node != null && node != end) {
if (node in removableNops && !keepNop) {
node = insnList.removeNodeGetNext(node)
} else {
if (node.isMeaningful) keepNop = false
node = node.next
}
}
}
private fun replaceWithPopTransformation(size: Int): Transformation =
when (size) {
1 -> REPLACE_WITH_POP1
2 -> REPLACE_WITH_POP2
else -> throw AssertionError("Unexpected pop value size: $size")
}
private fun insertPopAfterTransformation(size: Int): Transformation =
when (size) {
1 -> INSERT_POP1_AFTER
2 -> INSERT_POP2_AFTER
else -> throw AssertionError("Unexpected pop value size: $size")
}
private fun replaceWithNopTransformation(): Transformation =
REPLACE_WITH_NOP
private fun createRemovableNopInsn() =
InsnNode(Opcodes.NOP).apply { removableNops.add(this) }
private fun getInputTop(insn: AbstractInsnNode): SourceValue {
val i = insnList.indexOf(insn)
val frame = frames[i] ?: throw AssertionError("Unexpected dead instruction #$i")
return frame.top() ?: throw AssertionError("Instruction #$i has empty stack on input")
}
private fun isTransformableCheckcastOperand(it: AbstractInsnNode, resultType: String) =
it.isPrimitiveBoxing() && (it as MethodInsnNode).owner == resultType
private fun isTransformablePopOperand(insn: AbstractInsnNode) =
insn.opcode == Opcodes.CHECKCAST || insn.isPrimitiveBoxing() || insn.isPurePush()
private fun isDontTouch(insn: AbstractInsnNode) =
dontTouchInsnIndices[insnList.indexOf(insn)]
private fun AbstractInsnNode.shouldKeep() =
dontTouchInsnIndices[insnList.indexOf(this)]
}
}
fun AbstractInsnNode.isPurePush() =
isLoadOperation() ||
opcode in Opcodes.ACONST_NULL..Opcodes.LDC + 2 ||
isUnitInstance()
isLoadOperation() || opcode in Opcodes.ACONST_NULL..Opcodes.LDC + 2 || isUnitInstance()
fun AbstractInsnNode.isPop() =
opcode == Opcodes.POP || opcode == Opcodes.POP2
fun AbstractInsnNode.isUnitInstance() =
opcode == Opcodes.GETSTATIC &&
this is FieldInsnNode && owner == "kotlin/Unit" && name == "INSTANCE"
opcode == Opcodes.GETSTATIC && this is FieldInsnNode && owner == "kotlin/Unit" && name == "INSTANCE"
fun AbstractInsnNode.isPrimitiveTypeConversion() =
opcode in Opcodes.I2L..Opcodes.I2S

View File

@@ -39,7 +39,7 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
override fun transform(internalClassName: String, node: MethodNode) {
val interpreter = RedundantBoxingInterpreter(node.instructions, generationState)
val frames = MethodTransformer.analyze(internalClassName, node, interpreter)
val frames = analyze(internalClassName, node, interpreter)
interpretPopInstructionsForBoxedValues(interpreter, node, frames)
@@ -168,7 +168,8 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
val frame = frames[i] ?: continue
val insn = insnList[i]
if ((insn.opcode == Opcodes.ASTORE || insn.opcode == Opcodes.ALOAD) &&
(insn as VarInsnNode).`var` == localVariableNode.index) {
(insn as VarInsnNode).`var` == localVariableNode.index
) {
if (insn.getOpcode() == Opcodes.ASTORE) {
values.add(frame.top()!!)
} else {

View File

@@ -19,14 +19,12 @@ package org.jetbrains.kotlin.codegen.optimization.boxing
import org.jetbrains.kotlin.codegen.optimization.common.findPreviousOrNull
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import org.jetbrains.org.objectweb.asm.tree.InsnList
import org.jetbrains.org.objectweb.asm.tree.InsnNode
import org.jetbrains.org.objectweb.asm.tree.MethodNode
import org.jetbrains.org.objectweb.asm.tree.*
class StackPeepholeOptimizationsTransformer : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
while (transformOnce(methodNode)) {
while (true) {
if (!transformOnce(methodNode)) break
}
}
@@ -115,20 +113,26 @@ class StackPeepholeOptimizationsTransformer : MethodTransformer() {
opcode == Opcodes.DUP
private fun AbstractInsnNode.isPurePushOfSize1(): Boolean =
opcode in Opcodes.ACONST_NULL..Opcodes.FCONST_2 ||
opcode in Opcodes.BIPUSH..Opcodes.ILOAD ||
opcode == Opcodes.FLOAD ||
opcode == Opcodes.ALOAD ||
isUnitInstance()
!isLdcOfSize2() && (
opcode in Opcodes.ACONST_NULL..Opcodes.FCONST_2 ||
opcode in Opcodes.BIPUSH..Opcodes.ILOAD ||
opcode == Opcodes.FLOAD ||
opcode == Opcodes.ALOAD ||
isUnitInstance()
)
private fun AbstractInsnNode.isEliminatedByPop2() =
isPurePushOfSize2() ||
opcode == Opcodes.DUP2
private fun AbstractInsnNode.isPurePushOfSize2(): Boolean =
opcode == Opcodes.LCONST_0 || opcode == Opcodes.LCONST_1 ||
isLdcOfSize2() ||
opcode == Opcodes.LCONST_0 || opcode == Opcodes.LCONST_1 ||
opcode == Opcodes.DCONST_0 || opcode == Opcodes.DCONST_1 ||
opcode == Opcodes.LLOAD ||
opcode == Opcodes.DLOAD
private fun AbstractInsnNode.isLdcOfSize2(): Boolean =
opcode == Opcodes.LDC && this is LdcInsnNode && (this.cst is Double || this.cst is Long)
}

View File

@@ -29,4 +29,7 @@ class JvmCodegenStringTable @JvmOverloads constructor(
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), true)
}
}
override val isLocalClassIdReplacementKeptGeneric: Boolean
get() = true
}

View File

@@ -30,6 +30,7 @@ dependencies {
compile(project(":compiler:fir:fir2ir"))
compile(project(":compiler:fir:fir2ir:jvm-backend"))
compile(project(":compiler:fir:checkers"))
compile(project(":compiler:fir:checkers:checkers.jvm"))
compile(project(":kotlin-util-klib"))
compile(project(":kotlin-util-io"))

View File

@@ -151,9 +151,18 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
)
var irModuleName: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xir-legacy-property-access", description = "Force property access via JS properties (requires -Xir-export-all)")
var irLegacyPropertyAccess: Boolean by FreezableVar(false)
@Argument(value = "-Xir-base-class-in-metadata", description = "Write base class into metadata")
var irBaseClassInMetadata: Boolean by FreezableVar(false)
@Argument(value = "-Xir-per-module", description = "Splits generated .js per-module")
var irPerModule: Boolean by FreezableVar(false)
@Argument(value = "-Xir-per-module-output-name", description = "Adds a custom output name to the splitted js files")
var irPerModuleOutputName: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xinclude",
valueDescription = "<path>",
@@ -161,6 +170,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
)
var includes: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xcache-directories",
valueDescription = "<path>",
description = "A path to cache directories"
)
var cacheDirectories: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xir-build-cache", description = "Use compiler to build cache")
var irBuildCache: Boolean by FreezableVar(false)
@Argument(
value = "-Xgenerate-dts",
description = "Generate TypeScript declarations .d.ts file alongside JS file. Available in IR backend only."
@@ -212,7 +231,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
}
fun K2JSCompilerArguments.isPreIrBackendDisabled(): Boolean =
irOnly || irProduceJs || irProduceKlibFile
irOnly || irProduceJs || irProduceKlibFile || irBuildCache
fun K2JSCompilerArguments.isIrBackendEnabled(): Boolean =
irProduceKlibDir || irProduceJs || irProduceKlibFile || wasm
irProduceKlibDir || irProduceJs || irProduceKlibFile || wasm || irBuildCache

View File

@@ -30,6 +30,11 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR")
var includeRuntime: Boolean by FreezableVar(false)
@DeprecatedOption(
message = "This option is not working well with Gradle caching and will be removed in the future.",
removeAfter = "1.7",
level = DeprecationLevel.WARNING
)
@GradleOption(DefaultValues.StringNullDefault::class)
@Argument(
value = "-jdk-home",

View File

@@ -161,9 +161,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val outputFile = File(outputFilePath)
val moduleName = arguments.irModuleName ?: FileUtil.getNameWithoutExtension(outputFile)
configurationJs.put(
CommonConfigurationKeys.MODULE_NAME,
arguments.irModuleName ?: FileUtil.getNameWithoutExtension(outputFile)
moduleName
)
// TODO: in this method at least 3 different compiler configurations are used (original, env.configuration, jsConfig.configuration)
@@ -205,7 +206,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
friendDependencies = friendDependencies,
irFactory = PersistentIrFactory(), // TODO IrFactoryImpl?
outputKlibPath = outputFile.path,
nopack = arguments.irProduceKlibDir
nopack = arguments.irProduceKlibDir,
jsOutputName = arguments.irPerModuleOutputName,
)
}
@@ -273,9 +275,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
multiModule = arguments.irPerModule,
relativeRequirePath = true,
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
legacyPropertyAccess = arguments.irLegacyPropertyAccess,
baseClassIntoMetadata = arguments.irBaseClassInMetadata,
)
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
outputFile.writeText(jsCode.mainModule)
jsCode.dependencies.forEach { (name, content) ->

View File

@@ -53,6 +53,7 @@ public class Usage {
appendln(sb, "Advanced options are non-standard and may be changed or removed without any notice.");
}
else {
renderOptionJUsage(sb);
renderArgfileUsage(sb);
}
@@ -103,6 +104,15 @@ public class Usage {
appendln(sb, argument.description().replace("\n", "\n" + StringsKt.repeat(" ", OPTION_NAME_PADDING_WIDTH)));
}
private static void renderOptionJUsage(@NotNull StringBuilder sb) {
int descriptionStart = sb.length() + OPTION_NAME_PADDING_WIDTH;
sb.append(" -J<option>");
while (sb.length() < descriptionStart) {
sb.append(" ");
}
appendln(sb, "Pass an option directly to JVM");
}
private static void renderArgfileUsage(@NotNull StringBuilder sb) {
int descriptionStart = sb.length() + OPTION_NAME_PADDING_WIDTH;
sb.append(" ");

View File

@@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.light.LightJavaModule
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.cli.common.config.ContentRoot
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
@@ -37,6 +38,7 @@ import org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder
import org.jetbrains.kotlin.cli.jvm.modules.JavaModuleGraph
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.isValidJavaFqName
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
import org.jetbrains.kotlin.resolve.jvm.modules.KOTLIN_STDLIB_MODULE_NAME
@@ -52,10 +54,13 @@ class ClasspathRootsResolver(
private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?,
private val javaModuleFinder: CliJavaModuleFinder,
private val requireStdlibModule: Boolean,
private val outputDirectory: VirtualFile?
private val outputDirectory: VirtualFile?,
private val javaFileManager: KotlinCliJavaFileManager
) {
val javaModuleGraph = JavaModuleGraph(javaModuleFinder)
private val searchScope = GlobalSearchScope.allScope(psiManager.project)
data class RootsAndModules(val roots: List<JavaRoot>, val modules: List<JavaModule>)
private data class RootWithPrefix(val root: VirtualFile, val packagePrefix: String?)
@@ -160,7 +165,7 @@ class ClasspathRootsResolver(
}
if (moduleInfoFile != null) {
val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null
val moduleInfo = JavaModuleInfo.read(moduleInfoFile, javaFileManager, searchScope) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile)
}

View File

@@ -37,7 +37,7 @@ class CliKotlinAsJavaSupport(
return findFacadeFilesInPackage(packageFqName, scope)
.groupBy { it.javaFileFacadeFqName }
.mapNotNull { (facadeClassFqName, _) ->
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope)
KtLightClassForFacadeImpl.createForFacade(psiManager, facadeClassFqName, scope)
}
}
@@ -54,7 +54,7 @@ class CliKotlinAsJavaSupport(
.orEmpty()
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
return listOfNotNull(KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope))
return listOfNotNull(KtLightClassForFacadeImpl.createForFacade(psiManager, facadeFqName, scope))
}
override fun getScriptClasses(scriptFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {

View File

@@ -35,6 +35,10 @@ class CliVirtualFileFinder(
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? =
findBinaryClass(classId, classId.relativeClassName.asString().replace('.', '$') + ".class")
override fun findSourceOrBinaryVirtualFile(classId: ClassId) =
findBinaryClass(classId, classId.relativeClassName.asString().replace('.', '$') + ".class")
?: findSourceClass(classId, classId.relativeClassName.asString() + ".java")
override fun findMetadata(classId: ClassId): InputStream? {
assert(!classId.isNestedClass) { "Nested classes are not supported here: $classId" }
@@ -61,8 +65,11 @@ class CliVirtualFileFinder(
return findBinaryClass(classId, BuiltInSerializerProtocol.getBuiltInsFileName(packageFqName))?.inputStream
}
private fun findBinaryClass(classId: ClassId, fileName: String): VirtualFile? =
index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, _ ->
private fun findClass(classId: ClassId, fileName: String, rootType: Set<JavaRoot.RootType>) =
index.findClass(classId, acceptedRootTypes = rootType) { dir, _ ->
dir.findChild(fileName)?.takeIf(VirtualFile::isValid)
}?.takeIf { it in scope }
private fun findBinaryClass(classId: ClassId, fileName: String) = findClass(classId, fileName, JavaRoot.OnlyBinary)
private fun findSourceClass(classId: ClassId, fileName: String) = findClass(classId, fileName, JavaRoot.OnlySource)
}

View File

@@ -0,0 +1,234 @@
/*
* 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.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.ProjectScope
import org.jetbrains.kotlin.asJava.FilteredJvmDiagnostics
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensionsImpl
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.backend.jvm.jvmPhases
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.STRONG_WARNING
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.cli.jvm.config.JvmModulePathRoot
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
import org.jetbrains.kotlin.cli.jvm.config.jvmModularRoots
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
import org.jetbrains.kotlin.codegen.CodegenFactory
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.container.get
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.FirJvmBackendExtension
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
import org.jetbrains.kotlin.fir.session.FirSessionFactory
import org.jetbrains.kotlin.fir.session.FirSessionFactory.createSessionWithDependencies
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvider
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.resolve.CompilerEnvironment
import org.jetbrains.kotlin.resolve.diagnostics.SimpleGenericDiagnostics
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
import java.io.File
object FirKotlinToJvmBytecodeCompiler {
fun compileModulesUsingFrontendIR(
environment: KotlinCoreEnvironment,
buildFile: File?,
chunk: List<Module>,
extendedAnalysisMode: Boolean
): Boolean {
val project = environment.project
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
environment.messageCollector.report(
STRONG_WARNING,
"ATTENTION!\n This build uses in-dev FIR: \n -Xuse-fir"
)
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
val projectConfiguration = environment.configuration
val localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
val outputs = newLinkedHashMapWithExpectedSize<Module, GenerationState>(chunk.size)
val targetIds = environment.configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId)
val incrementalComponents = environment.configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
for (module in chunk) {
performanceManager?.notifyAnalysisStarted()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
val ktFiles = module.getSourceFiles(environment, localFileSystem, chunk.size > 1, buildFile)
if (!checkKotlinPackageUsage(environment, ktFiles)) return false
val syntaxErrors = ktFiles.fold(false) { errorsFound, ktFile ->
AnalyzerWithCompilerReport.reportSyntaxErrors(ktFile, environment.messageCollector).isHasErrors or errorsFound
}
val moduleConfiguration = projectConfiguration.applyModuleProperties(module, buildFile)
val sourceScope = GlobalSearchScope.filesWithoutLibrariesScope(project, ktFiles.map { it.virtualFile })
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
var librariesScope = ProjectScope.getLibrariesScope(project)
val providerAndScopeForIncrementalCompilation = run {
if (targetIds == null || incrementalComponents == null) return@run null
val fileSystem = environment.projectEnvironment.environment.localFileSystem
val directoryWithIncrementalPartsFromPreviousCompilation =
moduleConfiguration[JVMConfigurationKeys.OUTPUT_DIRECTORY]
?: return@run null
val previouslyCompiledFiles = directoryWithIncrementalPartsFromPreviousCompilation.walk()
.filter { it.extension == "class" }
.mapNotNull { fileSystem.findFileByIoFile(it) }
.toList()
.takeIf { it.isNotEmpty() }
?: return@run null
val packagePartProvider = IncrementalPackagePartProvider(
environment.createPackagePartProvider(sourceScope),
targetIds.map(incrementalComponents::getIncrementalCache)
)
val incrementalCompilationScope = GlobalSearchScope.filesWithoutLibrariesScope(
project,
previouslyCompiledFiles
)
librariesScope = librariesScope.intersectWith(GlobalSearchScope.notScope(incrementalCompilationScope))
FirSessionFactory.ProviderAndScopeForIncrementalCompilation(packagePartProvider, incrementalCompilationScope)
}
val languageVersionSettings = moduleConfiguration.languageVersionSettings
val session = createSessionWithDependencies(
Name.identifier(module.getModuleName()),
JvmPlatforms.unspecifiedJvmPlatform,
JvmPlatformAnalyzerServices,
externalSessionProvider = null,
project,
languageVersionSettings,
sourceScope,
librariesScope,
lookupTracker = environment.configuration.get(CommonConfigurationKeys.LOOKUP_TRACKER),
providerAndScopeForIncrementalCompilation,
getPackagePartProvider = { environment.createPackagePartProvider(it) },
dependenciesConfigurator = {
dependencies(moduleConfiguration.jvmClasspathRoots.map { it.toPath() })
dependencies(moduleConfiguration.jvmModularRoots.map { it.toPath() })
friendDependencies(moduleConfiguration[JVMConfigurationKeys.FRIEND_PATHS] ?: emptyList())
},
sessionConfigurator = {
if (extendedAnalysisMode) {
registerExtendedCommonCheckers()
}
}
)
val firAnalyzerFacade = FirAnalyzerFacade(session, languageVersionSettings, ktFiles)
firAnalyzerFacade.runResolution()
val firDiagnostics = firAnalyzerFacade.runCheckers().values.flatten()
AnalyzerWithCompilerReport.reportDiagnostics(
SimpleGenericDiagnostics(firDiagnostics),
environment.messageCollector
)
performanceManager?.notifyAnalysisFinished()
if (syntaxErrors || firDiagnostics.any { it.severity == Severity.ERROR }) {
return false
}
performanceManager?.notifyGenerationStarted()
performanceManager?.notifyIRTranslationStarted()
val extensions = JvmGeneratorExtensionsImpl()
val (moduleFragment, symbolTable, components) = firAnalyzerFacade.convertToIr(extensions)
performanceManager?.notifyIRTranslationFinished()
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
val codegenFactory = JvmIrCodegenFactory(moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases))
// Create and initialize the module and its dependencies
val container = TopDownAnalyzerFacadeForJVM.createContainer(
project, ktFiles, NoScopeRecordCliBindingTrace(), environment.configuration, environment::createPackagePartProvider,
::FileBasedDeclarationProviderFactory, CompilerEnvironment,
TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, ktFiles), emptyList()
)
val generationState = GenerationState.Builder(
environment.project, ClassBuilderFactories.BINARIES,
container.get(), dummyBindingContext, ktFiles,
moduleConfiguration
).codegenFactory(
codegenFactory
).withModule(
module
).onIndependentPartCompilationEnd(
createOutputFilesFlushingCallbackIfPossible(moduleConfiguration)
).isIrBackend(
true
).jvmBackendClassResolver(
FirJvmBackendClassResolver(components)
).build()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
performanceManager?.notifyIRLoweringStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, extensions, FirJvmBackendExtension(session, components)
) {
performanceManager?.notifyIRLoweringFinished()
performanceManager?.notifyIRGenerationStarted()
}
CodegenFactory.doCheckCancelled(generationState)
generationState.factory.done()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
AnalyzerWithCompilerReport.reportDiagnostics(
FilteredJvmDiagnostics(
generationState.collectedExtraJvmDiagnostics,
dummyBindingContext.diagnostics
),
environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished()
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
Disposer.dispose(environment.project)
}
val mainClassFqName: FqName? =
if (chunk.size == 1 && projectConfiguration.get(JVMConfigurationKeys.OUTPUT_JAR) != null)
TODO(".jar output is not yet supported for -Xuse-fir: KT-42868")
else null
return writeOutputs(environment, projectConfiguration, chunk, outputs, mainClassFqName)
}
}

View File

@@ -82,7 +82,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
private val binaryCache: MutableMap<ClassId, JavaClass?> = THashMap()
private val signatureParsingComponent = BinaryClassSignatureParser()
fun findClass(classId: ClassId, searchScope: GlobalSearchScope): JavaClass? = findClass(JavaClassFinder.Request(classId), searchScope)
fun findClass(classId: ClassId, searchScope: GlobalSearchScope) = findClass(JavaClassFinder.Request(classId), searchScope)
override fun findClass(request: JavaClassFinder.Request, searchScope: GlobalSearchScope): JavaClass? {
val (classId, classFileContentFromRequest, outerClassFromRequest) = request

View File

@@ -190,11 +190,17 @@ class KotlinCoreEnvironment private constructor(
sourceFiles.sortBy { it.virtualFile.path }
val javaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
val jdkHome = configuration.get(JVMConfigurationKeys.JDK_HOME)
val jrtFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JRT_PROTOCOL)
val javaModuleFinder = CliJavaModuleFinder(jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
})
val javaModuleFinder = CliJavaModuleFinder(
jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
},
javaFileManager,
project
)
val outputDirectory =
configuration.get(JVMConfigurationKeys.MODULES)?.singleOrNull()?.getOutputDirectory()
@@ -207,7 +213,8 @@ class KotlinCoreEnvironment private constructor(
this::contentRootToVirtualFile,
javaModuleFinder,
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE),
outputDirectory?.let(this::findLocalFile)
outputDirectory?.let(this::findLocalFile),
javaFileManager
)
val (initialRoots, javaModules) =
@@ -231,7 +238,7 @@ class KotlinCoreEnvironment private constructor(
updateClasspathFromRootsIndex(this)
}
(ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl).initialize(
javaFileManager.initialize(
rootsIndex,
packagePartProviders,
SingleJavaFileRootsIndex(singleJavaFileRoots),
@@ -240,7 +247,7 @@ class KotlinCoreEnvironment private constructor(
project.registerService(
JavaModuleResolver::class.java,
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList())
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList(), project)
)
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)

View File

@@ -78,10 +78,7 @@ import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.config.APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.extensions.*
import org.jetbrains.kotlin.extensions.internal.CandidateInterceptor
import org.jetbrains.kotlin.extensions.internal.TypeResolutionInterceptor
@@ -193,11 +190,16 @@ class KotlinCoreEnvironment private constructor(
sourceFiles.sortBy { it.virtualFile.path }
val javaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
val jdkHome = configuration.get(JVMConfigurationKeys.JDK_HOME)
val jrtFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JRT_PROTOCOL)
val javaModuleFinder = CliJavaModuleFinder(jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
})
val javaModuleFinder = CliJavaModuleFinder(
jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
},
javaFileManager
)
val outputDirectory =
configuration.get(JVMConfigurationKeys.MODULES)?.singleOrNull()?.getOutputDirectory()
@@ -210,7 +212,8 @@ class KotlinCoreEnvironment private constructor(
this::contentRootToVirtualFile,
javaModuleFinder,
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE),
outputDirectory?.let(this::findLocalFile)
outputDirectory?.let(this::findLocalFile),
javaFileManager
)
val (initialRoots, javaModules) =
@@ -234,7 +237,7 @@ class KotlinCoreEnvironment private constructor(
updateClasspathFromRootsIndex(this)
}
(ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl).initialize(
javaFileManager.initialize(
rootsIndex,
packagePartProviders,
SingleJavaFileRootsIndex(singleJavaFileRoots),
@@ -243,7 +246,7 @@ class KotlinCoreEnvironment private constructor(
project.registerService(
JavaModuleResolver::class.java,
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList())
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList(), project)
)
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)

View File

@@ -17,140 +17,42 @@
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.*
import com.intellij.psi.PsiElementFinder
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.search.DelegatingGlobalSearchScope
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.ProjectScope
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.asJava.FilteredJvmDiagnostics
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensionsImpl
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.backend.jvm.jvmPhases
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.writeAll
import org.jetbrains.kotlin.cli.common.toLogger
import org.jetbrains.kotlin.cli.jvm.config.*
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
import org.jetbrains.kotlin.codegen.CodegenFactory
import org.jetbrains.kotlin.codegen.DefaultCodegenFactory
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
import org.jetbrains.kotlin.codegen.state.GenerationState
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.Severity
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendExtension
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
import org.jetbrains.kotlin.fir.createSessionWithDependencies
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.ir.backend.jvm.jvmResolveLibraries
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvider
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CompilerEnvironment
import org.jetbrains.kotlin.resolve.diagnostics.SimpleGenericDiagnostics
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
import java.io.File
import kotlin.collections.set
object KotlinToJVMBytecodeCompiler {
private fun writeOutput(
configuration: CompilerConfiguration,
outputFiles: OutputFileCollection,
mainClassFqName: FqName?
) {
val reportOutputFiles = configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)
val jarPath = configuration.get(JVMConfigurationKeys.OUTPUT_JAR)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
if (jarPath != null) {
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
val noReflect = configuration.get(JVMConfigurationKeys.NO_REFLECT, false)
val resetJarTimestamps = !configuration.get(JVMConfigurationKeys.NO_RESET_JAR_TIMESTAMPS, false)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, noReflect, resetJarTimestamps, mainClassFqName, outputFiles, messageCollector)
if (reportOutputFiles) {
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
messageCollector.report(OUTPUT, message)
}
return
}
val outputDir = configuration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY) ?: File(".")
outputFiles.writeAll(outputDir, messageCollector, reportOutputFiles)
}
private fun createOutputFilesFlushingCallbackIfPossible(configuration: CompilerConfiguration): GenerationStateEventCallback {
if (configuration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY) == null) {
return GenerationStateEventCallback.DO_NOTHING
}
return GenerationStateEventCallback { state ->
val currentOutput = SimpleOutputFileCollection(state.factory.currentOutput)
writeOutput(configuration, currentOutput, null)
if (!configuration.get(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, false)) {
state.factory.releaseGeneratedOutput()
}
}
}
private fun Module.getSourceFiles(
environment: KotlinCoreEnvironment,
localFileSystem: VirtualFileSystem,
multiModuleChunk: Boolean,
buildFile: File?
): List<KtFile> {
return if (multiModuleChunk) {
// filter out source files from other modules
assert(buildFile != null) { "Compiling multiple modules, but build file is null" }
val (moduleSourceDirs, moduleSourceFiles) =
getBuildFilePaths(buildFile, getSourceFiles())
.mapNotNull(localFileSystem::findFileByPath)
.partition(VirtualFile::isDirectory)
environment.getSourceFiles().filter { file ->
val virtualFile = file.virtualFile
virtualFile in moduleSourceFiles || moduleSourceDirs.any { dir ->
VfsUtilCore.isAncestor(dir, virtualFile, true)
}
}
} else {
environment.getSourceFiles()
}
}
private fun CompilerConfiguration.applyModuleProperties(module: Module, buildFile: File?): CompilerConfiguration {
return copy().apply {
if (buildFile != null) {
fun checkKeyIsNull(key: CompilerConfigurationKey<*>, name: String) {
assert(get(key) == null) { "$name should be null, when buildFile is used" }
}
checkKeyIsNull(JVMConfigurationKeys.OUTPUT_DIRECTORY, "OUTPUT_DIRECTORY")
checkKeyIsNull(JVMConfigurationKeys.OUTPUT_JAR, "OUTPUT_JAR")
put(JVMConfigurationKeys.OUTPUT_DIRECTORY, File(module.getOutputDirectory()))
}
}
}
internal fun compileModules(
environment: KotlinCoreEnvironment,
buildFile: File?,
@@ -182,7 +84,7 @@ object KotlinToJVMBytecodeCompiler {
val projectConfiguration = environment.configuration
if (projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
val extendedAnalysisMode = projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS)
return compileModulesUsingFrontendIR(environment, buildFile, chunk, extendedAnalysisMode)
return FirKotlinToJvmBytecodeCompiler.compileModulesUsingFrontendIR(environment, buildFile, chunk, extendedAnalysisMode)
}
val result = repeatAnalysisIfNeeded(analyze(environment), environment)
@@ -214,40 +116,6 @@ object KotlinToJVMBytecodeCompiler {
return writeOutputs(environment, projectConfiguration, chunk, outputs, mainClassFqName)
}
private fun writeOutputs(
environment: KotlinCoreEnvironment,
projectConfiguration: CompilerConfiguration,
chunk: List<Module>,
outputs: Map<Module, GenerationState>,
mainClassFqName: FqName?
): Boolean {
try {
for ((_, state) in outputs) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
writeOutput(state.configuration, state.factory, mainClassFqName)
}
} finally {
outputs.values.forEach(GenerationState::destroy)
}
if (projectConfiguration.getBoolean(JVMConfigurationKeys.COMPILE_JAVA)) {
val singleModule = chunk.singleOrNull()
if (singleModule != null) {
return JavacWrapper.getInstance(environment.project).use {
it.compile(File(singleModule.getOutputDirectory()))
}
} else {
projectConfiguration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
WARNING,
"A chunk contains multiple modules (${chunk.joinToString { it.getModuleName() }}). " +
"-Xuse-javac option couldn't be used to compile java files"
)
JavacWrapper.getInstance(environment.project).close()
}
}
return true
}
internal fun configureSourceRoots(configuration: CompilerConfiguration, chunk: List<Module>, buildFile: File? = null) {
for (module in chunk) {
@@ -295,162 +163,6 @@ object KotlinToJVMBytecodeCompiler {
configuration.addAll(JVMConfigurationKeys.MODULES, chunk)
}
private fun compileModulesUsingFrontendIR(
environment: KotlinCoreEnvironment,
buildFile: File?,
chunk: List<Module>,
extendedAnalysisMode: Boolean
): Boolean {
val project = environment.project
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
environment.messageCollector.report(
STRONG_WARNING,
"ATTENTION!\n This build uses in-dev FIR: \n -Xuse-fir"
)
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
val projectConfiguration = environment.configuration
val localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
val outputs = newLinkedHashMapWithExpectedSize<Module, GenerationState>(chunk.size)
val targetIds = environment.configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId)
val incrementalComponents = environment.configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
for (module in chunk) {
performanceManager?.notifyAnalysisStarted()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
val ktFiles = module.getSourceFiles(environment, localFileSystem, chunk.size > 1, buildFile)
if (!checkKotlinPackageUsage(environment, ktFiles)) return false
val syntaxErrors = ktFiles.fold(false) { errorsFound, ktFile ->
AnalyzerWithCompilerReport.reportSyntaxErrors(ktFile, environment.messageCollector).isHasErrors or errorsFound
}
val moduleConfiguration = projectConfiguration.applyModuleProperties(module, buildFile)
val sourceScope = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
val librariesScope = ProjectScope.getLibrariesScope(project)
val languageVersionSettings = moduleConfiguration.languageVersionSettings
val session = createSessionWithDependencies(
module,
project,
languageVersionSettings,
sourceScope,
librariesScope,
lookupTracker = environment.configuration.get(CommonConfigurationKeys.LOOKUP_TRACKER),
getPackagePartProvider = { environment.createPackagePartProvider(it) },
getAdditionalModulePackagePartProvider = {
if (targetIds == null || incrementalComponents == null) null
else IncrementalPackagePartProvider(
environment.createPackagePartProvider(it),
targetIds.map(incrementalComponents::getIncrementalCache)
)
}
) {
if (extendedAnalysisMode) {
registerExtendedCommonCheckers()
}
}
val firAnalyzerFacade = FirAnalyzerFacade(session, languageVersionSettings, ktFiles)
firAnalyzerFacade.runResolution()
val firDiagnostics = firAnalyzerFacade.runCheckers().values.flatten()
AnalyzerWithCompilerReport.reportDiagnostics(
SimpleGenericDiagnostics(firDiagnostics),
environment.messageCollector
)
performanceManager?.notifyAnalysisFinished()
if (syntaxErrors || firDiagnostics.any { it.severity == Severity.ERROR }) {
return false
}
performanceManager?.notifyGenerationStarted()
performanceManager?.notifyIRTranslationStarted()
val extensions = JvmGeneratorExtensionsImpl()
val (moduleFragment, symbolTable, components) = firAnalyzerFacade.convertToIr(extensions)
performanceManager?.notifyIRTranslationFinished()
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
val codegenFactory = JvmIrCodegenFactory(moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases))
// Create and initialize the module and its dependencies
val container = TopDownAnalyzerFacadeForJVM.createContainer(
project, ktFiles, NoScopeRecordCliBindingTrace(), environment.configuration, environment::createPackagePartProvider,
::FileBasedDeclarationProviderFactory, CompilerEnvironment,
TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, ktFiles), emptyList()
)
val generationState = GenerationState.Builder(
environment.project, ClassBuilderFactories.BINARIES,
container.get<ModuleDescriptor>(), dummyBindingContext, ktFiles,
moduleConfiguration
).codegenFactory(
codegenFactory
).withModule(
module
).onIndependentPartCompilationEnd(
createOutputFilesFlushingCallbackIfPossible(moduleConfiguration)
).isIrBackend(
true
).jvmBackendClassResolver(
FirJvmBackendClassResolver(components)
).build()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
performanceManager?.notifyIRLoweringStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, extensions, FirJvmBackendExtension(session, components)
) {
performanceManager?.notifyIRLoweringFinished()
performanceManager?.notifyIRGenerationStarted()
}
CodegenFactory.doCheckCancelled(generationState)
generationState.factory.done()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
AnalyzerWithCompilerReport.reportDiagnostics(
FilteredJvmDiagnostics(
generationState.collectedExtraJvmDiagnostics,
dummyBindingContext.diagnostics
),
environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished()
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
Disposer.dispose(environment.project)
}
val mainClassFqName: FqName? =
if (chunk.size == 1 && projectConfiguration.get(JVMConfigurationKeys.OUTPUT_JAR) != null)
TODO(".jar output is not yet supported for -Xuse-fir: KT-42868")
else null
return writeOutputs(environment, projectConfiguration, chunk, outputs, mainClassFqName)
}
private fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
if (buildFile == null) sourceFilePaths
else sourceFilePaths.map { path ->
(File(path).takeIf(File::isAbsolute) ?: buildFile.resolveSibling(path)).absolutePath
}
fun compileBunchOfSources(environment: KotlinCoreEnvironment): Boolean {
val moduleVisibilityManager = ModuleVisibilityManager.SERVICE.getInstance(environment.project)
@@ -577,15 +289,6 @@ object KotlinToJVMBytecodeCompiler {
override fun toString() = "All files under: $directories"
}
private fun GenerationState.Builder.withModule(module: Module?) =
apply {
if (module != null) {
targetId(TargetId(module))
moduleName(module.getModuleName())
outDirectory(File(module.getOutputDirectory()))
}
}
private fun generate(
environment: KotlinCoreEnvironment,
configuration: CompilerConfiguration,
@@ -632,7 +335,4 @@ object KotlinToJVMBytecodeCompiler {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
return generationState
}
private val KotlinCoreEnvironment.messageCollector: MessageCollector
get() = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
}

View File

@@ -0,0 +1,150 @@
/*
* 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.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileSystem
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.writeAll
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile
import java.io.File
fun Module.getSourceFiles(
environment: KotlinCoreEnvironment,
localFileSystem: VirtualFileSystem,
multiModuleChunk: Boolean,
buildFile: File?
): List<KtFile> {
return if (multiModuleChunk) {
// filter out source files from other modules
assert(buildFile != null) { "Compiling multiple modules, but build file is null" }
val (moduleSourceDirs, moduleSourceFiles) =
getBuildFilePaths(buildFile, getSourceFiles())
.mapNotNull(localFileSystem::findFileByPath)
.partition(VirtualFile::isDirectory)
environment.getSourceFiles().filter { file ->
val virtualFile = file.virtualFile
virtualFile in moduleSourceFiles || moduleSourceDirs.any { dir ->
VfsUtilCore.isAncestor(dir, virtualFile, true)
}
}
} else {
environment.getSourceFiles()
}
}
fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
if (buildFile == null) sourceFilePaths
else sourceFilePaths.map { path ->
(File(path).takeIf(File::isAbsolute) ?: buildFile.resolveSibling(path)).absolutePath
}
fun GenerationState.Builder.withModule(module: Module?) =
apply {
if (module != null) {
targetId(TargetId(module))
moduleName(module.getModuleName())
outDirectory(File(module.getOutputDirectory()))
}
}
fun createOutputFilesFlushingCallbackIfPossible(configuration: CompilerConfiguration): GenerationStateEventCallback {
if (configuration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY) == null) {
return GenerationStateEventCallback.DO_NOTHING
}
return GenerationStateEventCallback { state ->
val currentOutput = SimpleOutputFileCollection(state.factory.currentOutput)
writeOutput(configuration, currentOutput, null)
if (!configuration.get(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, false)) {
state.factory.releaseGeneratedOutput()
}
}
}
fun writeOutput(
configuration: CompilerConfiguration,
outputFiles: OutputFileCollection,
mainClassFqName: FqName?
) {
val reportOutputFiles = configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)
val jarPath = configuration.get(JVMConfigurationKeys.OUTPUT_JAR)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
if (jarPath != null) {
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
val noReflect = configuration.get(JVMConfigurationKeys.NO_REFLECT, false)
val resetJarTimestamps = !configuration.get(JVMConfigurationKeys.NO_RESET_JAR_TIMESTAMPS, false)
CompileEnvironmentUtil.writeToJar(
jarPath,
includeRuntime,
noReflect,
resetJarTimestamps,
mainClassFqName,
outputFiles,
messageCollector
)
if (reportOutputFiles) {
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
messageCollector.report(CompilerMessageSeverity.OUTPUT, message)
}
return
}
val outputDir = configuration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY) ?: File(".")
outputFiles.writeAll(outputDir, messageCollector, reportOutputFiles)
}
fun writeOutputs(
environment: KotlinCoreEnvironment,
projectConfiguration: CompilerConfiguration,
chunk: List<Module>,
outputs: Map<Module, GenerationState>,
mainClassFqName: FqName?
): Boolean {
try {
for ((_, state) in outputs) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
writeOutput(state.configuration, state.factory, mainClassFqName)
}
} finally {
outputs.values.forEach(GenerationState::destroy)
}
if (projectConfiguration.getBoolean(JVMConfigurationKeys.COMPILE_JAVA)) {
val singleModule = chunk.singleOrNull()
if (singleModule != null) {
return JavacWrapper.getInstance(environment.project).use {
it.compile(File(singleModule.getOutputDirectory()))
}
} else {
projectConfiguration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
CompilerMessageSeverity.WARNING,
"A chunk contains multiple modules (${chunk.joinToString { it.getModuleName() }}). " +
"-Xuse-javac option couldn't be used to compile java files"
)
JavacWrapper.getInstance(environment.project).close()
}
}
return true
}

View File

@@ -15,10 +15,13 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.CompilerConfigurationKey
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.extensions.PreprocessedFileCreator
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.multiplatform.isCommonSource
import java.io.File
@@ -79,4 +82,22 @@ fun createSourceFilesFromSourceRoots(
}
return result
}
}
val KotlinCoreEnvironment.messageCollector: MessageCollector
get() = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
fun CompilerConfiguration.applyModuleProperties(module: Module, buildFile: File?): CompilerConfiguration {
return copy().apply {
if (buildFile != null) {
fun checkKeyIsNull(key: CompilerConfigurationKey<*>, name: String) {
assert(get(key) == null) { "$name should be null, when buildFile is used" }
}
checkKeyIsNull(JVMConfigurationKeys.OUTPUT_DIRECTORY, "OUTPUT_DIRECTORY")
checkKeyIsNull(JVMConfigurationKeys.OUTPUT_JAR, "OUTPUT_JAR")
put(JVMConfigurationKeys.OUTPUT_DIRECTORY, File(module.getOutputDirectory()))
}
}
}

View File

@@ -49,6 +49,9 @@ fun CompilerConfiguration.addJvmSdkRoots(files: List<File>) {
val CompilerConfiguration.jvmClasspathRoots: List<File>
get() = getList(CLIConfigurationKeys.CONTENT_ROOTS).filterIsInstance<JvmClasspathRoot>().map(JvmContentRoot::file)
val CompilerConfiguration.jvmModularRoots: List<File>
get() = getList(CLIConfigurationKeys.CONTENT_ROOTS).filterIsInstance<JvmModulePathRoot>().map(JvmContentRoot::file)
@JvmOverloads
fun CompilerConfiguration.addJavaSourceRoot(file: File, packagePrefix: String? = null) {
add(CLIConfigurationKeys.CONTENT_ROOTS, JavaSourceRoot(file, packagePrefix))

View File

@@ -45,6 +45,7 @@ data class JavaRoot(val file: VirtualFile, val type: RootType, val prefixFqName:
companion object RootTypes {
val OnlyBinary: Set<RootType> = EnumSet.of(RootType.BINARY)
val OnlySource: Set<RootType> = EnumSet.of(RootType.SOURCE)
val SourceAndBinary: Set<RootType> = EnumSet.of(RootType.BINARY, RootType.SOURCE)
}
}

View File

@@ -16,16 +16,25 @@
package org.jetbrains.kotlin.cli.jvm.modules
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleFinder
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
class CliJavaModuleFinder(
jrtFileSystemRoot: VirtualFile?,
private val javaFileManager: KotlinCliJavaFileManager,
project: Project
) : JavaModuleFinder {
private val modulesRoot = jrtFileSystemRoot?.findChild("modules")
private val userModules = linkedMapOf<String, JavaModule>()
private val allScope = GlobalSearchScope.allScope(project)
fun addUserModule(module: JavaModule) {
userModules.putIfAbsent(module.name, module)
}
@@ -41,7 +50,7 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? {
val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null
val moduleInfo = JavaModuleInfo.read(file) ?: return null
val moduleInfo = JavaModuleInfo.read(file, javaFileManager, allScope) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file)
}
}

View File

@@ -18,18 +18,24 @@ package org.jetbrains.kotlin.cli.jvm.modules
import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver
import java.util.concurrent.ConcurrentHashMap
class CliJavaModuleResolver(
private val moduleGraph: JavaModuleGraph,
private val userModules: List<JavaModule>,
private val systemModules: List<JavaModule.Explicit>
private val systemModules: List<JavaModule.Explicit>,
private val project: Project
) : JavaModuleResolver {
init {
assert(userModules.count(JavaModule::isSourceModule) <= 1) {
@@ -37,6 +43,14 @@ class CliJavaModuleResolver(
}
}
private val virtualFileFinder by lazy { VirtualFileFinder.getInstance(project) }
override fun getAnnotationsForModuleOwnerOfClass(classId: ClassId): List<JavaAnnotation>? {
val virtualFile = virtualFileFinder.findSourceOrBinaryVirtualFile(classId) ?: return null
return (findJavaModule(virtualFile) as? JavaModule.Explicit)?.moduleInfo?.annotations
}
private val sourceModule: JavaModule? = userModules.firstOrNull(JavaModule::isSourceModule)
private fun findJavaModule(file: VirtualFile): JavaModule? {
@@ -77,4 +91,8 @@ class CliJavaModuleResolver(
return null
}
companion object {
private const val MODULE_ANNOTATIONS_CACHE_SIZE = 10000
}
}

View File

@@ -101,7 +101,11 @@ object KotlinCompilerClient {
fun CompileService.leaseImpl(): CompileServiceSession? {
// the newJVMOptions could be checked here for additional parameters, if needed
registerClient(clientAliveFlagFile.absolutePath)
reportingTargets.report(DaemonReportCategory.DEBUG, "connected to the daemon")
val javaExecutablePath = compilerId.javaExecutable?.absolutePath ?: "'user jvm'"
reportingTargets.report(
DaemonReportCategory.DEBUG,
"connected to the daemon. Daemon is using following 'java' executable to run itself: $javaExecutablePath"
)
if (!leaseSession) return CompileServiceSession(this, CompileService.NO_SESSION)

View File

@@ -13,13 +13,13 @@ plugins {
dependencies {
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
testApi(intellijDep())
testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils"))
testApi(projectTests(":compiler:tests-compiler-utils"))
testApi(projectTests(":compiler:tests-common-new"))
testApi(project(":compiler:cli"))
testApi(project(":compiler:fir:checkers"))
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:fir-serialization"))
testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:frontend"))

View File

@@ -20,6 +20,7 @@ dependencies {
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
testApi(projectTests(":compiler:tests-common"))
testApi(project(":compiler:fir:checkers"))
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:frontend"))

View File

@@ -561,6 +561,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt");
}
@TestMetadata("integerOverloads.kt")
public void testIntegerOverloads() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/integerOverloads.kt");
}
@TestMetadata("invoke.kt")
public void testInvoke() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/invoke.kt");
@@ -970,6 +975,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testConstValWithGetterOrDelegate() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
}
@TestMetadata("constValWithTypealiasType.kt")
public void testConstValWithTypealiasType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithTypealiasType.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
@@ -2406,6 +2416,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
}
@TestMetadata("elvisAndUnit.kt")
public void testElvisAndUnit() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/elvisAndUnit.kt");
}
@TestMetadata("extensionCallableReferences.kt")
public void testExtensionCallableReferences() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/extensionCallableReferences.kt");
@@ -2475,6 +2490,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testTypeDepthForTypeAlias() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/typeDepthForTypeAlias.kt");
}
@TestMetadata("unitUpperBound.kt")
public void testUnitUpperBound() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@@ -2789,6 +2809,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.kt");
}
@TestMetadata("symbolsAndDescriptors.kt")
public void testSymbolsAndDescriptors() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/symbolsAndDescriptors.kt");
}
@TestMetadata("transform.kt")
public void testTransform() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt");
@@ -3440,6 +3465,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testCastToBareType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt");
}
@TestMetadata("typeAliasInArguments.kt")
public void testTypeAliasInArguments() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/types/typeAliasInArguments.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/visibility")

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
@@ -30,6 +31,7 @@ abstract class AbstractFirLoadCompiledKotlin : AbstractFirLoadBinariesTest() {
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_NO_RUNTIME)
}
@OptIn(ObsoleteTestInfrastructure::class)
fun doTest(path: String) {
val moduleDescriptor = compileKtFileToTmpDir(path)

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.serialization.builtins.BuiltinsTestUtils
import org.jetbrains.kotlin.test.ConfigurationKind
@@ -16,6 +17,7 @@ class BuiltInsDeserializationForFirTestCase : AbstractFirLoadBinariesTest() {
return createEnvironmentWithJdk(ConfigurationKind.ALL, TestJdkKind.FULL_JDK)
}
@OptIn(ObsoleteTestInfrastructure::class)
fun testBuiltInPackagesContent() {
val moduleDescriptor = BuiltinsTestUtils.compileBuiltinsModule(environment)
val session = createSessionForTests(environment, GlobalSearchScope.allScope(project))

View File

@@ -16,6 +16,7 @@ import com.intellij.psi.PsiPackageStatement
import com.intellij.psi.impl.PsiFileFactoryImpl
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.LightVirtualFile
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -82,6 +83,7 @@ abstract class AbstractFirTypeEnhancementTest : KtUsefulTestCase() {
}
}
@OptIn(ObsoleteTestInfrastructure::class)
fun doTest(path: String) {
val javaFile = File(path)
val javaLines = javaFile.readLines()

View File

@@ -81,7 +81,7 @@ public final class CharRange : R|kotlin/ranges/CharProgression|, R|kotlin/ranges
}
public abstract interface ClosedRange<T> : R|kotlin/Any| {
public abstract interface ClosedRange<T : R|kotlin/Comparable<T>|> : R|kotlin/Any| {
public open operator fun contains(value: R|T|): R|kotlin/Boolean|
public open fun isEmpty(): R|kotlin/Boolean|

View File

@@ -12,9 +12,9 @@ public final fun doubleArrayOf(vararg elements: R|kotlin/DoubleArray|): R|kotlin
public final inline fun <reified T> emptyArray(): R|kotlin/Array<T>|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T> enumValueOf(name: R|kotlin/String|): R|T|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T : R|kotlin/Enum<T>|> enumValueOf(name: R|kotlin/String|): R|T|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T> enumValues(): R|kotlin/Array<T>|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T : R|kotlin/Enum<T>|> enumValues(): R|kotlin/Array<T>|
public final fun floatArrayOf(vararg elements: R|kotlin/FloatArray|): R|kotlin/FloatArray|
@@ -529,7 +529,7 @@ public final class DoubleArray : R|kotlin/Any|, R|kotlin/Cloneable|, R|java/io/S
}
public abstract class Enum<E> : R|kotlin/Comparable<E>|, R|java/io/Serializable| {
public abstract class Enum<E : R|kotlin/Enum<E>|> : R|kotlin/Comparable<E>|, R|java/io/Serializable| {
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|kotlin/Enum.Companion|
@@ -551,7 +551,7 @@ public abstract class Enum<E> : R|kotlin/Comparable<E>|, R|java/io/Serializable|
public final val ordinal: R|kotlin/Int|
public get(): R|kotlin/Int|
public constructor<E>(name: R|kotlin/String| = STUB, ordinal: R|kotlin/Int| = STUB): R|kotlin/Enum<E>|
public constructor<E : R|kotlin/Enum<E>|>(name: R|kotlin/String| = STUB, ordinal: R|kotlin/Int| = STUB): R|kotlin/Enum<E>|
}

View File

@@ -1,17 +1,17 @@
FILE: annotationUsedAsAnnotationArgument.kt
public final annotation class Ann : R|kotlin/Annotation| {
@R|kotlin/annotation/Target|(vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|)) @R|kotlin/annotation/Retention|(Q|kotlin/annotation/AnnotationRetention|.R|kotlin/annotation/AnnotationRetention.SOURCE|) public final annotation class Ann : R|kotlin/Annotation| {
public constructor(): R|Ann| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann2 : R|kotlin/Annotation| {
@R|kotlin/annotation/Target|(vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|)) @R|kotlin/annotation/Retention|(Q|kotlin/annotation/AnnotationRetention|.R|kotlin/annotation/AnnotationRetention.SOURCE|) public final annotation class Ann2 : R|kotlin/Annotation| {
public constructor(): R|Ann2| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann3 : R|kotlin/Annotation| {
@R|kotlin/annotation/Target|(vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|)) @R|kotlin/annotation/Retention|(Q|kotlin/annotation/AnnotationRetention|.R|kotlin/annotation/AnnotationRetention.SOURCE|) public final annotation class Ann3 : R|kotlin/Annotation| {
public constructor(arg: R|kotlin/Int|, s: R|kotlin/String|): R|Ann3| {
super<R|kotlin/Any|>()
}

View File

@@ -1,11 +1,19 @@
// WITH_RUNTIME
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class Ann
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class Ann2
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class Ann3(val arg: Int, val s: String)
@Ann3(
<!WRONG_ANNOTATION_TARGET!>@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann<!> 5, ""
)<!> <!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann2<!> 1, ""
) val a = 0
)<!> val a = 0

View File

@@ -37,8 +37,8 @@ FILE: destructuring.kt
}
)
R|/foo1|(<L> = foo1@fun <anonymous>(<destruct>: R|C|): R|kotlin/Unit| <inline=NoInline> {
lval x: R|kotlin/String| = R|<local>/<destruct>|.R|/C.component1|()
lval y: R|kotlin/Int| = R|<local>/<destruct>|.R|/C.component2|()
lval x: R|kotlin/String| = R|<local>/<destruct>|.<CS errors: /C.component1>#()
lval y: R|kotlin/Int| = R|<local>/<destruct>|.<CS errors: /C.component2>#()
<Inapplicable(INAPPLICABLE): /C.C>#(R|<local>/x|, R|<local>/y|)
}
)
@@ -59,10 +59,10 @@ FILE: destructuring.kt
}
)
R|/foo2|(<L> = foo2@fun <anonymous>(<destruct>: R|C|, <destruct>: R|C|): R|kotlin/Unit| <inline=NoInline> {
lval x: R|kotlin/String| = R|<local>/<destruct>|.R|/C.component1|()
lval y: R|kotlin/Int| = R|<local>/<destruct>|.R|/C.component2|()
lval z: R|kotlin/String| = R|<local>/<destruct>|.R|/C.component1|()
lval w: R|kotlin/Int| = R|<local>/<destruct>|.R|/C.component2|()
lval x: R|kotlin/String| = R|<local>/<destruct>|.<CS errors: /C.component1>#()
lval y: R|kotlin/Int| = R|<local>/<destruct>|.<CS errors: /C.component2>#()
lval z: R|kotlin/String| = R|<local>/<destruct>|.<CS errors: /C.component1>#()
lval w: R|kotlin/Int| = R|<local>/<destruct>|.<CS errors: /C.component2>#()
<Inapplicable(INAPPLICABLE): /C.C>#(R|<local>/x|.R|kotlin/String.plus|(R|<local>/z|), R|<local>/y|.R|kotlin/Int.plus|(R|<local>/w|))
}
)

View File

@@ -1,5 +1,5 @@
fun test(
val f: String.() -> Int = { length }
f: String.() -> Int = { length }
): Int {
return "".f()
}

View File

@@ -0,0 +1,21 @@
FILE: x.kt
public final fun f(x: R|kotlin/Byte|): R|kotlin/Unit| {
}
public final fun f(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun f(x: R|kotlin/Long|): R|kotlin/Unit| {
}
public final fun g(x: R|kotlin/Byte?|): R|kotlin/Unit| {
}
public final fun g(x: R|kotlin/Int?|): R|kotlin/Unit| {
}
public final fun g(x: R|kotlin/Long?|): R|kotlin/Unit| {
}
public final fun main(): R|kotlin/Unit| {
Q|J|.R|/J.f|(Int(123))
Q|J|.R|/J.f|(Long(123123123123))
R|/f|(Int(123))
R|/f|(Long(123123123123))
R|/g|(Int(123))
R|/g|(Long(123123123123))
}

View File

@@ -0,0 +1,24 @@
// FILE: J.java
public class J {
public static fun f(Byte x) {}
public static fun f(Integer x) {}
public static fun f(Long x) {}
}
// FILE: x.kt
fun f(x: Byte) {}
fun f(x: Int) {}
fun f(x: Long) {}
fun g(x: Byte?) {}
fun g(x: Int?) {}
fun g(x: Long?) {}
fun main() {
J.f(123)
J.f(123123123123)
f(123)
f(123123123123)
g(123)
g(123123123123)
}

View File

@@ -7,7 +7,7 @@ FILE: main.kt
public abstract interface PsiClass : R|kotlin/Any| {
}
public final fun test(): R|kotlin/Unit| {
lval processor: R|AdapterProcessor<ft<PsiMethod, PsiMethod?>, ft<PsiClass, PsiClass?>>| = R|/AdapterProcessor.AdapterProcessor|<R|ft<PsiMethod, PsiMethod?>|, R|ft<PsiClass, PsiClass?>|>(R|/Function|<R|ft<PsiMethod, PsiMethod?>|, R|PsiClass?|>(<L> = Function@fun <anonymous>(method: R|PsiMethod?|): R|PsiClass?| <inline=NoInline> {
lval processor: R|AdapterProcessor<ft<PsiMethod, PsiMethod?>, ft<PsiClass, PsiClass?>>| = R|/AdapterProcessor.AdapterProcessor|<R|ft<PsiMethod, PsiMethod?>|, R|ft<PsiClass, PsiClass?>|>(R|/Function|<R|ft<PsiMethod, PsiMethod?>|, R|ft<PsiClass, PsiClass?>|>(<L> = Function@fun <anonymous>(method: R|PsiMethod?|): R|ft<PsiClass, PsiClass?>| <inline=NoInline> {
^ R|<local>/method|?.{ $subj$.R|/PsiMethod.containingClass| }
}
))

View File

@@ -10,7 +10,7 @@ FILE: A.kt
}
FILE: main.kt
public final fun test_1(): R|kotlin/Unit| {
lval a: R|ERROR CLASS: Unresolved name: A| = <Unresolved name: A>#()
lval a: <ERROR TYPE REF: Unresolved name: A> = <Unresolved name: A>#()
lval b: R|foo/A| = R|foo/A.A|()
lval c: R|foo/A| = <Unresolved name: A>#()
}

View File

@@ -18,7 +18,7 @@ FILE: cast.kt
}
public get(): R|(kotlin/String) -> kotlin/Boolean|
public final val hError: R|(ERROR CLASS: No type for parameter) -> kotlin/Boolean| = fun <anonymous>(_: R|ERROR CLASS: No type for parameter|): R|kotlin/Boolean| <inline=Unknown> {
public final val hError: R|(ERROR CLASS: No type for parameter) -> kotlin/Boolean| = fun <anonymous>(_: <ERROR TYPE REF: No type for parameter>): R|kotlin/Boolean| <inline=Unknown> {
^ Boolean(true)
}

View File

@@ -9,15 +9,15 @@ fun <T : Throwable> test() {
try {} catch (<!TYPE_PARAMETER_IN_CATCH_CLAUSE!>e: T<!>) {}
try {} catch (<!TYPE_MISMATCH!>e: () -> Int<!>) {}
try {} catch (<!THROWABLE_TYPE_MISMATCH!>e: () -> Int<!>) {}
try {} catch (<!TYPE_MISMATCH!>e: StringType<!>) {}
try {} catch (<!THROWABLE_TYPE_MISMATCH!>e: StringType<!>) {}
try {} catch (<!CATCH_PARAMETER_WITH_DEFAULT_VALUE, TYPE_MISMATCH!>e: Int = 5<!>) {}
try {} catch (<!CATCH_PARAMETER_WITH_DEFAULT_VALUE, THROWABLE_TYPE_MISMATCH!>e: Int = 5<!>) {}
try {} catch (e: Throwable) {}
}
inline fun <reified T> anotherTest() {
try {} catch (<!REIFIED_TYPE_IN_CATCH_CLAUSE, TYPE_MISMATCH!>e: T<!>) {}
try {} catch (<!REIFIED_TYPE_IN_CATCH_CLAUSE, THROWABLE_TYPE_MISMATCH!>e: T<!>) {}
}

View File

@@ -13,6 +13,6 @@ interface B
fun test_2(x: Any?) {
if (x is A && x is B) {
x is A
<!USELESS_IS_CHECK!>x is A<!>
}
}

View File

@@ -0,0 +1,4 @@
FILE: constValWithTypealiasType.kt
public final typealias Foo = R|kotlin/Int|
public final const val x: R|Foo| = Int(10)
public get(): R|Foo|

View File

@@ -0,0 +1,3 @@
typealias Foo = Int
const val x: Foo = 10

View File

@@ -26,7 +26,7 @@ FILE: kt41982.kt
super<R|DelegateProvider<kotlin/Any>|>()
}
public final var start: R|kotlin/Long|by this@R|/Test|.R|/long|<R|Test?|, R|Test?|>(<L> = long@fun <anonymous>(): R|kotlin/Long?| <inline=NoInline> {
public final var start: R|kotlin/Long|by this@R|/Test|.R|/long|<R|Test|, R|Test|>(<L> = long@fun <anonymous>(): R|kotlin/Long?| <inline=NoInline> {
^ Long(0)
}
)

View File

@@ -1,5 +1,5 @@
FILE: classInSupertypeForEnum.kt
public final class A : R|kotlin/Any| {
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}

View File

@@ -1,5 +1,5 @@
class A
open class A
interface C
enum class B : C, <!CLASS_IN_SUPERTYPE_FOR_ENUM!>A<!>(), Any()
enum class B : C, <!CLASS_IN_SUPERTYPE_FOR_ENUM!>A<!>(), <!MANY_CLASSES_IN_SUPERTYPE_LIST!>Any<!>()

View File

@@ -1,3 +1,5 @@
// FIR_IDE_IGNORE
<!CONFLICTING_OVERLOADS!>fun test(x: Int)<!> {}
<!CONFLICTING_OVERLOADS!>fun test(y: Int)<!> {}
@@ -16,7 +18,7 @@ fun test(z: Int, c: Char) {}
}<!>
<!REDECLARATION!>class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
<!REDECLARATION!>class B : <!FINAL_SUPERTYPE, SUPERTYPE_NOT_INITIALIZED!>A<!> {
<!CONFLICTING_OVERLOADS!>override fun rest(s: String)<!> {}
<!CONFLICTING_OVERLOADS!>fun rest(s: String)<!> {}

View File

@@ -3,5 +3,5 @@ interface <!CONSTRUCTOR_IN_INTERFACE!>A(val s: String)<!>
interface <!CONSTRUCTOR_IN_INTERFACE!>B constructor(val s: String)<!>
interface C {
<!CONSTRUCTOR_IN_INTERFACE!>constructor(val s: String)<!> {}
<!CONSTRUCTOR_IN_INTERFACE!>constructor(s: String)<!> {}
}

View File

@@ -125,7 +125,7 @@ FILE: cyclicConstructorDelegationCall.kt
}
}
public final class M : R|kotlin/Any| {
public open class M : R|kotlin/Any| {
public constructor(m: R|kotlin/Int|): R|M| {
super<R|kotlin/Any|>()
}

View File

@@ -58,7 +58,7 @@ class K(x: Int) {
constructor() : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>() {}
}
class M {
open class M {
constructor(m: Int)
}

View File

@@ -1,5 +1,5 @@
FILE: delegationInInterface.kt
public final class A : R|kotlin/Any| {
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}

View File

@@ -1,4 +1,4 @@
class A
open class A
interface B : <!DELEGATION_IN_INTERFACE, INTERFACE_WITH_SUPERCLASS!>A<!> by <!UNRESOLVED_REFERENCE!>a<!> {
val a: A

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