Commit Graph

2288 Commits

Author SHA1 Message Date
Ilya Kirillov 0089517b25 [Analysis API FIR] optimize KtFirCompletionCandidateChecker.checkExtensionFitsCandidate
We do not need running IMPLICIT_TYPES_BODY_RESOLVE to check candidate applicability.

Additional resolve to IMPLICIT_TYPES_BODY_RESOLVE takes about 5% of completion time

^KTIJ-24640
2023-02-27 09:40:41 +00:00
Egor Kulikov 163017fcaf [FIR] Do not dereference delegate in lazy mode
Tenth step for ^KT-52615
2023-02-24 19:42:11 +00:00
Jiaxiang Chen 7ce2f64c18 AA: apply java type enhancement to declaredMemberScope.
* added getDeclaredMemberScope to JavaScopeProvider.
2023-02-24 19:57:10 +01:00
Ilya Kirillov 69c024a5ce [FIR] optimize deprecation calculation for symbols
All symbols except member callables can be deprecated if they have non-empty annotation list

^KT-56800 fixed
2023-02-24 16:10:57 +01:00
Dmitriy Novozhilov 0bbc61f459 [FIR] Unwrap flexible types in when exhaustiveness checker
^KT-56942 Fixed
2023-02-24 14:58:18 +00:00
Dmitriy Novozhilov da581f38e1 [Test] Require specifying parser for FIR test. Unify names for FIR tests
Now all tests with `Fir` in name are named accordingly to parser which
  is used in them -- `FirPsi` or `FirLightTree`. This is needed to keep
  consistency between different types of tests, because there is no
  single default in parser mode between different scenarios of using FIR
2023-02-24 11:15:26 +00:00
Dmitrii Gridin 7e36a88b82 [LL FIR] FirDesignation: add workaround for LLFirLibraryOrLibrarySourceResolvableModuleSession
^KTIJ-24326
2023-02-24 11:09:43 +00:00
Svyatoslav Kuzmich 54a45c49f8 [Wasm] Add Wasm platform and K1 FE infrastructure 2023-02-24 01:05:23 +01:00
Dmitrii Gridin 550b4f1f11 [SLC] throw exception on redundant test data file 2023-02-23 17:15:53 +00:00
Pavel Mikhailovskii 9204f8162e [SLC] Fix modifiers for @JvmStatic methods in interfaces 2023-02-23 17:04:22 +00:00
Pavel Mikhailovskii 378bb4c4ac KT-56891 SLC Don't include abstract members in DefaultImpls 2023-02-23 12:50:59 +00:00
Dmitriy Novozhilov 331cc1465a [FE] Properly parse java class name from sources if java class has annotations
^KT-56847 Fixed
2023-02-23 12:14:15 +00:00
Jinseong Jeon 5455942859 AA: handle underscore as type arguments
^KTIJ-24742 Fixed
2023-02-23 13:02:34 +01:00
Pavel Mikhailovskii 7700484a16 [AA] Fix conversion of annotation values 2023-02-22 13:55:50 +00:00
Pavel Mikhailovskii 492a161d2c KT-56842 [SLC] Don't mark primitive context receiver parameters with @NotNull 2023-02-22 10:15:19 +00:00
Pavel Mikhailovskii de1927abb6 KT-56835 [SLC] Mark property$delegate fields as final and @NotNull 2023-02-22 09:40:32 +00:00
Denis.Zharkov 3f052af517 K2: Propagate explicit getter type to the property without initializer
In K1, we have the rules like:
- if there's explicit type of a property, then use it
- if there's an initializer, obtain its expression-type
- Otherwise, use getter's return type

The case when getter's type is implicit is handled at
FirDeclarationsResolveTransformer.transformProperty

^KT-56707 Fixed
2023-02-21 18:39:40 +00:00
Pavel Mikhailovskii d81170fbcc KT-56840 [SLC] Don't mark primitive-backed types with @NotNull 2023-02-21 17:29:16 +00:00
Nikita Bobko 9a865e4c55 [FE 1.0] Issue a warning if expect and actual are declared in the same module
The commit is based on b09561c3c3
Co-authored-by: Dmitriy Novozhilov <dmitriy.novozhilov@jetbrains.com>

^KT-40904 Fixed
^KT-55177 Fixed
Review: https://jetbrains.team/p/kt/reviews/8731

True negative test already exist:
`compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt`
2023-02-21 14:45:46 +01:00
Nikita Bobko 456605542c Make it possible to run hmpp tests with ENABLE_MULTIPLATFORM_COMPOSITE_ANALYSIS_MODE
In scope of KT-40904 KT-55177
Review: https://jetbrains.team/p/kt/reviews/8731

In order to make it possible to run hmpp tests with
`ENABLE_MULTIPLATFORM_COMPOSITE_ANALYSIS_MODE`, a dependency manager
must be implemented. This commit implements some basic dependency
manager. I'm not sure in its correctness because
`CommonDependenciesContainer` is an awkward API, but this dependency
manager works for my cases.

Why: I need hmpp + `ENABLE_MULTIPLATFORM_COMPOSITE_ANALYSIS_MODE`
infrastructure to cover `ExpectActualInTheSameModuleChecker` (I will add
the checker in the next commit) with tests. The checker couldn't be
covered with regular hmpp tests because regular hmpp tests and
`K2MetadataCompiler` run the compiler in a different way.
Contrary, `ENABLE_MULTIPLATFORM_COMPOSITE_ANALYSIS_MODE` runs the compiler in a
way `K2MetadataCompiler` does it.

I moved some tests from hmpp to `hmpp/multiplatformCompositeAnalysis`
because otherwise the tests would fail after I implement
`ExpectActualInTheSameModuleChecker` in the next commit.

Also the descriptor dumps were changed
(intermediateWithActualAndExpect.txt and
sealedInheritorsInComplexModuleStructure.txt). It happened because now
common source sets are no longer "squashed" into a single source set but
rather correct dependencies between source sets are established. And
each source set is analyzed separately (exactly like in
K2MetadataCompiler)
2023-02-21 14:45:45 +01:00
Denis.Zharkov 14ca12b50b K2: Add test for obsolete KT-56663
It was fixed via 898a9a0f2c together with
KT-53966

^KT-56663 Obsolete
2023-02-21 12:36:04 +00:00
Jinseong Jeon 527fc68778 ULC: match value parameter name of enum's valueOf 2023-02-20 14:07:01 +01:00
Ilya Kirillov b05a6e6e02 [Analysis API FE1.0] support multimodule tests for FE1.0 Analysis API 2023-02-20 11:01:32 +00:00
Ilya Kirillov 803c3b88ac [Analysis API] fix exception on symbol restore when symbol cannot be seen from the use-site module
^KT-56763 fixed
2023-02-20 11:01:32 +00:00
Ilya Kirillov ee1b018c9a [Analysis API] introduce a helper test function to get carets at multimodal tests 2023-02-20 11:01:31 +00:00
Egor Kulikov 6bb71b44f6 [FIR] Use lazy constructor delegate even if there's no KtConstructor
Twelfth step for ^KT-52615

Merge-request: KT-MR-8895
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-02-20 10:50:09 +00:00
Ilya Kirillov 477072b3e7 [Analysis API FIR] remove duplicated override of Fe10SyntheticPropertyAccessorReference.resolvesByNames 2023-02-20 10:28:56 +00:00
Ilya Kirillov 78d0749235 [Analysis API FIR] implement SyntheticPropertyAccessorReference.canBeReferenceTo for fir reference
it might improve find usages performance

^KTIJ-24696
2023-02-20 10:28:55 +00:00
Ilya Kirillov 6eda2742ff [LL FIR] optimize time spent in LLFirSessionsCache.getSessions
The most time were spent in `PersistentMap.get`, replacement to regular hash map should help.
This is thread-safe as we safe-publish the value via the volatile field `mappings`

^KTIJ-24697 fixed
2023-02-20 09:09:16 +00:00
Ilya Kirillov fbcaf3efeb [Analysis API] add information about KtModule to reported exceptions 2023-02-17 14:19:09 +00:00
Ilya Kirillov c37ee83791 [Analysis API] add more debug info to "pointer already disposed" error 2023-02-17 14:19:08 +00:00
Dmitrii Gridin 0eb90cccd1 [SLC] enum entries should be psi reference instead of psi expression
^KT-56728 Fixed
2023-02-17 13:11:14 +00:00
Dmitrii Gridin e65c863f8c [SLC] add test on single target annotation
^KT-56728
2023-02-17 13:11:14 +00:00
Dmitriy Novozhilov e70e85d51a [FIR] Move unwrapSmartcastExpression util into :compiler:fir:tree module 2023-02-17 12:29:17 +00:00
Dmitriy Novozhilov 86af01439c [FIR] Allow to access uninitialized member properties in non-inPlace lambdas in class initialization
^KT-56696 Fixed
^KT-56408
2023-02-17 11:26:18 +00:00
Dmitriy Novozhilov c87e489dc9 [FIR] Run CFA for member properties even if they have initializer
^KT-56678 Fixed
^KT-56682 Fixed
2023-02-17 11:26:17 +00:00
Ilya Kirillov 4c3672de0a [LL FIR] optimize FirCacheValue, do not create ConcurrentHashMap to store a single value
^KTIJ-24640
^KTIJ-24641
2023-02-17 10:24:20 +00:00
Nikolay Lunyak 516efe77c9 [FIR] KT-56612: Fully-expand types when casting bare types
^KT-56612 Fixed

Merge-request: KT-MR-8849
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-17 09:15:59 +00:00
Nikolay Lunyak 3c36a4fabd [FIR] KT-56665: Filter-out valid cycles
^KT-56665 Fixed

Merge-request: KT-MR-8861
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-16 17:48:38 +00:00
Ilya Kirillov c60fd38e05 [LL FIR] allow recursive access to the same FirThreadSafeCache
^KT-56721 fixed
2023-02-16 17:42:29 +00:00
Marco Pennekamp 5d391bc261 [FIR] KT-56505 Fix checkVisibilityModifier taking wrong modifier list
- KT-56505 occurred because `source.getChild(KtNodeTypes.MODIFIER_LIST)`
  returns any modifier list in the subtree of the source element, not
  necessarily the modifier list belonging to the checked element.
  `depth = 1` restricts the search to the modifier list belonging to the
  checked element itself.
- For example, given `f1` from KT-56505, `getChild` would return the
  modifier list of `public var foo = 0`. Because it contains a
  visibility modifier, `f1` wasn't marked with
  `NO_EXPLICIT_VISIBILITY_IN_API_MODE`.

^KT-56505 fixed
2023-02-16 10:50:48 +00:00
Marco Pennekamp e86c877733 [FIR] Explicit API mode: No REDUNDANT_VISIBILITY_MODIFIER for public
- In explicit API mode, the `public` visibility modifier is not
  redundant unless a declaration is hidden by a container. The
  `REDUNDANT_VISIBILITY_MODIFIER` diagnostic is now not reported in such
  cases.

^KTIJ-24485 fixed
2023-02-16 10:50:48 +00:00
Ilya Chernikov 27db8ce1bb FIR LT: extract syntax diagnostic info from error element
#KT-56701 fixed
2023-02-16 10:21:04 +00:00
Roman Efremov d120d83d60 Fix navigation in IDE to synthetic methods in compiled Kotlin
For some synthetic methods from compiled Kotlin classes, it is
not possible to find the PsiElement, when navigating to declaration
in the IDE.

For other methods it works like this:
1. There is a SourceElement with a psi inside
2. Or for K1, the element is searched in the decompiled text
   (see ByDescriptorIndexer),
3. Or for K2, the element is searched by Stub taken from metadata
   (see FirDeserializedDeclarationSourceProvider)

However, these approaches do not apply to synthetic methods which have
no SourceElement and are not written into decompiled text and metadata.

These are methods values, valueOf, entries from enum and
copy, equals, hashCode, toString from data classes.

Therefore, it was decided to handle their cases separately
at the resolve stage.

Tests (in idea repository):
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods

^KTIJ-24413 Fixed
2023-02-15 19:56:08 +00:00
Justin Paupore fa517180b7 [AA-FIR] Add support for constant evaluation of string templates.
Support FirStringConcatenationCall in FirCompileTimeConstantEvaluator.
This allows string templates ("foo${bar}") to be evaluated as constants,
assuming the interpolated expressions are themselves constant.

In addition, fixes some handling bugs with KtConstantEvaluationMode,
where some expressions that are not valid in a `const val` declaration
were being supported for `CONSTANT_EXPRESSION_EVALUATION`, including
non-static final Java fields in FIR, and composite expressions of
non-const properties in FE1.0.
2023-02-15 16:45:22 +01:00
Denis.Zharkov d84490dcfa K2: Delete failing test for KT-55555
It appeared again after 2b3f34cc52
And still needs some investigation

^KT-55555 Open
2023-02-15 09:17:11 +00:00
Denis.Zharkov b4b443034f K2: Fix false-positive OVERLOAD_RESOLUTION_AMBIGUITY
It's been introduced in the previous commit
("K2: Simplify handling mixed smartcast vs. original candidates")

Because previously, it was assumed wrongly that each next level of
ConeCallConflictResolver filter out the candidates that are 100% less
applicable/specific, but the main one (ConeOverloadConflictResolver)
either leaves the single candidate or the whole same set, thus at
FilteringOutOriginalInPresenceOfSmartCastConeCallConflictResolver
we've got 4 candidates only two of which we might filter out.
2023-02-15 08:13:57 +00:00
Denis.Zharkov b6b132a9a3 K2: Avoid false-positive overload resolution ambiguity with smart casts
The idea is that when we have successful candidates both from smart cast
and original type, we should discriminate in the favor of former ones.

While this problem (see kt55722.kt) existed before this branch is merged,
initially it was recognized on FP Ultimate when we stopped assuming
captured types from the same projections as equal (see kt55722Initial.kt).

^KT-55722 Fixed
^KT-55024 Fixed
^KT-56283 Related
^KT-56310 Related
2023-02-15 08:13:54 +00:00
Denis.Zharkov 2b3f34cc52 K2: Fix false-positive type equality for different captured types
This is mostly a revert of 2f61a2f56f
There, we erroneously assumed that we may take captured types as equal
if they are based on the same-typed projections.

Each instance of capturing defines its own captured type,
that should not be equal to any other type captured in other place.

Initial motivation was brought by FP Ultimate, where a piece of code
from the new test was found that started working differently after
recent changes.

The most obvious consequence is the change in addAllProjection.fir.kt:
one cannot use an instance as an argument when expected type
is captured type based on the same instance.

Otherwise, it would lead to CCE if we allowed to put arbitrary charsequences
to the list that initially was a MutableList<String>

All other test data changes (but addAllProjection.fir.kt and differentCapturedTypes.kt)
are irrelevant and will be fixed in the subsequent commits
2023-02-15 08:13:52 +00:00
Denis.Zharkov 181f23bd8d K2: Emulate K1 behavior in case of when-elvis combination
^KT-55692 Related
2023-02-15 08:13:51 +00:00