Commit Graph

4118 Commits

Author SHA1 Message Date
Nikita Bobko 8c0cf7d0bc [FIR] Fix disappeared ACTUAL_MISSING
^KT-59887 Fixed

Review: https://jetbrains.team/p/kt/reviews/13244
2023-12-04 13:08:23 +00:00
Nikita Bobko e44e84d1b0 [FIR] Reuse expect/actual matching data of outer declarations during matching of inner declarations
Review: https://jetbrains.team/p/kt/reviews/13244

Motivation:
    ```
    // Module :lib
    class Foo {
        val member: Int = 2
    }

    // Module :app
    // dependencies { implementation(project(":lib")) }
    class Foo {
        val member: Int = 2
    }
    ```

    Before the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual = lib_foo.member
    After the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual is `null`

    If I don't fix this problem then
    `CommonizerHierarchicalIT.testCommonizeHierarchicallyMultiModule`
    becomes red after I fix KT-59887 in the following commits

    `app_Foo.member.expectForActual = lib_foo.member` happens because we
    also need to match fake-overrides (KT-63550)

I didn't measure it, but theoretically, this commit should be a
performance improvement, becuase we reuse `expectForActual` cache

Additionally, The commit breaks some other tests (e.g.
compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.fir.kt).
The tests will become green again, once I fix KT-59887
2023-12-04 13:08:23 +00:00
Nikita Bobko 453d871b25 [LL] Run LLFirExpectActualMatchingTargetResolver only for KMP projects
Review: https://jetbrains.team/p/kt/reviews/13244

Motivation: Performance. When I fix KT-59887 in later commits, I will
make actual-to-expect resolve to work not only for actual declarations.
Considering that LLFirExpectActualMatcherLazyResolver worked even for
non-KMP projects that might be a potential performance regression

FirExpectActualMatcherProcessor in the compiler does the same thing (it
checks for MultiPlatformProjects before running the transformer)
2023-12-04 13:08:23 +00:00
Nikita Nazarov 1df318ff28 [FIR] Remove the redundant isFunctionType check
^KT-63865 fixed
2023-12-01 21:04:41 +00:00
Stanislav Ruban 3a77f39199 [tests] Regenerate test configurations 2023-12-01 19:20:28 +00:00
Pavel Kirpichenkov fb9bf1782e [AA] Fall back to JVM stdlib dependencies in common test modules
Returns the old test behavior, until KT-63769 is implemented.
2023-12-01 18:12:23 +00:00
Pavel Kirpichenkov 0eb1a63a2f [AA] Add symbol tests for symbols from JS klibs
Use test compiler runner to compile JS libraries. Determine compiler
by the specified TARGET_PLATFORM. Add tests for dynamic type and
JS-specific .proto extensions.

Refactor the code for mock library compilation to make the switch
between platforms more straightforward.

KTIJ-27566
KT-63217
2023-12-01 18:12:23 +00:00
Pavel Kirpichenkov 0736cb3fac [LL] Fix KtDynamicType deserialization
KT-63217
2023-12-01 18:12:23 +00:00
Pavel Kirpichenkov 171a6f1a87 [LL] Add K/J library providers
Note on .kjsm library symbol providers.

It's not clear whether the provider is necessary for K2 IDE and whether
there will be libraries with .kjsm files that we are going to support.
Since there are no tests that can prove the correct work of the symbol
provider right now, it's better add them later if needed.
The existing tests cover only .knm files.

KTIJ-27566
2023-12-01 18:12:23 +00:00
Pavel Kirpichenkov c06e516205 [minor] optimize imports 2023-12-01 18:12:23 +00:00
Alexander Kuznetsov e048d49bf0 [Analysis API] fe10: count value classes in isInline
#KT-63771 fixed


Merge-request: KT-MR-13220
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-12-01 17:33:30 +00:00
Pavel Kirpichenkov c4fe7e4453 [Raw FIR] don't add an implicit Any super reference to kotlin/Any itself
KTIJ-27966
2023-12-01 14:56:01 +00:00
Marco Pennekamp d7190af72d [AA] FE10 compiler facility: Remove old backend support
- Old backend support is not needed in `KtFe10CompilerFacility` anymore,
  because it has been removed for the bytecode tool window, which was
  the only user. The old backend is slated to be removed entirely.

^KTIJ-24522
2023-12-01 13:22:55 +00:00
Mikhail Glukhikh 526bc1744a K2: implement BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION
#KT-59390 Fixed
2023-12-01 10:54:29 +00:00
Mikhail Glukhikh 0ed6256bcc K2: implement BUILDER_INFERENCE_STUB_RECEIVER
#KT-59369 Fixed
2023-12-01 10:54:29 +00:00
Nikolay Krasko 5e5e5b8b9f Revert "[FIR] Remove the redundant isFunctionType check"
This reverts commit 1f97c268e1.
2023-12-01 11:27:39 +01:00
Ivan Kylchik 2b6845c032 [JVM_IR] Optimize properties delegated to const val
We can omit `get` call to delegated property and inline
constant value directly. If we are not going to
do that, we can get a runtime exception because
all usages of const property will be inlined and the property
itself will be dropped.

#KT-63567 Fixed
#KT-63580 Fixed
2023-11-30 14:27:36 +00:00
Nikita Nazarov 1f97c268e1 [FIR] Remove the redundant isFunctionType check
^KT-63865 fixed
2023-11-30 14:17:01 +00:00
marat.akhin f0f06ccf2e [tests] Add tests for conflicting overloads + hidden between open/final 2023-11-30 13:07:23 +00:00
marat.akhin 0bc79fe69d [K2] Make CONFLICTING_OVERLOADS + HIDDEN ignore work only for finals
When fixing KT-22004, the analysis was incomplete, the details are
available at KT-63540. This change restricts the ignore of conflicting
overloads on hidden callables only for final ones.

^KT-63540 Fixed
2023-11-30 13:07:23 +00:00
Alexander Udalov fc7de5ab97 IR: check type parameter bounds equality in overrides
The code is exactly the same as in K1's
`OverridingUtil.areTypeParametersEquivalent`.

 #KT-63442 Fixed
2023-11-30 11:04:02 +00:00
Kirill Rakhman 560c1cacf3 [FIR] Fix capturing of flexible types during resolution
Previously, because we didn't handle flexible types properly in
prepareCapturedType, projections inside flexible types would only be
captured during subtyping with captureStatus=FOR_SUBTYPING
which would lead to the constraint type being wrongly approximated
(see ConstraintInjector.TypeCheckerStateForConstraintInjector
.addNewIncorporatedConstraint).

Fixing the capturing produced two kinds of false positive diagnostics:

1. In ConstraintInjector.TypeCheckerStateForConstraintInjector
.addNewIncorporatedConstraint we would get two instances of cone types
that are structurally equal and containing the same captured type.
However, because we only skipped subtyping if the types were
referentially equal, we would get a contradiction here.
The fix was to use structural equality instead, which should be okay
as the captured type instances are the same.

2. Reified type variables were inferred to captured types because
flexible arrays with captured upper bounds
(Array<Foo>..Array<Captured(out Foo)>?) were not properly approximated.

#KT-62609 Fixed
2023-11-30 08:54:26 +00:00
Kirill Rakhman 934253878b [Tests] Add regression test for KT-63564
#KT-63564 Fixed
2023-11-30 08:39:05 +00:00
Kirill Rakhman dd1d36816b [FIR] Insert SAM conversion expressions during completion
#KT-62847 Fixed
2023-11-30 08:39:04 +00:00
Kirill Rakhman ebb6f4c70f [FIR] Add parameter flattenArrays to FirExpression.unwrapAndFlattenArgument 2023-11-30 08:39:03 +00:00
Stanislav Ruban 514ae0c813 [tests] builder inference test-set: regenerate diagnostic & codegen tests 2023-11-30 06:27:00 +00:00
Dmitrii Gridin f3b3dcee9e [LL FIR] LLFirLazyResolver: more generic checks and cleanup
We should use more common classes which it is possible to potentially
not miss any changes in the future

^KT-63681
2023-11-29 19:52:29 +00:00
Ivan Kylchik 1125891a13 [K2] Properly report diagnostics on const properties with Java usages
#KT-63752
#KT-59894
#KT-61920 Fixed
2023-11-29 16:33:18 +00:00
Denis.Zharkov bb548e3df4 K2: Fix exception for PropertyDelegateProvider + lazy case
^KT-63646 Fixed
2023-11-29 15:10:36 +00:00
Brian Norman f9933adf5e [FIR] Substitute parameter bounds when checking EXPANSIVE_INHERITANCE
^KT-63649 Fixed
2023-11-29 13:35:00 +00:00
Dmitrii Gridin 06aad65ed3 [FIR] pass correct scope during annotation resolve for local declarations
We should pass container for correct logic around CLASS_HEADER_ANNOTATIONS.
Also, such correct containers will be used in the context of KT-63042 to
correctly detect an annotation ownership

^KT-63042
^KT-63842 Fixed
2023-11-29 10:24:03 +00:00
Dmitrii Gridin fcb3f003dc [FIR] add more tests on annotations for local declarations
^KT-63842
2023-11-29 10:24:02 +00:00
Dmitrii Gridin 98e12b0d7b [FIR] add missed scope for annotations on property receiver, typealias and init and dangling list
Also, we shouldn't transform type alias during the implicit type phase

^KT-63042
^KT-63832 Fixed
2023-11-29 10:24:02 +00:00
Dmitrii Gridin aaaf35fcb8 [FIR] add missed tests for declaration annotations
^KT-63832
2023-11-29 10:24:02 +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
Nikolay Lunyak 875e2b0cd6 [FIR] Prohibit calling functions with dynamic receiver over non-dynamics
^KT-63071 Fixed
2023-11-28 15:37:09 +00:00
Roman Efremov 5147a5e805 [Test] Add test for current behavior of resolution of nested class type
...when it is actualized via typealias.

^KT-31636
2023-11-27 18:23:43 +00:00
Roman Efremov 205690b220 [IR] Fix incorrect matching of nested classes when actualized via typealias
Also, add tests for the cases when expect and actual nested classes
have no compatible matching to check new logic doesn't crash.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov cec644e9db [Test] Add test for expect nested classes unwrapping
...in type arguments, when they were actualized via
typealias.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov 4aaf290c99 [FIR] Fix incorrect matching of nested classes when actualized via typealias
There are still some places in `.fir.kt` where false-positive reports
remained. This is because of IR checker, which will be fixed in next
commit.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov a768ece70d [Tests] Add tests for other checkers having same problem with
...nested classes marching.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov bfc775faf5 [Tests] Create test for nested classes matching when actualized via typealias
^KT-31636
2023-11-27 18:23:42 +00:00
Stanislav Ruban 269b60b420 [tests] Add a test case for KT-61978
^KT-61978 Obsolete
2023-11-27 15:50:46 +00:00
Dmitriy Novozhilov 039baf95fc [Test] Add empty platform module for MPP diagnostic test with only one module
After previous commits IrActualizer runs only there are at least two modules
  in backend input. So to check diagnostics from Actualizer all tests
  should contain at least two modules

Diagnostics in test `extendExpectedClassWithAbstractMember.kt` were
  changed because there is an exception from IrActualizer caused by
  errors from frontend (`ABSTRACT_METHOD_NOT_IMPLEMENTED`), which is
  swallowed by this kind of tests
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 62d269b3b9 [AA] Use convertToIrAndActualize in KtFirCompilerFacility
It was the last place that manually called parts of fir2ir
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov e38b25c278 [FIR2IR] Make convertAndActualize method the only entrypoint to fir2ir
Fir2Ir conversion consists of multiple steps with complex logic (like
  conversion of each module, actualization, plugins application, constant
  evaluation), and to ensure that they all are executed correctly it's
  convenient to have the single entry point for all this machinery
2023-11-27 10:17:54 +00:00
Kirill Rakhman 06811dfc2f [FIR] Add enum entry to body resolve context containers
This fixes processing of annotations on enum entries.
Before, the check in BodyResolveContext.forAnnotation would set the
tower data mode to CLASS_HEADER_ANNOTATIONS because no containers were
present.
This would lead to some tower data elements like nested classifiers
missing, which would lead to false positive unresolved references.

#KT-63761 Fixed
2023-11-27 09:00:17 +00:00
Mikhail Glukhikh e391e68ea3 K2: drop TypeParameterAsCallable check for reified in ::class
Related to KT-63377
2023-11-24 21:28:16 +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
Mikhail Glukhikh 4e938d852c K2: add some more tests around KT-63377 and KT-58028 2023-11-24 21:28:16 +00:00