Commit Graph

219 Commits

Author SHA1 Message Date
Yan Zhulanow 88a85b8936 [Analysis API] Add reference tests for containing declaration provider 2024-03-14 10:20:29 +00:00
Anna Kozlova 943d829fa7 [AA] treat named arguments as write access
^KTIJ-16835 fixed
2024-03-08 22:12:25 +00:00
Dmitrii Gridin 8cc2208c00 [LL FIR] support lazy resolution tests for scripts with custom definition
^KT-66276
^KT-66232
2024-03-07 12:50:59 +00:00
Dmitrii Gridin 150af66b55 [LL FIR] implement diagnostic tests on custom script definitions
it is impossible to declare test data with another output yet
as `myScriptFile.test.ll.kts` won't be treated as custom definition as
it requires `test.kts` extension.

^KT-66232 Fixed
^KT-66276
2024-03-07 12:50:59 +00:00
Marco Pennekamp beb40484dd [LL] Add LLFirSession invalidation tests
- This commit moves all session invalidation tests from the IDE which
  are non-cyclic to the Analysis API. Cyclic session invalidation tests
  cannot be moved because the Kotlin test infrastructure doesn't support
  cyclic module dependencies.
- In fact, these new tests cover more cases, because the IDE tests only
  covered global module state and module out-of-block modification
  events. Crucially, global source modification events are now
  supported, which require libraries to be left alone.
- Module out-of-block modification for libraries is technically
  undefined, but the test still checks this behavior. The current
  session invalidation implementation behaves the same for any kind of
  module-level modification event, so it is possible to publish a module
  OOBM event for libraries. If this changes in the future, we can
  disable those tests. But for now, it's good that these tests run,
  because they will alert us to (accidental) changes to this behavior.

^KT-56288 fixed
^KT-65265 fixed
2024-02-28 21:08:18 +00:00
Kirill Rakhman 7ca6624af4 [Test gen] Reduce Kotlin reflection usage 2024-02-28 15:20:30 +00:00
Marco Pennekamp 5819f4eaa2 [LL FIR] Test resolve extension disposal after modification events
- These tests simply ensure that a resolve extension is disposed after
  any kind of modification event is raised. It's not meant to test
  complex scenarios, but rather to detect when resolve extension
  disposal isn't invoked *at all*.
- I tried implementing a similar test for resolve extension disposal
  after soft reference garbage collection, but the only way to force the
  GC to collect soft references is to allocate memory until an
  out-of-memory error occurs. That is bad for the test infrastructure,
  because it might allocate A LOT of memory (depending on the max heap),
  which is problematic for running tests locally. Also, our Kotlin tests
  stop on an OOM error altogether (so additional configuration would be
  required) and the heap is dumped into a 20GB file (on my machine),
  which is again problematic for local test runs.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp b5eccd63b1 [AA] Fix compilation facility "multi binary module" test module structure
- The module structure for these tests was set up backwards: We should
  keep the test module kind of the main module flexible (as it is
  configured by test configurators), but keep the module kinds of the
  binary libraries fixed.

^KT-65960
^KT-64994
2024-02-26 21:57:23 +00:00
Marco Pennekamp 78ef58bef4 [AA] Tests: Remove decompiled files from LibraryBinary and add LibraryBinaryDecompiled
- `LibraryBinary` should not contain any decompiled files, as we want
  FIR symbols in tests to be provided from indexed stubs or class files,
  but definitely not from decompiled PSI. This brings `LibraryBinary`
  much closer to the behavior of binary libraries in the IDE.
- Some tests may still require access to a decompiled file, for example
  when trying to test `getOrBuildFir` for some `KtElement` coming from a
  library. This commit introduces `LibraryBinaryDecompiled`, which
  does contain decompiled files.
- We don't really need `LibraryBinary` as a main test module kind
  anymore, since tests generally want to access some main `KtFile`.
  Hence, test configurators for `LibraryBinary` have been turned into
  configurators for `LibraryBinaryDecompiled`.
- An alternative would be decompiling files on demand, but this is not
  currently feasible because the Standalone API doesn't reconcile stubs
  with decompiled PSI, like the IDE does automatically. (For the same
  declaration, the stub and the PSI will have a different identity.) As
  long as there is no support for this, we'll have to rely on a separate
  test module kind.

^KT-65960
2024-02-26 21:57:23 +00:00
Pavel Kirpichenkov 1c1bdae973 [Tests] Add tests for additional stub info in .knm files
KTIJ-28668
2024-02-26 10:18:38 +00:00
Jaebaek Seo 171ea3571c K2: Use deserialized type annotation for lambda type resolution.
This commit adds code to check whether a deserialized cone type is a
special function type kind or not when resolving the type of a lambda
expression (anonymous function). If it is a special function kind, it
sets the type of lambda based on the special function kind.

^KT-64994 Fixed
2024-02-25 10:10:43 +00:00
Jaebaek Seo 512efb9649 K2: Support binary library dependencies between test modules
The test infrastructure for analysis supports binary module tests, but
the binary build does not use another binary module as a dependency when
it passes the class path. As a result, each binary module build does not
work when they have dependency on each other.

This commit fixes the issue by
1. Topological sort in the order of dependency graph for test modules.
2. Pass module paths as extra class paths when they have dependency on
   each other.

^KT-64994
2024-02-25 10:10:43 +00:00
Dmitriy Novozhilov 166c88b87c [Build] Add missing runtime dependency for AA Native tests generator 2024-02-21 10:12:07 +00:00
Dmitrii Gridin 072d191306 [compiler] replace Enum values() with entries
To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
2024-02-20 17:56:46 +00:00
Vladimir Sukharev bf0150108d [K/N][Tests] Move filecheck and cinterop tests to /native/
^KT-61259
2024-02-14 23:36:34 +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
Yan Zhulanow 3cd04a9e9e [Analysis API] Migrate existing code fragment tests to the new API 2024-01-30 11:41:26 +00:00
Vladimir Sukharev 39e2187d31 [K/N][Tests] Split filecheck part from test direct.kt
^KT-61259
2024-01-19 18:31:25 +01:00
Ilya Chernikov d6c9a492ad K2 Scripting: disable K2 lightTree-based script tests
they were enabled by mistake and do not work properly until
LT parsing is implemented
depends on #KT-60127
2024-01-19 15:54:54 +00:00
Yan Zhulanow 9021fdaf83 [Analysis API] Remove obsolete dependentCopy tests 2024-01-18 17:12:28 +00:00
Yan Zhulanow 74db837b7d [Analysis API] Remove obsolete on-air resolution tests 2024-01-18 17:12:28 +00:00
Dmitrii Gridin 6145255e2c [Analysis API test] extract AbstractPsiDeclarationProviderTest
^KT-64805
2024-01-10 22:07:03 +00:00
Dmitrii Gridin 0f3f0ff080 [Analysis API test] rename AbstractPsiDeclarationProviderMultiModuleBinaryTest to AbstractPsiDeclarationProviderBinaryTest
^KT-64805
2024-01-10 22:07:03 +00:00
Dmitrii Gridin 79a8b6de1f [Analysis API test] rename AbstractPsiDeclarationProviderSingleModuleTest to AbstractPsiDeclarationProviderSourceTest
^KT-64805
2024-01-10 22:07:03 +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
Yan Zhulanow 9c91158be6 [Analysis API] Add tests for dangling files 2024-01-05 16:04:14 +00:00
Dmitrii Gridin b6f0571f0b [LL FIR] introduce lazy resolution tests for fake overrides
^KT-64243
2023-12-19 16:21:57 +00:00
Jinseong Jeon 10c9b81c79 AA standalone: introduce multi-module binary dependency test 2023-12-19 07:03:29 +00:00
Jinseong Jeon 3fbc16af62 AA standalone: repackage test configurators
...before introducing a new test configurator for binary dependency
2023-12-19 07:03:28 +00:00
Jinseong Jeon 0832158017 AA standalone: rename previous test to include SingleModule
...before introducing multi-module / binary dependency tests
2023-12-19 07:03:28 +00:00
Vladimir Sukharev c09e8909d4 [K/N] Move cinterop tests from standalone to codegen/box
^KT-61259
2023-12-18 18:04:27 +00:00
Roman Golyshev 146d93a044 KT-64205 [AA] Rearrange testData for reference shortener
Get rid of `referenceShortener/referenceShortener` nested directory
2023-12-15 10:49:24 +00:00
Marco Pennekamp ae5a053025 [LL] Disable modifiable PSI tests due to application sharing issues
^KT-63650
2023-12-13 10:29:11 +00:00
Dmitrii Gridin 8dacd41818 [LL FIR] introduce lazy resolve tests for type annotations
From one side to check how annotation propagation works and from another
side to cover scenarios with lazy resolution from type position as it is
a valid case of usage in Analysis API (KtFirAnnotationListForType)

^KT-63042
2023-11-23 15:55:06 +00:00
Marco Pennekamp 6c67835128 [LL] Add PSI resilience tests for LLFirDeclarationModificationService
- The cause of KT-63130 is that `LLFirDeclarationModificationService`
  tries to analyze inconsistent PSI. These new tests replicate the
  inconsistent PSI by deleting different children and then call the
  declaration modification service with it, making sure that the service
  doesn't throw any exceptions. Both exceptions mentioned in the issue
  are reproduced by the added tests, specifically, the receiver and
  selector resilience tests for dot-qualified expressions.
- A few of the tests need to be marked with `IGNORE_FIR` until the error
  has been fixed in the subsequent commit.

^KT-63130
2023-11-16 19:50:51 +00:00
Roman Efremov 29980c6b85 [Tests] Run KMP tests in Analysis API LL FIR test suites
New tests are red in current commit!
All `.ll.kt` files are just copies of `.fir.kt` or `.kt`. This will be
fixed in the next commit to clearly show difference between LL and FIR.

The original purpose of this change was to test
`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic, for which FIR checker
will be run only in IDE (to be changed in next MR), so its reports
a lost from usual KMP tests.
But this looks like a useful change for all KMP tests, not only this
diagnostic.

^KT-62559
2023-11-10 19:36:09 +00:00
Ilya Kirillov 5f5daa0e06 [Decompiler] rename :analysis:decompiled:native -> :analysis:decompiled:decompiler-native
to avoid possible name clashes between different
Gradle subprojects with the same name.

see https://github.com/gradle/gradle/issues/16986
2023-11-10 06:41:03 +00:00
Ilya Kirillov bffbbe6293 [LL FIR] add LL FIR tests based on AbstractFirPsiNativeDiagnosticsTest
^KT-62910 fixed
2023-11-10 06:41:03 +00:00
Ilya Kirillov 68235b978b [Analysis] add test generator for Kotlin/Native tests inside Analysis API
This test generator is enabled only if Kotlin/Native support is enabled in the project

^KT-62910
2023-11-10 06:41:03 +00:00
Jaebaek Seo e80f044847 K2: Update reference shortener to handle import alias
The existing reference shortener does not use import alias when it
shortens a symbol. Instead, it adds a new import directive for the
symbol that is already imported. This commit updates reference shortener
to let it reuse the existing import alias rather than adding a new one:

 1. When shortening a symbol, check whether the symbol is already
    imported.
 2. If it is already imported by an import alias, keep the symbol
    reference expression and the import alias as a string together in
    `ShortenCommand`.

The actual PSI update (shortening) based on the ShortenCommand is done
by IntelliJ.

^KTIJ-27205
2023-11-09 14:34:38 +00:00
Jinseong Jeon 4110a9971a AA: fix KtTypeProvider#getReceiverTypeForDoubleColonExpression
K1 version has used a wrong expression to retrieve the slice.
K2 version mishandled property access as a receiver.

^KT-63195 fixed
2023-11-08 16:18:21 +00:00
Anna Kozlova 205a125c5f [AA] implement KtFirSimpleNameReference.getImportAlias
^ KT-62980 fixed

Merge-request: KT-MR-12786
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-11-02 21:23:43 +00:00
Ilya Kirillov 1aa5cf031f [Analysis API FIR] fix "ConeClassLikeTypeImpl is not resolved to symbol for on-error type"
We should not expect builtins to be always available as they are taken from indecies.

For K1 and FIR Standalone implementations, the builtins are always available.

^KT-62010 fixed
2023-10-31 12:24:16 +00:00
Roman Golyshev a6668919b0 KTIJ-26423 [AA] Remove FE10 tests for KtImportOptimizer
We don't plan to seriously support the FE10 implementation of
`KtImportsOptimizer` service, since it's not going to be used in IDE
(it has its own old version of import optimization logic)
2023-10-25 20:53:13 +00:00
Dmitrii Gridin 2f8026f335 [LL FIR] add missed diagnostic tests for scripts
^KT-62840
^KT-62841
^KT-62861
2023-10-24 19:32:54 +00:00
Anna Kozlova 5cac013d8c [AA] approximate inplace type parameters bounds
^ KTIJ-27211 fixed
2023-10-24 10:54:15 +00:00
Dmitrii Gridin 2eb761adae [LL FIR] generate resolution tests over codegen/box testData
Such testData can contain contract violations and other resolution
problems, so we should check them as well

^KT-62776
^KT-62832
^KT-62834
^KT-62836
2023-10-24 10:30:55 +00:00
Dmitrii Gridin 17ab005668 [Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations
This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
2023-10-20 09:27:21 +00:00
Marco Pennekamp 239cfa6d29 [AA] Add tests for combined declared member scopes
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 1408556511 [AA] Refactoring: Rename AbstractMemberScopeByFqNameTest to AbstractMemberScopeTest
^KT-61900
2023-10-10 13:38:00 +00:00