Commit Graph

9270 Commits

Author SHA1 Message Date
Egor Kulikov 163017fcaf [FIR] Do not dereference delegate in lazy mode
Tenth step for ^KT-52615
2023-02-24 19:42:11 +00:00
Ilya Kirillov d2f3dce8c9 [FIR] do not resolve to status inside FirNamedFunctionSymbol.isLocal
1. this optimizes the isLocal call
2. this allows to check isLocal without resolving the status from the `FirNamedFunctionSymbol.canBeDeprecated`
2023-02-24 16:10:58 +01:00
Ilya Kirillov c366a7a9b0 [FIR] optimize FirSymbol.resolvedContextReceivers 2023-02-24 16:10:58 +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
Ilmir Usmanov b3890885c4 JVM: Break infinite loop in finding meaningful instruction
during tail-call optimization.

There can be code, where all next instructions are non-meaningful and
there is a back-edge, for example, while(true){}. Previously, analyzer
incorrectly assumed, that this cannot happen. Now, it keeps track of
visited instructions and says, that there is no meaningful instruction
in such case.
 #KT-56815 Fixed
2023-02-23 17:54:46 +00:00
Igor Chevdar 5d3b61364a Added a test for KT-56500 2023-02-23 15:32:25 +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
Alexander Udalov d73d3c46e2 K2 JVM IR: fix access to Java field shadowed by Kotlin property
#KT-56386 Fixed

Co-authored-by: Mikhail Glukhikh <Mikhail.Glukhikh@jetbrains.com>
2023-02-23 12:54:00 +01:00
Alexander Udalov 4ad594a3cd Minor, move tests about Java field and Kotlin property
Because the `fieldRename` directory was originally about cases when
private fields are renamed because of clashes.
2023-02-23 12:54:00 +01:00
Alexander Udalov 1cb77a47ec Fir2Ir: extract error about unsupported mutation 2023-02-22 22:40:34 +00:00
Alexander Udalov 22b4b29292 IR: make most properties mutable 2023-02-22 22:40:34 +00:00
Pavel Mikhailovskii 7700484a16 [AA] Fix conversion of annotation values 2023-02-22 13:55:50 +00:00
Ilmir Usmanov 68841fa031 Minor. Regenerate tests 2023-02-22 12:45:03 +00:00
Ilmir Usmanov 6be734c27e JVM: Remove inplace arguments before state-machine building
#KT-56258 Fixed
2023-02-22 12:45:03 +00:00
Denis.Zharkov 66eb29962a K2: Add minor clarification comment to FirDeclarationsResolveTransformer 2023-02-21 18:39:40 +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
Denis.Zharkov c09607c791 K2: Minor. Reformat and clean up a couple of transformers
`@Suppress("UNCHECKED_CAST")` became redundant there
2023-02-21 18:39:40 +00:00
Denis.Zharkov bdb1e28912 K2: Minor. Simplify condition at FirDeclarationsResolveTransformer
Just to avoid double negation at !hasNonDefaultAccessors
2023-02-21 18:39:39 +00:00
Pavel Mikhailovskii 81746e5aa1 KT-56508 Add a test 2023-02-21 16:22:26 +00:00
Ilmir Usmanov bfa2937fb8 FIR2IR: Do not add fake override if the member is overridden
#KT-56398 Fixed
2023-02-21 17:18:01 +01: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
Denis.Zharkov 0c9fad87c3 K2: Fix deserialization of upper bound of type parameter in nested class
Previously, containingDeclarationSymbol for V was set to the outer class
BaseRoot, so its upper bounds was computed to the ones from TNested
at org.jetbrains.kotlin.fir.resolve.calls.CreateFreshTypeVariableSubstitutorStageKt.getTypeParameterFromExpandedClass

^KT-56706 Fixed
2023-02-21 12:35:34 +00:00
Denis.Zharkov 9f51d3fbeb K2: Minor. Make properties private in FirTypeDeserializer 2023-02-21 12:35:34 +00:00
Ivan Kylchik 4060cc2750 Regenerate tests for FirPsiBlackBoxCodegen to include kt56215 2023-02-20 21:39:10 +01:00
Pavel Mikhailovskii 752ba433cc KT-53846 LT: Copy context receivers to secondary constructors 2023-02-20 18:13:54 +00:00
Ivan Kylchik 477d092bb8 Avoid object's interpretation with nullable type
#KT-56215 Fixed
2023-02-20 15:52:52 +00:00
Denis.Zharkov 99448b77f3 FIR2IR: Imitate K1 behavior when SAM type has a bit different shape
See the relevant test at t/
estData/codegen/box/sam/contravariantIntersectionType.kt

After the previous commit, when generating a call for `doOnSuccess {}`,
we have a SAM type with removed projection Consumer<Any?>, while
real function type of the lambda is a bit different
(Function1<ConcreteType & ConcreteType2>).

While for me, that looks questionable, but in K1 it was effectively
resolved via the same implicit cast that on JVM is generated to an
INVOKEDYNAMIC that wraps initial function-typed value.

^KT-53552 Fixed
2023-02-20 14:54:09 +00:00
Denis.Zharkov 05ca001310 FIR2IR: Repeat the K1 behavior: SAM conversion with 'in' projection
It would be more consistently to prohibit the behavior from the unmuted
test (see KT-52428), but it was decided to postpone the breaking change.

Unfortunately, it didn't work to make a test where for computing
star projections we would need to substitute other type parameters
because effectively, it's not allowed to have SAM conversion when
star projections/wildcard is based on a type parameter which bounds
use other type parameters.

^KT-53552 In progress
2023-02-20 14:54:09 +00:00
Denis.Zharkov 45eefab811 FIR2IR: Drop the-same-value property from ConversionTypeContext 2023-02-20 14:54:09 +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
Dmitriy Novozhilov 8d587322e9 Regenerate tests 2023-02-20 12:06:24 +02:00
Dmitriy Novozhilov 9ee60e4648 [Build] Exclude FIR codegen tests with PSI mode from aggregate test suite
Also add nightly configuration for them
2023-02-20 08:40:31 +00:00
Dmitriy Novozhilov a7f62581a2 [FIR] Generate PSI and LT versions of all codegen tests
Also change default mode for codegen tests from PSI to LT
2023-02-20 08:40:30 +00:00
Dmitriy Novozhilov e70e85d51a [FIR] Move unwrapSmartcastExpression util into :compiler:fir:tree module 2023-02-17 12:29:17 +00:00
Dmitriy Novozhilov d52b52ff5c [FIR] Drop unused ResolvedStatusCalculator class 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 914acd841f [FIR] Add special kind for graph of init blocks and local functions 2023-02-17 11:26:17 +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
Dmitriy Novozhilov 79e4df72bf [CLI] Introduce utilities for creating FirSession hierarchy in CLI for all platforms
Also support session creation and compilation for HMPP projects

^KT-56209 Fixed
2023-02-17 11:08:51 +00:00
Dmitriy Novozhilov 30ea4b6b53 [FIR2IR] Adapt IrActualizer to HMPP modules
Previously it collected actual declaration only from platform module
2023-02-17 11:08:51 +00:00
Dmitriy Novozhilov d4bb740a62 [CLI] Store information about HMPP module for source files 2023-02-17 11:08:50 +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
Egor Kulikov d670e5a695 [FIR] Do not get expressions from contract effect list in lazy mode
Eleventh step for ^KT-52615
2023-02-16 17:18:10 +00:00