Commit Graph

2370 Commits

Author SHA1 Message Date
Artem Kobzar 633d840c88 [K/JS] Deprecate external enum declarations
^KT-57254 Fixed
2023-03-10 12:55:43 +00:00
Pavel Mikhailovskii 164cbc9968 KTIJ-24768 Fix IllegalArgumentException in KtType.isPrimitiveBacked 2023-03-10 11:03:45 +00:00
Yan Zhulanow 8d1cfe0017 [LL API] Allow multiple candidates for non-local callables (KTIJ-21108)
In a combined classpath, such as scripting classpath for the whole
project, there might be several versions of the same library.
2023-03-10 10:59:01 +00:00
Pavel Mikhailovskii d9f023db89 KT-56845 [SLC] Add @Override to overridden property accessors 2023-03-10 10:32:48 +00:00
Marco Pennekamp d0782cb5a5 [AA] KT-56617 Remove isValidityAssertion from internal properties of KtFirPsiJavaClassSymbol 2023-03-09 18:36:00 +00:00
Marco Pennekamp 037984b0e0 [AA] KT-56617 Introduce PSI-based Java type parameter symbols
- Instead of extending the API with `typeParameterNames`, this commit
  creates a PSI-based Java type parameter symbol similarly to the
  PSI-based Java class symbol. Because completion requires only the type
  parameter name, this approach works fine, and without exposing an
  optimization via the API.
2023-03-09 18:36:00 +00:00
Marco Pennekamp 1e43e8d975 [AA] KT-56617 Introduce shared equals/hashCode for class symbols
- Instead of spreading `equals` and `hashCode` implementations over
  `KtFirNamedClassOrObjectSymbol` and `KtFirPsiJavaClassSymbol`, this
  commit introduces a shared base class.
2023-03-09 18:35:59 +00:00
Marco Pennekamp c729435765 [AA] KT-56617 Sync hashCode/equals of Java and regular class symbols
- Some completion tests failed because the `hashCode` of
  `KtFirNamedClassOrObjectSymbol` and `KtFirPsiJavaClassSymbol` was
  different for symbols which should be equal. Both symbols now use the
  `ClassId` hash code.
- `KtFirNamedClassOrObjectSymbol.equals` is now properly symmetric with
  `KtFirPsiJavaClassSymbol`.
- `KtFirPsiJavaClassSymbol` now has a definite class ID, which
  simplifies its implementation a little. `KtFirPsiJavaClassSymbol`
  doesn't support local Java classes by design.
2023-03-09 18:35:59 +00:00
Marco Pennekamp f9fb718b37 [AA] KT-56617 Optimize deprecation calculation for Java class symbols
- Most Java classes aren't deprecated. To avoid building `firSymbol`
  in such cases, this commit adds a simple heuristic which checks the
  class's annotations for the presence of one of the deprecation
  annotations recognized by the Kotlin compiler.
- Note that annotations are compared via simple names, so there is a
  slight margin of error. However, comparing class IDs is more costly in
  my tests, because getting an annotation's class ID is not as cheap as
  getting its simple name.
2023-03-09 18:35:59 +00:00
Marco Pennekamp d5933f28ab [AA] KT-56617 Optimize type parameter access for Java class symbols
- Completion accesses symbol type parameters to render their names.
  Instead of building the whole list of type parameters, and
  consequently the whole FIR class, completion can now access the type
  parameter names directly.
2023-03-09 18:35:58 +00:00
Marco Pennekamp 77e374db77 [AA] KT-56617 Optimize KtFirVisibilityChecker for Java class symbols
- `KtFirVisibilityChecker` accessed `KtFirPsiJavaClassSymbol.firSymbol`
  a significant number of times during completion, which led to many
  instances of FIR class construction.
- This commit introduces a heuristic to `KtFirVisibilityChecker`
  specifically for `KtFirPsiJavaClassSymbol` to bypass the compiler's
  visibility checker. The fact that we're dealing with Java class
  visibility from Kotlin makes this feasible without reimplementing the
  full logic of `FirVisibilityChecker`.
2023-03-09 18:35:58 +00:00
Marco Pennekamp 26e2c48a46 [AA] KT-56617 Implement equals/hashCode without accessing firSymbol 2023-03-09 18:35:57 +00:00
Marco Pennekamp 46d443770e [AA] KT-56617 Don't defer to firSymbol for empty annotation lists
- `FirJavaClass` gets all its annotations from the Java annotations, so
  we can rely on `javaClass.annotations` to determine if any annotations
  are present.
2023-03-09 18:35:57 +00:00
Marco Pennekamp 0b98192cb0 [AA] Fix exception message in withFirForScope
- We should not pass a lambda to `error`, as the exception message is
  `() -> kotlin.String` then.
2023-03-09 18:35:57 +00:00
Marco Pennekamp 1c46d37663 [AA] KT-56617 Build FirClassSymbols for Java classes lazily
- Some completion performance tests (e.g. IntelliJ: "empty place typing
  with library cache") spent a considerable amount of time in
  `KtFirSymbolProviderByJavaPsi.getNamedClassSymbol`.
- This commit introduces `KtFirPsiJavaClassSymbol`, which implements
  many `KtNamedClassOrObjectSymbol` properties with the `PsiClass`
  instead of the FIR class. The `FirClassSymbol` is built only when
  necessary. This improves performance when no "slow" properties need to
  be computed for the symbol.

^KT-56617 fixed
2023-03-09 18:35:56 +00:00
Marco Pennekamp e70a3a899f [AA] Move classIdIfNonLocal to analysis-internal-utils
- The utility will be needed by a `KtFir*Symbol` class.
2023-03-09 18:35:56 +00:00
Kirill Rakhman fa432d7f0d [FIR] Prioritize double over float in overload resolution
#KT-57194 Fixed
2023-03-09 13:00:53 +00:00
Dmitriy Novozhilov d5e6102ed9 [FIR] Properly check is some setter function is applicable for synthetic property
^KT-56506 Fixed
2023-03-09 12:32:49 +00:00
Nikolay Lunyak f39467b4ba [FIR] KT-57175: Expand typealiases in the annotation class checker
^KT-57175 Fixed
2023-03-09 09:44:09 +00:00
Nikolay Lunyak 5cbe699fc4 [FIR] KT-56876: Ensure inner type classifiers are resolved in contracts
^KT-56876 Fixed
2023-03-09 09:43:03 +00:00
Nikolay Lunyak 409249267c [FIR] Ensure this@label doesn't work in K2 2023-03-09 09:43:02 +00:00
Nikita Bobko 62d2327ca3 Don't issue a warning about expect/actual in the same module for incompatible expect/actual pairs
^KT-57067 Fixed
Review: https://jetbrains.team/p/kt/reviews/9123
2023-03-09 09:30:29 +00:00
aleksandrina-streltsova 3d0bca5ca1 [Analysis API] Handle missed cases in PsiElement.getExpectedType()
^KTIJ-24256
2023-03-09 09:19:00 +00:00
Mikhail Glukhikh 7a6ff5de34 K2: add test for KT-56954 2023-03-09 08:52:46 +00:00
Kirill Rakhman f946ddeb40 [FIR] Implement checks for contract not allowed
^KT-55423 Fixed
2023-03-09 08:32:02 +00:00
Kirill Rakhman b2fbf8bed5 [FIR] Fix callable reference adaptation for overrides without defaults
Provide the correct scope to the argument mapping so that default values
in overridden functions are considered.

^KT-56864 Fixed
2023-03-09 08:26:16 +00:00
Yan Zhulanow c91ef606f7 [LL API] Treat built-ins as a part of the standard library
Normally, compiled declaration searcher should look up declarations
only inside the session declarations. However, built-ins are treated
as a separate dependency, so '...WithoutDependencies()' functions
return only a part of declarations for the Kotlin standard library.

This commit effectively reverts changes in the previous change
(07fdbeca19).

This commit fixes the rest of failing compiletion tests:
- HighLevelJvmBasicCompletionTestGenerated
- HighLevelMultiFileJvmBasicCompletionTestGenerated
2023-03-08 16:28:13 +00:00
Kirill Rakhman 83845fbab5 [FIR] Only add non-subsumed to overridden of intersection override
If an intersection override overrides members A.x, B.x and C.x and
B <: A, then A.x is subsumed by B.x, and we don't add it to the list of
overridden members. This fixes a false-positive MANY_IMPL_MEMBER_NOT_
IMPLEMENTED where an implementation is subsumed by an abstract override.

^KT-57092 Fixed
2023-03-08 11:01:56 +00:00
Nikolay Lunyak 07fa86f6bc [FIR] KT-57085: Ignore the diagnostic case in @Suppress()
^KT-57085 Fixed
2023-03-07 20:28:02 +00:00
Marco Pennekamp a725fe559c [FIR] KTIJ-24296 Allow special names in symbol provider pre-filtering
- A special name such as `<no name provided>` may not be contained in
  the list of names, but may still be found by a provider.
2023-03-07 11:44:14 +00:00
Marco Pennekamp ece038b49b [LL FIR] KTIJ-24296 Extract symbol provider name cache into a class
- The caching logic from `LLFirProvider` may be used in other symbol
  providers.
2023-03-07 11:44:14 +00:00
Marco Pennekamp d9a024bab2 [LL FIR] KTIJ-24296 Implement symbol name pre-filtering in LLFirProvider
- The optimization reduces time spent in `LLFirProvider.SymbolProvider`
  during my tests by 30-90% in some highlighted files. In other
  performance tests, the optimization makes performance worse, so more
  work is needed. In general, higher workload tests run faster with the
  optimization, while lower workload tests run slower. This is expected
  as the optimization trades short-term performance (for building
  classifier/callable name sets) in favor of long-term speedup.
- The changes should also reduce the size of declaration caches like
  `LLFirProviderHelper.classifierByClassId`.
- Building the name sets has a second use, as a similar optimization can
  be implemented for dependent module providers, which may rely on the
  sets computed here.
2023-03-07 11:44:13 +00:00
Nikolay Lunyak 93ba0c3e70 [FIR] KT-56769: Ensure @receiver: is only allowed on receivers
Note that there's no code that checks that
FirReceiverParameter's annotation's use-site target
is indeed `@receiver:`, because otherwise the
annotation wouldn't have made it into
the FirReceiverParameter.

In contrast, in K1 all such annotations are treated
as annotations on a KtTypeReference.

^KT-56769 Fixed
2023-03-07 11:35:46 +00:00
Yan Zhulanow 0044f49af8 Revert "[LL API] Fix vararg parameter matching in PSI-FIR comparison"
This reverts commit 2d8c3c5aaf.
2023-03-07 02:49:41 +09:00
Yan Zhulanow 07fdbeca19 [LL API] Search declarations in dependencies as a fallback
'JvmClassFileBasedSymbolProvider' works incorrectly for some cases,
such as built-in classes. Moreover, the whole declaration binding logic
looks over-complicated and redundant, as we get a 'ClassId'/'CallableId'
from a 'KtDeclaration', and look for it again in indices.

This commit fixes a bunch of failing completion tests:
- HighLevelJvmBasicCompletionTestGenerated
- HighLevelMultiFileJvmBasicCompletionTestGenerated
- FirKeywordCompletionHandlerTestGenerated
2023-03-06 17:49:16 +00:00
Yan Zhulanow 342488e66e [LL API] Restrict accepted declarations for on-air resolution
After 1cfd2ae7ff, all non-local
declarations became targets for on-air resolution. However, some of
them, including secondary constructors, are not supposed to be used
in that way. The commit restores the previous behavior.

This commits fixes failing tests in the following groups:
- FirIdeDependentAnalysisSourceModuleIsUsedAsExpressionTestGenerated
- FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated
- FirOnAirResolveTestGenerated
2023-03-06 17:49:16 +00:00
Yan Zhulanow 37760d1f2a [Analysis API] Support script declarations (KTIJ-21108) 2023-03-05 19:18:21 +00:00
Yan Zhulanow e5e0575ab0 [LL API] Avoid dependencies in compiled element searcher
Library modules depend on all other project modules. Such a
simplification is useful for cross-library analysis. However, this
seems to be rather harmful for PSI->FIR binding as there might be
several versions of the same library in a project.
2023-03-05 19:18:20 +00:00
Yan Zhulanow 2d8c3c5aaf [LL API] Fix vararg parameter matching in PSI-FIR comparison 2023-03-05 19:18:20 +00:00
Yan Zhulanow 8b1be89507 [LL API] Check raw expect/actual modifiers in PSI-FIR comparison
There might be both common and JVM artifacts of the same library
in dependencies.
2023-03-05 19:18:20 +00:00
Yan Zhulanow 1cfd2ae7ff [LL API] Fix on-air analysis for scripts (KTIJ-21108)
The implementation is rather limited. Advanced cases, such as
replacing a script with another one with different import directives,
won't work because of non-trivial relationship between 'FirFile' and
'FirScript'.
2023-03-05 19:18:19 +00:00
Yan Zhulanow ae40ddcf03 [LL API] Provide basic support for scripts in K2 (KTIJ-21108) 2023-03-05 19:18:19 +00:00
Pavel Mikhailovskii 086d914f64 Regenerate tests 2023-03-03 19:27:24 +01:00
Pavel Mikhailovskii a6e1826bbc Reimplement the fix for KtSuperTypeList.findEntry 2023-03-03 15:38:12 +00:00
Artem Vasilev 564d44b16d [FIR] Test for duplicate filtering for overrides from Java 2023-03-03 11:06:19 +00:00
Artem Vasilev f7dea5bd70 [FIR] Filter duplicates in KtSymbolDeclarationOverridesProvider's output
^KT-54430
2023-03-03 11:06:18 +00:00
Artem Vasilev cac612f967 [FIR] Use symbol's FirSession in KtFirSymbolDeclarationOverridesProvider
^KT-54430 Fixed
2023-03-03 11:06:18 +00:00
aleksandrina-streltsova 1a10e0fdb6 [Analysis API] Render annotations of type parameters 2023-03-03 06:43:08 +00:00
Dmitriy Novozhilov 8c6d4a6f4b [FIR] Create intersection overrides for fields in intersection type scope
^KT-56820 Fixed
2023-03-02 13:40:59 +00:00
Dmitriy Novozhilov ae07d0e9ce [FIR] Unwrap smartcast on dispatch receiver in CFA for class initialization
^KT-56863 Fixed
2023-03-02 10:32:07 +00:00