Commit Graph

3780 Commits

Author SHA1 Message Date
Anastasia.Nekrasova 9ad4cf4c55 [K2] Disappeared OPT_IN_USAGE_ERROR for a data class property during the destructuring declaration
^KT-62450
2023-10-17 21:27:13 +00:00
Dmitrii Gridin b03e3f0b0d [LL FIR] pass correct context during class annotation arguments mapping
The root cause of the problem is that we visit class annotations more
accurately than in the regular compiler transformer, so we have
a difference: the compiler assumes that annotation processing
of the class is called already inside this class, so it should enable
CLASS_HEADER_ANNOTATIONS mode to not capture extra context.
But we in LL FIR do this out of the class, so such context switching
is redundant and results in cutting out the outer class context

^KT-62587 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin bbd09c6272 [LL FIR] add tests for nested class as annotation argument
^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin 5298d79dec [LL FIR] drop extra withContainingClass from annotation transformers
This call is redundant for annotation transformers because
they are override withRegularClass and add this call there,
so, as result, we have a class duplication in
containingClassDeclarations

^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin 21f81a8057 [LL FIR] fix lazy annotation arguments calculation for unresolved type references
Such references don't have explicit annotations yet (KT-62628), so we
should explicitly check type attributes

^KT-62625 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin ec79d8cd27 [SLC] add multiplatform test cases on typealias actualization
^KT-62345
2023-10-17 17:19:40 +00:00
Dmitrii Gridin 8f0cf3f0cc [SLC] allow multi-module test cases
^KT-62345
2023-10-17 17:19:40 +00:00
Dmitrii Gridin 0771b60777 [Analysis API] support multiplatform test cases
^KT-62345
2023-10-17 17:19:40 +00:00
Ilya Kirillov 7db2fc522e [Analysis API Standalone] fix builtin resolution for common module
StubBasedBuiltInsSymbolProvider does not work for now for common modules (KT-61757)
 but compiler builtins provider `FirBuiltinSymbolProvider` works.

Also, stub-based symbol providers should not be used in standalone mode.

Testdata from standalone is updated because of the difference
in property accessors (KT-62449) between stub and compiler builtin symbol providers.

Additionally, this commit fixes the behavior of `KotlinStaticPsiDeclarationFromBinaryModuleProvider`.
As compiler builtin declarations have no PSI attached,
`KotlinStaticPsiDeclarationFromBinaryModuleProvider` is used to get PSI
from `DecompiledPsiDeclarationProvider.findPsi`.
`DecompiledPsiDeclarationProvider` is only used in UAST standalone mode.
2023-10-17 13:23:11 +00:00
Evgeniy.Zhelenskiy 5b4731a780 [FIR] Fix local typealias visibility resolution
#KT-60026
2023-10-17 12:48:04 +00:00
Dmitriy Novozhilov 8ccbbedbd5 [Test] Update debugger testdata because of KT-62521 2023-10-17 12:46:28 +00:00
Dmitriy Novozhilov 000c24fc69 [Raw FIR] Add test for callable ids of functions inside body of enum entry 2023-10-17 12:46:27 +00:00
Vladimir Sukharev 242c1cf5f0 [FIR] Fix disappeared REPEATED_ANNOTATION for dynamic types
https://youtrack.jetbrains.com/issue/KT-59916/K2-Disappeared-REPEATEDANNOTATION
FirAnnotationChecker does not detect repeated annotation on dynamic type, since FirTypeResolverImpl wrongly did not convert source annotations to attributes of ConeDynamicType.
This MR improves FirTypeResolverImpl to convert attributes of FirDynamicTypeRef to annotations and attach them to ConeDynamicType.

Merge-request: KT-MR-12551
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-17 10:18:36 +00:00
Dmitrii Gridin d9071aed78 [LL FIR] LLFirAnnotationArgumentsTargetResolver: add missing context for value parameters 2023-10-17 09:30:44 +00:00
Roman Golyshev cb65d2420f KTIJ-27139 [AA] Clean-up KtFirReferenceShortener
Unify the code which detects whether qualified expression/type is
actually selected
2023-10-16 20:05:01 +00:00
Roman Golyshev d2fcd71d23 KTIJ-27139 [AA] Shorten qualified expressions only when the callee/type reference is in selection
If you want to shorten call like `foo.bar()` into `bar()`, then you
need your range to intersect with `bar` callee reference. Having only
`foo` in the range is not enough

Same goes for the type references - to shorten `foo.Bar` into `Bar`, you
need at least some intersection of your range with `Bar` reference

^KTIJ-27139 Fixed
^KTIJ-27015 Fixed
2023-10-16 20:05:01 +00:00
Ivan Kochurkin 498f2e534a [FIR] Don't enhance Int and String Java final static fields
It's effectively a breaking change (^KT-62558)

K2 assigns flexible type to all static fields (from Java) and, for example,
`String? becomes String unlike K1. It affects IR signature generating.
That's why signature dump is disabled for some tests.

^KT-57811 Fixed
^KT-61786 Fixed
2023-10-16 17:16:56 +00:00
Ivan Kochurkin 2d61b9a477 [FIR] Elvis operator: flexible rhs type implies flexible type of whole elvis
It's required for further removing of enhancement of final static fields

Also, it's k2-potential feature

^KT-62467 Fixed
2023-10-16 17:16:56 +00:00
Dmitrii Gridin 976fb7d093 [LL FIR] support lazy resolution for synthetic properties and accessors
Such declarations are just wrappers, so we should delegate
resolution to the original declarations

^KT-61990 Fixed
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 2d1d5fb3a8 [LL FIR] add missed check to getDesignationsToResolveRecursively
^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin b8000d611a [FIR] FirSyntheticProperty: drop resolveState
Such properties should be stateless and just wrap over accessories.
Logic inside contract transformer is unreachable because we do not
allow lazy resolution for synthetic properties.

^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 6c1405cf99 [FIR] FirResolvePhaseRenderer: change format for FirSyntheticPropertyAccessor
^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 5de269147f [LL FIR] add tests for synthetic property
^KT-61990
2023-10-16 15:07:11 +00:00
Ilya Goncharov e9cc2931cc [JS] Use kotlin-stdlib-js.klib instead of *.jar 2023-10-16 13:34:37 +00:00
Alexander Udalov 2788dcb5ff K2: resolve remove(Int) clash in JavaOverrideChecker
In Kotlin subclasses of `MutableCollection<Int>`, the method
`remove(Int)` has its argument boxed, so that it wouldn't clash with the
method from `java.util.List`. So `JavaOverrideChecker` should understand
that a Java method `boolean remove(java.lang.Integer)` overrides it,
otherwise platform declaration clash was reported.

The code is adapted from `forceSingleValueParameterBoxing` in K1's
`methodSignatureMapping.kt`.

The test has been moved and adapted from diagnostic to codegen box
tests, to check correct backend execution + runtime.

 #KT-62316 Fixed
2023-10-16 11:26:58 +00:00
Roman Efremov 4c75fb108f [Test] Add test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic
...when annotations arguments are lazily resolved.

MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Anna Kozlova 3c2be4551b [AA] getExpectedType should not calculate expression type
if property doesn't specify explicit type,
property's return type would be calculated by provided initializer

^KT-62588 fixed


Merge-request: KT-MR-12564
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-16 09:31:52 +00:00
Vladimir Sukharev 16dfc6df71 [FIR] Missing NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE
^KT-59433 Fixed
2023-10-16 09:08:23 +00:00
Dmitrii Gridin 90102ad8b7 [LL FIR] avoid body resolve during getOrBuildFir for super types
This also covers a case with annotations on a super type entry

^KT-61789 Fixed
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 515e05cd94 [LL FIR] add test for getOrBuildFir for super type
^KT-61789
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 4d29d6e3b4 [LL FIR] FileStructure: accurate processing of generated declarations inside classes
We should process generated property as a part of the primary constructor.
This was already implemented in 8387ea8a, but some parts were missed.

ClassDiagnosticRetriever:
* dropped relation to properties generated from constructor parameters
as they should belong to the primary constructor only
* accurate logic to fully visit an implicit primary constructor to be
able to process nested declarations (e.g., inside a super type call)

SingleNonLocalDeclarationDiagnosticRetriever:
* add relation to generated properties as now they fully belong to
the constructor

FileElementFactory:
* dropped explicit resolution of generated properties from a constructor
* added explicit resolution of generated enum members for consistency.
Effectively, this is not required because we don't have compiler
checkers for such generated enum member declarations

ClassDeclarationStructureElement:
* do not collect mapping for generated properties from constructor
* explicitly declare that we should process only ClassDelegationField

^KT-62437 Fixed
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 1a01dd4dd4 [Analysis API] add diagnostic tests for unresolved reference inside primary constructor
^KT-62437
2023-10-13 17:13:14 +00:00
Yan Zhulanow 45a59f0a55 [LL API] Filter duplicating compiled callables inside FirSymbolProvider
Before the code fragment analysis was extracted to the separate module,
it was impossible to modify the symbol provider, so a conflict resolver
was patched instead. The solution was not complete, though, as it only
covered call resolution ambiguities. The compiler sometime calls a
symbol provider directly, like it's done in 'BuiltinSymbolsBase'.

Relevant tests are in the IntelliJ project (see singleBreakpoint/
conflictingStdlib.kt).

^KTIJ-27329 Fixed
2023-10-13 17:07:03 +00:00
Dmitrii Gridin b2c8d7e777 [FIR] do not treat external ide annotations as real one
Such annotations are supposed to affect only diagnostic warnings

^KT-62310 Fixed
2023-10-13 12:16:12 +00:00
Dmitrii Gridin 2cac922cd0 [FIR] add tests on external annotations
Tests are excluded in COMPILED_JAVA mode because in this
mode external annotations are not present at all

^KT-62310
2023-10-13 12:16:12 +00:00
Nikolay Lunyak a9ceae9667 [FIR] Add the privateInFileInDifferentModule test
We only see the redeclaration
diagnostics on the declarations inside
the second file, because of
`FirRecorder::visitRegularClass`.
`data.state.classifierContainerFileMap`
references the last file, so
when checking the visibility of
the first `private class C { ... }`
(when collecting declarations that
conflict with the second `private class C`)
the provider returns the second file
instead of the first one, so the class
behaves as it is visible, and
`collectTopLevelConflict` returns in
this case.

As for why `INVISIBLE_*`s are reported
inside the first file: this is because
`data.state.classifierMap` stores the
last classifier it sees instead of
the first one.

^KT-62537
2023-10-13 11:56:54 +00:00
Ilya Kirillov ba37ad9b85 [build] remove obsolete -opt-in=kotlin.ExperimentalStdlibApi from :analysis:proejct-structure module 2023-10-13 11:49:55 +00:00
Marco Pennekamp a62ac940c4 [AA] Add abstraction for composable Kotlin providers
This further improves the `KotlinCompositeProvider` abstraction:

- Pulling the abstraction's interfaces outside the `impl` package allows
  us to write consolidated documentation on composable Kotlin providers.
- The addition of `KotlinComposableProvider` allows more specific bounds
  for the type parameters of `KotlinCompositeProvider` and
  `KotlinCompositeProviderFactory`. It also clarifies to Analysis API
  implementors which providers can be composed at all, as providers like
  `KotlinDeclarationProvider` extend this interface.
- `KotlinComposableProviderMerger` provides a unified interface for
  provider mergers.

^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp c289da6cf3 [LL FIR] Use mergePackageProviders in LLFirCombinedKotlinSymbolProvider
^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp b9e3d848a6 [AA] Add KotlinPackageProviderMerger
- In parallel to Kotlin declaration provider merging, we need a proper
  merging strategy for package providers as well, because resolve
  extensions may define additional package providers.
- Additionally, other non-scope-based package providers may be added in
  the future, and the merger preserves these out of the box.

^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp c63dde4f7e [AA] Add abstraction for composite provider creation and merging
- Composite declaration providers and declaration provider mergers are
  extremely similar to the composite package providers and (newly to be
  implemented) package provider mergers. This commit extracts the common
  parts into a `KotlinCompositeProviderFactory`.

^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp 0e6cc92958 [LL FIR] Optimize getPackage in combined Kotlin symbol providers
- `getPackage` can also benefit from a combined index access.
- Care has to be taken with allowed/disallowed `kotlin` packages. Since
  we're not delegating to individual symbol providers after the index
  access, `allowKotlinPackage` has to be taken into account in the
  combined symbol provider explicitly.

^KT-61791 fixed
2023-10-12 16:10:32 +00:00
Jaebaek Seo a6c432587f K2: Add extension point for additional KDoc resolution
Similar to K1 KDocLinkResolutionService used by Fe10KDocReference (to
support additional KDoc resolution), this commit adds K2 counterpart
AdditionalKDocResolutionProvider and uses it for KDocReferenceResolver.

^KT-62187
2023-10-12 15:17:31 +00:00
Ilya Kirillov 34ea0678ae [Analysis API Standalone] refactoring, use predefined paths to libraries in StandaloneSessionBuilderTest wher it's possible 2023-10-12 15:15:05 +00:00
Ilya Kirillov 4d38cc4548 [Analysis API Standalone] fix exception on invalid KLib from symbol provider
^KT-62244 fixed
2023-10-12 15:15:05 +00:00
Svyatoslav Kuzmich a10042f909 [Wasm] Add K2 checkers.wasm module (KT-56849)
Add first K2 checker ExternalInheritanceChecker to test the infra
2023-10-12 13:26:58 +00:00
Roman Efremov a05b37c652 [K2] Support reporting of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS
...on regular classes and enum entries.

^KT-59979 Fixed
2023-10-12 13:01:40 +00:00
Nikolay Lunyak 598b5dbdf4 [FIR] Reproduce KT-62146 2023-10-12 08:56:12 +00:00
Alejandro Serrano Mena 166b99181b [Test] Ensure that properties cannot be used as operators
In some cases the combination of property + invoke was incorrectly allowed

^KT-62349
2023-10-12 08:32:17 +00:00
Nikolay Lunyak 54e9cafc73 [FIR] Reproduce KT-62473 2023-10-11 08:33:05 +00:00