Commit Graph

681 Commits

Author SHA1 Message Date
Igor Chevdar 5d3b61364a Added a test for KT-56500 2023-02-23 15:32:25 +00:00
Svyatoslav Kuzmich 26c1098a4f [Wasm] Fix inliner issues (KT-56584)
* Fix objects in inline functions and lambdas:
  * Add common lowerings used in K/JS and K/Native
* Fix inline lambda call detection logic in presence of additional casts


Merge-request: KT-MR-8791
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-13 13:14:43 +00:00
Nikolay Lunyak a9343aeb7d [FIR] KT-55840: Ensure everything actually works
This inconsistency is present due to not using the `// WITH_STDLIB`
in the above tests. When K1 creates the enum, it tries to generate
`entries()`, and for that it tries to load `kotlin.enums.EnumEntries`,
but this is actually an unresolved reference. K1 silently swallows it,
and proceeds.

The reason K2 doesn't fail is that in order to generate `entries()` it
simply creates the necessary `ConeClassLikeType` with the desired
`classId` instead of loading the whole `ClassDescriptor`.

The reason we can still observe `$ENTRIES` and `$entries` in K1
is because they are generated during the JVM codegen, and it
only checks if the `EnumEntries` language feature is supported. It
doesn't check if the `entries` property has really existed in IR
(by this time it's expected to have already been lowered to the
`get-entries` function - that's why "has ... existed").

The reason why the codegen doesn't fail when working with
`kotlin.enums.EnumEntries` is because it creates its
own `IrClassSymbol`.

^KT-55840 Fixed

Merge-request: KT-MR-8727
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-10 16:57:51 +00:00
Svyatoslav Kuzmich e1f72d60dc [Wasm] stdlib API: Mark primitives constructor properties as private
These are implementation detail and were not meant to be public
2023-01-24 14:55:00 +01:00
Vladimir Sukharev 924898afb7 [K/N] KFC-446: K2 platform: Native alpha
Merge-request: KT-MR-7905
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-01-04 16:10:40 +00:00
xiaozihan.larryxiao 64d40aa285 KT-55398 Add test case
Add KT-55398 test case into boxInline/reified
2022-12-23 01:15:18 +00:00
Dmitriy Novozhilov 6b343515e1 [Test] Save IR bytecode dumps from BytecodeListingHandler to .ir.txt file instead of _ir.txt
This is needed to keep consistency with other dumps and to allow
  test helper plugin to recognize those dumps
2022-12-01 07:29:37 +00:00
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
Igor Yakovlev 033e2c45f1 [WASM] Caching string literals in global pool 2022-11-01 13:15:09 +00:00
vladislav.grechko 70c2f2b86f Support specifying different bytecode listings for FIR and old frontend 2022-10-21 12:57:11 +00:00
Igor Yakovlev 5218acd5c9 [WASM] Optimise interop adapters 2022-10-18 20:48:12 +02:00
Igor Yakovlev 38dd68f1f4 [WASM] Enable passing tests 2022-09-15 16:27:46 +00:00
Vsevolod Tolstopyatov 22e26d0756 Move EnumEntries LVS to 1.9
* Also cleanup tests to avoid using obsolete WITH_RUNTIME
2022-08-12 09:35:32 +00:00
Vsevolod Tolstopyatov c0f81cbc45 [JVM] Improve code coverage of EntriesMapping
Ensure that when .entries is accessed from an inline function body
or lambda argument, EntriesMapping are properly generated and used
without excessive mappings and duplicated fields

#KT-53236
2022-08-12 09:35:24 +00:00
Alexander Korepanov bb8da65188 [Common IR] Do inlining of callable references of inline functions
^KT-52805 Fixed
2022-08-08 17:40:45 +00:00
Alexander Korepanov 794229d012 [box-tests] Add tests about anonymous classes uplifting
^KT-50175 Fixed by commits before
2022-08-08 08:39:59 +00:00
Igor Chevdar e38f02b53a [box-tests] Added a bunch of tests on local objects in inline lambdas 2022-08-08 08:39:57 +00:00
Mads Ager 59c2bde10a [K/N] Unmute passing tests. 2022-08-01 08:57:16 +00:00
Igor Chevdar 8981eb85de [box-tests] Added a couple of reproducers for KT-52795 2022-07-28 16:01:17 +00:00
Steven Schäfer 2acfb3a41f JVM IR: Avoid direct lambda invokes in inline tests 2022-07-14 23:24:18 +02:00
Igor Chevdar e36bd5fe90 [box-tests] Added a multi-module box test 2022-07-13 08:01:51 +00:00
Igor Chevdar a61d05971e [box-tests] Added a couple of multi-module box tests 2022-07-10 17:56:36 +00:00
pyos a1f0c6208c Add a test from KT-51950 2022-06-13 11:58:15 +02:00
pyos 27c51f5f88 JVM_IR: skip SAM lambdas when computing enclosing method of objects
This is what Java 15+ does, and it permits accessing captured type
parameters via reflection. The alternative is to emit generic signatures
on the lambda methods, but that was disabled and I have no clue why.

^KT-52417 Fixed
2022-06-08 23:59:58 +02:00
Mikhail Glukhikh 7c89f0188a FIR: resolve conflicts around SAM calls properly 2022-05-24 12:29:27 +00:00
Georgy Bronnikov 39bba7973c Fir2Ir: create file level signatures where appropriate
This is godugly code, where a flag for file level signatures is passsed
around.
An alternative would be not to create file level signatures for toplevel
private clases, since those still need unique names, at least on JVM.
But that would break binary compatibility.
Signatures are due for overhaul anyway. Hopefully this code can be
reverted at that point.
2022-05-19 12:02:43 +02:00
Georgy Bronnikov 109bdb9572 Adjust tests for FirSerializeCompileKotlinAgainstKotlin 2022-05-19 12:02:43 +02:00
Georgy Bronnikov 5605463ecf Introduce IGNORE_BACKEND_FIR_MULTI_MODULE directive 2022-05-19 12:02:43 +02:00
Zalim Bashorov 11d9751844 [Wasm] Unmute inlineVararg 2022-05-05 21:03:39 +00:00
Zalim Bashorov 76806eba8a [Wasm] Mute failing tests in boxInline 2022-05-05 21:03:38 +00:00
pyos effd21d074 JVM_IR: do not optimize suspend$$forInline functions
`$$forInline` functions do not pass through the state machine generator,
and optimizing `Ref`s before that changes how assignments inside lambdas
passed to `suspendCoroutine`, etc. behave: without a `Ref`, the
assignment is not reflected in the continuation object, so the variable
has old value on resumption.

These functions will be optimized later, after they are inlined
somewhere and the state machine is generated.

^KT-52198 Fixed
2022-05-02 20:18:08 +02:00
Sergej Jaskiewicz d7d86a0e95 [JS IR] Lift lambdas that capture no context
If a lambda expression does not capture any local variables, convert
it to a global free function and replace the lambda creation with
a reference to that function.

Example: for the following Kotlin code

```kotlin
fun foo(f: () -> Unit) = f()

fun bar() = foo { console.log("hello") }
```

before this patch, we generated:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda());
}
function bar$lambda() {
  return function () {
    console.log('hello');
  };
}
```

after this patch, we generate:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda);
}
function bar$lambda() {
  console.log('hello');
}
```
2022-04-07 10:31:35 +00:00
Dmitriy Novozhilov aeb68f956c [FIR] Turn LEAKED_IN_PLACE_LAMBDA into a warning 2022-02-18 17:44:36 +03:00
Georgy Bronnikov d2738c02cc Add test for IR serialization 2022-01-27 01:02:24 +03:00
Pavel Punegov 5d50e02d6b [K/N][test] Ignore test ^KT-36880 2022-01-10 09:01:02 +00:00
Alexander Udalov d5372521f1 Add tests for obsolete issues
#KT-12126
 #KT-12189
 #KT-23628
 #KT-24209
 #KT-34338
 #KT-47279
 #KT-48498
2021-12-29 17:07:03 +00:00
Alexander Korepanov b82c306530 [JS IR] Add deep copying for callable reference
Perform a deep copy of callable reference adapter on inline lowering

^KT-49844 Fixed
2021-12-20 14:02:11 +00:00
Igor Yakovlev 4f9b54da26 [WASM] Remove ignore from wasm std text tests 2021-12-07 21:33:28 +03:00
Anton Bannykh 58bd4ffd71 [JS IR] disable some AST checks for now 2021-11-19 00:38:55 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Denis.Zharkov 65d7da122f FIR: Fix invalid INITIALIZER_TYPE_MISMATCH for suspend lambda 2021-11-10 22:00:01 +03:00
Mads Ager b79ca7d7df [FIR] Allow annotation instantiation.
This commit disables the frontend error reporting for supported cases.
2021-11-09 23:51:48 +03:00
Alexander Udalov 1071919706 Remove backend tests on old inference
Also remove any mentions of NewInference, and rename some tests.
2021-11-09 20:07:33 +01:00
Mads Ager 41aa0a7c7f [FIR] Fix line number differences between psi2ir and fir2ir. 2021-11-01 15:43:13 +03:00
Artem Kobzar 790e8843f9 fix(JS_IR): add outer classes resolving inside the function inliner. 2021-10-28 17:34:58 +00:00
Ivan Kylchik f4bbcdc013 [TESTS] Move global directives outside file scope 2021-10-25 00:14:19 +03:00
Svyatoslav Kuzmich 279f184703 [JS] Remove failed checks based on unstable naming 2021-10-12 23:29:39 +03:00
Svyatoslav Kuzmich 15acc412ba [Wasm] Update testdata after coroutines support 2021-10-12 08:42:00 +03:00
Sergej Jaskiewicz 65d40c2253 [JS IR] Make tests that use directives pass with IR BE 2021-10-06 09:23:50 +00:00