Commit Graph

5993 Commits

Author SHA1 Message Date
Ilmir Usmanov 91491eef06 Fixup end label of local variable if it is before start label
In that case, put end label to next label after start label.
2021-09-20 21:29:58 +00:00
pyos f786084a0a JVM_IR: mark direct uses of inline lambdas as conditionally suspend
They may or may not be inlined later.

IDK how the test passes when both modules are compiled with the old
backend - perhaps this has something to do with the fact that when `f`
is compiled with the IR backend, the call to `x()` is followed by `pop`
and `getstatic kotlin/Unit.INSTANCE`? This is probably why the original
issue in kotlinx.coroutines reports that everything works fine with
kotlinx-coroutines-core:1.4.3.

^KT-46879 Fixed
^KT-48801 Fixed
2021-09-20 19:29:44 +02:00
Igor Yakovlev 41a69ad388 [WASM] Add receiver capturing to callable references 2021-09-20 19:08:22 +03:00
Igor Yakovlev b8d11f7938 [WASM] Add text section to implement debug info 2021-09-20 19:08:21 +03:00
Roman Artemev 0bfc88fad0 [JS IC] Implement test infra for incremental caches 2021-09-20 12:23:36 +03:00
Svyatoslav Kuzmich 0abc798da9 [Wasm] Add JS interop tests 2021-09-16 14:20:35 +03:00
Igor Chevdar e194a07358 [tests] Added some tests 2021-09-16 10:54:14 +00:00
pyos 8724bc9525 Add test for KT-48478 2021-09-15 13:23:11 +02:00
Tianyu Geng 3c84fbcab1 IR: make calls with explicit singleton receiver tailrec [KT-48602] 2021-09-14 23:48:52 +03:00
Roman Artemev a2e4ebd820 [JS IC] Support //RECOMPILE directive in js box tests
- change test runner to production mode when sources are being compiled
 into klib and then klib is being translated into js, not directly from
 kt to js
 - fix IC cache format
 - support IC tests
2021-09-13 13:44:55 +03:00
Roman Artemev 3b53c97c2c [JS IR] Fix test data 'kt -> ir -> klib -> ir -> js' aka prod mode
- fix order in dts tests
 - unmute fixed test in prod mode
 - mute filing expect-actual link test in prod mode
2021-09-13 13:44:46 +03:00
pyos 23420ecf7a IR: do not infer array element types for non-annotation constants
While annotations restrict the set of allowed types to a few final
built-ins, in arbitrary constants we can have array elements that are
some subtype of the array's element type.

 #KT-48671 Fixed
2021-09-10 21:55:15 +02:00
Mikhail Glukhikh 007cf2ce7c Rename AnalysisFlags.useExperimental to optIn 2021-09-10 16:29:18 +03:00
Sergej Jaskiewicz 2f07589b42 [JS IR] Avoid name clashes for @JsQualifier-annotated declarations
#KT-42039 Fixed
2021-09-10 15:48:43 +03:00
Dmitriy Novozhilov 0260bf8767 [FE] Move diagnostic parameter renderers to common module 2021-09-09 17:20:20 +03:00
Dmitriy Novozhilov 850ca1916f [FE] Commonize positioning strategies and move them to :frontend-psi module 2021-09-09 17:20:17 +03:00
Igor Laevsky 00f61978b8 WASM: Enable exception handling tests 2021-09-08 19:56:38 +03:00
Igor Laevsky 6ca965af6f WASM: Generate throw instruction instead of wasmThrow call 2021-09-08 19:56:33 +03:00
Igor Laevsky a246ec636e WASM: Stupidify unit handling
Now every IR instruction returns an actual Unit instance.
All Unit's are actual objects passed around except for function boundaries.
2021-09-08 19:56:29 +03:00
Svyatoslav Kuzmich b79719d6f5 [Wasm] Fix unit issues
- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
2021-09-08 19:56:26 +03:00
Victor Petukhov 1d9ffebad6 Create resolution context for delegated property resolve as well
^KT-48445 Fixed
2021-09-08 13:10:46 +03:00
Victor Petukhov ce02cd4729 Enable suspend conversions by default in 1.6
^KT-48618 Fixed
2021-09-08 13:09:20 +03:00
Dmitry Petrov d9e4dec810 JVM_IR reuse loop variable as index variable should happen after LDL
We can't apply "reuse loop variable as index variable" transformation
before local declarations lowering, otherwise it will affect captured
loop variable behavior, resulting in KT-48626.

Since it's JVM-specific, move it to JvmOptimizationLowering.
2021-09-06 22:16:40 +03:00
Sergej Jaskiewicz f62ffeaa0a [JS, Frontend] Forbid @JsExporting inline/value classes
Previously the compiler would just crash.

#KT-46202 Fixed
2021-09-06 16:13:00 +03:00
Sergej Jaskiewicz 5eaea04bc8 [JS, Frontend] Fix a typo in an error message
The single apostrophe was eaten, resulting in the wrong
spelling "cant".
2021-09-06 16:13:00 +03:00
Sergej Jaskiewicz cb3d5f90e6 [JS IR] Export protected members too
#KT-47524 Fixed
#KT-47525 Fixed
2021-09-06 12:46:25 +00:00
Alexander Udalov a06fc20680 JVM IR: erase parameter default value when copying it to bridge
#KT-48391 Fixed
2021-09-03 15:00:44 +02:00
Sergej Jaskiewicz be999564b1 [JS IR] Export nested objects
Companion objects are exported as ParentClass.Companion.
Companion object's members are not exposed to its parent class —
one must reference the companion object explicitly if they want to
access its members.

#KT-43783 Fixed
2021-09-02 14:40:15 +03:00
Mikhael Bogdanov 19474ee30f Support large strings in indy-with-constants concatenation
#KT-47917 Fixed
2021-09-01 14:03:56 +00:00
Leonid Startsev 1932546a90 Support instantiation of annotations in JS
#KT-47700 Fixed
2021-09-01 11:13:55 +00:00
Alexander Udalov cc52832943 JVM IR: fix incorrect type of IrCheckNotNull intrinsic
It is not correct to assume that arg0 has been generated to have the
same IrType as the whole expression.

The reason it only backfired in throwing exceptions probably has to do
with the fact that visitThrow might be the only place in
ExpressionCodegen right now which uses the IrType from PromisedValue to
make a decision on whether to generate checkcast.

It seems suspicious that ExpressionCodegen.visitFieldAccess/visitCall
return PromisedValue whose IrType mentions type parameters which are
declared outside of the call site, but that should probably be
investigated separately.

 #KT-48440 Fixed
2021-08-31 18:45:23 +02:00
Dmitry Petrov 1c1b9547c1 JVM_IR KT-48435 use Java-like counter loop when possible 2021-08-31 16:39:25 +03:00
Alexander Udalov 04c5bbdcf8 JVM IR: change generation scheme of property $delegate methods
Generate $delegate method as instance method in
PropertyReferenceDelegationLowering, and remove dispatch receiver later
in MakePropertyDelegateMethodsStatic. The method needs to be static to
be non-overridable (see delegateMethodIsNonOverridable.kt), and public
to be accessible in reflection.

Otherwise we generated incorrect IR where a static function accessed an
instance field of the containing class, which failed in multiple places
including LocalDeclarationsLowering.

 #KT-48350 Fixed
2021-08-31 14:07:22 +02:00
pyos 5e4f022c59 JVM_IR: use nullability when boxing/unboxing inline class types
Given inline class V(Any?), a coercion from (Object, V) to (Object, V?)
is boxing.

In theory, the same issue in the old backend can be fixed by making
`KotlinTypeMapper.mapUnderlyingTypeOfInlineClassType` use
`computeExpandedTypeForInlineClass`, but for some reason this breaks a
lot of stuff.

 #KT-48430 Fixed
2021-08-31 12:05:34 +03:00
Ilmir Usmanov 1f8dd45c2b Remove experimental coroutines support. Part 2 2021-08-30 14:21:57 +03:00
Dmitry Petrov c2b575505a JVM_IR KT-48432 fix overflow in const-bound range optimization 2021-08-27 16:42:52 +03:00
Mads Ager 8dee3c1ca0 [JVM] Do not unbox when local variable initialized with null.
This is already the case for straightline code such as

```
inline fun <R> f(size: Int, block: () -> R): R {
    var result: R
    result = block()
    return result
}
```

However, if the local variable introduction happens at a merge
point as in the following example, we allow the unboxing but
only do it halfway. The initialization of the local is still
done with a null value.

```
inline fun <R> f(size: Int, block: () -> R): R {
    var result: R
    while (true) {
        result = block()
        if (size == 0) break
    }
    return result
}
```

This change disallows unboxing for this move complicated
case as well by bailing out if a local use is with a
TaintedBoxedValue (merge of Object and Integer).

^KT-48394 Fixed.
2021-08-26 15:14:02 +03:00
Ilya Goncharov 0ca9e08c11 [JS IR] Add test with fail with vararg call in suspend
^KT-48344 fixed
2021-08-26 08:52:34 +00:00
Ilya Goncharov 4179d078ca [JS IR] Add test on call of suspend super type 2021-08-26 08:50:14 +00:00
Alexander Udalov 8d4f26cf84 IR: use inlineClassRepresentation in getInlineClassUnderlyingType
Looking for the primary constructor manually doesn't work if it's
private in the other module on JVM, because private declarations are
skipped in IrLazyClass.
2021-08-24 12:28:31 +02:00
pyos a15a5aa429 JVM_IR: generate instance fields even when reification is needed
The inliner supports that, we just need to generate the reification
markers on GETFIELD to instance fields.
2021-08-23 14:27:51 +02:00
Ilmir Usmanov c01c356817 Do not extend LVT ranges during inplace arguments inlining
Otherwise, R8 does not transform kotlin-reflect, failing bootstrap.
Leaving end label the same is safe, since we do not remove labels during
transformation.
2021-08-23 11:51:30 +00:00
Victor Petukhov bf1e68a53f Resolve calls using the builder inference despite the presence of the annotation if there are uninferred type variables
^KT-48194 Fixed
2021-08-20 01:28:11 +03:00
Victor Petukhov 55811c8851 Don't use builder inference if possible
The builder inference is running only if there are still uninferred type variables

^KT-48193 Fixed
2021-08-20 01:28:10 +03:00
pyos d3de0109ca Add tests for KT-48180 2021-08-18 18:39:33 +02:00
Mikhael Bogdanov a5e59e09ee Copy methods for lambdas to DefaultImpls without receiver transformation
#KT-48230 Fixed
2021-08-18 09:58:27 +00:00
pyos 6d7eb2bd21 Add test for KT-48230 2021-08-18 09:58:27 +00:00
Ilmir Usmanov 486c6b3c15 Remove obsolete experimental coroutines support
in compiler.
2021-08-13 22:31:30 +02:00
Alexander Udalov 0fb398d45e Build: enable Werror for almost all compileKotlin tasks
The only exception at this point is :kotlin-gradle-plugin:compileKotlin.
2021-08-13 17:46:57 +02:00
Dmitry Petrov 15c41b2610 JVM_IR KT-47984 add test for argument reordering 2021-08-13 18:08:52 +03:00