Commit Graph

104162 Commits

Author SHA1 Message Date
Dmitriy Novozhilov 08ebe04485 [FIR2IR] Extract logic of IR declarations generation into separate component. Part 1
This commit just moves methods, which create IR callable declarations
  from Fir2IrDeclarationStorage to newly created Fir2IrCallableDeclarationsGenerator
  and Fir2IrLazyDeclarationsGenerator without any modifications.

Code in generators contains some errors (mostly because it refers to the
  logic of caching created declaration), and those errors will be fixed
  in following commits
2023-08-30 14:51:44 +00:00
Ilya Kirillov 714cb67254 [decompiler] add tests for generated psi text by builtin decompiler 2023-08-30 14:45:15 +00:00
Ilya Kirillov 5fc458d5a4 [LL FIR] implement toString for LLFirKotlinSymbolProvider and LLFirSession 2023-08-30 14:45:15 +00:00
Ilya Kirillov 9ea344fe76 [decompiler] fix ambiguities to builtin members resolve in K2 IDE
If a user has multiple kotlin-stdlib libraries in a project, all those stdlib libraries will contain builtins
which will result in resolution ambiguities.

To prevent such kind of ambiguities inside LLFirDependenciesSymbolProvider,
callables are grouped by facade class name.
Only matching callables from the first facade are used.

Facade is a Kotlin/JVM-term so right now it works only for JVM targets.
Builtins are also used in JVM, so the current solution is to have a Facade name also for builtins.

^KTIJ-26760
2023-08-30 14:45:14 +00:00
Ilya Kirillov 866368cf69 [LL FIR] fix navigation to stdlib declarations in K2 IDE
If a user has kotlin-stdlib in their project,
the IDE should resolve the builtin declarations to the kotlin-stdlib
instead of builtins from the Kotlin plugin.

^KTIJ-26760
2023-08-30 14:45:14 +00:00
Ilya Kirillov 5ab408859b [LL FIR] create a single builtin symbol provider which will be reused for the whole project when no stdlib is available
Previously, every kotlin stdlib containing builtins was searched causing resolution ambiguities.

^KTIJ-26760 fixed
2023-08-30 14:45:14 +00:00
Ilya Kirillov e8db349f24 [decompiler] extract builtin VirtualFile creation to a separate service for further reuse
^KTIJ-26760
2023-08-30 14:45:14 +00:00
Nikita Bobko 373abbde5d Partially revert "[FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes"
^KT-61039 Fixed
KT-59739 is now open for K1 (but fixed in K2)
Review: https://jetbrains.team/p/kt/reviews/11867/timeline

This partially reverts commit 4f3ecedbca.
Only K1 part is reverted.

Motivation for revert: KT-59739 cannot be properly fixed in K1 because
of the bug it causes - KT-61039

We just accepted that we will have one more "green in K1 -> red in K2"
case
2023-08-30 14:35:59 +00:00
Nikita Bobko 3534a4b7a9 Improve NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION diagnostic message
In scope of: KT-22841
Review: https://jetbrains.team/p/kt/reviews/11867/timeline
2023-08-30 14:35:58 +00:00
Nikita Bobko 3722f4d7d6 ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker: reuse "expect-actual" matcher
In scope of: KT-22841
Review: https://jetbrains.team/p/kt/reviews/11867/timeline

Reduce complexity by reusing "expect-actual matcher" (namely
`AbstractExpectActualCompatibilityChecker.getCallablesCompatibility`)

The current solution has worse algorithmic complexity. Previously it was
O(n) in the best case, where `n` is a number of members. Now, it's
O(m^2), where `m` is number of members in one overload group. But we
prefer to have worse complexity but reuse expect-actual matcher, number
of elements in one overload group shall not be big on real world
examples.

The previous logic was non-trivial because it compared types with with
double comparison in `equals`.
2023-08-30 14:35:56 +00:00
Nikita Bobko 17089276a7 Add regression tests for modality changes
Motivation: the discovered false negative in test
changeModalityFromAbstractToOpenInOverride.kt

Unfortunately, it can't be fixed in K1, so we will just live with that.
Luckily, we report ABSTRACT_MEMBER_NOT_IMPLEMENTED additionally.

In K2, MODALITY_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION
will be correctly reported as a compilation error

In scope of: KT-22841
Review: https://jetbrains.team/p/kt/reviews/11867/timeline
2023-08-30 14:35:55 +00:00
Roman Golyshev 21dffe4639 KT-61568 [FIR][AA] Do not add redundant file scopes in AllCandidatesResolver
`firResolveSession.getTowerContextProvider` should already
contain all the relevant scopes, including default and
importing scopes for the file

Because of this, import and default scopes had presence over the
more local scopes, and the resolve was performed incorrecty - top level
candidates were given higher priority

^KT-61568 Fixed
^KTIJ-26824 Fixed
2023-08-30 14:30:21 +00:00
Bogdan Mukvich 826297979d SBOM for native artifacts
^KTI-1240
2023-08-30 13:20:33 +00:00
Aleksei.Cherepanov 68af705664 Add import tracker
This tracker reports import directives to IJ's JPS to track changes and detectwehen it is needed to adjust compilation scope.

#KT-44835 Fixed
2023-08-30 12:42:39 +00:00
Aleksei.Cherepanov b27aef2c61 Add test
#KT-44835 In Progress
2023-08-30 12:42:39 +00:00
Alexander Shabalin 3ec4f2e0ee [K/N] Remove jsinterop because K/N wasm32 target is removed ^KT-59008
See https://kotl.in/native-targets-tiers for details
2023-08-30 12:17:52 +00:00
Stanislav Ruban 857bfeb92c [KMP] Fix multiplatform test data with ACTUAL_WITHOUT_EXPECT messages 2023-08-30 12:06:43 +00:00
Stanislav Ruban e7b7ef18fa [KMP] Tweak ACTUAL_WITHOUT_EXPECT message to include 'value' modifier
See KT-59660 for an example of relevant code.
2023-08-30 12:06:43 +00:00
Nikolay Lunyak 6c6474bb19 [FIR] Fix a typo in one of the multiple defaults diagnsotics messages
Merge-request: KT-MR-11942
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-08-30 11:40:07 +00:00
Ilya Gorbunov 516383b995 [Docs] add wasm source sets for wasm-js and wasm-wasi 2023-08-30 11:37:29 +00:00
strangepleasures ece40ca775 Lazy evaluation of an error prefix in MethodInliner (performance optimization) 2023-08-30 09:51:54 +00:00
Alexander Udalov 5aa0000b3e Tests: remove IGNORE_BACKEND_K2_LIGHT_TREE directive
This is a partial revert of f47040696e. This directive is not used
anymore.

 #KT-56757 Fixed
2023-08-30 09:50:36 +00:00
vladislav.grechko e9ccc0329c Fix isKotlinFunctionWithBigArity function
fixup! Fix `isKotlinFunctionWithBigArity` function

Fix `isKotlinFunctionWithBigArity` function

Previous implementation could return false positive results, e.g. for
class named `abacaba.kotlin.Function42`

^KT-61548: Fixed


Merge-request: KT-MR-11928
Merged-by: Vladislav Grechko <Vladislav.Grechko@jetbrains.com>
2023-08-30 09:15:00 +00:00
Dmitriy Novozhilov 84d863aaf4 [Doc] Add documentation for FIR checkers 2023-08-30 08:51:56 +00:00
Yan Zhulanow ebd0ac8933 [LL API] Minor, move the call conflict resolver to the right package 2023-08-30 06:38:44 +00:00
Yan Zhulanow 8ad9718310 [LL API] Check the class file is in a conventional place
Although 'VirtualFile's are typically inside the containing package
directory, e.g. 'foo/bar/Baz.class' for 'foo.bar.Baz', there might
be classes with files in unexpected places. Sources of such classes
may include broken stubs, or just classes from misbehaving IDE plugins.

As we are yet to identity such cases, here we treat them as 'other'
candidates.
2023-08-30 06:38:44 +00:00
Yan Zhulanow faaba52ed5 [LL API] Minor, clean up 'LLLibraryScopeAwareConeCallConflictResolver' 2023-08-30 06:38:44 +00:00
Yan Zhulanow 4c3d414067 [LL API] Minor, fix documentation for 'globalLanguageVersionSettings' 2023-08-30 06:38:44 +00:00
Yan Zhulanow b96c1a644f [LL API] Fix code fragment compilation in library sources (KT-61383)
In complex projects, there might be several library copies (with the
same or different versions). As there is no way to build a reliable
dependency graph between libraries, a project library depends on all
other libraries. As a result, there might be several declarations in the
classpath with the same name and signature.

Normally, K2 issues a 'resolution ambiguity' error on calls to such
libraries. It is acceptable for resolution, as resolution errors are
never shown in the library code. However, the backend, to which
'evaluate expression' needs to pass FIR afterwards, is not designed for
compiling ambiguous (and non-completed) calls.
2023-08-30 06:38:44 +00:00
Yan Zhulanow 4b80c2197f [Analysis API] Run code fragment compilation tests against libraries 2023-08-30 06:38:44 +00:00
Yan Zhulanow dbb7e788b2 [LL API] Provide customizable default language version settings 2023-08-30 06:38:44 +00:00
Yan Zhulanow 705a97e9d4 [Analysis API] Fix test data for context receivers
Currently, the test files are only analyzed as source code, and present
errors do not affect code fragment analysis. In the following commits,
however, the test files will be compiled to test code fragment
analysis against library sources.
2023-08-30 06:38:43 +00:00
Alexander Kuznetsov 58350b83a8 KtFe10CompilerFacility: analyze inline delegated property accessors
One of the compiler lowerings, namely `PropertyReferenceLowering`,
optimizes usages of property references in some cases,
and if a containing delegated property accessor is inline,
it might need this accessor's bytecode.

If an accessor function is defined in a different module,
IDE tries to acquire its bytecode via the index, however,
the index doesn't cover classfiles from compiler output,
and that leads to errors like KTIJ-26706 and IDEA-320283.

One of the ways to ensure that the bytecode exists is to include files
that contain inline accessors in the compilation process. For example,
if file f1.kt from the analysis result contains property `val p by D()`,
and `D.getValue` is an inline function defined in file f2.kt,
then f2.kt must be present in the analysis result.
If f2.kt contains another property `val q by E()`,
and `E.getValue` is an inline function defined in f3.kt,
then f3.kt must be present in the analysis result. And so on.

Fixes KTIJ-26706, IDEA-320283


Merge-request: KT-MR-11793
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-08-29 23:55:31 +00:00
Vladislav Grechko f11c96cba2 Use handwritten tokenizer for SMAP parsing
SMAP parsing is a hot spot. Handwritten tokenization significantly boosts the performance.

See ^KT-61527
2023-08-29 21:28:50 +00:00
Aleksei.Glushko 4eac193463 [K/N] Generalize GC-assistance pause logic
Merge-request: KT-MR-11790
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
2023-08-29 19:31:02 +00:00
Aleksei.Glushko a99db60117 [K/N] Reenable mark&sweep statistics match assertion 2023-08-29 19:03:34 +00:00
Aleksei.Glushko 1437a9bb69 [K/N] Make GCStatistics handles movable 2023-08-29 19:03:34 +00:00
Brian Norman e48ab4deb4 [FIR] Fix stackoverflow when checking for type cast erasure
#KT-59478 Fixed
2023-08-29 18:54:19 +00:00
vladislav.grechko 593b326c80 Don't do full type parameters erasure in resultIsActuallyAny
The only case when erasure required is when type is a type parameter.
2023-08-29 18:46:53 +00:00
vladislav.grechko 8f2825506a Don't do full type parameters erasure in PromisedValue::materializeAt
The only case when erasure matters in a context of materialization of
`PromisedValue` is when the type is a type parameter which upper bound
is an inline class. Since `PromisedValue::materializeAt` is a hot spot
and `eraseTypeParameters` is an expensive operation, we should not do
type erasure in other cases.
2023-08-29 18:46:53 +00:00
Bogdan Mukvich 5456ef3ad8 [Gradle] Remove ':kotlin-project-model' from artifacts-tests test data
^KT-61463 Verification Pending
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 223714478a [Gradle] Update verification-metadata.xml
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair eb0e7fa55b [Gradle] Remove kpm Gradle integration tests
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 02c2c76ffe [Gradle] Remove ':kotlin-project-model' and ':kotlin-project-model-tests-generator'
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 6d38a314cc [Gradle] Remove kpm native variant codegen
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair c889c2f217 [Gradle] Dissolve plugin.mpp.pm20 package
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 282d2f4454 [Gradle] Remove Gradle KPM implementation
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 34abc008ec [Gradle] Update api dump after removing KPM import code
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair ea3c275961 [Gradle] Dissolve .kotlin.gradle.kpm package
KT-61463
2023-08-29 16:45:12 +00:00
Sebastian Sellmair 0a8cca9be4 [Gradle] Remove KPM IDE Gradle Sync support
KT-61463
2023-08-29 16:45:12 +00:00