We need to supply signatures for private declarations even when their
containing file is not known. In situations where the FirDeclaration in
question is already known (i.e. where we are never going to serach for
the declaation based on that signature), FirDeclaration itself is
sufficient as a key.
1. merge(null of type A, null of type B) = null of unknown type;
2. merge(null of type A, something of type B) = merge(unknown null, B).
^KT-52311 Fixed
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
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.)
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
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
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
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
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
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');
}
```
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