Commit Graph

2579 Commits

Author SHA1 Message Date
Roman Golyshev fb9de6ba45 [213] Avoid using ConcurrentCollectionFactory.createConcurrentIdentityMap
The `ConcurrentCollectionFactory` class was moved to the module
which is no longer available in the 213 platform distribution

`MapMaker().weakKeys().makeMap()` is used as drop-in replacement of
concurrent hash map with identity-based equals strategy

The new implementation stores keys on weak references, which should not
change the behavior of the `ModuleFileCacheImpl`.

1. If someone still has a strong reference to the `ktFile`, then the
cache will also keep it.

2. If there are no more strong references to the `ktFile`, then the
cache will not hold it from being garbage-collected. However, since
nobody  has a strong reference to the `ktFile` anymore, nobody can call
 `fileCached` or `getCachedFirFile` with it, and it will never be
 requested from the cache.

KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Yan Zhulanow c9c6508b03 [LL API] Fix declaration mapping for library dependencies
As there is no accurate way to figure out exact dependencies for each
library JAR, all project libraries but the current one are added as
dependencies. However, for performance reasons, each library is not
treated as an individual 'LLFirLibrarySession', instead a scope-based
'JvmClassFileBasedSymbolProvider' is used.

Although code analysis is correct with this setup, navigation between
libraries was broken. The reason is that source declarations were only
queried inside the library itself.

After the fix, declarations are first queried in the library,
and if there are no good candidates, all other libraries are scanned.
The same way things work in the Java plugin.

^KTIJ-23073 Fixed
2023-04-21 12:49:43 +00:00
Dmitrii Gridin f85dc95b66 [SLC] SymbolLightAccessorMethod: reduce number of requests on symbol restoring
We can avoid extra restoring of property accessors
if the corresponding property is already restored

^KT-57850
2023-04-21 11:10:20 +00:00
Dmitrii Gridin 5d1c853adf [AA FIR] fix contract violation for java Target annotation
^KT-57849 Fixed
2023-04-21 10:14:05 +00:00
Dmitrii Gridin f540826207 [AA FIR] add tests on java target annotation stability
^KT-57849
2023-04-21 10:14:05 +00:00
Dmitrii Gridin 7b91cd0ff3 [FIR] calculate java Target annotation on COMPILER_REQUIRED_ANNOTATIONS phase
^KT-57849
^KT-57949
2023-04-21 10:14:05 +00:00
Dmitrii Gridin 1c456b216b [AA FIR] add lazy resolve test on java target
^KT-57849
2023-04-21 10:14:05 +00:00
Dmitrii Gridin 0caaca45ae [AA FIR] fix contract violation for Target annotation
^KT-57849
2023-04-21 10:14:05 +00:00
Dmitrii Gridin d66b919c12 [AA] introduce tests on annotation stability
^KT-57849
2023-04-21 10:14:05 +00:00
Egor Kulikov c46c922841 [ClsStubs] Add context receivers on function types 2023-04-20 18:57:51 +00:00
Dmitrii Gridin bca8be6c39 [LL FIR] avoid resolve to find property accessor declaration
^KT-57850 Fixed
2023-04-20 11:12:39 +00:00
Kirill Rakhman 8b47a4fa48 [FIR] Fix resolution of objects in presence of low-priority candidates
For CallKind.VariableAccess, the condition when to *skip* resolution of
objects was previously collector.isSuccess. This wasn't strict enough
because collector.isSuccess could be true when the best found candidate
has an applicability like RESOLVED_WITH_LOW_PRIORITY (e.g. from dynamic
scope or annotated with @LowPriorityInOverloadResolution). In these
cases, we do want to resolve objects. To fix this, the condition is
changed to collector.shouldStopResolve which is stricter.

#KT-57960 Fixed
2023-04-20 08:04:07 +00:00
Dmitrii Gridin 2463b904f7 [LL FIR] add ability to suppress contract violation exception
^KT-56543
2023-04-19 20:12:43 +00:00
Dmitrii Gridin 8387ea8a39 [LL FIR] FileStructure: process annotations from constructors correctly
^KT-56543
2023-04-19 20:12:43 +00:00
Dmitrii Gridin 71f48ede53 [LL FIR] resolve compiler required annotations correctly
Original AbstractFirSpecificAnnotationResolveTransformer can jump
to other classes and resolve them outside
our transformers, so it leads to
problems with locks and lazy bodies

^KT-56543
2023-04-19 20:12:42 +00:00
Dmitrii Gridin 6170d83301 [FIR] update reversed testData
^KT-56543
2023-04-19 20:12:41 +00:00
Dmitrii Gridin 26f8147a8c [LL FIR] FileStructure: process super class calls correctly
^KT-56543
^KT-57793
2023-04-19 20:12:39 +00:00
Dmitrii Gridin d0e801054c [FIR] builder: add test on class with wrong super call
^KT-56543
^KT-57793
2023-04-19 20:12:39 +00:00
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 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
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 3b681cd2eb [LL FIR] extract base class from LLFirSymbolProviderNameCache
^KT-57930
2023-04-19 16:08:59 +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
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
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
Mikhail Glukhikh f9a7a7fda2 K2: reproduce KT-57889 2023-04-18 17:05:00 +00:00
Dmitriy Novozhilov f8dc8057f0 [FIR] Prohibit referencing type parameters in contracts ...
...if they are not reified or not belong to owner declaration of the contract

KT-57911
2023-04-18 13:31:28 +00:00
Mikhail Glukhikh 7bd5491498 K2: reproduce KT-57873 2023-04-18 09:23:20 +00:00
Mikhail Glukhikh c8b74e5655 K2: reproduce KT-57991 2023-04-17 18:05:43 +00:00
Nikita Bobko 5a96754aec Shift ReferencesToSyntheticJavaProperties feature release from 1.9 to 2.1
Other related tests:
- testGenericJavaProperty
- testFunInterfaceConstructorReference

Meta issue: KT-8575
Review: https://jetbrains.team/p/kt/reviews/9595

UnsupportedSyntheticCallableReferenceChecker only existed for K1,
because we wanted to release the feature for 1.9 and the feature should
have been working for K2 unconditionally. But since, we're postponing
the release until 2.1, we also need to port the checker from K1 to K2
2023-04-17 17:42:01 +00:00
Jinseong Jeon fbe558a0de AA FIR: handle smartcasted arg when building call's argument mapping
^KTIJ-25112 Fixed
2023-04-17 13:57:08 +02:00
Marco Pennekamp 73d99019bd [AA] KT-57515 Add createCompositeModificationTracker 2023-04-17 11:20:52 +00:00