Commit Graph

2800 Commits

Author SHA1 Message Date
Nikita Bobko 771f82bcf6 [FE] Fix "Not reachable case" exception
Review: https://jetbrains.team/p/kt/reviews/9967

This commit fixes:

    Cause 2: java.lang.IllegalStateException: Not reachable case. We can always suggest making `open val` property `final`
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.reportMustBeInitialized(DeclarationsChecker.kt:845)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkPropertyInitializer(DeclarationsChecker.kt:778)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkProperty(DeclarationsChecker.kt:614)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.process(DeclarationsChecker.kt:106)
            at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:258)

Reproducible in K1 & K2
2023-05-23 14:12:29 +03:00
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
Nikita Bobko 151144bbed [Test] Cover properties deferred initialization with more tests
Review: https://jetbrains.team/p/kt/reviews/9967

I'm going to change the logic in this area in the next few commits
KT-57553. So let's cover the current behaviour with tests.

*.fir.kt tests are not properly formatted because of K1 and K2 different
behaviour. I will fix it in the next commits
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
Alexander Udalov 40c628d431 FIR: fix order of property accessor annotations
#KT-57219 Fixed
2023-05-22 20:12:29 +00: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 7a9c516f68 [FIR] Use Throwable as expected type for throw expressions
#KT-58533 Fixed
2023-05-22 14:05:28 +00:00
Nikolay Lunyak f446fc4154 [FIR] KT-58719: Ensure the compiler resolves to the class 2023-05-22 11:40:30 +00:00
Dmitrii Gridin 447e1711da [LL FIR] do not update phase if exception occurred
Exception (even PCE) can lead to inconsistent situations, for example,
where a function can be marked as resolved, but arguments – not.
Also, in this case, it is possible that the function will be
marked as resolved to TYPES, but not all its type really resolved

^KTIJ-25582 Fixed
2023-05-19 22:59:32 +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
Mikhail Glukhikh 941446ea39 FE: rework tests around changed progression resolve
Related to KT-54261, KT-36932, KT-49276
2023-05-19 14:57:26 +00:00
Dmitrii Gridin 500016df87 [LL FIR] do not drop resolvePhase for recreated class
Because now all phases below DECLARATIONS do not depend on the class
declarations

^KT-56551
2023-05-19 14:33:37 +00:00
Alexander Udalov 75197d1b86 JVM: remove diagnostics related to JVM target 1.6 2023-05-19 13:24:00 +00:00
Alexander Udalov e4e1bcefbd JVM: remove tests on JVM target 1.6 2023-05-19 13:23:59 +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 b88cde11b1 [LL FIR] mark super types phase as non-jumping
It is supposed that this phase can't be called from itself
because now it is impossible to jump under a lock

^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 0d7ddd65c2 [LL FIR] drop global phase lock from status phase
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 2885df14ee [LL FIR] rewrite status phase transformer
Now we will try to avoid redundant calculation:
* Class-like declarations can be calculated without super types
* Overridden search logic not is out of lock

Unfortunately, right now it is not safe to use
StatusResolveMode.FunctionWithSpecificName and
StatusResolveMode.PropertyWithSpecificName
because lazyResolveToPhaseWithCallableMembers can lead to an incorrect
state of scope. Example:
```
open class A {
  open fun a() {}
  open fun b() {}
}
class C : A()
```
Steps:
1. Resolve constructor of C to STATUS
2. Now we want to call lazyResolveToPhaseWithCallableMembers on
C, and this call will do nothing because this class and all
its declarations (only constructor) are already in STATUS phase,
so class A won't be resolved as expected

^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin e464af00db [LL FIR] do not calculate constructors with classes during types phase
^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
Dmitrii Gridin 595279887a [LL FIR] add correct isResolved check to expect-actual phase transformer 2023-05-19 12:19:36 +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 c646008438 [Analysis API] refactoring, extract forEachNonKotlinPsiElementFinder to a separate file 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
Kirill Rakhman 47b8fd7e0c [AA] Mute tests related to decompilation of aliased types from stubs
#KT-58786
2023-05-19 11:50:40 +00:00
Kirill Rakhman 8f447e5b78 Revert "[AA] Deserialize reference to typealias from stubs as fully expanded"
This reverts commit 3c22b1ce53.

#KT-58335
#KT-58786
2023-05-19 11:50:40 +00:00
Ilmir Usmanov f3a22e0ac4 Warn about suspend extension functional types as supertypes
They will become error in 2.0

 #KT-58529 Fixed
 #KT-49175 Fixed
2023-05-19 12:41:37 +02:00
Dmitrii Gridin 16214e01d1 [LL FIR] do not process member declarations during expect-actual phase
^KT-56551
2023-05-19 09:26:43 +00:00
Dmitrii Gridin 76b9cc6a04 [LL FIR] add lazy resolve test on expect-actual phase
^KT-56551
2023-05-19 09:26:43 +00:00
Dmitrii Gridin 14b28ba99b [LL FIR] drop redundant lazy resolve to imports phase
Also, createTowerDataContext now uses cache

^KT-56551
2023-05-19 09:22:22 +00:00
Dmitrii Gridin 81ff3916e6 [LL FIR] resolve file to import phase only under lock
^KT-56551
2023-05-19 09:22:21 +00:00
Pavel Kirpichenkov 88d68f77e5 [LL FIR] Temporarily stub common FIR session factory with JVM
A measure to not break tests until common session factory impl is ready

KT-58769
2023-05-18 09:48:40 +00:00
Pavel Kirpichenkov 2a79643dcf [LL FIR] introduce platform-aware LL FIR session factories
KT-58769
2023-05-18 09:48:40 +00:00