Commit Graph

6875 Commits

Author SHA1 Message Date
Ilmir Usmanov 00a08fc6a4 Minor. Add tests and comment about copying generic parameters to
constructor, but not function reference to the constructor.

 #KT-32162
2022-02-15 08:11:19 +01:00
Ilmir Usmanov 84ccf412cb Minor. Ignore some tests on old JVM, JS_IR, JS and WASM
#KT-32162
2022-02-15 08:11:18 +01:00
Ilmir Usmanov 2fedb97d16 Correctly map nullable generic underlying value of inline class
if upper bound is primitive type.
 #KT-32162
2022-02-15 08:11:17 +01:00
Ilmir Usmanov a7e2f7a6b6 Map nullable type parameter with nullable inline class upper bound
which, in turn, has primitive or nullable underlying type to inline
class.
 #KT-32162
2022-02-15 08:11:15 +01:00
Ilmir Usmanov cece7120df Minor. Add more tests 2022-02-15 08:11:13 +01:00
Ilmir Usmanov c8817893d4 Support default parameters of inline type with generic underlying value
#KT-32162
2022-02-15 08:11:11 +01:00
Ilmir Usmanov 4f95171472 Minor. Add tests 2022-02-15 08:11:10 +01:00
Ilmir Usmanov 909b455758 Support generic underlying type of inline class in FIR
#KT-32162
2022-02-15 08:11:09 +01:00
Ilmir Usmanov 9060168542 Support generic underlying type of inline class
Use upper bound in JVM representation.
 #KT-32162
2022-02-15 08:11:08 +01:00
Denis.Zharkov 58408d8a78 FIR: Fix incorrect qualifier resolution in case of type parameters
^KT-51265 Fixed
2022-02-14 17:16:22 +03:00
Victor Petukhov fd6500c167 [FE 1.0] Set a fixation priority for self type variables less than any of ready for fixation kinds
^KT-51040 Fixed
^KT-49838
2022-02-14 15:43:53 +03:00
Ilmir Usmanov 8f23fc54a4 Mangle bridges if its return type is not inline
#KT-51235 Fixed
2022-02-14 13:06:13 +01:00
Svyatoslav Kuzmich 4636f71076 [Wasm] Loader improvements
- Output ES modules instead of plain files
- Support -Xwasm-launcher=d8 for d8 shell used in tests and benchmarks.
- Reuse launcher generation logic in CLI and box tests runners.
- Create separate output directory for each box since
  there are multiple output files generated for each test.
- Stop using absolute paths in generate JS files
  to simplify running generated code on different machine
- Remove ">>>" from println output


Merge-request: KT-MR-5729
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2022-02-10 22:59:44 +00:00
Vladimir Dolzhenko 918a91dbdf Escape special names with backticks in test data
#KT-51248
2022-02-10 21:20:47 +00:00
Mads Ager c8cade5bf3 [FIR] Ensure qualifier resolution takes place for type aliases.
When resolving a name that is used as a receiver and all
candidates are classifier symbols, we need to perform
qualifier resolution. The code used to only do that for
regular classes, and would not perform qualifier resolution if
there was a type alias candidate.

^KT-51171 Fixed
2022-02-10 16:27:32 +03:00
Ilmir Usmanov 47ee0e5b0a Get type arguments from supertype in supercall
Otherwise, when the function has inline class parameter, we get ICE.
We do not get the error without inline class parameter, since we
substitute type parameters in limited situations, which includes
inline class lowering.

 #KT-51157 Fixed
2022-02-10 10:40:55 +01:00
Dmitriy Novozhilov 0eb526a8b4 [FE 1.0] Report warning about conflict in inherited members from deserialized dependencies
^KT-51194
^KT-51223 Fixed
2022-02-09 19:35:56 +03:00
Svyatoslav Scherbina 62c1bd0044 Native: fix using nested expect enum entry in a default argument
^KT-51156 Fixed
2022-02-09 14:41:11 +00:00
Ivan Kochurkin 5391ee91af [FIR2IR] Fix incorrect type of typealias for suspend functional type, ^KT-50997 Fixed 2022-02-07 17:21:59 +03:00
Ivan Kochurkin 8a8bdc9ff4 [FIR2IR] Fix synthetic property reference in delegate expression 2022-02-07 17:21:58 +03:00
Dmitriy Novozhilov 1591518cf6 [FIR] Support constant unary operators for integer literal operators
^KT-38895
2022-02-07 13:36:37 +03:00
Dmitriy Novozhilov 52b72a7dac [FIR] Implement Int -> Long conversions for literals and operators over them
^KT-38895
^KT-50996 Fixed
^KT-51000 Fixed
^KT-51003 Fixed
^KT-51018 Fixed
2022-02-07 13:36:36 +03:00
Igor Yakovlev 81c688b207 [WASM] Unmute passing test 2022-02-03 21:25:58 +01:00
Xin Wang fdbcb64d39 JVM_IR: frame optimization for cast to IntProgression
#KT-29199
2022-02-03 17:45:06 +03:00
Mikhael Bogdanov 15e08893aa FIR: support DefinitelyNotNull types
#KT-49465 Fixed
2022-02-03 14:07:20 +01:00
Igor Yakovlev 0ae7e00ed8 Revert "[WASM] Remove ignore from passing tests"
This reverts commit a655f9da58.
2022-02-02 16:44:48 +03:00
Denis.Zharkov 772579143b FIR: Change semantics for combination of safe calls and operators
^KT-41034 Fixed
2022-02-01 13:12:49 +03:00
Pavel Punegov f819a10968 [K/N][test] Ignore test with synchronized java keyword 2022-02-01 11:46:35 +03:00
Dmitry Petrov beb4cf3d99 PSI2IR KT-51036 fix lambda return value generation 2022-01-31 12:18:19 +00:00
Sergej Jaskiewicz 8149189585 [JS IR] Optimize away upcasts
#KT-50212 Fixed
2022-01-28 10:03:53 +00:00
Mikhail Glukhikh 983fa4c8c7 FIR: add temporary access to Enum.getDeclaringClass (see KT-49653) 2022-01-27 17:27:39 +03: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
Georgy Bronnikov d2738c02cc Add test for IR serialization 2022-01-27 01:02:24 +03:00
Igor Yakovlev a655f9da58 [WASM] Remove ignore from passing tests 2022-01-26 23:40:42 +03:00
Igor Yakovlev 2ec0411a7f [WASM] DCE implementation 2022-01-26 23:40:41 +03:00
Ilmir Usmanov da80ac008b Make CHECKCAST not break TCO
So, treat CHECKCASTs as { POP, Unit } sequences. If the CHECKCAST is
between suspension point and ARETURN, put check for COROUTINE_SUSPENDED
before it and return if the suspension point is suspended.

This is safe, since if the function throws CCE, it will be thrown from
the last state in state-machine and we cannot reenter the function
during resume. So, in case of CHECKCAST throwing CCE the behavior is the
same, whether we have state-machine or not.

We do not need to disable TCO in some cases, as we do for functions,
returning Unit, since in latter case suspend function, returning Unit
might appear as returning non-Unit during resumption due to missing
{ POP, Unit } sequence, which is not executed, since the function is
tail-call. However, in case of functions, returning non-Unit there is
no such concern, since we do not POP result of suspension point, but
rather, return it after CHECKCAST.

 #KT-50835 Fixed
2022-01-25 03:30:22 +01:00
Xin Wang ebcc2cc3b2 PSI2IR: KT-49485 chunk ktConditions to avoid stackoverflow 2022-01-24 19:28:59 +03:00
Ivan Kochurkin ed836f28f4 [FIR2IR] Function reference type approximation hack KT-49526 2022-01-21 19:34:11 +03:00
Ivan Kochurkin 070e860669 [FIR] Fix visibility for property accessors in raw fir common 2022-01-21 19:34:10 +03:00
Mikhail Glukhikh e8be9d4861 FIR: support don't use builder inference if possible
In this commit we upgrade FIR builder inference logic from
the compiler version to 1.7. FIR-based compiler now works with
"don't use builder inference" flag always ON and supports switching
the flag "use builder inference only if needed". To do it,
ContraintSystemCompleter (FIR) and KotlinConstraintSystemCompleter (FE 1.0)
are made similar with extracting some common parts into
ConstraintSystemCompletionContext.

Test status: one BB test fails after this commit (KT-49285).
Also we have a crush in DFA logic in FIR bootstrap test and somehow
questionable behavior in FIR diagnostic test. However,
two BB tests were fixed, the 3rd case from KT-49925 were also fixed.

#KT-49925 Fixed
2022-01-20 23:46:36 +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
Dmitry Petrov 12d8b189a9 JVM_IR KT-50856 fix generic signature for SAM proxy function 2022-01-20 10:41:55 +00:00
Xin Wang 56e5db9f0e JVM_IR KT-50074 generate tableswitch for literal string subject of when expression 2022-01-19 22:25:49 +03:00
Dmitriy Novozhilov c80cfb0fdb [FIR] Replace single supertype scope with list of scopes of supertypes in use site scopes
This big refactoring is needed to cleanup building of overrides
  mappings and prevent creating redundant intersection overrides in
  cases when there is no need in them:

```kotlin
interface A {
    fun foo()
}

interface B {
    fun foo()
}

interface C : A, B {
    override fun foo()
}
```

Before this refactoring there was next override tree:
C.foo
  intersection override (A.foo, B.foo)
    A.foo
    B.foo

Also this commit fixes special mapping of overrides in jvm scopes
  for declarations which have kotlin builtins in supertypes with
  special java mapping rules (collections, for example)
2022-01-19 15:24:43 +03: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
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
Xin Wang 60657022e0 JVM_IR: Generate counter loop for reversed array (KT-22429) 2022-01-14 21:48:07 +03:00
Evgeniy.Zhelenskiy e97ca2ada4 [Psi2Ir, Fir2Ir] Generate toString, hashCode, equals methods for MF VC 2022-01-14 13:51:57 +00:00
Evgeniy.Zhelenskiy c7edc353d3 [FIX, Frontend] Fix recursive check for multi-field value classes 2022-01-14 13:51:57 +00:00