Commit Graph

2743 Commits

Author SHA1 Message Date
Nikolay Lunyak 737c8c20f6 [FIR] KT-58674: Ensure loop conditions have no expected type in K2 2023-05-16 10:40:25 +00:00
Kirill Rakhman 3c22b1ce53 [AA] Deserialize reference to typealias from stubs as fully expanded
#KT-58335
2023-05-16 09:20:57 +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 a93e9c3c19 [LL API] Remove incorrect ways to get modules/sessions
^KT-57559 Fixed
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
Yan Zhulanow c90d094af6 [LL API] Pass a contextual module to ProjectStructureProvider
In certain cases, it's impossible to determine which module owns a
particular file without knowing the analysis context. For instance,
the file might be a part of a physical module, and be also included into
a virtual ad-hoc module (to be analyzed in separate, e.g. a VCS diff).

The new API allows to pass a contextual module. Basically it means
"give me a module for this element, implying that we are now analyzing a
contextual module".

^KT-57559 Fixed
2023-05-16 08:42:57 +00:00
Yan Zhulanow 5e04c0d4f7 [LL API] Move 'FileBasedKotlinDeclarationProvider' to be used in IDE 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
Nikolay Lunyak 200fb1e5ce [FIR] KT-54874: Ensure this code is red
^KT-54874 Fixed
2023-05-15 14:44:10 +00:00
Jinseong Jeon 41473a948d SLC: implement PsiAnnotation#find(Declared)AttributeValue
^KT-58448 Fixed
2023-05-15 14:16:14 +02:00
Nikolay Lunyak 99ff36c77a [FIR] KT-58523: Ensure the compiler resolves to the typealias 2023-05-15 10:03:18 +00: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
Nikolay Lunyak 834ba397ad [FIR] KT-58284: Prevent missing diagnostics on for loops
^KT-58284 Fixed
2023-05-12 14:47:24 +00:00
Nikita Bobko 9a65dcb664 MUST_BE_INITIALIZED: take into account containingDeclaration's modality
^KT-58587 Fixed
Review: https://jetbrains.team/p/kt/reviews/10136

This commit is important in scope of KT-57553. It makes the migration
more smooth.

Other related tests:
- testUninitializedOrReassignedVariables
- testAugmentedAssignmentInInitializer
2023-05-12 13:48:49 +00:00
Dmitrii Gridin 1d974b1ef7 [LL FIR] LLFirSuperTypeTargetResolver: propagate looped types more accurately
'forceSkipResolvedClasses' is wrong here, because nested class (`CC`)
won't be marked as cycle but the outer is.
Instead of this, we should check
canHaveLoopInSupertypesHierarchy recursively

```kotlin
open class C : <!CYCLIC_INHERITANCE_HIERARCHY!>D<!>() {
    open class CC
}
open class D : <!CYCLIC_INHERITANCE_HIERARCHY!>C.CC<!>()
```

Also, this commit adds an optimization to avoid hierarchy search
for non-source classes (forceSkipResolvedClasses was introduced for this before)
2023-05-12 11:36:43 +00:00
Pavel Mikhailovskii 7ac5233a32 KT-54804 [SLC] Generate synthetic functions for annotations on properties in light classes 2023-05-12 09:39:37 +00:00
Egor Kulikov 34db304ef7 [FIR] Init packageFqName when calculating lazy arguments of anotations
^KT-58584 fixed

Merge-request: KT-MR-10113
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-05-11 22:00:09 +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
Ilya Kirillov 89dbc4daec [Analysis API] tests: add possibility to avoid FqName for Kt psi classes in ExpressionMarkerProvider 2023-05-11 20:44:31 +02:00
Ilya Kirillov 176f77c0ef [Analysis API] tests: add possibility to specify LOOK_UP_FOR_ELEMENT_OF_TYPE for all tests 2023-05-11 20:44:31 +02:00
Dmitrii Gridin 25506d3be6 [LL FIR] add more lazy resolve tests on status phase
^KT-56551
2023-05-11 17:38:59 +02:00
Kirill Rakhman 993925f656 [FIR] Ignore private properties in accessor override check
JavaClassUseSiteMemberScope won't return a Java method getFoo if there
is an inherited Kotlin property foo in scope because calling this method
would effectively call the property accessor which is not possible in
Kotlin.
This commit excludes private properties from this consideration because
no accessor methods are generated for them, and so calling a Java method
getFoo is ok.

#KT-58577 Fixed
2023-05-11 15:22:42 +00:00
Denis.Zharkov 442844f165 K2: Fix false-positive overload ambiguity after smart cast
Mostly, the change is just mirroring the same logic from K1
OverloadingConflictResolver

^KT-58524 Fixed
2023-05-11 15:01:37 +00:00
Dmitrii Gridin 09dbae5eca [LL FIR] add more restrictions to getNonLocalContainingOrThisDeclaration
^KTIJ-25437
KT-MR-10036
2023-05-11 16:09:02 +02:00
Mikhail Glukhikh 134284e496 FE: add test for KT-58055 2023-05-11 12:19:40 +00:00
Pavel Mikhailovskii 25c0725da9 [SLC] Treat error class types as not-nullable 2023-05-11 11:48:45 +00: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
Dmitrii Gridin add47aa041 [FIR] provide correct origin and source to default backing field
Now it is aligned with default accessors
Covered by
analysis/analysis-api/testData/symbols/symbolByReference/accessorField.kt
test

^KT-57648
^KT-55723
2023-05-11 10:31:52 +00:00
Dmitrii Gridin aa5261395e [LL FIR] allow parallel resolve for non-jumping phases
^KT-56550 Fixed
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 7f778eafa5 [LL FIR] add missing declarations transformations for COMPILER_REQUIRED_ANNOTATIONS phase
The transformed does nothing previously

^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 231c59bd2c [LL FIR] drop redundant lazy annotations calculation from ANNOTATIONS_ARGUMENTS_MAPPING phase
They must be calculated on the previous ARGUMENTS_OF_ANNOTATIONS phase

^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin a429367890 [LL FIR] unify annotation transformers
^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 5ebba92a6e [LL FIR] FirLazyBodiesCalculator: do not calculate annotations during body calculation
All annotations must be calculated on the corresponding phases

^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 6b8b5c256d [LL FIR] FirLazyBodiesCalculator: cleanup naming
^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 64c2ba1a2a [LL FIR] calculate lazy annotations only for target declaration
To avoid visiting not locked declarations

^KT-56550
^KT-58495 Fixed
^KT-58500 Fixed
^KT-58493 Fixed
^KT-58496 Fixed
^KT-58497 Fixed
^KT-58499 Fixed
^KT-58491 Fixed
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 5c8045f3d0 [LL FIR] add test on nested declarations and annotations
To see the effect of subsequent changes

^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin 990f23a11b [LL FIR] FirLazyBodiesCalculator: covert non-public api to private functions
^KT-56550
2023-05-10 17:17:46 +00:00
Dmitrii Gridin a7692ba2c5 [LL FIR] do not calculate lazy body recursively by default
To avoid visiting not locked declarations

^KT-56550
2023-05-10 17:17:45 +00:00
Dmitrii Gridin d1f3ba0286 [LL FIR] cleanup LLFirBodyTargetResolver
Avoid redundant withRegularClass call

^KT-56550
2023-05-10 17:17:45 +00:00
Dmitrii Gridin b51a416682 [LL FIR] ignore constructors on implicit body phase
^KT-56551
2023-05-10 17:17:45 +00:00
Dmitriy Novozhilov 40b8b682f9 [FIR] Don't save DFA implications for unstable local vars
^KT-57502 Fixed
2023-05-10 14:19:25 +00:00
Egor Kulikov 6f20ac4f38 [FIR] Enable asserts for not building AST tree in lazy mode
Make interface delegate expressions lazy
2023-05-10 11:49:42 +00:00
Kirill Rakhman b2fa104081 [FIR] Keep all failed resolution candidates and fully resolve them
Previously, when a candidate was found with an applicability that is
better than the current best applicability, all previous candidates were
thrown away. Now we keep them, unless the new applicability is
successful. If no successful candidates are found, we fully resolve all
the unsuccessful ones and select the ones with the least bad
applicability. This improves diagnostics for unresolved calls.

#KT-57844 Fixed
2023-05-10 11:48:58 +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
Dmitrii Gridin b3aa2dd60f [LL FIR] calculate designation path by FirFile where it is possible
This will fix problems with declaration clash.
Otherwise, a designation path to the constructor of the second class
from the snippet
```
class A
class A
```
Will contain the first class instead of the second

Also, this is more performed than trying to find a segment of
a path by providers

^KT-58546 Fixed
2023-05-10 09:59:15 +00:00
Dmitrii Gridin ae88726fae [FIR] treat constructors of local classes as local declarations
The main problem: we are trying to lazily resolve local declaration

^KT-58546
^KT-58490
2023-05-10 09:59:15 +00:00
Dmitriy Novozhilov 1936658e40 [FIR] Consider stability of receiver for DFA variables
^KT-57425 Fixed
2023-05-10 07:50:31 +00:00
Dmitrii Gridin 2c294cba64 [FIR] SupertypeComputationSession: fix false positive invisible reference for local object
The problem is that FirAnonymousObject was ignored during getResolvedSuperTypeRefsForOutOfSessionDeclaration from SupertypeSupplier

^KT-58583 Fixed
2023-05-09 17:23:45 +00:00