Commit Graph

3633 Commits

Author SHA1 Message Date
Kirill Rakhman 4e1dfcd2a8 [FIR] Improve readability of rendered types in diagnostics
#KT-61824 Fixed
#KT-61688 Fixed
2023-09-21 07:18:19 +00:00
Kirill Rakhman 99b852adf8 [FIR] Refactor constructors of ConeTypeRenders 2023-09-21 07:18:19 +00:00
Yan Zhulanow 834cbaac5a [LL API] Run fir2ir separately for files in different modules
Each module may have its own compiler configuration.

^KTIJ-27061 Fixed
2023-09-21 06:19:15 +00:00
Ivan Kochurkin 1026cdf035 [FIR] Register necessary resolve components for library session for all backends
^KT-61876 Fixed
2023-09-20 17:12:52 +00:00
Mikhail Glukhikh 0c287c9945 K2: reproduce KT-61933 2023-09-20 15:42:03 +00:00
Roman Efremov ad4d1a5ba8 [IR] Support ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE in K2
It's implemented as IR checker because in K2 constant expressions are
evaluated on backend. FIR diagnostic removed because isn't needed.

"annotationViaActualTypeAlias" test has no `// FIR_IDENTICAL` because
diagnostic reported on entire typealias declaration instead of its name.
This is because in IR+LightTree we have only offsets, so can't navigate
to typealias name element.

^KT-59940 Fixed
2023-09-20 15:40:37 +00:00
Dmitrii Gridin 1d0785e246 [LL FIR] do not try to apply in-block modifications for unresolved bodies
In-block modifications are applicable only for FIR declarations with
fully resolved bodies. It can happen only during implicit type and body
phases. The implicit type phase probably is not applicable for our
particular case, but we will play safe because properties have a
complicated resolution logic, so it is hard to be sure that only body
phase will be enough.
Changes inside contracts are treated as out-of-block, so we can avoid
marker from this phase. Also, all mentioned calls inside bodies resolve
the corresponding declarations to the contract phase, so we will save a
lot with this optimization.

Q: Why in-block modification can be heavy?
A: In most cases this invalidation is pretty cheap because we have all
required information inside caches. But it is possible that we can
receive an in-block modification event for PSI without a corresponding
FIR element, or it is not yet fully resolved. In this case, for example,
we will do such redundant works as a raw FIR building or KtModule search

^KT-61842 Fixed
2023-09-20 15:36:02 +00:00
Dmitrii Gridin f7fe33bd98 [LL FIR] move in-block analysis declarations closer to service
^KT-61842
2023-09-20 16:04:03 +02:00
Ilya Kirillov b25185530f [Analysis API Standalone] use compiler FirSymbolProvider for standalone mode
^KT-61371 fixed
2023-09-20 07:47:59 +00:00
Ilya Kirillov d377d87c77 [LL FIR] refactoring, add service accessor for LLFirLibrarySymbolProviderFactory
^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov 9c50308954 [LL FIR] refactoring, rename LLFirLibrarySymbolProviderFactory.createJvmFirDeserializedSymbolProviders -> createJvmLibrarySymbolProvider
to match the behavior

^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov cce8bc6f83 [LL FIR] refactoring, use Project from project session constructor for implementations of LLFirLibrarySymbolProviderFactory
^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov 2422fc6df3 [LL FIR] refactoring, extract LLFirLibrarySymbolProviderFactory implementation to the standalone module
^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov 575c7ea0d9 [LL FIR] refactoring, rename JvmFirDeserializedSymbolProviderFactory
so it can be used not only for JVM

^KT-61371
2023-09-20 07:47:59 +00:00
Nikolay Lunyak ec9cb8beb6 [FIR] Rename JvmNames -> JvmStandardClassIds
This is more consistent with the code of
the common compiler checkers.

It would be nice to refactor the contents
of this object further, but it's out
of scope of the current branch.

^KT-54596
2023-09-19 22:14:09 +00:00
Nikolay Lunyak 986f1624ec [FIR] Remove jvm-specific annotations from common compiler code
^KT-54596 Fixed
2023-09-19 22:14:09 +00:00
Ilya Chernikov e5ee364419 IC: Implement expect/actual tracking
fixes NewMultiplatformIT.testIncrementalCompilation
also #KT-61590 fixed
2023-09-19 15:46:30 +00:00
Dmitrii Gridin 11d86992c5 [SLC] update test data for 2.0 version
* disable compiled tests for scripts because they are not supported yet
* fix test data

^KT-60590 Fixed
2023-09-19 15:46:27 +00:00
Dmitrii Gridin 9ff3871a8b [LL FIR] LLFirPhaseUpdater: add missing update for code fragment block 2023-09-19 14:03:29 +00:00
Dmitrii Gridin e5f0356e16 [LL FIR] LLFirPhaseUpdater: add missing update for initializer body 2023-09-19 14:03:29 +00:00
Dmitrii Gridin 12dc6b1ebc [FIR] FirRenderer: render name for scripts
A script name is important information, so it is better to render it.
This also will fix the inconsistency with redundant space after 'SCRIPT:'.
2023-09-19 14:03:29 +00:00
Dmitrii Gridin c6bb9af823 [FIR] FirRenderer: add missing resolvePhaseRenderer usage for anonymous initializer and dangling modifiers 2023-09-19 14:03:29 +00:00
Dmitrii Gridin c9df6aff5f [LL FIR] do not crash on attempt to resolve class initializer in case of class clash
^KT-61788 Fixed
2023-09-19 14:03:29 +00:00
Dmitrii Gridin e3ad946d23 [LL FIR] add more debug info into containingClass
^KT-61788
2023-09-19 14:03:29 +00:00
Alexander Udalov 5cae87b263 K2: add package FQ name to ClassId of anonymous objects
This is needed because in order to figure out which declarations are
visible from anonymous objects in terms of overridability (see
`FirVisibilityChecker.isVisibleForOverriding`), we need to get the
package name of that anonymous object, because there's package-private
visibility on JVM.

 #KT-62017 Fixed
2023-09-19 09:32:55 +00:00
Dmitrii Gridin 5981fb3022 [LL FIR] drop copyright from testData 2023-09-18 21:12:45 +00:00
Dmitrii Gridin 33e6a85a2d [LL FIR] rename testdata to testData to avoid copyright generation
We exclude testData pattern from copyright scope
2023-09-18 21:12:45 +00:00
Yan Zhulanow 40ecd4bc1e [fir2ir] Fix annotation conversion on partial module compilation
Backend requires annotation constructors to be fully resolved for the
'IrConst' default value lowering. However, in the IDE there is usually
no need in complete annotation class resolution.

^KTIJ-27061 Fixed
2023-09-18 19:48:08 +00:00
Dmitrii Gridin f4df4f8007 [FIR] do not invoke body resolution for properties with excplicit type on implicit type phase
`property.backingField != null` is too soft condition because currently
each property has a backing field. We should trigger the full body
resolution only in the case of an implicit type on the property or on
the backing field

^KT-61991 Fixed
2023-09-18 15:26:53 +00:00
Jinseong Jeon cec299ac0a K2 UAST: Improve performance of PSI declaration provider
When it comes to finding regular class (of `PsiClass`) from the given
`ClassId`, we've reinvented the wheel in a worse way. `JavaFileManager`
is there to find `PsiClass`, and we already build/populate index for
that while initializing AA standalone mode's own project environment.
We can simply load that manager and send a query, that's it.

However, our efforts so far on binary PSI declaration providers are not
entirely useless. `JavaFileManager` can't handle top-level declarations
and search for all callables/classes in a given package in general. So,
we can still use existing logic for non-ClassId queries. We just need to
cache the intermediate results: fq name to `VirtualFile`s.

To fully utilize the aforementioned cache, we also need to cache an
instance of `KotlinPsiDeclarationProvider`.

Combing these three ideas, now running K2 UAST on a very large module is
"on par", e.g.,
K1:
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 112.8s
  Stats over 7 runs: max = 112.8s, min = 104.3s, avg = 107.9s, dev = 3.6s
K2 (before):
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 303.0s
  Stats over 7 runs: max = 303.0s, min = 286.8s, avg = 294.4s, dev = 5.0s
K2 (after):
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 112.8s
  Stats over 7 runs: max = 112.8s, min = 105.7s, avg = 108.9s, dev = 2.4s
2023-09-18 14:55:11 +00:00
Nikolay Lunyak 93958ec73d [FIR] Check conflicts between nested classes' constructors and member functions
For an example of an object with
an implicit primary constructor,
see `FirPsiOldFrontendDiagnosticsTestGenerated.testSingletonAndFunctionSameName`.

^KT-62005 Fixed


Merge-request: KT-MR-12242
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-09-18 11:41:42 +00:00
Roman Golyshev a78d631b16 KTIJ-27050 [Analysis API] Correctly handle type parameters in KtFirReferenceShortener
Make `FirShorteningContext` correctly return symbols for type
parameters, so they are not ignored when scopes are inspected

Add additional type of `PartialOrderOfScope` - `TypeParameter`, because
otherwise it would have been classified as `Unclassified`, and that
breaks scopes comparison

Add missing type parameters to the scope of class header in
`ContextCollector`, add testdata for that

There is a bug in the compiler with type parameters leaking to nested
classes headers (KT-61959). After it's fixed, the testData with
incorrect expected shortenings/scopes should be adjusted and fixed too

^KTIJ-27050 Fixed
2023-09-18 10:23:30 +00:00
Roman Golyshev e2019ceb95 KTIJ-27050 [Analysis API] Refactor FirShorteningContext
Use `AvailableSymbol<FirClassLikeSymbol<*>>` instead
of `AvailableSymbol<ClassId>`
2023-09-18 10:23:29 +00:00
Roman Golyshev 020f8c0742 KTIJ-27050 [Analysis API] Refactor FirShorteningContext
Remove duplication from `findFirstClassifier*` functions
2023-09-18 10:23:29 +00:00
Roman Golyshev b4209a4196 KT-61889 [Analysis API] Remove last usage of onAirResolve from Reference shortener
Add factory function `create` to
`FirTowerContextProviderByContextCollector`

^KT-61889 Fixed
2023-09-15 19:18:09 +00:00
Mikhail Glukhikh f8ada456e4 K2: rename FakeOverrideTypeCalculator to CallableCopyTypeCalculator
This commits performs a rename.
According to KT-61443 this calculator is applicable not only to
fake (substitution/intersection) overrides.
2023-09-15 15:21:10 +00:00
Roman Efremov 420dceb7d8 [FE, IR] Store PsiElement for mismatched annotation's actual target
There is IDE quick fix which suggests to copy mismatched annotation
from `expect` to `actual` (see KTIJ-26633). It needs to find
`actual` PsiElement where to add annotation. Before previous commit, it
was easy - just get source of `Incompatibility.actualSymbol`.
After previous commit, the problem might be in value parameter, while
`actualSymbol` would contain function symbol. This is solved by adding
new field `Incompatibility.actualAnnotationTargetElement`.

`SourceElementMarker` introduced, because it's needed to be used in
abstract checker. Existing `DeclarationSymbolMarker` doesn't fit
because in next PR for this issue annotations set on types will be reported,
and types are not declarations.

^KT-60671
2023-09-15 14:41:37 +00:00
Roman Efremov 371db10330 Remove IncDecOperatorsInExpectClass test
It is incorrect because has expect and actual in same module,
which results in ACTUAL_WITHOUT_EXPECT reported in FIR.
But there is already same test
`multiplatform/incDecOperatorsInExpectClass.kt`, so there is no need
to fix and maintain test `IncDecOperatorsInExpectClass`.

^KT-60075 Fixed
2023-09-15 12:04:08 +00:00
Pavel Kunyavskiy 9a9598c16b [Klib] Run prerelease checker in all backends
The checker also checks the metadata version, which
would be handled separately. Now it would never
emmit this error for klib-based backends.

^KT-61773
^KT-61596
^KT-55809
2023-09-15 09:48:42 +00:00
Dmitrii Gridin 1b1e1d5b3f [Analysis API] DebugSymbolRenderer: unify error types
They are still can be different in the case of error inside
type argument (e.g. `kotlin/Array<out ERROR CLASS: Incomplete code>`)
2023-09-14 18:53:25 +02:00
Dmitrii Gridin 2d83509200 [Analysis API Fe10] add missing initializer for properties 2023-09-14 18:53:25 +02:00
Dmitrii Gridin bb470b5504 [Analysis API Fe10] fix isFromPrimaryConstructor 2023-09-14 18:53:25 +02:00
strangepleasures cf01d2970f [SLC] [KAPT] KT-61916 Fix generation of annotations in annotation arguments 2023-09-14 13:21:07 +00:00
Kirill Rakhman 0d628c9e59 [FIR] Inline FirExpression.coneTypeSafe und use resolvedType
The call-sites don't actually need to handle unresolved expressions,
they only need safe-casts to ConeClassLikeType or
ConeIntegerLiteralType.

#KT-61367
2023-09-14 10:03:03 +00:00
Kirill Rakhman aebb3bf0ee [FIR AA] Use resolvedType instead of coneTypeOrNull where applicable
#KT-61367 Fixed
2023-09-14 10:03:02 +00:00
Dmitrii Gridin 7d42bfa859 [LL FIR] LLFirResolveTarget: mark class as internal
^KT-61296
2023-09-13 20:26:50 +00:00
Dmitrii Gridin 31b36ee766 [LL FIR] introduce lazyResolveRecursively API
FirFile after KT-56683 has its own phases and resolution logic,
so we should have a separate API for lazy resolution for FirFile and for
the entire file

^KT-61296 Fixed
2023-09-13 20:26:50 +00:00
Dmitrii Gridin b77ae5d275 [LL FIR] rework LLFirResolveTarget
* Move visiting logic to LLFirTargetResolver to
avoid code duplication
* Introduce more common LLFirWholeElementResolveTarget

^KT-61296
2023-09-13 20:26:50 +00:00
Dmitrii Gridin aeeb64b9ef [LL FIR] LLFirResolveTarget: more accurate toString
^KT-61296
2023-09-13 20:26:49 +00:00
Dmitrii Gridin 6893c44a06 [LL FIR] merge LLFirResolveTargetWithDedicatedElement into LLFirResolveTarget
^KT-61296
2023-09-13 20:26:49 +00:00