Commit Graph

107661 Commits

Author SHA1 Message Date
Yan Zhulanow e4b574de38 [Analysis API] Update test data after rebase 2024-01-06 07:18:47 +00:00
Mikhail Glukhikh 64948fe48f Minor cleanup: JvmMappedScope 2024-01-06 07:11:27 +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
Igor Yakovlev c80854eb7c [Wasm/WASI] Extract js-wasi mode to context property 2024-01-05 22:04:25 +00:00
Ivan Kochurkin 1f0fb5a1a8 [FIR] Check for ConeErrorType in doUnify to prevent endless recursion
^KT-64625 Fixed
2024-01-05 19:21:10 +00:00
Artem Kobzar 567433cc12 [K/Wasm, K/JS] Unmute explicit backing fields tests 2024-01-05 17:27:31 +00:00
Mikhail Glukhikh ae358fe194 K1/K2: add more tests regarding SequencedCollection.add/remove calls
Related to KT-64640
2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 0ef41d75b5 K1/K2: consider List.(add/remove)(First/Last) as mutable list methods
#KT-64640 Fixed
2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 8a560d2629 FE tests: don't render text of disabled diagnostics 2024-01-05 17:20:32 +00:00
Mikhail Glukhikh e1b7b0e768 K1/K2: reproduce KT-64640 2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 8c2f5c767f K1/K2: add BB test for (add/remove)(First/Last) calls on mutable list
Related to KT-64640
2024-01-05 17:20:32 +00:00
Filipp Zhinkin 940c3c81ad KT-64361 delegate Int/Long::sign to methods from Java stdlib
Merge-request: KT-MR-13708
Merged-by: Filipp Zhinkin <filipp.zhinkin@jetbrains.com>
2024-01-05 17:13:37 +00:00
Yan Zhulanow 1b7d1dd08a [Analysis API] Simplify 'getNotUnderContentRootModule()'
In the resulting implementation of dangling file modules,
'getNotUnderContentRootModule()' is never called with a not-null file.
2024-01-05 16:04:14 +00:00
Yan Zhulanow bed73fd650 [Analysis API] Collect designations only for autonomous declarations
Parameters, type parameters, and property accessors are not
self-sufficient declarations (their resolution depends on resolution
of their parent), so a proper designation path cannot be computed
for them.

Without a designation path, 'ContextCollector' performs analysis of the
whole file, which is inefficient.
2024-01-05 16:04:14 +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
Yan Zhulanow 452d22e14f [Analysis API] Add IGNORE_SELF dangling file resolution mode
In the 'IGNORE_SELF' mode, dangling files don't have their own
declarations in providers. As a result, all references there resolve to
declarations of the original file. It is conceptually similar to that we
had in on-air resolve, however, now it's possible to work with the whole
content of the in-memory 'FirFile'.

As it can be seen in 'ProjectStructureProvider.kt'
(KtFile.danglingFileResolutionMode), the 'IGNORE_SELF' mode is
automatically applied for non-physical files with an original file being
set. For other scenarios, now there is a new 'analyzeCopy()' function
that allows to pass the analysis mode explicitly.
2024-01-05 16:04:14 +00:00
Yan Zhulanow ae6b690d4f [Analysis API] Invert the 'isAutonomousDeclaration' flag 2024-01-05 16:04:14 +00:00
Yan Zhulanow 087398edd7 [Analysis API] Do not force session creation in 'LLSessionProvider' 2024-01-05 16:04:14 +00:00
Yan Zhulanow 6bbd252c07 [Analysis API] Implement separate caching for unstable dangling files
PSI events do not arrive for dangling files with no backing
'VirtualFile', so its partial invalidation becomes non-trivial.
In the change, a short-living cache is implemented for these 'unstable'
dangling files.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 9c91158be6 [Analysis API] Add tests for dangling files 2024-01-05 16:04:14 +00:00
Yan Zhulanow 2899822102 [Analysis API] Extract dangling file module computation
Use the same code for creating dangling file modules inside tests,
the stand-alone API, and in the IDE.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 441f3e0209 [Analysis API] Give a standalone module provider a better naming
Some components in Analysis API have the 'Impl' suffix both in test
and standalone environments. This commit fixes the logical ambiguity
for a project structure provider.
2024-01-05 16:04:14 +00:00
Yan Zhulanow a614d0325f [Analysis API] Move test-only project provider closer to tests 2024-01-05 16:04:14 +00:00
Yan Zhulanow f0a21654f8 [PSI] Allow to create contextual 'KtPsiFactory' with eventSystemEnabled
The change allows creating trackable in-memory files, which are useful
for intention preview.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 7944602066 [Analysis API] Rework in-block modifications for dandling file modules
Before the change, all code fragment sessions were invalidated on any
PSI change. It was a simple solution, though not very effective.
Fragments were invalidated not only on a physical module change, but
also on change in another, unrelated code fragment.

As code fragment sessions were reworked to support also ordinary '.kt'
files, the old logic started to have even less sense, because ordinary
dangling files do not have a context element (they only have a context
module).

Currently, code fragment sessions are invalidated on any change in a
physical (non-dangling) module, and are also invalidated on any change
in their contextual dangling module, if any. With some work, this can be
improved further, so code fragments will be invalidated only on changes
in modules they depend on.

Relevant tests can be found in the IntelliJ project
(DanglingFileModuleInvalidationTest).
2024-01-05 16:04:14 +00:00
Yan Zhulanow 432884fe84 [Analysis API] Use resolution components from the same session
In 'getFirForNonBodyElement()', a wrong 'FirProvider' was used for
elements from modules other than a use-site one, and it could lead to
"Modules are inconsistent" exceptions from 'LLFirFileBuilder'.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 297920fde9 [Analysis API] Support dangling file copies in 'KtFirVisibilityChecker'
Dangling files are copies of files in the context module, or just
depend on it. In any way, dangling file modules see all internals of
the context module.
2024-01-05 16:04:14 +00:00
Yan Zhulanow b7c774b9e5 [Analysis API] Generify 'KtCodeFragmentModule' to support ordinary files
This commit introduces dangling file modules, which may be either
code fragments or ordinary Kotlin files. As before, code fragments are
analyzed against some context element, however ordinary files only
have a context module.

Code fragments can also have a dangling file module as a contextual one,
including other code fragment. This is done to support potential usages
in completion, intentions and refactorings.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 916e46debe [Analysis API] Provide sessions in 'LLFirModuleData' for dependencies
Normally, 'bindSession()' is called on a 'FirModuleData' right after its
instantiation to make it fully initialized. For source sessions,
this is done directly during the session creation. However, module data
created for dependencies (see 'LLFirModuleData.dependencies' & friends)
stay uninitialized, breaking 'collectAllDependentSourceSessionsTo()'.
2024-01-05 16:04:14 +00:00
Yan Zhulanow c7aedd932c [Analysis API] Support compiler plugins in code fragments
Compiler plugins are currently only supported in source modules.
This commit makes them also available in code fragments with source
context.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 5179462632 [Analysis API] Support non-JVM platforms in code fragments
The 'evalJs' test is not available, as there is no proper support for
klib loading in non-standalone Analysis API yet.

^KT-64197 Fixed
2024-01-05 16:04:14 +00:00
Yan Zhulanow 75abae23d8 [Analysis API] Fix WITH_STDLIB for common modules in Analysis API tests
The previous implementation in 'TestModuleStructureFactory' had very
custom and redundant logic for binary dependency collection.
In particular, JDK and kotlin-stdlib were specifically computed,
although both already were in the module classpath, which was handled in
'createLibrariesByCompilerConfigurators()'. In addition, there was no
support for common modules.

The new behavior is much closer to what happens in production.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 1a5b9ad79c [Analysis API] Support multi-module projects in compiler facility tests 2024-01-05 16:04:14 +00:00
strangepleasures 894df8f641 KT-64719 K2 KAPT stub generation should fail on syntax errors 2024-01-05 15:58:41 +00:00
Marco Pennekamp bace053ea9 [AA decompiler] Store sealed modifiers in interface stubs
- If the `sealed` modifier is not kept in the interface's stub, a
  sealed interface will have an `abstract` modality instead, which
  causes issues with `when` exhaustiveness analysis in K2.
- This issue also affected K1, but it was less visible there because
  `when` exhaustiveness analysis in K1 uses deserialized descriptors.

^KT-62895
2024-01-05 15:55:29 +00:00
Marco Pennekamp 5797b4877c [FIR/AA decompiler] Add tests for sealed interfaces
^KT-62895
2024-01-05 15:55:29 +00:00
Dmitrii Gridin 7c8aff963f [SLC] do not create light classes for expect declarations
We shouldn't build expect declarations as they do not
exist. We can omit check on member declarations as we
won't request them as we skip expect classes

^KT-57536 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin c14c12479c [SLC] fix multifile-classes in multiplatform case
Multifile-class can contain not only files from the same
module, but also files from the common part.
This commit also fixes KotlinByModulesResolutionScopeProvider as
it should provide all transitive dependencies

^KT-64714 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin fc519b2339 [SLC] add test on multiplatform facade
^KT-64714
2024-01-05 15:07:55 +00:00
Mikhail Glukhikh 3d560cd92c K2: use correct scope for overrides calculation in ObjCName checker
To call retrieveDirectOverriddenOf,
one must use directly the owner scope of a callable symbol we consider,
and not a scope of some derived class.

#KT-64276 Fixed
2024-01-05 14:39:05 +00:00
Artem Kobzar e4c244d5db [K/Wasm] Generate source-map for WAT-files 2024-01-05 14:16:32 +00:00
Nikolay Lunyak aea2e8052a [FIR] Ensure KT-64089 works
Make sure SENSELESS_COMPARISON
is absent in this case.

^KT-64089 Obsolete


Merge-request: KT-MR-13754
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 14:15:06 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Alexander Shabalin 3f2584bb02 [K/N] Move calls checker into separate module ^KT-62091 2024-01-05 13:35:35 +00:00
Nikolay Lunyak 8cd87059c8 [FIR] Fix the failing test after merging 533ed5c6
It started failing because of other
changes having been merged right before it

^KT-64644 Fixed

Merge-request: KT-MR-13755
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 13:34:43 +00:00
Alexander Shabalin d7929f93f2 [K/N] Fix samples compilation 2024-01-05 13:31:53 +00:00
Yahor Berdnikau 41003732b1 [Gradle] Add JVM toolchain configure method to Kotlin target
These methods are only added to provide more user-friendly error
when user tries to configure JVM toolchain in Kotlin target DSL.

^KT-64629 Verification Pending
2024-01-05 12:34:27 +00:00