Commit Graph

8105 Commits

Author SHA1 Message Date
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
Dmitriy Novozhilov f5028bfc27 [Test] Reformat test for KT-57105 and add an additional case to it 2023-12-14 08:32:58 +00:00
Pavel Kunyavskiy 8e047e6d8a [FIR2IR] Make all source sets friends for IrFakeOverrideBuilder
^KT-63644
2023-12-14 08:32:58 +00:00
Artem Kobzar 1473b4bb41 [K/Wasm] Introduce JsBigInt type 2023-12-13 18:44:57 +00:00
Dmitriy Novozhilov 34bf32866b [Test] Remove redundant K1 ignore directives from K2 MPP box tests
Corresponding tests for K1 are no longer generated, so there is no need
  to ignore them anymore
2023-12-13 16:47:42 +00:00
Nikita Nazarov 251fdb21c9 [FIR] Generate spread element for unsigned arrays
Previously when unsigned arrays were passed as vararg in a named form the necessary spread element wasn't generated, which resulted in a compilation error.

^KT-63514 fixed
2023-12-13 15:30:27 +00:00
Mikhail Glukhikh dbca7358af K2: add explicit cast to Any for Any function calls on stub types
This commit solves a stub type inconsistency problem.
As a part of KT-59369 fix we decided (see commit 299d2799),
that ConeStubTypeForChainInference has a scope of Any,
so we can safely resolve only to equals/hashCode/toString.
However, later we can replace a stub type with some inferred type,
which can have its own equals/hashCode/toString implementation,
while the call still refers Any member.
In this situation FIR2IR decides that we are calling a fake override,
which is not true, in fact we are calling an overriding method.
This leads to a crash in Native backend.

To solve this situation, we provide an explicit cast of a dispatch
receiver with a stub type (ConeStubTypeForChainInference) to Any,
thus confirming directly we are calling Any method and nothing else.

#KT-63932 Fixed
2023-12-13 14:56:58 +00:00
Kirill Rakhman 6d1ca3d379 [FIR] Fix CCE in deserialization of suspend function type with star projection continuation
#KT-64148 Fixed
2023-12-13 14:36:01 +00:00
Svyatoslav Kuzmich 76e132e758 [Wasm] Fix overloading virtual methods by vararg and array element type
Context:
- Kotlin allows functions overloaded with different array element types.
- Varargs are lowered to Array parameters.
- Before this commit, K/Wasm erased an array element type
  from the signature, similar to type argument erasure in other cases.

Fix:
Stop erasing type arguments in arrays when computing v-table signatures.

^KT-58852 Fixed
2023-12-13 13:30:50 +00:00
Dmitriy Novozhilov 93563d7c80 [FIR] Report PROPERTY_AS_OPERATOR for all operator conventions
^KT-62347 Fixed
^KT-59715 Fixed
2023-12-13 09:27:14 +00:00
Ivan Kylchik 97ba3fe396 [K2] Revert changes done in KT-61786
Changes in this ticket remove type enhancement in java fields
for K2. But after KT-61920 fix, we can actually support it.
2023-12-12 13:54:31 +00:00
Dmitriy Novozhilov 4a2f9a5123 [FIR] Mute some tests back due to KT-64081
They were accidentally fixed with `[FIR] Process all overridden members from intersection scopes`
  commit, which itself introduced incorrect behavior, which was properly
  fixed with ... commit. So KT-64081 started to appear again
2023-12-08 15:19:55 +00:00
Dmitriy Novozhilov 385bff3be1 [FIR] Update all required places according to changed overridden processing contract
This commit fixes all places that relied on the contract described in
  the previous commit and also updates corresponding tests

^KT-63738
2023-12-08 15:19:55 +00:00
Dmitriy Novozhilov 4272f2e156 [FIR] Process all overridden members from intersection scopes
Previously, there was a contract that each callable symbol in the chain
  of `processDirectOverriddenWithBaseScope` will be unique. And if some
  symbol is accessible from multiple scopes, then only last of them will
  be returned as a component of `MemberWithScope`

But after the change from previous commit, we don't have this contract anymore.
  Which means that we may meet the same symbol during processing hierarchy
  of overridden functions (but with different base scopes)

So if some code utilizes `process...Overridden...WithBaseScope` functions
  it should consider that the same symbol may be obtained several times

^KT-63738 Fixed
2023-12-08 15:19:55 +00:00
Dmitriy Novozhilov a15057b2ca [FIR2IR] Unwrap only call-site overrides during delegated members generation
^KT-60251 Fixed
2023-12-08 15:19:55 +00:00
Brian Norman 0881910a1b [FIR] Rewind DFA after call arguments for correct receiver smartcasting
^KT-63709 Fixed
2023-12-08 14:32:22 +00:00
Dmitriy Novozhilov 7d685522ce [IR] Fix calculation of receiver type for properies in expect/actual context
^KT-62926 Fixed
2023-12-08 13:28:27 +00:00