Commit Graph

8267 Commits

Author SHA1 Message Date
Ilmir Usmanov 27081231d9 Use original instead of lowered function to retrieve toString-impl
in string concatenation lowering. Otherwise, inliner tries to get
body of already lowered function, failing.
 #KT-48284 Fixed
2021-10-06 11:12:26 +00:00
Sergej Jaskiewicz 65d40c2253 [JS IR] Make tests that use directives pass with IR BE 2021-10-06 09:23:50 +00:00
Roman Artemev 1d39b37c90 [IR] Add test describes case from KT-48912
It actually doesn't check behaviour because we don't have proper infra
for that but explains a bit a problem for further investigations.
2021-10-06 03:47:17 +03:00
Nikolay Lunyak e5d5e5be44 [FIR] Reorder scopes for KT-34822 2021-10-05 19:37:53 +03:00
Dmitry Petrov 1dae2aca4c JVM_IR KT-48954 prohibit indy reference creation in some cases 2021-10-05 15:38:46 +03:00
pyos 337cbeded1 JVM_IR: do not move receivers on functions with inline class parameters
^KT-48993 Fixed
2021-10-05 13:34:32 +02:00
Denis.Zharkov 0a3c950e7f FIR: Fix resolution scope of constructor delegation calls 2021-10-05 13:48:53 +03:00
Igor Chevdar 232608e300 [box-tests] Added a test 2021-10-04 14:34:56 +00:00
Svyatoslav Kuzmich fa3e75463e [Wasm] Support throwIAE and throwNoBranchMatchedException
Add a couple of test stubs
Unmute tests
2021-10-02 06:14:36 +00:00
Svyatoslav Kuzmich 6eb81517a0 [Wasm] Unmute passed Wasm tests 2021-10-02 06:14:35 +00:00
Svyatoslav Kuzmich c88cde2f8b [Wasm] DONT_TARGET_WASM_BACKEND => IGNORE_BACKEND in testdata 2021-10-02 06:14:35 +00:00
Roman Artemev fcf44be785 [JS IR] Add test for KT-46225 2021-10-01 23:36:41 +03:00
Roman Artemev 0621b79505 Add test for KT-46225 2021-10-01 23:36:40 +03:00
Roman Artemev 38f21b7139 [JS IR] Add test to check proper type substitution 2021-10-01 23:02:24 +03:00
Tianyu Geng fadde98a86 FIR: fix label stealling and crash with multiple labels
Consider the code below

```
fun test() {
  a@ b@ {
    {}
  }
}
```

Currently when the code is converted to FIR, label `b` is bound to the
outer lambda and `a` gets bound to the inner lambda because it's not
consumed. This is wrong and also leads transfromation to fail with
exceptions because of the unexpected consumption of `a`.

This change fixes the above issue by designating a specific node in the
AST as the allowed user of a label when the label is added.
2021-10-01 17:21:40 +03:00
Svyatoslav Kuzmich ab9a23cbfa [Wasm][Stdlib] Reuse K/N collections and StringBuilder 2021-10-01 17:18:49 +03:00
Ilya Goncharov 8bd009c5fd [JS IR] Eager initialization on side effect test 2021-10-01 13:32:13 +00:00
Ilya Goncharov 4c0045b136 [JS IR] Add test on initialization calling only once 2021-10-01 13:32:11 +00:00
Ilya Goncharov c2cf221965 [JS IR] Add annotation for eager property initialization 2021-10-01 13:32:10 +00:00
pyos cb505d1101 IR: keep capture sets the same when copying objects for tailrec funs
tailrec f(x: () -> T = { y }, y: T = ...) = f()

-- at the call we know that in `x` the observed value of `y` is `null`,
but the constructor should still have a single parameter.
2021-10-01 14:37:54 +02:00
pyos a4d1358e57 FIR: permit tailrec calls in inline lambdas 2021-10-01 14:37:54 +02:00
pyos 2afab62dae JVM_IR: optimize tailrec calls in inline lambdas
^KT-48600 Fixed
2021-10-01 14:37:54 +02:00
pyos 7c63d50d1c IR: create more temporary vals when optimizing tailrec calls
This is needed so that SharedVariablesLowering doesn't get confused, and
SharedVariablesLowering should run after TailrecLowering to properly
optimize tailrec calls in inline lambdas.
2021-10-01 14:37:54 +02:00
pyos b2315a4a05 IR: optimize f(); return in tailrec fun f(): Unit
It's equivalent to `return f()`.
2021-10-01 14:37:54 +02:00
Dmitry Petrov aea2db97c5 JVM_IR simplify null check on trivially initialized vals only 2021-10-01 14:31:48 +03:00
Alexander Udalov 31ba7f24b1 JVM IR: fix generic signatures of suspend function references
Using `kotlin.jvm.functions.Function{n+1}` (via
`getJvmSuspendFunctionClass`) for suspend functions was wrong in the
function reference lowering, because we didn't adapt the parameter types
by transforming the last type to Continuation and adding Object, and
generic signature ended up being incorrect.

Actually there was no need to use `kotlin.jvm.functions.Function{n+1}`
at all. We can just use the built-in
`kotlin.coroutines.SuspendFunction{n}` as a supertype, and it will be
mapped correctly later in codegen. It's not even needed to add the
`kotlin.coroutines.jvm.internal.SuspendFunction` marker manually, since
it's also handled by the codegen (see `IrTypeMapper.mapClassSignature`).

 #KT-48732 Fixed
2021-10-01 12:43:00 +02:00
Victor Petukhov 43a83dd07a Don't add LHS type constraint for callable references too early, before the resolution
The constraint depends on a resolution candidate, because it can be Java static or companion object's member (don't need add constraint in this case)

^KT-41978 Fixed
2021-10-01 13:33:21 +03:00
Ilya Chernikov fd2929d2c5 IR: skip script inner classes in LDL
#KT-49012 fixed
2021-10-01 09:01:36 +02:00
Dmitry Petrov 7e86f5dcd9 JVM_IR don't use Intrinsics.stringPlus for 2-argument concatenation 2021-10-01 02:59:52 +03:00
Mads Ager b61389f6f9 [JVM IR] Do not generate clinit as enclosing method.
The JVM and newer Android runtimes treats that the same as if
there is no enclosing method. However, older Android runtimes
for Android 5 and 6 throw exceptions on reflective access
and even older runtimes have different behavior. To avoid
those issues, exclude <clinit> from enclosing method attributes.

^ KT-48754 Fixed
2021-09-30 23:02:43 +02:00
Victor Petukhov 5326c875c0 Update compiler tests after rebase 2021-09-30 20:09:00 +03:00
Victor Petukhov b5661ccabd Don't run contract-specific checks in propery scopes
^KT-45118 Fixed
2021-09-30 20:08:59 +03:00
Victor Petukhov 80312789b2 [PSI2IR] Use candidate descriptor to get original type parameters while generating assignment receiver for property
^KT-46829 Fixed
2021-09-30 20:08:44 +03:00
Victor Petukhov 01e853fb9b Introduce error for SUPER_CALL_FROM_PUBLIC_INLINE
^KT-45378 Fixed
2021-09-30 20:08:36 +03:00
Roman Artemev 882016c22f [IR] Add tests for KT-47342 2021-09-30 15:42:03 +03:00
Alexander Udalov dbd28142d0 Fix callable reference adaptation for vararg in fake override
`mappedVarargElements` are populated with parameters from
`argumentMapping`, which is computed using `ArgumentsToParametersMapper`
which calls `original` on all value parameters (see
ArgumentsToParametersMapper.kt:136).

So the code that adds empty lists for unassigned vararg parameters
should also call `original`. Otherwise, in the added test, we ended up
with two arguments for the parameter `s` in `id(::base1)`, one for
`Base.s` containing the correct value, and another for `Derived.s`
containing the empty list. Psi2ir took the last one, which resulted in
empty array being passed to the vararg parameter.

Note that all of this is caused by the fact that `original` of a fake
override parameter is the parameter of the base function. This seems
suspicious because `original` of a fake override _function_ is that fake
override itself (NOT the base function), but this would probably be very
risky to change at this point.

 #KT-48835 Fixed
2021-09-30 14:08:38 +02:00
Alexander Udalov 9857af7823 Psi2ir: fix function type check for fun interface conversion
Parameter of a synthetic SAM adapter always has a function type (not a
subtype). Checking for the subtypes broke the case from KT-46908, where
fun interface is itself a subtype of a function type.

 #KT-46908 Fixed
2021-09-30 14:07:07 +02:00
Roman Artemev f644f47360 [IR] Add test for KT-47767 2021-09-30 14:39:01 +03:00
Alexander Udalov b821b26cfe JVM IR: do not try to optimize casts in TypeOperatorLowering
In case the cast value is used as a receiver to a private method call,
the cast is actually necessary, see KT-48927. Also, this optimization
has backfired once already (see kt48659_identityEqualsWithCastToAny.kt).
It seems that the best way to optimize these casts is not to generate
them in the first place, and/or use bytecode postprocessing.

Apparently the only kind of casts which need to be eliminated are those
which occur on an inline class to its supertype. Otherwise the
unsafe-coerce intrinsic is inserted at the incorrect place, and several
tests fail (uncastInlineClassToAnyAndBack.kt, genericOverride.kt,
classGenericOverride.kt).

 #KT-48927 Fixed
2021-09-30 13:32:36 +02:00
Mikhail Glukhikh 11459aced6 Replace UseExperimental with OptIn in BB builder inference tests 2021-09-29 19:39:26 +03:00
Dmitry Petrov 86b3ea09c2 JVM_IR handle @EnhancedNullability types in null check simplification 2021-09-29 19:14:38 +03:00
Dmitry Petrov 9325660f06 JVM_IR fold safe calls and elvises 2021-09-29 19:14:36 +03:00
Dmitry Petrov 7370d096ee JVM_IR recognize safe calls and elvises in arbitrary IR 2021-09-29 19:14:34 +03:00
Dmitry Petrov ca7ee75f88 JVM replace redundant GOTOs with NOPs to preserve debugging behavior 2021-09-29 19:14:33 +03:00
Dmitry Petrov 0a67ab54fe JVM_IR more compact safe call chains (almost as old BE) 2021-09-29 19:14:32 +03:00
pyos e1520c61da IR: use parameters for captures in field/instance initializers
val y = 1
    object { val x = y }
  ->
    class XKt$1(`$y`: Int) { val x: Int = `$y` }

Note that `$y` is not stored in a field because it's not used outside
the primary constructor.

One exception is captured inline parameters on the JVM backend, as the
bytecode inliner uses field assignment instructions (setfield) to locate
them; removing the field is thus not possible.
2021-09-29 16:25:43 +02:00
pyos 85c53bc24e IR: do not create unused capture fields
^KT-48784 Fixed
2021-09-29 16:25:43 +02:00
Leonid Startsev e7f1cef3a1 Correctly rearrange arguments for annotation constructors copied from another module
It won't fix KT-48181 completely, but it will allow to create such annotations
if all value arguments are specified.

For the full fix, we need to read default annotation values from classfiles in jar.

#KT-48181 In progress
2021-09-29 13:45:45 +00:00
Tianyu Geng a5435c0efc Make FE1.0 report tailrec diagnostics on the keyword 2021-09-28 22:30:20 +03:00
Tianyu Geng 5252effb10 FIR checker: report tailrec problems on the keyword
FE1.0 reports it on the declaration signature. This is not ideal so we
move it to the `tailrec` keyword in FIR.
2021-09-28 22:30:09 +03:00