Commit Graph

91998 Commits

Author SHA1 Message Date
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
Sergej Jaskiewicz 026f292f4f [IR] Add IrClass.invokeFun helper and use it throughout 2022-04-07 10:31:34 +00:00
Pavel Punegov 4b3a5ad875 [K/N][samples] Use compilations for libcurl dependency setting 2022-04-07 10:13:04 +00:00
Ilmir Usmanov 1488790cd3 Replace recursion with a loop
#KT-51530 Fixed
2022-04-07 01:08:22 +00:00
Denis.Zharkov 6937e08b9c FIR: Remove effectively incorrect code from Candidate.getReceiverType 2022-04-06 16:05:42 +00:00
Denis.Zharkov 3d06a92eea K1: Adjust positioning for NO_CONTEXT_RECEIVER 2022-04-06 16:05:41 +00:00
Denis.Zharkov 82b6fdf97e FIR: Serialize type attributes for non-type-ref types, too 2022-04-06 16:05:41 +00:00
Denis.Zharkov 66bd8dccfa FIR: Unignore all Fir2IrText tests on context receivers 2022-04-06 16:05:40 +00:00
Denis.Zharkov 55159eba45 FIR: Do not verify descriptors consistency for FIR-based IR functions 2022-04-06 16:05:40 +00:00
Denis.Zharkov 2a6700e5d5 FIR: Unignore all blackbox tests on context receivers 2022-04-06 16:05:39 +00:00
Denis.Zharkov 41bc842b9d FIR: Support context receivers in Fir2Ir 2022-04-06 16:05:39 +00:00
Denis.Zharkov aa74bd4293 FIR: Minor. Drop effectively-always-null body parameter 2022-04-06 16:05:38 +00:00
Denis.Zharkov 512446843b FIR: Support typeRef-name label for this 2022-04-06 16:05:37 +00:00
Denis.Zharkov ac399321f0 FIR: Add replace method for contextReceiverNumber 2022-04-06 16:05:37 +00:00
Denis.Zharkov 445705369e FIR: Support context receivers in FirPropertyTypeParametersChecker 2022-04-06 16:05:36 +00:00
Denis.Zharkov 0ba5c528d0 FIR: Support (de)serialization of context receivers 2022-04-06 16:05:35 +00:00
Denis.Zharkov dfc736161a FIR: Fix overload resolution with context receivers 2022-04-06 16:05:35 +00:00
Denis.Zharkov 4349060db1 K1: Support referencing class context receivers in a form of this@Name 2022-04-06 16:05:34 +00:00
Denis.Zharkov c33f06b9e4 FIR tree: add context receivers helper properties 2022-04-06 16:05:34 +00:00
Denis.Zharkov 202413c2f4 FIR: Add context receivers from the containing class to constructors 2022-04-06 16:05:33 +00:00
Denis.Zharkov b2d5bf3eae FIR: Adjust diagnostics test data after resolution of context receivers 2022-04-06 16:05:32 +00:00
Denis.Zharkov ef84dddc88 FIR: Add preliminary support for context receivers in resolution 2022-04-06 16:05:32 +00:00
Denis.Zharkov 588dd23fd9 Drop unused members from DescriptorStorageForContextReceivers 2022-04-06 16:05:31 +00:00
Denis.Zharkov 90b12433ec FIR: Add replaceContextReceivers to FirCallableDeclaration 2022-04-06 16:05:31 +00:00
Denis.Zharkov 8f013db94d FIR: Simplify resolution for invokeExtension on implicit extension 2022-04-06 16:05:29 +00:00
Denis.Zharkov 9a070ad4f6 FIR: Get rid of SessionBasedTowerLevel 2022-04-06 16:05:28 +00:00
Denis.Zharkov 150f951fb2 FIR: Simplify and clarify contracts in FirInvokeResolveTowerExtension 2022-04-06 16:05:28 +00:00
Denis.Zharkov f7371816de FIR: Minor. Simplify FirInvokeResolveTowerExtension 2022-04-06 16:05:27 +00:00
Denis.Zharkov c595780d83 FIR: Add two label-related fields to FirContextReceiver 2022-04-06 16:05:26 +00:00
Denis.Zharkov 550d24f8c6 FIR: Introduce ContextFunctionTypeParams type attribute 2022-04-06 16:05:26 +00:00
Denis.Zharkov f3e28c3767 FIR: Prepare ConeAttribute infrastructure for non-singleton attrs 2022-04-06 16:05:25 +00:00
Denis.Zharkov 54c3e7e7c5 FIR: Support context receiver in FIR building 2022-04-06 16:05:24 +00:00
Denis.Zharkov 4379460177 Fix AST/PSI structure for context receivers in function types
Having CONTEXT_RECEIVER_LIST inside FUNCTION_TYPE_RECEIVER looks a bit hacky
2022-04-06 16:05:24 +00:00
Denis.Zharkov a89680fb34 FIR: Prepare tree for context receivers 2022-04-06 16:05:23 +00:00
Alexander Korepanov c4bb445c01 [JS IR] IC close input streams
^KT-51853 Fixed
2022-04-06 15:42:17 +00:00
Yahor Berdnikau 92d9c5b150 Remove 'kotlin2js' Gradle plugin
Plugin class is still left untouched as it is used by
js platform old plugin.

^KT-48276 Fixed
2022-04-06 13:32:34 +00:00
Mikhail Glukhikh 9bd6a9c069 FIR: handle 'SinceKotlin' as a special kind of deprecated
#KT-51850 Fixed
2022-04-06 12:51:20 +00:00
Mikhail Glukhikh 07b5bd72ae FIR: suppress CONFLICTING_OVERLOADS diagnostic properly 2022-04-06 12:51:19 +00:00
Abduqodiri Qurbonzoda 33fb49f20d Fix JDK7 failing tests 2022-04-06 07:42:58 +00:00
Igor Laevsky 81eae94821 [Wasm] Disable range checks for arrays. Add cli argument to enable them back. 2022-04-05 18:00:32 +00:00
Igor Laevsky 2c9bfe901d [Wasm] Pull array range checks into single function 2022-04-05 18:00:31 +00:00
Ivan Kylchik 6f448820f0 Add new internal annotation IntrinsicConstEvaluation 2022-04-05 17:20:38 +00:00
Ivan Kochurkin 46dd6520af Fix typo 2022-04-05 15:50:48 +00:00
Ivan Kochurkin 3566b7fe02 [FIR] Fix smartcast after elvis with escaping lambda, ^KT-44510 Fixed 2022-04-05 15:50:48 +00:00
Ivan Kochurkin c7122c1492 [FIR] Fix break/continue in try-finally in loop, ^KT-51759 2022-04-05 15:50:47 +00:00
Ivan Kochurkin e9b9322672 [FIR] Track inc and dec operator calls in preliminary loop visitor, ^KT-44879 Fixed 2022-04-05 15:50:46 +00:00
Ivan Kochurkin fc77d0d26b [FIR] Fix false positive errors for members with explicit API mode, ^KT-51758 Fixed 2022-04-05 15:50:45 +00:00
Ivan Kochurkin 1eefca4259 [FIR] Fix dependencies duplication 2022-04-05 15:50:44 +00:00
Ivan Kochurkin 48dbb9ceb9 [FIR] Fix resolving of refs with implicit this in lambdas in smartcasts 2022-04-05 15:50:43 +00:00
Ivan Kochurkin c6f52893fb [FIR] Fix inconsistent RETURN_TYPE_MISMATCH and TYPE_MISMATCH reporting on functions and properties
^KT-51203 Fixed
2022-04-05 15:50:43 +00:00