Commit Graph

444 Commits

Author SHA1 Message Date
Anna Kozlova e650ba9855 [AA] return expect declaration for "implicit" actual
If actual declaration is broken (missing explicit `actual` keyword),
expect declaration still makes sense.
This way, we allow refactorings on broken code

^KT-65191 fixed
2024-02-27 18:49:02 +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
Jaebaek Seo 2f64a878e4 K2: Support dependency symbol providers for binary libraries
When a symbol X from a binary library A uses another symbol Y from
another binary library B, `LLFirDependenciesSymbolProvider` cannot
resolve Y for X. This is because the existing
LLFirAbstractSessionFactory passes symbol providers for only builtin
libraries to `LLFirDependenciesSymbolProvider` even when the session has
dependencies. As a result, when `LLFirDependenciesSymbolProvider`
searches a symbol, it can find only symbols from the builtin libraries,
but it cannot find a symbol from libraries other than builtin libraries.
This happens only for the binary libraries.

^KT-65240 Fixed
2024-02-26 18:02:08 +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
Nikita Bobko 4120d6a8aa [FIR] Search expect for actual only in dependsOn dependencies
Before this commit, the expect-actual resolver could find expects in
regular dependencies

Note: The appeared `VIRTUAL_MEMBER_HIDDEN` in
compiler/fir/analysis-tests/testData/resolveWithStdlib/multiModule/FakeOverrides.kt
isn't caused by my change. It's caused by fixing the testData dependency
syntax notation.

The testData improperly used regular dependency syntax notation, while
it should have been using dependsOn

Before:
    Regular dependency syntax notation

    // MODULE: androidMain(commonMain)

After:
    dependsOn dependency syntax notation

    // MODULE: androidMain()()(commonMain)
2024-02-22 16:06:35 +00:00
Kirill Rakhman f231338cd6 [FIR] Render list of symbols with linebreaks as separators
#KT-61823 Fixed
2024-02-21 12:25:22 +00:00
Dmitriy Novozhilov bd66b96f8a [FIR] Set EnhancedNullability attribute for former flexible types
In some cases we transform flexible type into non-flexible during
  enhancement, but don't add `@EnhancedNullability` attribute to them,
  which breaks consistency with K1 on IR level

This commit fixes it

^KT-65302
2024-02-21 12:04:11 +00:00
Anna Kozlova c628382b29 [AA] keep nullability for the recreated type
...when computing receiver type for double colon expression

^KT-65930 fixed
2024-02-20 08:50:04 +00:00
Anna Kozlova a0fef89423 [AA] take resolved type of FirThisReceiverExpression
...when computing receiver type for double colon expression

^KT-65914 fixed
2024-02-19 16:25:21 +00:00
Pavel Kunyavskiy 0fa42a9c11 [Tests] More conservative stableOrdered dump
Order of enum entries and fields matters, we can't sort them too.

^KT-65460
2024-02-16 10:19:38 +00:00
Nikolay Lunyak 7056ad5325 [FIR] Set status.isOverride for fake overrides
Even though SO may not be correct
overrides sometimes, it feels more
natural to treat fake overrides as...
well, "overrides". And without it
we'd need to make the code in
`FirOverrideChecker` less intuitive.
2024-02-15 16:10:13 +00:00
Nikolay Lunyak afd8895e51 [FIR] Introduce the PluginGenerated source kind
Make parcelize work consistently with
`FirOverrideChecker`.

Actually, there is a philosophical question about
what to do when a plugin generates a class
in a new package, and this class is red code
(for instance, doesn't implement an abstract
member from a supertype). There's no source
to report such an error, but we probably do
want to run checkers to avoid trying to
compile red code to binaries (because it may
crash in backend, or it may silently work).
2024-02-15 16:10:13 +00:00
Ilya Kirillov d925d3be76 [Analysis API] Fix Unexpected FirClassLikeSymbol null for class org.jetbrains.kotlin.fir.types.ConeClassLikeErrorLookupTag exception
on calling `asPsiType` on an unresolved type with type arguments

 ^KT-65550 fixed
2024-02-15 06:38:47 +00:00
Ilya Kirillov 50d526fe91 [Analysis API] Check all possible combinations of arguments in tests for KtType.asPsiType() 2024-02-15 06:38: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
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
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 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 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
Nikita Bobko 21fff5634e [FIR] Fir modality of FirPropertyAccessor
^KT-61798 Fixed
Review: https://jetbrains.team/p/kt/reviews/14230/timeline

Q: How resolved modality of an accessor affects expect/actual matching
   algorithm of properties?
A: It's not expect/actual matching of properties, but expect/actual
   matching of properties setter. Declarations (setters in our case) in
   actual are allowed to have wider visibility but only if the
   appropriate expect is `final`. Before this commit, all property
   accessors were always `final` by mistake. After this commit, they
   have the modality derived from their containingProperty.

Related problem: PositionStrategy for ACTUAL_WITHOUT_EXPECT can be
improved KT-65720

The fix in `resolveModality` is similar to how `resolveVisibility` works

Related tests:
- ConfigurationCacheForAndroidIT.testKotlinAndroidProject
- FirIdeNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testDelegateInterfaceLibrary
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated.testEnumEntryOverride
- FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated.testEnumValueMember
- FirStandaloneNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirStandaloneNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- DiagnosticCompilerTestFE10TestdataTestGenerated*testChangeSetterVisibilityInOverride
2024-02-09 19:49:35 +00:00
Alexander Udalov 3f034e8b67 Enable lightweight lambdas (aka invokedynamic) since 2.0
#KT-45375 Fixed
 #KT-58173 Open
2024-02-08 19:46:18 +00:00
Kirill Rakhman 3b841dcb98 [FIR] Don't remove subsumed members from intersection overrides's overriddens
This fixes a bunch of missing overridden symbols in IR.
This is also required for fixing KT-59921 in the following commit
where we need to keep all overridden symbols of intersection overrides
so that we can enhance them properly.

#KT-57300 Fixed
#KT-57299 Fixed
#KT-59921
#KT-57300
#KT-62788
#KT-64271
#KT-64382
2024-01-31 11:16:50 +00:00
Yan Zhulanow e001fa4e72 [Analysis API] Explicitly specify the context module in a directive 2024-01-30 11:41:26 +00:00
Yan Zhulanow 3cd04a9e9e [Analysis API] Migrate existing code fragment tests to the new API 2024-01-30 11:41:26 +00:00
Yan Zhulanow c548bed6f6 [Analysis API] Fix 'getContainingDeclaration()' for code fragments
^KT-65075 Fixed
2024-01-30 11:41:26 +00:00
Jinseong Jeon 42e8245007 AA: take into account type arguments if available
...when computing receiver type for double colon expression
2024-01-30 06:57:27 +00:00
Jinseong Jeon 2429d09edd AA: use explicit qualifier type if available
...when computing receiver type for double colon expression

^KT-65150 fixed
2024-01-30 06:57:27 +00:00
aleksandrina-streltsova d935db9e3a [Analysis API] render enhanced types
^KTIJ-28555 Fixed
2024-01-29 09:37:59 +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
Yan Zhulanow e393282c67 [Analysis API] Remove test infrastructure for obsolete on-air analysis 2024-01-18 17:12: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 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
Sergej Jaskiewicz ad9f7bf90e [IR] Don't use the GET_PROPERTY origin on IrGetField expressions.
This origin was set somewhat arbitrarily.
It actually only makes sense for `IrCall`s to property getters.
There were no places in lowerings that checked `IrGetField` expressions
for this origin value.

^KT-62500 Fixed
2024-01-16 09:26:27 +00:00
Dmitrii Gridin 052622b862 [Analysis API test] migrate more tests from doTestByModuleStructure to doTestByMainFile
^KT-64805
2024-01-10 22:07:03 +00:00
Denis.Zharkov b9019d3de1 K2: Adjust test data after PCLA implementation [red-to-green]
^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
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
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 4a2f11b2f5 Revert "Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider""
This reverts commit 644e29a2ea.
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 1a5b9ad79c [Analysis API] Support multi-module projects in compiler facility tests 2024-01-05 16:04:14 +00:00
Roman Golyshev df8c6c694a KTIJ-28167 [AA] Support SAM constructors in KtFirReferenceShortener
Utilize `FirSamResolver` to obtain the potential SAM constructor
from the classifier

Also, accept K2_SYNTHETIC_RESOLVED in the `resolveUnqualifiedAccess`,
since this is the kind of resolve success which corresponds to the
SAM constructor call resolution

^KTIJ-28167 Fixed
2024-01-04 20:07:41 +00:00
Roman Golyshev 31291fc8fa KTIJ-28385 [AA] Support SAM constructors in computeImportableName
This allows to properly report them as used in `KtFirImportOptimizer`

This change will also be important for properly fixing KTIJ-28167,
since `computeImportableName` is also used in reference shortener

^KTIJ-28385 Fixed
2024-01-04 20:07:41 +00:00