Commit Graph

1439 Commits

Author SHA1 Message Date
Brian Norman 42ebbb937c [FIR] Recursively search dependsOn modules in visibility checks
#KT-59071 Fixed
2023-07-24 14:20:57 +00:00
Dmitrii Gridin 8820867341 [FIR] support flexible types in ConeKotlinType#independentInstance
^KT-60580 Fixed
2023-07-20 17:22:56 +00:00
Dmitrii Gridin dc56c5cf9e [LL FIR] FileStructure: avoid synchronizations on cache access
From `ConcurrentMap#compute`
>The entire method invocation is performed atomically.
>Some attempted update operations on this map by other threads may
>be blocked while computation is in progress, so the computation
>should be short and simple

And we can call resolution (`reanalyze()`) under this synchronized
block that can take unpredictable time.

This fix drops all heavy operations from synchronization
2023-07-20 14:20:51 +00:00
Kirill Rakhman 6ca95dc338 [Tests] Fix test data after bed6cb7154 2023-07-20 13:37:38 +00:00
Nikolay Lunyak 84dd1acec1 [FIR] Check typealiases in supertypes
^KT-59830 Fixed

Merge-request: KT-MR-11187
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-20 12:50:06 +00:00
Ivan Kochurkin d8ccf21894 [FIR] Fix false positive "suspension point is inside a critical section"
^KT-55072 Fixed
2023-07-20 10:38:59 +00:00
Kirill Rakhman bed6cb7154 [FIR] Make FirFile.annotationsContainer nullable
Previously, when no file annotations were present, the FIR element
didn't have a source.
By making it nullable, it will only be created when appropriate and the
source will never be null.

#KT-55835
2023-07-20 07:29:18 +00:00
Dmitrii Gridin d0854d5b45 [FIR] propagate copy of original ConeKotlinType to anonymous functions to avoid concurrent modification
It is required to avoid leakage of annotations instance from
the original type
It should be enough to just create a new instance of an annotation
without a deep copy, because transformer shouldn't touch it

^KT-60387 Fixed
2023-07-19 11:50:12 +00:00
Dmitrii Gridin b59e66c217 [LL FIR] add test on annotation type copy
^KT-60387
2023-07-19 11:50:12 +00:00
Dmitrii Gridin 14327d51ed [LL FIR] invalidateAfterInBlockModification: do not treat adding of body as in-block modification
It is an out-of-block modification because some diagnostics depend
on a fact of a body's existence

^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin 5f24ad114c [LL FIR] AbstractInBlockModificationTest: add more tests
^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin f0d8a1cbe9 [LL FIR] AbstractInBlockModificationTest: cover getNonLocalReanalyzableContainingDeclaration
^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin 32ad4380b3 [FIR] make java annotation mapping lazily
to avoid contract violations from getDeprecation

^KT-59342 Fixed
^KT-60520
2023-07-18 16:48:53 +00:00
Ilya Kirillov 08400d930f [Analysis API, FIR] migrate ::class.java -> ::class inside error messages
They seem to provide similar results and the `.java` part is redundant
2023-07-18 11:49:21 +00:00
Ilya Kirillov 24db4e62f5 Migrate some FIR/Analysis API KotlinExceptionWithAttachment usages to buildErrorWithAttachment API 2023-07-18 11:49:21 +00:00
Ilya Kirillov a9cd881a07 [FIR] add utilities to FIR compiler to throw error with attachment 2023-07-18 11:49:20 +00:00
Ilya Kirillov c5014d4765 Move PsiElement.getElementTextWithContext to psi module with small adjustments
* replace existing function (the new one makes it more clear which element was printed)
* prints position for element
* handles invalid psi element
2023-07-18 11:49:20 +00:00
Ilya Kirillov 4b3bff3344 Rework checkWithAttachment/requireWithAttachment
* better naming
* throw corresponding KotlinIllegalStateExceptionWithAttachments/KotlinIllegalArgumentExceptionWithAttachments instead of general KotlinRuntimeExceptionWithAttachments
2023-07-18 11:49:20 +00:00
Ilya Kirillov 2d791eb292 Rename buildErrorWithAttachment -> errorWithAttachment to emphasise the similar semantics to kotlin.error 2023-07-18 11:49:20 +00:00
Ilya Kirillov 15f6fe2627 Move ExceptionAttachmentBuilder near KotlinExceptionWithAttachments so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Dmitriy Novozhilov 73b580572b [FE] Move @PrivateForInline optIn into :core:compiler.common
This is needed to be able to use it in backend modules too
2023-07-17 21:02:40 +00:00
Dmitrii Gridin 38b55c659b [LL FIR] LLFirResolveSessionDepended: add missing mapping for resolveToFirSymbol
We should try to find a declaration from our mapping firstly
Otherwise we can find an invalid element

^KT-60451 Fixed
2023-07-17 17:15:35 +00:00
Dmitrii Gridin 1642eaa48a [FIR] getValueClassUnderlyingParameters: fix TODO
^KT-53573 Obsolete
2023-07-17 08:59:17 +00:00
Justin Paupore 9f85739599 [AA] Add KtResolveExtensionInfoProvider to AA.
This provider is responsible for answering queries related to resolve
extensions. At the moment, this includes retrieving a KtScope with all REx
top-level declarations (moved from KtSymbolFromResolveExtensionProvider), and
retrieving information necessary to supply a GeneratedSourcesFilter for REx
generated code. Future REx-related functions can be added to this interface.

^KT-59329
2023-07-14 19:32:09 +02:00
Mikhail Glukhikh 402e1de5fe K2: reproduce KT-60229 2023-07-14 16:38:47 +00:00
Brian Norman d2ad426350 [FIR] Fix node ordering for delegating constructor graph
Inject delegated constructor and other in-place initializer sub-graphs
after the delegated constructor call node. This ensures property
initialization and use is calculated correctly when there are complex
calculations for the arguments to the delegated constructor.

#KT-59708 Fixed
#KT-59832 Fixed
2023-07-14 13:42:29 +00:00
Egor Kulikov 70d49999ac [FIR] Generate an error primary constructor when super call is invalid
Merge-request: KT-MR-11026
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-07-13 17:37:48 +00:00
Stanislav Ruban 5c644bcac8 [test infra] Add a directive for type checking utils that use @Exact 2023-07-13 13:41:36 +00:00
Dmitrii Gridin 3d40eba379 [LL FIR] LLFirContractsLazyResolver: add isResolved check
Currently, FirLegacyRawContractDescription is a valid class for
resolved contract in case of error description.
This condition should be dropped after KT-60310

^KT-60310
2023-07-13 12:27:02 +00:00
Dmitrii Gridin 4b330e88be [LL FIR] LLFirLazyResolver: implement checkIsResolved
To simplify logic and avoid boilerplate
2023-07-13 12:27:02 +00:00
Dmitrii Gridin 5b6e6b7a4e [LL FIR] LLFirLazyResolver: implement updatePhaseForDeclarationInternals
To avoid code duplication in each implementation
2023-07-13 12:27:02 +00:00
Dmitrii Gridin 660385b67d [LL FIR] move annotation type checks to TYPES phase resolver
LLFirTypeTargetResolver in general is responsible for annotation
type resolution, so such checks should be done on its phase.

Also, there is no sense to trying to check a type of annotation mapping
values because they will be initialized only during
LLFirAnnotationArgumentsMappingTargetResolver so, in most cases,
current check during LLFirAnnotationArgumentsLazyResolver is useless

^KT-60295 Fixed
2023-07-13 12:27:02 +00:00
Dmitrii Gridin b67b37cdb3 [FIR] FirJavaFacade: do not duplicate record constructor
The fresh version of intellij has all record-related declarations,
so an additional fake constructor leads to errors like
KTIJ-25364 (OVERLOAD_RESOLUTION_AMBIGUITY)

^KTIJ-25366 Fixed
^KTIJ-25364 Fixed
^KTIJ-25368 Fixed
^KTIJ-25370 Fixed
2023-07-13 09:21:38 +00:00
Anna Kozlova a2cefbc6be [LL] retrieve module by original file
originalDeclaration is set for non-local declarations only,
thus requesting symbols for local declarations still goes
with non-physical elements
This lead to ModuleKind.BINARY_MODULE
for `NotUnderContentRootModule`s, because the declaring file is different

KT-60377
2023-07-12 15:37:53 +00:00
Brian Norman 10ed26991d [FIR] Extract LHS receiver of assignment operator statements
#KT-53490 Fixed
2023-07-12 11:41:33 +00:00
Anastasia.Nekrasova fcba0ad75e [Test] Add a test covering for resolution to subsumed members for raw types
^KT-57620
2023-07-12 09:11:01 +00:00
Mikhail Glukhikh 71456c5514 FIR2IR: properly set constant expression type 2023-07-11 08:28:04 +00:00
Andrei Klunnyi a1385103bf KT-60236 K2 scripting: completion fails with exception
^KT-60236 fixed
2023-07-10 14:37:16 +02:00
Andrei Klunnyi 527d20c7be KT-60171 K2-scripting: CLI specific providers are used in IDE context
^KT-60171 fixed

Merge-request: KT-MR-10987
Merged-by: Andrei Klunnyi <andrei.klunnyi@jetbrains.com>
2023-07-10 11:03:11 +00:00
Nikolay Lunyak 79fce56c95 [FIR] Add a test for KT-59233 2023-07-10 10:26:43 +00:00
Nikolay Lunyak 4f0563dee1 [FIR] Add a test for KT-55933 2023-07-10 09:43:22 +00:00
Yan Zhulanow e5f9eb5b24 [LL API] Fix 'getResolvableSessionFor()' for library sessions 2023-07-07 13:34:01 +00:00
Dmitrii Gridin 6867dffff1 [LL FIR] rewrite on-air resolve
Now we will resolve declarations only ones and to the
minimal required phase to get a fully resolved element
depends on an insert position, because not all elements
require body resolution

A side change: `getOnAirGetTowerContextProvider` now
won't do rebind to the original declaration. In the future,
this part will be rewritten to avoid on-air resolution,
so it is not a problem

^KT-59685 Fixed
2023-07-07 11:42:22 +00:00
Dmitriy Novozhilov fc57f48c8f [FIR] Union CFG edges from postponed lambdas only if outer call was analyzed independently
Before this change nodes unification was called if outer call was
  completed in the FULL mode, but it may happen even if this call is
  actually a part of some other outer call
2023-07-07 06:45:20 +00:00
Mikhail Glukhikh 15b070b494 K2: don't resolve callable reference to enum entries #KT-59611 Fixed 2023-07-06 15:06:31 +00:00
Yan Zhulanow 7e075ec64a [FIR] Pass the whole body context to the resolve context collector
Collector for the 'FirCodeFragment' analysis needs to capture also
data-flow information.
2023-07-06 15:58:30 +09:00
Dmitrii Gridin 83d0dbe436 [LL FIR] FileStructure: reanalyze declarations without name as well
^KT-60132 Fixed
^KT-59687
2023-07-05 20:29:01 +02:00
Dmitrii Gridin 9e88da2e66 [LL FIR] FileStructure: add tests for re-analyzable elements without names
^KT-60132
^KT-59687
2023-07-05 20:29:01 +02:00
Dmitrii Gridin e354b2a900 [LL FIR] rewrote in-block modifications logic
Now we will invalidate bodies for FIR declarations
immediately after in-block modifications in these declarations
We assume that such in-block modifications can happen
only under write action,
so it should be safe to make changes for FirFile

^KT-59687 Fixed
^KT-59199 Fixed
^KTIJ-26066 Fixed
2023-07-05 20:29:00 +02:00
Dmitrii Gridin a50efd7aa2 [LL FIR] treat changes inside contract description as OOBM
Because contracts affects resolution

^KT-59687
^KTIJ-26085 Fixed
^KTIJ-26066
2023-07-05 20:28:28 +02:00