Commit Graph

37 Commits

Author SHA1 Message Date
Alexander Korepanov f5d0c22736 [K2 JS] Unmute and link to issue some JS K2 tests 2024-01-18 15:48:55 +00:00
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Artem Kobzar 08bd0d6ce1 [K/JS] Generate tests for K2 + ES-classes compilation 2023-08-01 09:16:20 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +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
Ilya Chernikov 7e4ee399c8 FIR JS: temporarily mute remaining codegen tests 2022-11-12 16:28:25 +01: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
Xin Wang 4277827506 Don't transform irBranch if tableswitch can't be generated
#KT-34466 Fixed
2022-03-12 14:30:00 +03:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Dmitry Petrov 8905586cbb IR KT-50258 rewrite enum-based 'when' more carefully 2021-12-21 06:06:45 +00: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
Sergej Jaskiewicz 55ae6d1f3e [JS IR] Optimize pattern-matching of enums into comparing their ordinals
For this code:
```
enum class Season {
    WINTER,
    SPRING,
    SUMMER,
    AUTUMN
}

fun bar1(x : Season) : String {
    return when (x) {
        Season.WINTER, Season.SPRING -> "winter_spring"
        Season.SUMMER -> "summer"
        else -> "autumn"
    }
}
```

previously we generated this:
```
function foo(x) {
    var tmp0_subject = x;
    return (tmp0_subject.equals(Season_WINTER_getInstance())
        ? true
        : tmp0_subject.equals(Season_SPRING_getInstance()))
            ? 'winter_spring'
            : tmp0_subject.equals(Season_SUMMER_getInstance())
                ? 'summer'
                : 'autumn';
}
```

And now we generated this:
```
function bar2(x) {
  var tmp0_subject = x;
  var tmp0 = tmp0_subject._get_ordinal__0_k$();
  var tmp;
  switch (tmp0) {
    case 0:
    case 1:
      tmp = 'winter_spring';
      break;
    case 2:
      tmp = 'summer';
      break;
    case 3:
      tmp = 'autumn';
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  return tmp;
}
```
2021-10-14 11:44:01 +00:00
Svyatoslav Kuzmich 279f184703 [JS] Remove failed checks based on unstable naming 2021-10-12 23:29:39 +03:00
Sergej Jaskiewicz 65d40c2253 [JS IR] Make tests that use directives pass with IR BE 2021-10-06 09:23:50 +00:00
Mikhail Glukhikh d8f9643650 [FIR2IR] Use intersection type approximation for receivers 2020-05-07 15:27:17 +03:00
Mikhail Glukhikh a4c7619c89 [FIR2IR] Introduce & use FirBuiltInsPackageFragment
Without this commit, JVM name mapping logic in BE does not work for FIR,
because FIR cannot use old BuiltInsPackageFragmentImpl descriptor.
In this commit we add our own implementation thus fixing
a pack of FIR black box tests.
2020-03-24 10:37:53 +03:00
Mikhail Glukhikh 94fe79578e [FIR2IR] Generate unconditional branch in exhaustive whens 2020-03-20 11:55:34 +03:00
Mikhail Glukhikh 39bd97147f [FIR] Don't create initializers for simple enum entries
Usually FIR enum entry is initialized by anonymous object,
which is the container for all enum entry' declarations.
However, for simple enum entries there is no need of initializer at all.
2020-02-21 16:38:52 +03:00
Alexander Udalov 8f30b25b24 Minor, fix some codegen tests for language version 1.4
These tests check behavior of an old language version on purpose: the
original bug KT-24708 has been fixed by introducing an error here in
1.4.
2019-12-30 16:30:45 +01:00
Mark Punzalan 9df2f69f09 [FIR] Disable failing blackbox codegen tests for FIR. 2019-11-19 11:00:09 +03:00
Alexander Udalov 95be7171bc JVM IR: fix "null" as the first entry in MappedEnumWhenLowering
If "null" was the first entry in an optimizable "when" over enum,
mapRuntimeEnumEntry was called before mapConstEnumEntry, and the
$WhenMappings field was not created. Now both mapConstEnumEntry and
mapRuntimeEnumEntry create this field on the first access
2019-10-23 11:03:22 +02:00
Mikhael Bogdanov 1b2145af22 Fix test data 2018-10-25 09:12:26 +02:00
Mikhael Bogdanov e5ef5d096e Fix test data 2018-10-25 09:10:40 +02:00
Svyatoslav Kuzmich 7074909230 [JS IR BE] Support enumValues<T>() and enumValueOf<T>(name) 2018-10-10 19:35:17 +03:00
Denis Zharkov c1cc722ac4 Turn off incorrect switch-optimization for when by enums
#KT-24708 Fixed
2018-09-12 09:49:25 +03:00
Roman Artemev 6c8e30eb05 Fix test failures
* add metadata
 * unmute working tests
 * mute temporary broken ones
2018-08-09 20:55:50 +03:00
Mikhael Bogdanov 357359b1dd Unmute ir-tests after CR support 2018-08-09 14:22:50 +03:00
Svyatoslav Kuzmich 625983b28a [JS IR BE] Enum class lowering 2018-07-23 15:08:18 +03:00
Mikhael Bogdanov e149cbe852 Mute failed jvm ir tests 2018-06-28 12:26:41 +02:00
Anton Bannykh 96355e2732 JS IR: mute codegen box tests automatically 2018-06-09 19:15:38 +03:00
Alexey Andreev 89db4dfe79 JS: translate when against enum to JsSwitch when possible 2017-11-17 11:07:41 +03:00
Igor Chevdar d7e4350d42 Ignored/fixed some tests for Kotlin/Native 2017-06-28 12:54:32 +03:00
Mikhael Bogdanov df8394bcd2 Fix for KT-14597: "When" over smartcasted enum is broken and breaks all other "when"
#KT-14597 Fixed
2017-01-24 15:17:47 +01:00
Alexey Andreev b5358122e2 JS: unmute shared box tests 2016-11-16 19:50:10 +03:00
Zalim Bashorov 596f3364c6 Automatically mute failed tests 2016-11-09 21:41:12 +03:00
Alexander Udalov 06a67e6602 Merge boxWithStdlib testData into box, delete BoxWithStdlib test 2016-03-09 10:25:38 +03:00
Alexander Udalov 20e36438e2 Move some tests from boxWithStdlib/ to box/
Move those tests which do not require neither stdlib nor reflect
2016-03-09 10:25:38 +03:00