Commit Graph

8267 Commits

Author SHA1 Message Date
Denis.Zharkov e632689d90 FIR2IR: Fix case of using context receivers in property initializers 2022-05-13 18:04:02 +00:00
Denis.Zharkov b87412c5af FIR2IR: Fix substitution work for context receivers 2022-05-13 18:04:02 +00:00
Denis.Zharkov 9ec2411218 FIR: Fix behavior for context-receiver contained super class constructor
^KT-51889 Fixed
2022-05-13 18:04:02 +00:00
Denis.Zharkov 81416d1c46 Fix codegen for context-receiver contained super class constructor calls
^KT-51889 In Progress
2022-05-13 18:04:01 +00:00
Dmitriy Novozhilov be76cd39d2 [JS] Ignore some tests due to KT-52339 2022-05-10 16:16:55 +00:00
Ilmir Usmanov 4f53b085ec Do not override collection stub, if the override is suspend
but the stub is not. The other way around should be OK.

 #KT-52237 Fixed
2022-05-09 23:16:58 +00:00
pyos b19b265735 JVM_IR: generate continuation classes for suspend inline references
This is somewhat suboptimal since this results in `::suspendInline`
generating 2 classes while `{ suspendInline() }` only creates 1, but
it's the best allowed by the existing hierarchy of classes in stdlib. At
least it works?

^KT-50832 Fixed
2022-05-09 23:15:05 +00:00
Victor Petukhov 9f31f074da [FE 1.0] Take care callable reference candidates with recursive candidate return type
^KT-51844 Fixed
2022-05-09 19:23:43 +00:00
Victor Petukhov ec6ec20728 [FE 1.0] Fix subtyping for captured integer literal types
^KT-50877 Fixed
2022-05-09 19:23:42 +00:00
Victor Petukhov 7675361380 [FE 1.0] Continue completion of calls inside that builder inference call postponed type variables of which has already been inferred 2022-05-09 12:38:39 +00:00
Victor Petukhov b8030ec1de [FIR] Substitute lambda implicit receivers with builder inference stub types
^KT-51988 Fixed
2022-05-09 12:38:38 +00:00
Victor Petukhov 6027c2a9aa [FE] Substitute fixed type variables with inferred stub types
Actually, a type variable might be fixed into a stub type. Such stub type should be substituted before sub calls completion

^KT-51988 Fixed
2022-05-09 12:38:37 +00:00
Alexander Udalov ba20549e13 Fix JVM target in tests using boolean comparisons
These tests don't work on JVM target 1.6 after 6d664bcd10 because we're
generating `Boolean.compare` which is only available since 1.8. (It is
not a big deal because JVM target 1.6 is prohibited for users now.)
2022-05-06 03:47:25 +02:00
Alexander Udalov 6d664bcd10 JVM IR: fix operand type for CompareTo intrinsic
It's incorrect to take the first parameter type from the expression
itself because it can be nullable if smart casts are used. And if it's
nullable, it's mapped to the wrapper type and calling
`comparisonOperandType` for it makes no sense. Instead, take the type
from the callee function, as it's guaranteed to be mapped to a JVM
primitive type.

E.g. in `test1` function in the added test, the problem was that the
dispatch receiver type of the call expression is `Double?`, which is
mapped to `java/lang/Double`, whereas we clearly wanted to obtain the
primitive `D` (double) type.

 #KT-52163 Fixed
2022-05-05 23:06:21 +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
Zalim Bashorov 2c20a71d08 [Codegen tests] Specify JVM as target backend for inferenceFlexibleTToNullable.kt 2022-05-05 21:03:37 +00:00
Zalim Bashorov a6e8912af0 [Wasm] Mute failing tests in box/delegatedProperty 2022-05-05 21:03:36 +00:00
Zalim Bashorov 6ebeeabe0f [Codegen tests] Fix the test (kt39588)
For negative case, throwing CCE, we already have the issue KT-8135
and dedicated tests:
* genericDelegateUncheckedCast1.kt
* genericDelegateUncheckedCast2.kt

Related issues: KT-8135 KT-39588 KT-48749 KT-49837
2022-05-05 15:47:54 +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
pyos c43acba0b9 JVM: restore call site line number after inlining lambda
E.g. in `x + f()` where `f` is an inline lambda, the instructions for
`+` should have the line number of that expression (while previously
they instead had the line number of the last line of the lambda).

^KT-51738 Fixed
2022-05-02 19:28:10 +02:00
Victor Petukhov fb76d819f0 [FE] Erase type parameters of super types during intersection type emptiness check as well 2022-04-27 19:50:27 +00:00
Victor Petukhov 0f1d212fc5 [FE] Fix tests 2022-04-27 19:50:27 +00:00
Alexander Udalov 24f3c7dc7d Psi2Ir: fix usage of flexible vararg type after approximation
This only affects JVM IR, and this is similar to how this was done in
the old JVM backend in `CallBasedArgumentGenerator.generateVararg`.

 #KT-52146 Fixed
2022-04-22 14:15:28 +02:00
Alexander Udalov 6734f542b3 JVM IR: sanitize indy lambda proxy names correctly
In case there are several proxy functions for indy lambdas in the same
container, its names are "...__proxy", "...__proxy-0", "...__proxy-1",
..., yet before this change, only the first one was sanitized. So if
it's happening inside a constructor, `<init>` was left unrenamed which
led to ClassFormatError.

 #KT-52040 Fixed
2022-04-21 17:06:16 +02:00
Ivan Kochurkin 8c7fad9a5e [FIR] Support of type arguments in annotations ^KT-48444 Fixed 2022-04-18 15:36:19 +00:00
Ivan Kochurkin 05bed8f751 [FIR] Hide local type for return type of single expression function ^KT-51418 Fixed 2022-04-18 15:36:18 +00:00
Igor Chevdar 231fe42c0a [klibs] Fixed a bug in the signature-to-descriptor searcher
#KT-51927 Fixed
2022-04-14 07:33:56 +00:00
wrongwrong 2da8d53791 Fix callBy for InlineClassAwareCaller in case of >=32 parameters
#KT-51804 Fixed
2022-04-13 23:35:48 +02:00
Ilya Gorbunov 3778b1fde1 Remove ExperimentalStdlibApi no longer required in tests 2022-04-12 15:03:42 +00:00
pyos a07e21d913 JVM: streamline handling of tail-call suspend functions
Just see if every suspend call is followed only by safe instructions or
returns, then insert a suspension point check if there isn't a direct
return.

The first part of this is equivalent to the old implementation, just
refactored. The second part generates strictly more checks; see, for
example, the fixed test, in which the previous implementation failed to
insert a check before a CHECKCAST.

^KT-51818 Fixed
2022-04-11 17:00:26 +00:00
Ilmir Usmanov 1e3f84402d Safely check for suspend function parent
The issue here is that the function can be in unlowered file, and
thus its parent package fragment and not class.

 #KT-49317 Fixed
2022-04-08 23:31:49 +02:00
Dmitriy Novozhilov 6e2402620f [FIR] Fix collecting member candidates on receiver with smartcast
^KT-51460 Fixed
^KT-51827
2022-04-07 12:18:48 +00: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
Ilmir Usmanov 1488790cd3 Replace recursion with a loop
#KT-51530 Fixed
2022-04-07 01:08:22 +00:00
Denis.Zharkov 2a6700e5d5 FIR: Unignore all blackbox tests on context receivers 2022-04-06 16:05:39 +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
Mikhail Glukhikh 9bd6a9c069 FIR: handle 'SinceKotlin' as a special kind of deprecated
#KT-51850 Fixed
2022-04-06 12:51:20 +00:00
Ilya Goncharov 002d62de89 rra/ilgonmic/revert-signatures-changes
[JS IR] Fix line number test

[JS IR] Ignore isInstance repl test

[JS IR] Ignore isInstance repl test

[JS IR] Add test with unsafe variance

Revert "[JS IR] Optimize away upcasts"

This reverts commit 8149189585.

Get rid of duplicated signatures

Revert "[JS IR] Consider erasing type parameters in return type in js signatures"

This reverts commit 6adcbe081e.

Revert "rra/ilgonmic/exported-bridges-2 [JS IR] Use js name for signature"

This reverts commit 00289d35

[JS IR] Leave as is

[JS IR] Add test with overloading by generic

[JS IR] Add test from master

[JS IR] Add tests from master

Merge-request: KT-MR-5987
Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com>

^KT-51700 fixed
^KT-51523 fixed
^KT-51685 fixed
2022-04-05 15:35:12 +00:00
Alexander Udalov df86290083 Add another test for KT-49715 and fix JS IR behavior
#KT-49715
 #KT-51798 Fixed
2022-04-05 01:06:57 +02:00
Xin Wang 24105139ea Handle methods descriptor clash in data class
1. Extension functions declared in data classes are generated earlier by `generateMembersDeclaredInClassBody`
2. Extension functions fake override from parent class are generated earlier by `generateFakeOverrideMemberDeclarations`

So it is safe to filter out extension functions inside `generateAdditionalMembersForDataClass`

 #KT-49715
 #KT-51798
2022-04-05 01:06:57 +02:00
Pavel Kunyavskiy 4873f18067 [K/N] Enable definitely not null cast test for native 2022-03-31 09:02:14 +00:00
Ilmir Usmanov 7579be6c68 Generate CHECKCAST after ACONST_NULL in coroutines
If we do not do this, the state-machine builder will not know the type
of the ACONST_NULL, defaulting to Object, leading to VerifyError.
Alternatively, we could use LVT to deduce the type, but getting types
from LVT is something I got rid of long time ago, and I have no desire
to return it back.

Generating CHECKCAST hints the state-machine builder the type of the
variable avoiding the issue of VerifyError. However, this CHECKCAST
replaces StrictBasicValue.NULL_VALUE with BasicValue in
OptimizationBasicInterpreter. To preserve optimization on not-spilling
known nulls, introduce BasicValues, which represent typed nulls and
create BasicInterpreter, which is aware of them. This way we have the
best of two worlds - we do not spill known nulls, and we know the type
of ACONST_NULL.

 #KT-51718 Fixed
2022-03-30 14:27:29 +00:00
Ilya Chernikov 5d6e2b57a7 Sort sealed class inheritors to ensure reproducible builds with IC
without this sorting the inheritors field in the metadata may depend on
whether some inheritors are compiled in the IC round or not.
2022-03-30 08:35:30 +00:00
Pavel Kunyavskiy 7ba4d9e1f0 Rework nullability in IR 2022-03-30 06:27:59 +00:00
Svyatoslav Scherbina 8bb178e4a7 Native: ignore delegatedProperty/provideDelegate/kt39588.kt box test
It performs unchecked cast from `String` to `List<Any>`, which
legitimately fails when global optimizations are enabled.

^KT-48749 Declined
2022-03-29 13:27:44 +00:00
Svyatoslav Scherbina cf581738c3 Native: improve ClassCastException message for local classes
Previously it was like "null cannot be cast to MyObject" or
"MyObject cannot be cast to null", because `KClass.qualifiedName` is
`null` for local classes (including anonymous ones).

Use `KClass.toString()` instead, for both object actual dynamic type
and cast target type. This string representation is generally more
meaningful for such cases, and contains useful details for local
classes.
2022-03-28 08:21:55 +00:00
Evgeniy.Zhelenskiy 28bf83ceac [IR] Unite inline class and multi-field value class representation
#KT-1179
2022-03-24 11:38:43 +00:00
Evgeniy.Zhelenskiy 282ab398c6 [IR] Generify lowerings
#KT-1179
2022-03-24 11:38:42 +00:00
Victor Petukhov 22b2554368 [FE 1.0] Support suspend only SAM conversions
^KT-50477 Fixed
2022-03-24 09:28:28 +00:00