Commit Graph

100438 Commits

Author SHA1 Message Date
Dmitrii Gridin 332cdc514b [LL FIR] reanalyse declarations on the air for incremental analysis
We cannot do it inplace now as we do not have a lock to do
it under after analysis started to use declaration-level lock

This part is mostly covered by the plugin tests
(which failed after the previous commit)

^KT-56543
2023-04-19 20:12:39 +00:00
Dmitrii Gridin 72def186a3 [LL FIR] rework transformers, so transformers resolve only a specific set of declarations
The change is needed for the parallel resolution (^KT-55750), so we can resolve the declaration
under a lock that is specific to this declaration.
Previously, if LL FIR was resolving some FirClass, LL FIR  resolved all its children too, and it had no control over what parts of the FIR tree were modified.
The same applied to the designation path, sometimes the classes on the designation path
might be unexpectedly (and without lock) modified.

This commit introduces LLFirResolveTarget, which specifies which exact declarations should be resolved during the lazy resolution of the declaration.
All elements outside the declarations specified for resolve in LLFirResolveTarget, should not be modified.

The logic of lazy transformers is the following:
- Go to target declaration collecting all scopes from the file and containing classes
- Resolve only declarations that are specified by the LLFirResolveTarget, performing the resolve under a separate lock for each declaration

^KT-56543
^KT-57619 Fixed
2023-04-19 20:12:38 +00:00
Dmitrii Gridin 18a8cfb090 [AA FIR] firSymbolUtils: avoid redundant resolve
^KT-56543
2023-04-19 20:12:36 +00:00
Dmitrii Gridin 093695962a [FIR] hacky fix lazy resolve contract violation for deprecation of enum entries
Enum entries can be used as types in Kotlin (even it's a compilation error)
To use the classifier as a type, we need to find if it's hidden or not.
The deprecations for classes are calculated on COMPILER_REQUIRED_ANNOTATION phase, and that's okay as it goes before the TYPES phase.
For enum entries, the deprecations are calculated on TYPES phase which goes on TYPES phase.
This is incorrect as we cannot jump from lower phase to upper phase

The hack ignores such deprecation search for enum entires.

Test: org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.Tests.testEnumEntryAsType

^KT-57648
^KT-56543
2023-04-19 20:12:36 +00:00
Dmitrii Gridin 7e380e7df5 [LL FIR] remove LLFirPhaseRunner as it does nothing
^KT-56543
2023-04-19 20:12:36 +00:00
Dmitrii Gridin 72fce82f2f [LL FIR] remove useless checks for resolve phases inside transformers
Those checks are not performed during locking

^KT-56543
2023-04-19 20:12:35 +00:00
Dmitrii Gridin 0f379e592a [LL FIR] make LLFirLazyTransformerExecutor an object
^KT-56543
2023-04-19 20:12:35 +00:00
Dmitrii Gridin a172439f2a [LL FIR] move update declaration resolve phase out of updatePhaseForDeclarationInternals
needed for further safe publication of phase update

^KT-56543
2023-04-19 20:12:35 +00:00
Dmitrii Gridin d52c8b6793 [LL FIR] move updateDeclarationInternalsPhase checks out of LLFirLazyTransformer
needed for further safe publication of phase update

^KT-56543
2023-04-19 20:12:34 +00:00
Dmitrii Gridin e686e840b0 [LL FIR] move checkIsResolved checks out of LLFirLazyTransformer
needed for further safe publication of phase update

^KT-56543
2023-04-19 20:12:34 +00:00
Ilya Kirillov 930708ebb0 [LL FIR] lazy resolve imports under a separate lock
^KT-56543
2023-04-19 20:12:34 +00:00
Abduqodiri Qurbonzoda c1fb6528aa [WASM] Introduce internal ExperimentalNativeApi
To be able to OptIn usages in shared native-wasm directory.
2023-04-19 19:02:14 +00:00
Abduqodiri Qurbonzoda b6c2ce2dc8 [K/N] Make assert functions experimental with ExperimentalNativeApi 2023-04-19 19:02:14 +00:00
Abduqodiri Qurbonzoda 245ef256bd [K/N] Mark Throwable.getStackTrace[Addresses] with ExperimentalNativeApi
As a part of efforts to stabilize Native stdlib #KT-55765.
2023-04-19 19:01:36 +00:00
Abduqodiri Qurbonzoda 2140580fb1 [K/N] Mark Any?.identityHashCode() with ExperimentalNativeApi
Instead of ExperimentalStdlibApi

As a part of efforts to stabilize Native stdlib #KT-55765.
2023-04-19 19:01:36 +00:00
Dmitriy Novozhilov 92ab82b2f3 [Test] Remove duplicating testdata files 2023-04-19 18:41:21 +00:00
Anna Kozlova 04eb02085a [psi] bump stub version
missed from f810d435f4
2023-04-19 19:09:00 +02:00
Simon Ogorodnik ecf40e5c7a Revert "KT-57927: Fix deserialization of K2JVMCompilerArguments in FP/MT tests"
This reverts commit f8fdfc5d332b171b0e9e410b09a0b1e30d0d510e.

The change should be reverted as original change of the format in the
K2JVMCompilerArguments was reverted by commit:
5d0bf2de24

Merge-request: KT-MR-9684
Merged-by: Simon Ogorodnik <Simon.Ogorodnik@gmail.com>
2023-04-19 16:30:11 +00:00
Leonid Startsev f29e505bd3 Use correct check in FirSerializationPluginClassChecker to determine if the given type is a enum class.
Otherwise, findTypeSerializerOrContextUnchecked works incorrectly when analyzing code
compiled with Kotlin 1.7.20 and serialization 1.4.1.

#KT-57704 Fixed
2023-04-19 16:13:28 +00:00
Ilya Kirillov 167ed5e049 [Analysis API] add a KDoc for the LLFirSymbolProviderNameCache 2023-04-19 16:09:07 +00:00
Ilya Kirillov 806fff0887 [Analysis API] forbid Analysis inside KtResolveExtensionProvider
As it's called during FIR sessions initialization

^KT-57930
2023-04-19 16:09:06 +00:00
Ilya Kirillov 0d0b1b7945 [Analysis API] add ability for a custom element navigation for a KtResolveExtensionFile
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov 51eaa3f9cf [Analysis API] provide tests for the KtResolveExtensionProvider
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov d68587de77 [Analysis API] implement API to extend Kotlin resolution by generated declarations
^KT-57930 fixed
2023-04-19 16:09:04 +00:00
Ilya Kirillov 0dbc948616 [LL FIR] introduce CompositeKotlinDeclarationProvider
^KT-57930
2023-04-19 16:09:01 +00:00
Ilya Kirillov 9ca99ba7c7 [LL FIR] introduce CompositeKotlinPackageProvider
^KT-57930
2023-04-19 16:09:00 +00:00
Ilya Kirillov 9dcc9d0d10 [LL FIR] introduce LLFirCompositeSymbolProviderNameCache
^KT-57930
2023-04-19 16:09:00 +00:00
Ilya Kirillov 2beb4c0017 [PSI] allow creating KtFiles with eventSystemEnabled = true in KtPsiFactory
so we have a VirtualFile for every KtFile created by it

^KT-57930
2023-04-19 16:08:59 +00:00
Ilya Kirillov 3b681cd2eb [LL FIR] extract base class from LLFirSymbolProviderNameCache
^KT-57930
2023-04-19 16:08:59 +00:00
Nikolay Lunyak c9d7b47900 [FIR] Report == for identity-less
Since we forbid overriding `equals` for
value classes, and value classes may only
implement interfaces, we know everything
about their `equals`, hence we can
guarantee if it always returns `false`
for different value classes.
2023-04-19 16:05:19 +00:00
Nikolay Lunyak 8d04ab3142 [FIR] Ignore nullability in the definition of "identity-less"
The definition of a "builtin" already
ignores nullability.

`Int? === String?` must trigger a
diagnostic by design.
2023-04-19 16:05:19 +00:00
Nikolay Lunyak 5ecedcbb16 [FIR] Ensure K2 doesn't report Int? === String? 2023-04-19 16:05:18 +00:00
Alexander Korepanov 898ed7658a [JS IR] Update list of config settings affecting IC invalidation 2023-04-19 15:43:22 +00:00
Denis.Zharkov 4e2107abe7 K2: Fix false positive NotImplemented error for size property
The problem appeared because not all of the `realOverridden` have been
collected because inside AbstractSerializableListDecorator some of the
scopes returned the same instance as direct overridden and after that
overridden tree traversal stopped without detecting real overrides.

Thus, the modality of intersection for
AbstractSerializableListDecorator::size and MutableSet::size
was incorrectly computed to ABSTRACT

The similar thing is already done at the place where we're obtaining
all overrides.
See https://github.com/JetBrains/kotlin/commit/c80cfb0fdb00323ba9b5e1dd98c5cbd0bfab6b8b#diff-182d90c9b8050557e4e2eb319a84b9a51fd0600c728dd0fce85cf6491c13e16dR152

^KT-57693 Fixed
2023-04-19 15:20:49 +00:00
Dmitriy Novozhilov 6544220b3e [FIR] Check only for visibility modifiers for NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED error
^KT-58033 Fixed
2023-04-19 14:53:42 +00:00
Nikita Bobko 8314812ef9 2/2 FirUnsupportedSyntheticCallableReferenceChecker: don't report error on FirJavaOverriddenSyntheticPropertySymbol
Meta issue: KT-8575
^KT-58061 Fixed
Review: https://jetbrains.team/p/kt/reviews/9677

This commit fixes an inconsistency between
FirUnsupportedSyntheticCallableReferenceChecker and
UnsupportedSyntheticCallableReferenceChecker

In K1 such properties were not considered synthetic and are called
JavaPropertyDescriptor. That's why we need to do an additional check in
K2 checker, while in K1 we didn't need to do it

Also see the previous commit for more related tests that already was
green without this fix but are related to KT-58061 problem
2023-04-19 14:33:45 +00:00
Nikita Bobko 11f376ae84 1/2 Covert FirUnsupportedSyntheticCallableReferenceChecker with more tests
Review: https://jetbrains.team/p/kt/reviews/9677

I'm going to fix KT-58061 in the next commit. Firstly, let's cover
FirUnsupportedSyntheticCallableReferenceChecker with more tests that
already pass, but are related to KT-58061 problem.
2023-04-19 14:33:45 +00:00
Dmitriy Novozhilov 6287968511 [FIR Test] Migrate AbstractFirLoadCompiledKotlin to new test infrastructure
Also introduce two different modes for those tests:
- load metadata compiled with K1
- load metadata compiled with K2
2023-04-19 14:33:25 +00:00
Dmitriy Novozhilov 63829876b7 [Test] Add empty new line at the end of dump in MultiModuleInfoDumper if needed 2023-04-19 14:33:25 +00:00
Dmitriy Novozhilov e94a64a4f2 [FE Test] Move FIR dumps for LoadCompiledKotlin tests close to original testdata 2023-04-19 14:33:24 +00:00
Dmitriy Novozhilov de33a21fd1 [FE Test] Rename nested directory in testdata into nestedClasses
This is needed to avoid clash between generated test class `Nested` and
  `@Nested` annotation from JUnit 5
2023-04-19 14:33:24 +00:00
Jinseong Jeon 0ca86c86be SLC: add nullability annotation to value param of non-synthetic enum members
^KT-57567
2023-04-19 16:14:23 +02:00
Jinseong Jeon 9fe30bfc12 SLC: regression test for final modifier on enum members
^KT-57567
2023-04-19 16:14:23 +02:00
Dmitry Savvinov a3db0f14af [mpp] Minor: fix broken link to docs
^KT-57144 Fixed
2023-04-19 14:02:36 +00:00
Ivan Kylchik 6b75b3bc4a [IR] Drop duplicated meta info from interpreters tests 2023-04-19 13:52:48 +00:00
Ivan Kylchik 3f60c83921 [IR] Add id method in interpreter's tests to avoid optimizations 2023-04-19 13:52:48 +00:00
Ivan Kylchik 621f5a0fb7 [IR] Reorganize test files in involvesIrInterpreter dir 2023-04-19 13:52:48 +00:00
Ivan Kylchik c00c7ffbe0 [K2] Use file name as one of parameters to extract evaluated const
It is not enough to store evaluated constants only by
<startOffset, endOffset> pair. We need to consider case there constant
can be located in different files with the same offset but with
different values.

#KT-57928 Fixed
#KT-57929 Fixed
2023-04-19 13:52:46 +00:00
Ivan Kylchik 8cc8e54a9f [IR] Extract toString interpretation test of float value into new file
We need to distinguish `toString` results for JVM and JS
2023-04-19 13:52:46 +00:00
Ivan Kylchik 45aacae945 [K2] Rewrite the way of extraction const values from IR for FIR
Right now it is much easier to extract constant values from
`EvaluatedConstTracker`

#KT-57928
#KT-57929
2023-04-19 13:52:44 +00:00