Commit Graph

759 Commits

Author SHA1 Message Date
Anna Kozlova 943d829fa7 [AA] treat named arguments as write access
^KTIJ-16835 fixed
2024-03-08 22:12:25 +00:00
Jinseong Jeon d089db5a45 AA: honor wildcard suppression on type during type conversion
^KT-61734
2024-03-07 10:16:59 +00:00
Jinseong Jeon d4d2bae630 AA: add tests about wildcard suppress
^KT-61734
2024-03-07 10:16:58 +00:00
Jinseong Jeon b47a33cf9d Back to getOrDefault test
The main purpose was to test getOrDefault w/ non/null value does not
bother the resolution. To be aligned with test file
mapGetOrDefault_nullable.kt, this one should test getOrDefault too.
All we needed was // WITH_STDLIB
2024-03-06 19:26:52 +00:00
Dmitrii Gridin 28c80a1581 [LL FIR] StubBasedFirMemberDeserializer: add missed deprecation provider
^KT-60996 Fixed
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 805b7bc8f4 [Analysis API] add diagnostic tests on deprecated declarations
^KT-60996
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 1ba81fca57 [Analysis API] add tests on incomplete function type parameter symbol
^KT-65858 Obsolete
2024-03-06 16:09:43 +00:00
Jaebaek Seo a17ad6bc55 Fix K2 CodeGen annotation parameter resolution failure
When we have parameters of annotation like
```
// FILE: Anno.kt
package p3

@Target(AnnotationTarget.FUNCTION)
annotation class Anno(vararg val x: String)

// FILE: main.kt
import p3.Anno

@Anno("A", "B")
fun foo(): Int = 10
```
the K2 CodeGen causes an exception reporting the unresolved type
reference. A lazy resolution call fixes the issue.

In addition, FIR for the value parameter to IR conversion fails because
`Fir2IrLazyProperty` for the value parameter tries to resolve the
initializer before creating the `IrParameterSymbol`. When it checks the
`localStorage`, it reports an error for the missing `IrParameterSymbol`.
This commit adds `IrParameterSymbol` before resolving the initializer.

^KT-65099 Fixed
2024-02-29 06:44:05 +00:00
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
Ilya Chernikov 9037975758 K2 Scripting: Skip base class params from resolution scope
The base class in scripting considered obsolete and therefore supported
via some ad-hoc mechanisms. In particular parameters to the base class
c-tor are passed via script provided properties. But in combination
with the resolution logic, this leads to issues described in KT-60452
This commits filters out such parameters from script resolution
scope and avoids this problem for now.
Bot it should be noted that proper diagnostics for properties shadowing
should still be implemented - see #KT-65809
#KT-60452 fixed
2024-02-23 22:03:44 +00:00
Roman Golyshev c1ea878e52 KT-64808 [stubs] Add extra tests for synthethic declarations from data and value classes
It's not related to the stubs format changes, but there were no tests
for that in symbols resolve tests
2024-02-23 10:51:28 +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
Jinseong Jeon 460339870a K2 UAST: lookup declarations mangled due to value class
^KT-65653 fixed
2024-02-15 17:02:04 +00:00
Jinseong Jeon 7e65f125cc Reproduce wrong binary resolution to fun w/ value class
^KT-65653
2024-02-15 17:02:03 +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
vladislav.grechko 9aa8fb80e7 Set correct IR origins for inc/dec operations
NB: in order to produce correct IR origins, the source element kinds for
some FIR elements has been changed. As a side effect, mapping PSI to FIR
slightly changed: namely, for `a[b]++`, `a[b]` used to be mapped on
`set` call or callable reference, but now it is mapped on `get` call.

^KT-61891: Fixed
^KT-64387: Fixed
2024-01-30 14:26:10 +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 892212bdf6 [Analysis API] Add type code fragment test for a local class 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 ef890e9b76 [Analysis API] Add reference resolution tests for code fragments 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
Roman Golyshev d45662c2c3 KT-62695 [AA] Better resolve ambiguous receiver types in KDocReferenceResolver
When encountering multiple available same named types,
resolve all of them together with corresponding extensions.
This aligns well with the current resolve behavior of classes
with the same name (see `SameNameClassesFromStarImports.kt`)

Also, add extra test for resolving the ambiguous type without
the extension function. The behavior is the same - resolve to the
both classes.
2024-01-26 10:12:09 +00:00
Roman Golyshev fb225f5f20 [tests] Return caret names from ExpressionMarkerProvider
Render caret names in resolve testData, so that we don't have to guess
the indices of the carets;
it makes the multi-caret testData less error-prone.

Relevant for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 2befd2bffb KT-62695 [AA] Implement resolution of extension functions in KDoc
The solution is not complete, since resolution of KDocs is not
fully specified and is rather tricky.
Many more corner cases are to be expected.
This solution should at least give some groundwork for the future
improvements/fixes of the resolver.

^KT-62695 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev f9d4a35d80 KT-62695 [AA] Preliminary set of tests for extensions resolve 2024-01-26 10:12:09 +00:00