Commit Graph

1477 Commits

Author SHA1 Message Date
aleksandrina-streltsova d935db9e3a [Analysis API] render enhanced types
^KTIJ-28555 Fixed
2024-01-29 09:37:59 +00:00
Yan Zhulanow 36d5ffd4eb Revert "AA FIR: have KtFirReceiverParameterSymbol implement KtFirSymbol"
The commit is reverted due to failing tests:
    - FirGotoTypeDeclarationTestGenerated
    - FirGotoDeclarationTestGenerated

This reverts commit eb23984182.
2024-01-27 15:56:27 +09:00
Sonya Valchuk eb23984182 AA FIR: have KtFirReceiverParameterSymbol implement KtFirSymbol
Aside from making the code shorter, this allows for correct equals/hashCode.
2024-01-26 16:07:57 +00:00
Roman Golyshev f9348c69ba KT-62695 [AA] Refactor KDocReferenceResolver.findParentSymbol
Avoid traversing parents when there are none
2024-01-26 10:12:09 +00:00
Roman Golyshev d45662c2c3 KT-62695 [AA] Better resolve ambiguous receiver types in KDocReferenceResolver
When encountering multiple available same named types,
resolve all of them together with corresponding extensions.
This aligns well with the current resolve behavior of classes
with the same name (see `SameNameClassesFromStarImports.kt`)

Also, add extra test for resolving the ambiguous type without
the extension function. The behavior is the same - resolve to the
both classes.
2024-01-26 10:12:09 +00:00
Roman Golyshev 2befd2bffb KT-62695 [AA] Implement resolution of extension functions in KDoc
The solution is not complete, since resolution of KDocs is not
fully specified and is rather tricky.
Many more corner cases are to be expected.
This solution should at least give some groundwork for the future
improvements/fixes of the resolver.

^KT-62695 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev 42753c461f KT-62695 [AA] Add ResolveResult data class to KDocReferenceResolver
It's a part of implementation; it will be required to properly navigate
from resolved extension function to its receiver type, since receiver
type cannot be properly inferred from the function symbol itself
2024-01-26 10:12:09 +00:00
Roman Golyshev f9d4a35d80 KT-62695 [AA] Preliminary set of tests for extensions resolve 2024-01-26 10:12:09 +00:00
Roman Golyshev c0d54f9bbf KT-65152 [AA] Add extra test for package resolution
Make sure that, when ambiguous, both the package
and the callable/class/property are resolved from
KDoc reference.

Do a slight refactoring of `KDocReferenceResolver`

This behavior is also true for K1
2024-01-26 10:12:09 +00:00
Roman Golyshev f402daba98 KT-65152 [AA] Fix resolve of partial package qualifiers in KDocs
^KT-65152 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev 38e0b154c3 KT-65152 [AA] Add resolve testData for a package with multiple qualifiers resolve 2024-01-26 10:12:09 +00:00
Simon Ogorodnik 53e89a9722 K2. Minor. Rename FirConstExpression to FirLiteralExpression
FirConstExpression is usually confused with "constant" calculations,
while in fact, it just denotes a simple literal expression
and `1 + 1` isn't represented by a FirConstExpression.

^KT-64314 Fixed
2024-01-25 23:05:15 +00:00
Dmitriy Novozhilov 150ff1172e [FIR] Add session parameter to all "element --> reference" utilities
`FirDeserializedEnumAccessExpression` requires session to build proper
  reference, so it's important to have it in all utilities, which may
  pass this element as input

^KT-64975
2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov bd9cb2b7e0 [FIR] Refactor val FirElement.calleeReference utility
1. Convert it to `toReference()` function to make it consistent with other
   similar utilities
2. Provide the proper implementation

^KT-64975
2024-01-25 15:55:19 +00:00
Marco Pennekamp 641cae009e [AA] Remove obsolete KtFirAnalysisSession.mode
- On-air analysis was recently removed.
2024-01-23 16:00:43 +00:00
Nikolay Lunyak c55a7dd038 [FIR] Add SAFE_CALLABLE_REFERENCE_CALL
^KT-59835
2024-01-23 08:46:29 +00:00
Pavel Kirpichenkov ed8d3092cd [IDE, JS] Add regression test for KTIJ-27571
Reference resolve for kotlin.js.asDynamic
2024-01-22 18:28:24 +00:00
Jinseong Jeon e91e5db0ce AA FIR: build argument mapping for SAM conversion node
^KT-64910 fixed
2024-01-19 17:05:06 +00:00
Sergej Jaskiewicz bc5810ee67 [FIR2IR] Don't use descriptor manglers in FIR2IR
They don't do anything, only complicate the initial configuration.

KT-64990
2024-01-19 13:36:00 +00:00
Sergej Jaskiewicz 8b4cc050eb [FIR2IR] Remove linkViaSignatures from Fir2IrConfiguration
^KT-64809 Fixed
2024-01-19 13:36:00 +00:00
Yan Zhulanow 5d7f54500f [Analysis API] Remove 'FirTowerContextProvider'
The only implementation of 'FirTowerContextProvider' that is not
obsolete is inside the reference shortener.
2024-01-18 17:12:28 +00:00
Yan Zhulanow 9227359256 [Analysis API] Remove components of obsolete on-air analysis
On-air analysis only worked correctly inside declaration bodies, and
required special handling ('analyzeInDependedAnalysisSession()').
Dangling files, the on-air replacement, works seamlessly, and it is
available in all contexts.
2024-01-18 17:12:28 +00:00
Yan Zhulanow e47f505eb9 [Analysis API] Use 'ContextCollector' in implicit receiver type provider
'getTowerContextProvider()', which operates on top of obsolete on-air
analysis can be replaced with more robust 'ContextCollector'.
2024-01-18 17:12:28 +00:00
Kirill Rakhman e91e9d8ca8 [FIR] Don't lose error level enhancements in warning-level-enhanced arguments
The error-level enhancement is kept as warning-level and a new
LanguageFeature is introduced to turn the warning into an error.

#KT-63208 Fixed
#KT-63209

(cherry picked from commit 371b1eb3d5)
2024-01-18 08:27:10 +00:00
Mikhail Glukhikh e999e289ee K2: split EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS to property/objects
Related to KT-64982
2024-01-17 16:51:48 +00:00
Roman Golyshev 6884266328 KTIJ-27841 [AA] Add explicit containingFile to ElementsToShortenCollector
This simplifies the code in a few places, and also allows to avoid
retrieving the `containingKtFile` from the PSI elements
2024-01-17 10:15:28 +00:00
Roman Golyshev 646cdb56e5 KTIJ-27841 [AA] Do not import and shorten class constructor if it will alter other references in the file
N.B. This implementation does not 100% prevent conflicts or resolve
alterations when shortening functions.
To guarantee that,
we would need to carefully consider all the references in the file,
and to check whether they have changed their resolve in the presence
of a new import.
This is not trivial and will be approached separately under a different
task.

^KTIJ-27841 Fixed
2024-01-17 10:15:28 +00:00
Roman Golyshev 1e2f612cbc KTIJ-27841 [AA] Add simple test cases for the classes with same name conflicts 2024-01-17 10:15:28 +00:00
Roman Golyshev 0e244b3fbf KTIJ-27841 [AA] Introduce intermediate ElementsToShortenCollector.importBreaksExistingReferences
This clarifies the semantics a little bit
2024-01-17 10:15:27 +00:00
Roman Golyshev 702be98927 KTIJ-27841 [AA] Refactor ElementsToShortenCollector.processCallableQualifiedAccess
Rename it, and return `ElementToShorten` from it
2024-01-17 10:15:26 +00:00
Roman Golyshev d0d29bea57 KTIJ-27841 [AA] Refactor ElementsToShortenCollector.findClassifierQualifierToShorten
Extract the cycle body into a separate function for clarity
2024-01-17 10:15:26 +00:00
Roman Golyshev 67d32c3072 KT-64993 [AA] Unwrap safe call when deducing the expected type of function argument in KtFirExpressionTypeProvider
^KT-64993 Fixed
2024-01-16 22:36:59 +00:00
Roman Golyshev 318fd52567 KT-64993 [AA] Add test case for expected type in unsafe call arg 2024-01-16 22:36:59 +00:00
Roman Golyshev 72a0f2023d KT-64988 [AA] Unwrap safe call when resolving named arguments in FirReferenceResolveHelper
^KT-64988 Fixed
2024-01-16 22:36:59 +00:00
Kirill Rakhman 121536d2e5 Revert "[FIR] Don't lose error level enhancements in warning-level-enhanced arguments"
This reverts commit 371b1eb3d5.
2024-01-16 09:14:21 +01:00
Kirill Rakhman 371b1eb3d5 [FIR] Don't lose error level enhancements in warning-level-enhanced arguments
The error-level enhancement is kept as warning-level and a new
LanguageFeature is introduced to turn the warning into an error.

#KT-63208 Fixed
#KT-63209
2024-01-15 12:23:26 +00:00
Alejandro Serrano Mena b077293396 [FIR] Allow, but also warn, KMutableProperty with captured types
^KT-63589 Fixed
2024-01-12 10:07:14 +00:00
Sergej Jaskiewicz a0ba878b1d [FIR2IR] De-duplicate creation of Fir2IrConfiguration
This will help to prevent inconsistencies between creating
the configuration in the actual compiler pipeline and in compiler tests.
2024-01-11 12:16:54 +00:00
Denis.Zharkov 9ae5287df8 K2: Pass resolution mode to CallInfo
It's going to be used for PCLA implementation in later commits

^KT-59791 In Progress
2024-01-10 14:56:30 +00:00
Marco Pennekamp eabbe21b66 [AA] Add diagnostics tests for sealed classes/interfaces
- KT-62895 cannot be reproduced on the Analysis API side. Still, it is
  useful to add tests here for better coverage in the future.
- The reason is likely that Analysis API tests specifically use
  `SealedClassesInheritorsCaclulatorPreAnalysisHandler` to compute
  sealed class inheritors (which are usually the breaking point for
  problems in `when` exhaustiveness checking), so the tests do not use
  the production implementation. See KT-64505 for future work on this
  problem.

^KT-62895
2024-01-10 10:13:23 +00:00
Nikita Bobko e6860054ea [FIR] Cleanup: drop AMBIGUOUS_ACTUALS diagnostic from the frontend
Motivation: AMBIGUOUS_ACTUALS can't be reported on frontend (because it
requires expect to actual mapping, but the mapping is only available on
backend)

In scope of KT-59938
Review: https://jetbrains.team/p/kt/reviews/13760
2024-01-10 08:08:41 +00:00
Jinseong Jeon f1ce57f08f AA: handle PsiType conversion for recursive type parameter case (again)
^KT-64595 fixed
2024-01-10 04:04:20 +00:00
Roman Golyshev 93f1555322 KTIJ-28080 [AA] Move selection checking to ElementsToShortenCollector.findClassifierQualifierToShorten
This way, even if the whole qualifier is not selected, but some of its
parts are, the reference shortener will correctly find and shorten
those parts

^KTIJ-28080 Fixed
2024-01-09 20:07:38 +00:00
Roman Golyshev 3b448b284c KTIJ-28080 [AA] Refactor ElementsToShortenCollector.findClassifierElementsToShorten
Move unrolling the qualifiers into the function, add some simple KDoc
2024-01-09 20:07:38 +00:00
Ilya Kirillov d5b59c48c2 [Analysis API] fix "Cannot compute containing PSI for unknown source kind 'org.jetbrains.kotlin.KtFakeSourceElementKind$DefaultAccessor'" exception on getContainingSymbol call for default setter parameter
^KT-64825 fixed
2024-01-08 20:06:20 +00:00
Mikhail Glukhikh f5453690a6 K2: prefer base class sources for JVM mapped functions
This commit is a follow-up to 3cb9396b20
"K2: prefer derived class sources for callable copies (e.g. fake overrides)"

#KT-64044 Fixed
2024-01-06 07:11:27 +00:00
Yan Zhulanow 4a2f11b2f5 Revert "Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider""
This reverts commit 644e29a2ea.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 3761c1051d [Analysis API] Use ContextCollector in 'KtFirCompletionCandidateChecker' 2024-01-05 16:04:14 +00:00
Yan Zhulanow f14a67cb7d [Analysis API] Support IGNORE_SELF in containing declaration provider 2024-01-05 16:04:14 +00:00
Yan Zhulanow 957617081f [Analysis API] Refactor 'KtFirSymbolContainingDeclarationProvider'
Move out logic for dependent (not self-sufficient) declarations, as
well as for declarations, parents of which are only computed using PSI.
2024-01-05 16:04:14 +00:00