Commit Graph

406 Commits

Author SHA1 Message Date
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
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 faf33e4fa4 [Analysis API] add diagnostic test of type inference from getValue delegate
^KT-62888
2024-01-03 13:39:41 +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
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
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
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
Dmitrii Gridin e033fe5ba1 [Analysis API FIR] more tests for KtSymbolDeclarationOverridesProvider
^KT-64108
2023-12-12 16:13:10 +00:00
Roman Golyshev 78f492394c KT-64186 [LL] Correctly handle anonymous objects' headers in ContextCollector
This bug spilled into reference shortener, and then to
"redundant qualifier inspection" and code completion from there;
it caused KTIJ-26024 to reproduce again (but only for anonymous objects)

^KT-64186 Fixed
2023-12-08 09:14:43 +00:00
Vladimir Dolzhenko a3c1f4ea12 Fix rendering of platform type for value parameters
#KT-63979 Fixed
2023-12-08 06:45:22 +00:00
Egor Kulikov 001e9a4489 [FIR] Source for property delegates should not be null
^KT-60327 fixed


Merge-request: KT-MR-13221
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-29 08:27:53 +00:00
Mikhail Glukhikh 83cfcc30c6 K2: handle type parameter vs nested class conflict in body resolve properly
This commit does two things:
- prioritize type parameter scopes against static scopes in body resolve
(effectively it's a revert of KT-58028 fix)
- consider type parameters as inapplicable callable, so during callable
resolve we can go up the tower and still resolve to static scope

This allows both KT-58028 and KT-63377 to work properly
#KT-63377 Fixed
2023-11-24 21:28:16 +00:00
Roman Golyshev 644e29a2ea Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider"
This reverts commit 47a00bf9

See KTIJ-27918
2023-11-24 11:21:15 +00:00
Ivan Kochurkin 115d685d91 [FIR] Fix ambiguity of Throws and other std annotations importing
Including `SharedImmutable` and `ThreadLocal`

Simplify code, remove `DefaultImportPriority.KOTLIN_THROWS`

Introduce `FirNativeClassMapper`
2023-11-23 23:51:23 +00:00
Egor Kulikov 43fc4ccf40 [FIR] Source for implicit iterator calls in for should not be null
^KT-62111 fixed


Merge-request: KT-MR-13029
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-22 17:15:24 +00:00
Roman Golyshev 7d7256536c KT-63627 [AA] Properly handle object declarations when traversing scopes in KtFirReferenceShortener
`KtClass` denotes only classes, interfaces and enums.
To handle object declarations, we now use
`KtClassOrObject` PSI type

^KT-63627 Fixed
2023-11-21 18:08:43 +00:00
Roman Golyshev 4f5926a88f KT-62675 [AA] Handle labeled this expressions in reference shortener
At the moment, there is no good way to meaningfully filter `this`
expressions. The filters for the reference shortener can work only with
symbols, and it does not make a lot of sense to check any particular
symbol when deciding whether to shorten a labeled `this` expression.

We would probably need a better API for the shortener to be able
to filter more precisely (see KT-63555)

^KT-62675 Fixed
2023-11-20 20:18:18 +00:00
Dmitriy Novozhilov 3dff232710 [FIR2IR] Generate IR for unbound symbols in allowNonCachedDeclarations mode
`allowNonCachedDeclarations` mode allows referring source declaration which
  does not belong to the set of sources passed to fir2ir (e.g. for debugger
  support). So if code refers to such declaration, fir2ir creates symbol
  for it but not the IR declaration itself
2023-11-20 13:36:27 +00:00
Egor Kulikov c0a05e435c [FIR] Correctly process invalid implicit invoke
^KT-60170 fixed


Merge-request: KT-MR-12926
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-15 11:43:48 +00:00
Roman Golyshev d865a44c94 KT-61890 [AA] Add test for ContextCollector at loop variable position
This turns out to be important for conflict resolution in
postfix completion in K2 IDE (see `KotlinDeclarationNameValidator`)
2023-11-14 22:15:05 +00:00
Roman Golyshev 47a00bf97e KT-61890 [AA] Use ContextCollector in KtFirScopeProvider
^KT-61890 Fixed
2023-11-14 22:15:04 +00:00
Roman Golyshev 4f136cde31 KT-61890 [AA] Add testdata to ensure KDoc completion support in IDE
Completion in the IDE relies on correct scopes for KDoc positions.
So we add testData for `KtScopeProvider` and `ContextCollector`
to ensure that there are no regressions
2023-11-14 22:15:04 +00:00
Marco Pennekamp dd219cb6e6 [LL] Commit pending diagnostics from file checkers on script declarations
- In addition to file declarations and class members, we also need to
  commit pending diagnostics on declarations in scripts, to honor
  suppressions before the diagnostics are committed indiscriminately.

^KT-62899
2023-11-13 10:20:26 +00:00
Marco Pennekamp c482786bc4 [AA] Add tests for diagnostics suppression on top-level declarations in scripts
- `scriptUninitializedTopLevelProperty` is currently disabled in FIR
  because it fails with a mismatch between diagnostics from the file and
  the individual elements. It will be enabled in the next commit.

^KT-62899
2023-11-13 10:20:26 +00:00