Commit Graph

907 Commits

Author SHA1 Message Date
Nikita Bobko de8c3826c2 [FE] Prohibit missed MUST_BE_INITIALIZED when there is no primary constructor
^KT-58472 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967
2023-05-23 14:12:29 +03:00
Nikita Bobko ac40010501 [FE] Prohibit open val deferred initialization
^KT-57553 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

Other related tests:
- testUninitializedOrReassignedVariables
- testUseOfPropertiesWithoutPrimary
- @TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
- testAugmentedAssignmentInInitializer
- testInitOpenSetter
- testInitOverrideInConstructorComplex
- testPropertyInitializationOrder
2023-05-23 14:12:28 +03:00
Nikita Bobko 38319c55a8 [FE] Replace some MUST_BE_INITIALIZED messages with MUST_BE_INITIALIZED_OR_BE_FINAL
From user point of view it's an improvement in compilation message.

From technical point of view it's an introduction of new compilation
diagnostic.

Review: https://jetbrains.team/p/kt/reviews/9967

I'm going to deprecate `open val` case in the next few commits KT-57553.
But it is always possible to suggest using `final` for `open val` case.
2023-05-23 14:12:28 +03:00
Egor Kulikov f432bbad2e Revert "[FIR] Fix error with incorrect destructing declaration"
This reverts commit b47910e86b.
2023-05-23 12:51:43 +02:00
Egor Kulikov b47910e86b [FIR] Fix error with incorrect destructing declaration
^KTIJ-25342 fixed
2023-05-23 12:48:41 +02:00
Marco Pennekamp 326b6fa7c2 [AA] Add missing withValidityAssertion calls to scopes
^KT-58653
2023-05-22 19:21:34 +00:00
Egor Kulikov 1d8eb6dc9e [FIR] Only take receiver on lambda if present
^KTIJ-25127 fixed
2023-05-22 17:10:52 +00:00
Kirill Rakhman df03f0df0a [FIR] Implement deprecation for implementing var by inherited val
#KT-56779 Fixed
2023-05-19 15:04:46 +00:00
Alexander Udalov 75197d1b86 JVM: remove diagnostics related to JVM target 1.6 2023-05-19 13:24:00 +00:00
Dmitrii Gridin b713dfd7ea [AA FIR] KtFirOverrideInfoProvider: resolve to status only if needed
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 5b3f617378 [FIR] add memberRequiredPhase to declaredMemberScope
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 01a94624f5 [AA FIR] KtFirScopeProvider: use lazy resolve only if needed
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin f2da13b39d [AA FIR] KtFirMemberSymbolPointer: replace explicit lazy resolve call with implicit
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 04231d7497 [AA FIR] add missing memberRequiredPhase to some usages of unsubstitutedScope
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin aaf173687b [FIR] rename requiredPhase to requiredMembersPhase for type scope
Also move `requiredMembersPhase` use inside `unsubstitutedScope`

^KT-56551
2023-05-19 12:43:44 +00:00
Ilya Kirillov 993acad3f3 [Analysis API] optimize DeclarationsInPackageProvider.getTopLevelClassifierNamesInPackageProvider 2023-05-19 11:53:16 +00:00
Ilya Kirillov d1da3b8acd [Analysis API] fix missing names in KtFirStarImportingScope
The missing name types were: java classifier names, callable/classifier names generated by plugins
2023-05-19 11:53:16 +00:00
Ilya Kirillov 546191d1b3 [Analysis API] refactoring, simplify constructor KtFirStarImportingScope 2023-05-19 11:53:16 +00:00
Ilya Kirillov 50c49838ba [Analysis API] refactoring, extract top level name collecting to a separate file
out of KtFirPackageScope
2023-05-19 11:53:16 +00:00
Ilya Kirillov 51c04b624f [Analysis API] optimize KtFirPackageScope.getPossibleClassifierNames
Previously, we did the kotlin subclasses name search two times:
- via `KotlinDeclarationProvider`
- via `JavaElementFinder`

which is redundant and slows down the searching
2023-05-19 11:53:16 +00:00
Ilya Kirillov f8ddf204e2 [Analysis API] add KtTypeScope.getCallableSignatures/getClassifierSymbols overloads which accept a candidate name set
This is needed for the cases when a candidate name set is known
to avoid retrieving a set with all possible names when processing the scope.

Similar to KtScope.

^KT-58653
2023-05-19 11:53:15 +00:00
Ilya Kirillov ee1fd9f6e9 [Analysis API] optimize composite scope
Do not create KtCompositeScope for empty or single scopes
2023-05-19 11:53:15 +00:00
Ilya Kirillov 950a32901c [Analysis API FIR] refactoring, remove duplicated code from KtFir(Non)StarImporting scope
use base class implementation instead.
2023-05-19 11:53:15 +00:00
Ilya Kirillov 55bbc5eb02 [Analysis API FIR] refactoring, extract base part of KtFirDelegatingScope into a separate class
For further reuse
2023-05-19 11:53:15 +00:00
Ilya Kirillov 41976a2932 [Analysis API] optimize scope members processing when a candidate name set is known
Use KtScope.getCallableSymbols/getClassifier symbols overloads which accept a candidate name set.

^KT-58653
2023-05-19 11:53:15 +00:00
Ilya Kirillov 29be88e3c9 [Analysis API] add KtScope.getCallableSymbols/getClassifier symbols overloads which accept a candidate name set
This is needed for the cases when a candidate name set is known
 to avoid retrieving a set with all possible names when processing the scope.

^KT-58653 fixed
2023-05-19 11:53:15 +00:00
Egor Kulikov bff1520c9e [FIR] Resolve where subjects to corresponding type argument
^KTIJ-25295 fixed

Merge-request: KT-MR-10044
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-05-17 15:28:02 +00:00
Dmitrii Gridin 4472e1ae4e [AA FIR] add tests on implicit type in delegated scope
^KT-58727
2023-05-17 09:51:21 +00:00
Yan Zhulanow c6d8876f9f [LL API] Pass the project instance to ProjectStructureProvider
Eliminate unnecessary PSI tree traversal by providing the 'Project'
instance explicitly.
2023-05-16 08:42:57 +00:00
Yan Zhulanow bb37a959d4 [LL API] Move composite declaration provider to be used in IntelliJ 2023-05-16 08:42:57 +00:00
Yan Zhulanow d3cb41cbab [LL API] Pass contextual modules to 'KotlinDeclarationProvider' factory
^KT-57559 Fixed
2023-05-16 08:42:57 +00:00
Yan Zhulanow e9c077220f [LL API] Migrate 'getKtModule()' usages to 'ProjectStructureProvider'
Ensure the contextual module is passed wherever possible.

^KT-57559 Fixed
2023-05-16 08:42:57 +00:00
Jinseong Jeon b42d2e56a4 AA: use nameFilter of KtFileScope#get*Symbols 2023-05-15 19:25:05 +02:00
Roman Golyshev 90a0b34bf7 [AA FIR] KT-58503 Use resolvedStatus to access modality only in case of Status Transformers present
ATM unconditional `resolvedStatus` call in `modality` causes a
performance degradation in our completion tests

Since `resolvedStatus` is called to make sure that all the
status-transforming compiler plugins had finished their job, it doesn't
make sense to call `resolvedStatus` if there are no such compiler
plugins registered

N.B. After KT-56551 is fixed, this optimization might become obsolete
and can be removed if proved so
2023-05-12 16:22:48 +00:00
Ilya Kirillov 4c69f2fbcb [Analysis API] fix "Unexpected class FirTypeProjectionWithVarianceImpl" exception
from KtFirExpressionTypeProvider.getKtExpressionType

^KTIJ-23432 fixed
2023-05-11 20:44:31 +02:00
Dmitrii Gridin 9a267176f5 [FIR] move deprecation calculation to COMPILER_REQUIRED_ANNOTATIONS phase
Also, this change adds SinceKotlin and Java.Deprecated to this phase
It fixes some problems with API_NOT_AVAILABLE, so now it is closer to K1

^KT-57648 Fixed
^KT-55723 Fixed
2023-05-11 10:31:52 +00:00
Anna Kozlova e6b8a09375 [AA] assert that shortener is not called on compiled code
KTIJ-25188


Co-authored-by: Roman Golyshev <anstreth@gmail.com>

Merge-request: KT-MR-10064
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-05-10 11:12:05 +00:00
Roman Golyshev 7a9021aa6b [AA FIR] KT-58503 Do not use resolvedStatus for visibility yet
It's done to avoid lazy resolve contract violation errors. See KT-58572
2023-05-09 13:20:17 +00:00
Roman Golyshev 105611679e [AA FIR] KT-58503 Use resolvedStatus to access visibility and modality of a class
Compiler plugins (AllOpen, for example) can modify the status of a
declaration, including visibility and modality. If we observe them
without enforcing STATUS resolve, we risk to see incorrect information,
which in turn can lead to false negatives/positives in
inspections/intentions.

Add test for light classes. See KT-58503 description for the explanation
how the initial problem was influencing Spring inspections from intellij
repository.

^KT-58503 Fixed
2023-05-09 13:20:16 +00:00
Anna Kozlova 92b6a77431 [LL] [cls] remove search for sources for decompiled FIR
stub based deserializer provides sources during initialization,
no need to search afterward
2023-05-09 07:36:10 +00:00
Dmitrii Gridin c2b09d3b1e [LL FIR] rewrite LLFirSuperTypeTargetResolver
The previous implementation had issues with
locks, publication and performance

Also, this change fixed a problem with mixed cycle inheritance

^KT-56550
^KTIJ-25430 Fixed
^KTIJ-23520 Fixed
^KT-57623 Fixed
^KTIJ-25372 Fixed
^KT-58357 Fixed
2023-05-05 12:35:46 +00:00
Kirill Rakhman bdf0b41026 [FIR] Consolidate SYNTAX and SYNTAX_WITH_MESSAGE diagnostics 2023-05-05 09:34:23 +00:00
Jinseong Jeon 384ed9cc9e AA: regression test for default value that calls previous params 2023-05-04 18:26:32 +02:00
Ilya Kirillov 66de893963 [LL FIR] refactoring: rename LowLevelFirApiFacadeForResolveOnAir.onAirGetTowerContextProvider -> getOnAirGetTowerContextProvider
so it matches its counterpart getOnAirTowerDataContextProviderForTheWholeFile
2023-05-04 15:26:50 +00:00
Ilya Kirillov eeac3f53b4 [Analysis API] add tests for getImportingScopeContext
^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov 20f921c0bf [Analysis API] fix getScopeContextForFile and clarify its semantic
It was used to get importing scope, so it was renamed to getImportingScopeContext.

It was broken after changing the behaviour of `LowLevelFirApiFacadeForResolveOnAir.onAirGetTowerContextProvider` for the whole file

^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov 349e55cb00 [Analysis API FIR] refactor, extract createScopesWithKind to a separate function
it will be reused in the following commits

^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov e9f75b1350 [LL FIR] add test which checks reference shortening for the whole file
^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov 3b85715f0f [LL FIR] fix KtFirReferenceShortener collection for the whole file
previously it worked only for separate declarations

^KT-57966 fixed
2023-05-04 15:26:49 +00:00
Dmitrii Gridin fdcfb1d190 [AA FIR] add missing new line to addImportToFile
^KTIJ-25416
2023-05-02 14:37:28 +00:00