Commit Graph

8121 Commits

Author SHA1 Message Date
Denis.Zharkov 72b0372927 K2: Allow PCLA inference when a value parameter has a TV type
^KT-64877 Fixed
2024-01-11 10:32:12 +00:00
Vladimir Sukharev b78455093e [K/N][Tests] Adapt test single_tls_load.kt to optional inline of EnterFrame 2024-01-10 23:31:00 +00:00
Vladimir Sukharev 86c88c0c77 [K/N][Tests] Ignore alwaysDisable test which fails without caches
^KT-64868
2024-01-10 23:31:00 +00:00
Vladimir Sukharev fee2a20a55 [K/N][Tests] Support test directive ASSERTIONS_MODE
^KT-64844 Fixed
2024-01-10 23:31:00 +00:00
Vladimir Sukharev 809d652bdf [K/N][Tests] Change assertions and runtime assertions modes to default, when optimizationMode=OPT
^KT-64844 Fixed
2024-01-10 23:31:00 +00:00
Denis.Zharkov 7e4d9d9f64 K2: Add new tests for PCLA implementation
Many of them have been found & minimized at FP tests/user projects

^KT-59791 Fixed
2024-01-10 14:56:31 +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
Denis.Zharkov 8459465177 K2: Adjust test data after PCLA implementation [green-to-red, controversial]
^KT-59791 In Progress
2024-01-10 14:56:30 +00:00
Denis.Zharkov f945dce4c8 K2: Adjust test data after PCLA implementation [green-to-red]
^KT-59791 In Progress
2024-01-10 14:56:30 +00:00
strangepleasures bb8ff9e299 KT-62584 Fix generation of type arguments for local classes
Merge-request: KT-MR-13684
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-01-10 14:20:09 +00:00
Alexander Udalov dd5fffebf2 JVM: do not generate assertion message for captured fields
#KT-64615 Fixed
2024-01-10 11:10:08 +00:00
Alexander Udalov f01e633f8b JVM: do not put public field access into a single expression block
It affects the `is IrGetField` check in
TypeOperatorLowering.computeNotNullAssertionText, which leads to missing
NPE messages when accessing backing fields of public properties.

 #KT-64615
2024-01-10 11:10:08 +00:00
Pavel Kunyavskiy 9374cacdd6 [IrActualizer] Don't actualize expect types
This was never semantically correct, but was not important
before KT-63644, as they were immediately dropped after that anyway.

After KT-63644, they were used to compute fake overrides inside them,
which were later matched against actual class, which can
produce false-positive matching errors.

^KT-64835
2024-01-09 17:53:06 +00:00
Alexander Udalov 70cfd34a7b Tests: minor, change test mute reason to KT-64432 2024-01-09 16:19:14 +00:00
Vladimir Sukharev 3d0a91bf3c [K/N][tests] Ignore test redundant_safepoints.kt under linux_x64
^KT-64844
2024-01-09 13:42:18 +00:00
Alexander Udalov d08c9ba222 JVM IR: transform fake override properties in SAM adapters
Replace every property with its getter and setter. This is needed
because later on, JVM backend assumes that all properties have been
lowered (by JvmPropertiesLowering) to this state.

 #KT-64116 Fixed
2024-01-08 21:31:13 +00:00
Vladimir Sukharev 35e5b0613d [K/N] Migrate filecheck test redundant_safepoints to new infra
^KT-62157
2024-01-08 08:59:24 +00:00
Mikhail Glukhikh 050d74a22e FE: fix PlainJavaClassifierType.isRaw (take inner classes into account)
#KT-64090 Fixed
2024-01-08 08:33:03 +00:00
Mikhail Glukhikh d5b784805b K2: add tests for KT-58579 and for KT-64090 reproduction 2024-01-08 08:33:03 +00:00
Pavel Kunyavskiy c6e32571d6 [FakeOverrideBuilder] Workaround KT-64743
Because of KT-64743 there is unexpanded type-alias in a place we don't
expect it to occur. To workaround this, we just expand typialiases in
one more place.

^KT-64743
2024-01-08 07:46:07 +00:00
Artem Kobzar 567433cc12 [K/Wasm, K/JS] Unmute explicit backing fields tests 2024-01-05 17:27:31 +00:00
Mikhail Glukhikh 8c2f5c767f K1/K2: add BB test for (add/remove)(First/Last) calls on mutable list
Related to KT-64640
2024-01-05 17:20:32 +00:00
Alexander Udalov ee8d42532b Fir2Ir, JVM IR: support flexible Array types loaded from Java
We don't have true flexible types in the IR, but we approximate it with
internal type annotations, such as FlexibleNullability,
FlexibleMutability, RawType. These annotations are then handled
specially in JvmIrTypeSystemContext, which can construct a fake flexible
type so that type checker on IR types would behave exactly as on
frontend types.

As shown in KT-63441, one instance of flexible types where flexibility
was lost during conversion to IR is Java array/vararg types. It's
necessary to support it so that IR fake overrides could be constructed
correctly, because IR fake override checker requires parameter types to
be equal. So this change introduces another internal type annotation,
FlexibleArrayElementVariance, which is only applicable to types with
classifier kotlin/Array, and which signifies that the annotated type
`Array<X>` should rather be seen as `Array<X>..Array<out X>`.

 #KT-63441 Fixed
 #KT-63446 Fixed
2024-01-04 15:54:27 +00:00
Nikita Nazarov 438b2dd164 [K2, MPP] Actualize value class representation
^KT-63638 fixed
2024-01-03 16:39:56 +00:00
Artem Kobzar da4c6dd443 [K/JS, K/N, K/Wasm] Fix more general case of the ^KT-61929 issue 2024-01-02 12:18:34 +00:00
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Dmitrii Gridin 48c36ce475 [FIR] FirJavaFacade: calculate default value for annotations lazily
To avoid contract violation

^KT-62776 Fixed
2023-12-21 18:43:19 +00:00
Kirill Rakhman 49ae1b8d01 [FIR2IR] Consolidate type approximation
This commit gets rid of the redundant typeApproximatorConfiguration
in Fir2IrTypeConverter and uses the type approximator for captured
types instead of the manual approximation used before.

This fixes the nullability of approximated captured types, which fixes
a runtime error in WASM.

This also brings K2 IR closer to K1 IR in one test.

#KT-64261 Fixed
2023-12-21 15:56:49 +00:00
Artem Kobzar 053bc08626 [K/Wasm] Add Binaryen sizes to Wasm size tests 2023-12-21 14:19:09 +00:00
Kirill Rakhman ad2689ecbf [FIR] Prefer the non-smartcasted receiver in resolution if it's visible
Previously, we would ignore the candidate with the non-smartcasted
receiver if they have the same symbol.
Now we prefer them when they're visible or when the smart cast changes
the nullability.
2023-12-21 13:29:01 +00:00
Mikhail Glukhikh 1ebf0f5376 K2: show all Java function with suspend view if possible
This commit fixes two tests related to removed workaround of KT-59818,
and also makes processing suspend functions in J/K hierarchy more consistent.
Before this commit, when we had Java class "suspend" method
(implemented with the help of Continuation) overriding Kotlin suspend fun,
the Kotlin suspend fun was visible in outer use-site scope,
and the Java method was invisible.
Also, we used a special "Java suspend view" just to determine
that Java method overrides Kotlin suspend fun and no more.
After this commit, Java class "suspend" method will be visible
in this hierarchy and Kotlin suspend fun will not.
Also, the "suspend" is visible as a synthetic Kotlin suspend fun
which is more correct.

Related to KT-63233
#KT-59818 Fixed
2023-12-21 13:10:17 +00:00
Kirill Rakhman f47705f123 [Tests] Add box tests for #KT-59904 2023-12-21 12:03:48 +00:00
Dmitrii Gridin 6ca6221be9 [LL FIR] LLFirStatusLazyResolver: more conservative optimization for actual classes
We cannot skip resolution in the case of type actualization as we cannot
guaranty that there are no any classes in super types which can be
actualized in the current context

^KT-62832 Fixed
^KT-63547
2023-12-21 09:34:39 +00:00
Mikhail Glukhikh a7dc381b93 K2: disable compatibility mode for new inference
#KT-64306 Fixed
#KT-64307 Fixed
#KT-64308 Fixed
2023-12-20 21:39:21 +01:00
Mikhail Glukhikh 4783822fbc K1/K2: add test confirming the work of KT-54487 case
#KT-54487 Obsolete
#KT-63350 Declined
2023-12-19 12:24:37 +00:00
Vladimir Sukharev b1508a49ac [K/N] Add failed test for KT-63049
^KT-63049
2023-12-19 09:15:39 +00:00
Vladimir Sukharev 089b7f31b5 [K/N] Fix indents
^KT-61259
2023-12-18 18:04:27 +00:00
Vladimir Sukharev c09e8909d4 [K/N] Move cinterop tests from standalone to codegen/box
^KT-61259
2023-12-18 18:04:27 +00:00
Artem Kobzar 2530cba82a [K/JS] Compile Kotlin coroutines as JS generator ^KT-63038 Fixed 2023-12-18 17:13:07 +00:00
Igor Chevdar 7907231bf2 [box-tests] Added a reproducer for #KT-64139 2023-12-18 12:55:51 +00:00
Dmitriy Novozhilov 94c46d384a [FIR2IR] Properly calculate the type of delegated function call
```
interface A {
    fun <T> foo(): T
}

class B(val a: A) : A by A {
    generated fun <T'> foo(): T' {
        return a.foo() // <------
    }
}
```

There was a problem that type of generated delegated call used
  an unsubstituted type of the original delegated declaration, which led
  to a situation when (see example) type of call `a.foo()` was not `T'`
  but `T`, which led to incorrect IR and further exceptions on backend

^KT-64257 Fixed
^KT-64284 Obsolete
2023-12-18 12:45:28 +00:00
Kirill Rakhman 984493fe8b [Tests] Add regression test for #KT-62865 2023-12-15 16:25:46 +00:00
Dmitriy Novozhilov 7813bb35cf [FIR2IR] Provide remapped f/o symbols to declaration storage
After a generation of fake overrides some code may still to refer old
  symbols from declaration storage (like computation of overridden
  symbols for lazy functions), so we need to remap those symbols using
  information from IR f/o generator
2023-12-15 15:38:10 +00:00
Dmitriy Novozhilov 97cf62e291 [FIR2IR] Properly calculate overridden symbols for lazy declarations
This change affects only mode with IR f/o generator

The old way of overridden computation with fir2ir f/o generator relied
  on the fact that fir2ir generator creates IR for all f/o and fills
  its caches. But with IR f/o generator enabled, we don't call fir2ir
  generator, so some caches are missing. And for this mode it's enough
  to acquire the symbol using the original declaration symbol and the
  lookup tag of the corresponding supertype

Relates to KT-64202
2023-12-15 15:38:10 +00:00
Pavel Kunyavskiy c485382e80 [FIR2IR] Rework actualization pipeline
There are a lot of restrictions between different parts of the pipeline.

1. Fake overrides can't be built before classes are actualized
2. Constants can't be evaluated before callables are actualized
3. Callables can't be actulaized before fake overrides are built
4. Checkers can't run before constants are evaluated

This commit reorders things to make all these restrictions happy.

^KT-63644
2023-12-15 15:38:10 +00:00
Brian Norman b2041e0927 [FIR] Disable data flow from in-place lambdas
There are many complications with the current design of passing data
from within in-place lambdas to surrounding code. Solving these
complications will involve more time to investigation than is available
within the K2 release. So we are disabling passing type statement
information from lambdas for the time being until more time can be
devoted to a more complete solution.

^KT-60958 Fixed
^KT-63530 Fixed
2023-12-14 16:40:27 +00:00
Dmitriy Novozhilov 28f0f1ea88 [FIR2IR] Properly set isAssignable flag for parameters of tailrec functions
^KT-63973 Fixed
2023-12-14 09:58:03 +00:00
Dmitriy Novozhilov f4e3203cd8 [FIR] Unregister java element finders from previous sessions
The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
2023-12-14 09:51:15 +00:00
Dmitriy Novozhilov 39063e59f6 [FIR2IR] Treat assignment on smartcasted this in classes using FIR instead of IR
KT-57105
2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 56a48b1148 [Test] Add missing WITH_STDLIB directive to test
This particular test references kotlin.reflect.KProperty1 both in
  common and platform sourceset. And if there is no stdlib in dependecies
  it resolves to KProperty1 from builstins, which is expect (see KT-64061),
  which leads to broken expectations that after IR actualization there
  are no referenced expect classes
2023-12-14 08:32:58 +00:00