Commit Graph

4832 Commits

Author SHA1 Message Date
Dmitrii Gridin 8c63e75f06 [LL FIR] update destructuringEntryScript testData
To reproduce getOrBuildFir for KtDestructuringDeclarationEntry

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 312feb3dca [FIR] make script destructuring declaration entry initializer lazy expression
This change is required to properly support such declarations in lazy
resolution mode as we usually replaced initializers with lazy
expressions during the body calculation phase

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin c0f4f7fefd [LL FIR] AbstractFirLazyBodiesCalculatorTest: add ability to suppress test
We have inconsistency in lazy body calculator, but only tests are
affected, because in the production we recreated bodies anyway

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 256d83b005 [LL FIR] support lazy resolve of <destruct> script declaration
But support for entries still is not implemented yet

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 792af849df [LL FIR] add getOrBuildFir test on destructuring declaration annotation
It doesn't resolve the property as it is treated as a local one

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 9ca0bdcb80 [FIR] make script destructuring declaration initializer lazy expression
This change is required to properly support such declarations in lazy
resolution mode as we usually replaced initializers with lazy
expressions during the body calculation phase

^KT-62840
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 898c8c002e [LL FIR] add lazy body calculation tests for scripts
After KT-65344 we can effectively calculate lazy bodies in scripts,
so we can safely add the test

^KT-62840
2024-02-14 16:16:01 +00:00
Vladimir Dolzhenko 95ea711659 Fix PsiLiteral#getReferences
#KTIJ-28769


Merge-request: KT-MR-14391
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-02-14 13:39:50 +00:00
aleksandrina-streltsova 89681e0a47 [Analysis API] override equals in KtFirReceiverParameterSymbol
KTIJ-28786
2024-02-14 13:25:47 +00:00
Kirill Rakhman 2f49272c42 [FIR] Create fake hidden versions of List.getFirst/getLast in JDK < 21
... so that overrides are marked as deprecated regardless of the JDK.

#KT-65440 Fixed
2024-02-14 13:13:01 +00:00
Pavel Kunyavskiy 6e8a7d4662 [ObjCInterop] Implement @ObjCSignatureOverride
This annotation leads to conflicting overloads error supression,
in case where several function with the same argument types,
but different argument names are inherited from ObjC class.

We need to implement it in both K1 and K2 to make the IDE experience
better.
But the annotation itself wouldn't be available in K1.

    ^KT-61323
2024-02-14 11:44:01 +00:00
Nikolay Lunyak fa5ae18980 [FIR] Fix a typo in a test data file name
^KT-65337
2024-02-14 09:57:13 +00:00
Nikolay Lunyak 7f42596935 [FIR] Reproduce KT-65337
^KT-65337
2024-02-14 09:57:12 +00:00
Mikhail Glukhikh 6ed7c041b4 K1/K2: add various tests for context receiver tower resolve priority
Related to KT-64531, KT-64488
#KT-64531 As Designed
2024-02-14 09:55:51 +00:00
Kirill Rakhman e88865e4c7 [FIR] Fix methods with erased parameters missing from raw collection scope
#KT-65448 Fixed
2024-02-14 09:55:24 +00:00
Alexander Udalov b72effab98 IR: remove isFromJava check from isOverridableMemberOrAccessor
This is needed because in case a static member is inherited via a Kotlin
class (class C in the newly added test), its origin becomes
FAKE_OVERRIDE which is technically not Java anymore. After this change,
we'll build fake overrides for static members from superclasses
regardless of whether they come from Java or Kotlin.

Also, move the previous logic of
isOverridableFunction/isOverridableProperty to the only call site at
IdSignatureFactory.

 #KT-65589 Fixed
2024-02-13 21:03:33 +00:00
Marco Pennekamp b24c75d04c [LL] Fix computeIfAbsent contract violation during dangling file session creation
- To avoid recursive updates, we can create sessions which cannot be
  created in isolation outside `computeIfAbsent`. Note that this is the
  current behavior of the default implementation of
  `ConcurrentMap.computeIfAbsent`, which will be replaced soon with
  the stricter behavior of `CleanableSoftValueCache` (see KT-61222).

^KT-65683 fixed
2024-02-13 17:14:20 +00:00
Dmitrii Gridin 2e2e592cc3 [Analysis API] CliTestModuleCompiler: support LANGUAGE_VERSION directive
^KT-64884
2024-02-13 16:07:17 +00:00
Dmitrii Gridin a567793d10 [LL FIR] add workaround for deserialization of data classes
To correctly process old metadata without properly sorted properties

^KT-64884 Fixed
2024-02-13 16:07:17 +00:00
Dmitrii Gridin faebef171d [Analysis API] add regression tests for data class copy arguments usage
This issue is not reproducible against the K2 compiler

^KT-64884
2024-02-13 16:07:17 +00:00
Vladimir Dolzhenko ad119a707c Fix equals/hashCode for LC fake files
#KTIJ-28770 Fixed


Merge-request: KT-MR-14341
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-02-13 15:47:09 +00:00
Dmitrii Gridin ab328e76d4 [LL FIR] FirDesignation: update KDoc for collectDesignationWithOptionalFile
^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin ca484fae2c [LL FIR] KtFirReferenceShortener: add order for FirScriptDeclarationsScope
It is similar mostly to FirClassUseSiteMemberScope or NestedClassifier

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 18978ca3f1 [LL FIR] FirDesignation: add toString
^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin cc46b6e3e9 [LL FIR] rename collectDesignationWithFile to collectDesignation
It should have a more simple name as it is the main function now

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 0b4dac9d8d [LL FIR] rename collectDesignation to collectDesignationWithOptionalFile
To make the choice more visible

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 3c26d0e85d [LL FIR] refactor collectDesignation and friends
to simplify code and add KDoc

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 8f987644ab [LL FIR] designation refactoring
Collect `FirDesignation` by default with `FirFile` instead of just
a separate path and additional repeated logic around

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 47e8d987b9 [LL FIR] ContextCollector: optimize collector for file elements
We shouldn't trigger declaration processing if we want to check just
annotations/package/imports.
But currently, we still will iterate over the entire file
if there is an element somewhere inside package/import
(see `fileImportInside.kt` test case)

^KT-65344
^KT-65560 Fixed
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 0c3a1dfd67 [LL FIR] ContextCollector: add tests for file package and imports
It reproduces redundant resolution

^KT-65344
^KT-65560
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 58ad26ee5b [LL FIR] make script initializers independent
Now we can resolve all script declarations independently

^KT-65344 Fixed
2024-02-13 14:58:31 +00:00
Dmitrii Gridin d59b8b3244 [LL FIR] LLFirStatusTargetResolver: add missing branch for FirFile
It is better to explicitly say that we shouldn't do anything in the
case of the file. It worked before because of `needResolveMembers == false`
and `needResolveNestedClassifiers == false` inside
`LLFirStatusTargetResolver.Transformer`

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 697f1477fd [LL FIR] drop forEachDependentDeclaration
Now this function is redundant

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 5de5f70ec9 [LL FIR] LLFirPhaseUpdater: update backing field initializer directly
Instead of the backing field itself as we already update its phase
during `updatePhaseForNonLocals`

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 6415f423a8 [LL FIR] PhaseUpdatingTransformer: drop redundant checks
We shouldn't check the current phase as this condition effectively
always is **false** as we use this updater only once for the phase

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 348c9664c1 [LL FIR] drop isScriptDependentDeclaration
Now this property is redundant

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 4f0bc86ad4 [LL FIR] make result$$ property independent
Now we can resolve this generated property in the same way
as other regular properties.
This is the pre-step for independent script initializers

^KT-65344
^KT-65523
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 6135a98e4e [LL FIR] do not rebuild entire script for lazy calculation of result$$ property
After the previous commit, it is possible to rebuild initializer for
`result$$` property without a full script creation.
Also, this commit fixes anchor symbol for annotations
inside script statements

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 338c533a58 [FIR] FirScriptConfigurationExtensionImpl: change source element for result$$ property
We should use the source from replaced `FirAnonymousInitializer` as it
is more equivalent. Another point – the previous implementation
duplicated the source between generated FirProperty and initializer

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin f972c8d239 [LL FIR] add more tests for script initializer
^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 0e16788b0a [FIR] value parameters from data class copy should be marked as resolved
^KT-65763 Fixed
2024-02-13 11:54:04 +00:00
Dmitrii Gridin ab7ae180f9 [LL FIR] add test data for data class from library
^KT-65763
2024-02-13 11:54:04 +00:00
Dmitrii Gridin addbb713a5 [LL FIR] FileStructure: collect diagnostics from bottom to top
In this way, we can be sure that all nested declarations will be fully
resolved before the outer one. As an example, we had a workaround for
file diagnostics as its `FileStructure` element resolves the file only
to `IMPORTS` phase yet.
Also, this commit probably should improve the performance of highlighting
as we will trigger the resolution from bottom to top while other
highlighting passes will iterate from top to bottom.

^KT-65562
2024-02-12 23:14:12 +00:00
Dmitrii Gridin 31852c6c05 [LL FIR] FileStructure: support dangling modifier list in non-end position
The root cause of the exception is that we missed such an element, and
it led to unresolved declaration during iteration over file declarations

^KT-65562 Fixed
2024-02-12 23:14:12 +00:00
Anna Kozlova 932ad3e2c1 [AA] an expression in delegated super entry is used as expression
^KT-65665 fixed
2024-02-12 20:38:23 +00:00
Vladimir Dolzhenko 038fe15dd4 PsiLiteral have to provide reference(s)
#KTIJ-28769 Fixed


Merge-request: KT-MR-14314
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-02-12 17:16:32 +00:00
Pavel Kunyavskiy 9532172a22 [Fir2IR] Don't use FIR f/o builder when IR f/o builder is enabled
Before this commit, fir f/o builder was inconsistently
disabled in some places, while it should work only for lazy declarations

Attempt to use it for non-lazy declarations, without maintaining
invariant, that it would also be used for super classes
led to unpredictable results.

This commit introduces opt-in, and marks all related API to three types
* Propagate error to user
* Fine to use, as it's checked if ir f/o builder is enabled
* Fine to use, as it is definitely a lazy class.

Several cases of missing checks was fixed.

^KT-65707
2024-02-12 15:02:50 +00:00
Kirill Rakhman 58264e177f [FIR] Improve UPPER_BOUND_VIOLATED message
Suggest removing explicit type arguments when the upper bound is a
captured type since the only way to satisfy the upper bounds is
by letting the type variable be inferred to its bound.

#KT-65681 Fixed
2024-02-12 10:42:51 +00:00
Kirill Rakhman 91e4837c95 [Tests] Add test for #KT-65712 2024-02-12 10:42:51 +00:00
Pavel Kirpichenkov 3dede06d51 [Tests] Add diagnostic tests for sealed class inheritors
- Fix unrelated resolution errors in an existing test
- Add separate test for sealed classes and interfaces in HMPP projects,
located in different source sets

KT-64919
2024-02-12 10:17:20 +00:00