Commit Graph

694 Commits

Author SHA1 Message Date
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
Dmitrii Gridin 052622b862 [Analysis API test] migrate more tests from doTestByModuleStructure to doTestByMainFile
^KT-64805
2024-01-10 22:07:03 +00:00
Jinseong Jeon 45b8f99107 SLC: distinguish last v.s. non-last vararg during binary resolution
^KT-64795 fixed
2024-01-10 15:36:40 +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
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
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 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 9c91158be6 [Analysis API] Add tests for dangling files 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
Dmitrii Gridin 2bad2f37ce [LL FIR] add missed ClassId check for combined Java classes symbol provider
findClasses works over regular `PsiElementFinder`, which doesn't know
about out ClassId conception. So, `a/b/A.B` and `a/b/A/B` are the same
from `FqName` point of view.
`FirJavaFacade` has this check, so this problem appears only in the case
of combined provider.

^KT-62892 Fixed
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 7efbcad121 [Analysis API] add diagnostic tests for inner Java class usage
^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 8a3f850bca [LL FIR] StubBasedFirMemberDeserializer: deserialized properties must have default getter/setter
In FIR we always have either real getter/setter or the default one

^KT-62888 Fixed
^KT-62651 Fixed
2024-01-03 13:39:42 +00:00
Dmitrii Gridin 02d99769ff [Analysis API] Use library name in result jar
^KT-62888
^KT-62651
2024-01-03 13:39:41 +00:00
Dmitrii Gridin a341dc704f [Analysis API] Add symbol tests for properties from libraries
^KT-62888
^KT-62651
2024-01-03 13:39:41 +00:00
Dmitrii Gridin faf33e4fa4 [Analysis API] add diagnostic test of type inference from getValue delegate
^KT-62888
2024-01-03 13:39:41 +00:00
Marco Pennekamp af7eb8b7af [AA] Add reference resolve tests for Java enums with getName function
^KT-62524
2024-01-02 16:41:34 +00:00
Marco Pennekamp c611f1923f [AA] Refactoring: Move Java reference resolve tests to java subfolder 2024-01-02 16:41:34 +00:00
Kirill Rakhman 6b049df87c [FIR] Render deprecation message if it's not a named argument. 2024-01-02 15:17:02 +00:00
Dmitrii Gridin d88249bda7 [Analysis API decompiler] materialize delegate declarations in stubs
We should materialize delegated declarations to process callables
in scopes correctly. Standalone mode works the same way as it
deserialize directly into FIR.
Another solution is to rework proto and stub serializer/deserializer to
restore FirFields like `$$delegate_0` correctly to work with
`FirDelegatedMemberScope`

^KT-62896 Fixed
^KT-64584 Fixed
2023-12-28 08:48:08 +00:00
Dmitrii Gridin 06950f57db [Analysis API] add tests for delegate field
^KT-64584
2023-12-28 08:48:08 +00:00
Dmitrii Gridin 3f337bf62d [Analysis API] add diagnostic test for delegate from library
^KT-62896
2023-12-28 08:48:08 +00:00
Dmitrii Gridin 441072c6fe [LL FIR] StubBasedFirDeserializedSymbolProvider: fix loading of nested classes
We cannot load nested class without an outer as in this case we will
miss a symbol of the outer class, which is crucial in some cases
(e.g., during status calculation).
So we have to load the topmost class as it will load all nested classes
with the correct context as well

^KT-62891 Fixed
2023-12-26 16:53:36 +00:00
Dmitrii Gridin 1ec994cd0d [Analysis API] add diagnostic test for FP expose diagnostic from library
^KT-64468
^KT-62891
2023-12-21 19:48:22 +00:00
Marco Pennekamp 43a3f7db5f [AA] Use MODULE_KIND in standalone API multi-module binary tests
- `MODULE_KIND` is a more general and straight-forward approach than an
  "app" magic module name.

^KT-64468
2023-12-21 19:48:22 +00:00
Dmitrii Gridin 69a2bc9abc [Analysis API] add regression test on error diagnostics for functional interfaces
^KT-63432 Obsolete
2023-12-21 19:36:44 +00:00
Jinseong Jeon ea17bbeddc AA: avoid using compiler impl detail as API return type 2023-12-21 15:34:34 +00:00
Jinseong Jeon f5d2ce3022 AA: render containing file and JvmClassName 2023-12-21 15:34:34 +00:00
Jinseong Jeon 797174ee1f AA: introduce new APIs to get containing file (symbol) and JvmClassName
^KTIJ-27686
2023-12-21 15:34:34 +00:00
Dmitrii Gridin 1538c125c3 [LL FIR] LLFirReturnTypeCalculatorWithJump: use declaration-site ScopeSession
We should use the declaration-site session to have stable
resolution order. The same scheme is applicable during
regular lazy resolution calls

^KT-63547
2023-12-21 09:34:39 +00:00
Dmitrii Gridin e3841a1728 [Analysis API] add test for duplicated callable during implicit type
^KT-63547
2023-12-21 09:34:39 +00:00
Dmitrii Gridin 51f6525238 [LL FIR] LLFirCompilerAnnotationsLazyResolver: pass correct ScopeSession
We should use the declaration-site session to have stable
resolution order. The same scheme is applicable during
regular lazy resolution calls.

^KT-63547 Fixed
2023-12-21 09:34:39 +00:00
Dmitrii Gridin 4bd73e4ccd [Analysis API] add diagnostic test for compiler annotation with argument from another module
^KT-63547
2023-12-21 09:34:39 +00:00
Jinseong Jeon 4c7e9f3cbf AA standalone: more tests about resolving properties in nested class/object from binary 2023-12-19 07:03:31 +00:00
Jinseong Jeon d603115def AA standalone: set binary dependency kind in test configurator 2023-12-19 07:03:30 +00:00
Jinseong Jeon e5095a60ba K2 UAST: lookup properties in the containing class, not companion object
...because properties in the companion object are materialized
in the containing class.

^KTIJ-27684 fixed
2023-12-19 07:03:29 +00:00
Jinseong Jeon 10c9b81c79 AA standalone: introduce multi-module binary dependency test 2023-12-19 07:03:29 +00:00
Roman Golyshev deb7999bfb KT-64205 [AA] Adjust defaultCallableShortenStrategy to import only top-level callables
^KT-64205 Fixed
2023-12-15 10:49:25 +00:00
Roman Golyshev d5896f20f0 KT-64205 [AA] Add shortening with default settings to the testData 2023-12-15 10:49:24 +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
Yan Zhulanow 0944e8fc36 [Analysis API] Keep the collected 'FirTowerDataContext' mutable
'ContextCollector' is used for computing context of 'FirCodeFragment's.
Code fragments themselves might contain additional smart cast operations
that modify the context receiver stack.

^KT-63056 Fixed
2023-12-12 17:31:52 +00:00
Dmitrii Gridin b458d69689 [Analysis API FIR] KtFirSymbolDeclarationOverridesProvider: unwrap fake overrides
We should unwrap substitution overrides as they sometimes cannot be
resolved on demand. We already have this in KDoc contract.
```kotlin
class MyClass {
    val prop = object : LazySchemeProcessor<Int, Int>() {
        override fun is<caret>SchemeFile(name: CharSequence) = name != "str"
    }
}

abstract class LazySchemeProcessor<SCHEME : Number, MUTABLE_SCHEME : SCHEME> {
    open fun isSchemeFile(name: CharSequence) = true
}
```
In this case, we will try to resolve fake override in the context of the
anonymous object, and it will fail because we cannot lazily resolve
local declarations as they are a part of the containing declarations
(KT-64243 for more details)

^KT-64108 Fixed
2023-12-12 16:13:10 +00:00