Commit Graph

6316 Commits

Author SHA1 Message Date
Dmitry Petrov beb4cf3d99 PSI2IR KT-51036 fix lambda return value generation 2022-01-31 12:18:19 +00:00
Ilya Goncharov 32cda8a37e [JS IR] Fix cache format, module name one the second line 2022-01-31 12:00:12 +00:00
Sergej Jaskiewicz 8149189585 [JS IR] Optimize away upcasts
#KT-50212 Fixed
2022-01-28 10:03:53 +00:00
Sergej Jaskiewicz 400a5a0f34 [JS] Add CHECK_TERNARY_OPERATOR_COUNT and CHECK_BINOP_COUNT directives 2022-01-28 10:03:52 +00:00
Artem Kobzar f835433221 test: add optional argument d.ts generation. 2022-01-27 19:45:00 +00:00
Mikhail Glukhikh 5798320e9e Drop usages of CompilerArguments::useExperimental 2022-01-27 11:48:21 +00:00
Sergej Jaskiewicz 4a724611d8 [JS IR] Extract varargs in bridges generated for external methods
The issue this commit fixes occurs when we have an external interface
implemented by a Kotlin class, if that interface has methods with
varargs.

Kotlin functions expect varargs passed as arrays, but JavaScript code
may be unaware of this convention.

So, when generating a bridge for external interface method
implementaion, we insert some additional logic for extracting varargs
using the JavaScript `arguments` object.

A simplified example:

```kotlin
external interface Adder {
    fun sum(vararg numbers: Int): Int
}

class AdderImpl: Adder {
    override fun sum(vararg numbers: Int) = numbers.sum()
}
```

For `AdderImpl` we generate the following JS code:
```js
AdderImpl.prototype.sum_69wd7h_k$ = function (numbers) {
  return sum(numbers);
};
AdderImpl.prototype.sum = function () {
  var numbers = new Int32Array([].slice.call(arguments));
  return this.sum_69wd7h_k$(numbers);
};
```

#KT-15223 Fixed
2022-01-27 11:06:17 +00:00
Artem Kobzar 9547b0cae1 fix(Generic Constraints d.ts): add to d.ts generic type parameters constraints. 2022-01-27 10:37:10 +00:00
Igor Yakovlev 2ec0411a7f [WASM] DCE implementation 2022-01-26 23:40:41 +03:00
Dmitriy Dolovov 9096725d1d [IR, JS] KLIB ABI tests: separate testing logic so that it can be reused in non-JS tests
^KT-50775
2022-01-26 13:36:25 +03:00
Alexander Korepanov 68117faa73 [JS Legacy] Add an implicit cast to int for the mod operation
^KT-45620 Fixed
2022-01-25 13:40:37 +00:00
Alexander Korepanov b40227b66e [JS IR] Re-export all JS-exports from main module in multi-module mode
Add an implicit transitive re-export through
main module for all other module's JS-exports.
2022-01-24 15:17:56 +00:00
Dmitriy Novozhilov dd953908df [FE 1.0] Add compiler flag for rendering internal diagnostic names in error messages 2022-01-23 11:14:56 +03:00
Alexander Udalov f40a0ca704 JVM IR: avoid unnecessary toIrBasedKotlinType in ExpressionCodegen
Result of calling `ExpressionCodegen.gen` was used only in two call
sites in the inliner. In all other call sites, we were doing unnecessary
work (and sometimes were even failing) by trying to construct a
KotlinType instance out from an IrType.

Note that even though the code from KT-50617 no longer fails to compile,
the underlying problem is still not solved, since the IrType for foo's
dispatch receiver is constructed incorrectly. The reason is that
SymbolTable links everything by IdSignature, which is identical for
classes with the same FQ name.

 #KT-50617 Fixed
2022-01-20 16:05:42 +01:00
Alexander Korepanov 59173baf5a [JS IR] Pass forward -Xir-property-lazy-initialization option
Pass forward -Xir-property-lazy-initialization option
for the incremental cache.

^KT-50175 Fixed
2022-01-19 13:28:47 +00:00
Ilmir Usmanov b794b0f1be Check if there is bridge by signatures instead of IR
#KT-50649 Fixed
2022-01-18 16:57:00 +03:00
Alexander Korepanov 8fe4e9030f [JS IR] Add an implicit cast to int for the mod operation
^KT-45620 Fixed
2022-01-18 12:01:37 +00:00
Sergej Jaskiewicz ceb744b53b Revert "[JS IR] [runtime] Remove valueOf method from Long"
This reverts commit e13b6b2a90.

The significance of the breakage caused by the removal of `valueOf`
was underestimated.

#KT-50202 Open
2022-01-18 10:33:54 +00:00
Alexander Udalov f84f3cae97 Decrease operand count in tests on invokedynamic string concat
Otherwise the tests are flaky for some reason; stack overflow is thrown
from psi2ir sometimes. Probably it has something to do with the fact
that the JVM stack which is used by the compiler here is around the
default limit (which is 1M).
2022-01-17 23:59:59 +01:00
Mikhail Glukhikh a4f74f60d9 Fix apostrophes in error messages #KT-50183 Fixed 2022-01-14 22:20:23 +03:00
Evgeniy.Zhelenskiy 7595f798e1 [JVM] Introduce MF Value Classes to frontend 2022-01-14 13:51:55 +00:00
Dmitry Petrov d184babda6 JVM_IR fix cast to non-null primitive type (FIR bootstrap issue) 2022-01-13 12:47:00 +00:00
Andrey Uskov 2adc851f1b Don't use global state for keeping incremental compilation state
Previously IC state was stored in System properties. As result parallel
compilation might cause incorrect state of IC, what led to corruption
of kotlin_module files. Now IC state is stored via CompilerArguments
and CompilerConfiguration
#KT-46038 Fixed
2022-01-12 13:37:46 +03:00
Igor Yakovlev 82455c849d [WASM] Lazy properties initialization 2022-01-05 13:12:32 +01:00
Dmitry Petrov 4ad6cfcf53 JVM_IR fix cast to not-null type
We can't rely on argument type nullability here, because it still can
hold an uninitialized value on JVM.

KT-50577 KT-35272 KT-27427
2021-12-30 13:41:17 +03:00
Alexander Korepanov 4a29a8a7af [JS IR] Update an error on cross-module symbol redeclaration
The temporary solution for KT-50546.

The complete solution requires the understanding,
whether a cross-module symbol redeclaration is a valid case or not.
If the case is valid, the linker symbol table logic must be reworked.
2021-12-30 08:44:11 +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
Dmitry Petrov 5946242d75 JVM_IR fix special bridges in mixed Java/Kotlin hierarchies
KT-50257 KT-50476
2021-12-29 13:29:19 +00:00
Anton Bannykh 1b631da3a0 [JS IC] fix cross-module nested class references and interface inheritance
^ KT-50528 fixed
2021-12-29 16:04:06 +03:00
Ivan Kylchik 6fc56477bf Drop all tests that disable features for language version less than 3 2021-12-28 20:08:56 +03:00
Ilmir Usmanov 549ea1a3b9 If fun interface methods are already mangled, do not mangle them twice
There are two possible scenarios, when fun interface method with inline
class parameter can be compiled.

First is when we compile fun interface itself before SAM adapter. In
that case, fun interface is lowered before we lower SAM adapter. Thus,
its method is mangled and mangling in the second time is an error.

Second is when we compile SAM adapter before the fun interface. In that
case, fun interface is not lowered, and we have to mangle the method.

The only way to distinguish there two cases I can think of is to check
whether the overridden method is already mangled, in other words, check,
whether the overridden method's suffix is doubled.

 #KT-48499: Fixed
2021-12-28 17:35:12 +01:00
Sergej Jaskiewicz 71732afae0 [JS IR] Copy JS artifacts to the build directory if the compiler crashes
Previously in 3fb1096c18 we've implemented
dumping the IR after each phase when running JS IR box tests.

However, because those dumps are saved to a temporary directory,
they can be lost in case we never make it to
`jsArtifactsHandlersStep` where files from that temporary
directory were copied to the `build/out` directory.
This could happen if, for example, the compiler crashed.
In that case, having IR dumps is even more useful, as they can help
investigate the crash.

Here we make `JsArtifactsDumpHandler` an `AfterAnalysisChecker` so that
it runs no matter what.
2021-12-28 14:42:04 +00:00
Roman Artemev 723ef8f1fb [KLIB] Deserialize backing field initializers of const in IB-only mode
Missing const initializer leads to crash in property accessors inline
lowering during IC recompilation on JS.

 - fix #KT-50512
 - add test for JS IR IC
2021-12-27 23:43:43 +03:00
Ilya Kirillov 49e9c47071 Move DynamicTypeDeserializer.id from IR module to common module
So, it can be used from cls-psi-stub-builder module
2021-12-27 16:23:06 +03:00
Roman Artemev 4babc30624 [IR] Remove Persistent IR 2021-12-24 16:50:42 +03:00
Roman Artemev 353bfe9018 [JS IR] Cleanup pir IC code 2021-12-24 16:50:40 +03:00
Evgeniy.Zhelenskiy 610429a278 [Tests] Move non-value class test to the corresponding folder 2021-12-24 00:26:18 +00:00
Ilya Goncharov 52ccf3d6ec [JS IR] Not export fun with stable name and default argument
if it is not exported, but just with stable name

^KT-50464 fixed

Merge-request: KT-MR-5324
Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com>
2021-12-23 15:21:00 +00:00
Sergej Jaskiewicz 3fb1096c18 [JS IR] Support IR dump in JS tests 2021-12-22 17:55:33 +00:00
Anton Bannykh 4c33cb8016 [JS IR] IC: support per-module in K2JsIrCompiler 2021-12-22 10:14:33 +03:00
Anton Bannykh ca60caa7e9 [JS IR] IC: pass through the main args 2021-12-22 10:14:32 +03:00
Anton Bannykh aa628ae7b3 [JS IR] tests both per-module and regular mode 2021-12-22 10:14:08 +03:00
Anton Bannykh 95b5c44fba [JS IR] IC: emit source maps 2021-12-22 10:13:07 +03:00
Anton Bannykh 4d8926cf26 [JS IR] IC: support per-module layout 2021-12-22 10:13:07 +03:00
Anton Bannykh 670572bbc6 [JS IR] IC: test private declarations with same names 2021-12-22 10:13:07 +03:00
Anton Bannykh 175d722097 [JS IR] save JsIrProgramFragment definitions 2021-12-22 10:13:07 +03:00
Dmitry Petrov 915e949dbc JVM KT-49092 fix stack corruption in redundant boxing elimination 2021-12-22 05:32:26 +00:00
Roman Artemev 702ab3408b [JS IC TEST] Add test case about renaming file in module 2021-12-21 18:07:57 +03:00
Roman Artemev 76b9167c15 [JS IC TEST] Add test case about moving file between modules 2021-12-21 18:07:57 +03:00
Roman Artemev 9b49f0eb70 [JS IC] Support deleted files in IC cache invalidator
- support them in test too
2021-12-21 18:07:56 +03:00