Commit Graph

7804 Commits

Author SHA1 Message Date
Alexander Udalov 47c48efa33 JVM IR: do not generate extension receiver parameter as ACC_MANDATED
Otherwise Java reflection is not able to load its type as a
parameterized type.

 #KT-40857 Fixed
2023-03-06 20:57:52 +00:00
Kirill Rakhman b80970b09f [FIR] Fix references to generic synthetic properties
When synthetic properties are built from a substitution override,
set originalForSubstitutionOverride, too.

^KT-56251 Fixed
2023-03-06 09:45:02 +00:00
vladislav.grechko 7033d78641 Fix SAM conversion generation condition
Remove check if array is passed to vararg parameter as it's not
relevant anymore and leads to ^KT-51821.

^KT-51821: Fixed
2023-03-04 12:53:48 +00:00
Sergej Jaskiewicz f40278c036 An option to allow out-of-scope type parameters in IrManglerComputer
In the lowered IR there are often references to type parameters whose
containers are not in the current scope. This is incorrect semantically,
but it works in practice due to erasure, so when the mangler is used on
the lowered IR, we don't want to crash the compiler.
2023-03-03 22:08:57 +00:00
Svyatoslav Kuzmich 01fcc84d73 [Wasm] Refactor callingWasmDirectly.kt test from @JsFun to @WasmImport 2023-03-03 19:39:11 +00:00
Svyatoslav Kuzmich 7175b9f31c [Wasm] Migrate usages of @JsFun to js("code") 2023-03-03 19:39:10 +00:00
Svyatoslav Kuzmich 71e6b19760 [Wasm] Support restricted version of js("code") (KT-56955) 2023-03-03 19:39:09 +00:00
Svyatoslav Kuzmich 3c35328c09 [Wasm] Fix overriding external fun with default parameters (Fix KT-56976) 2023-03-03 12:33:53 +00:00
Kirill Rakhman 1f0e6321b0 [FIR2IR] Use companion as bound receiver if expected type requires it
A::foo is preferably resolved as an unbound reference to A.foo, however
if A.Companion is a subtype of A and the expected type has one fewer
parameter than the type of the unbound reference, generate a bound
reference with the companion as receiver.

^KT-56519 Fixed
2023-03-02 10:55:46 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00
Kirill Rakhman 3b9724d20e [FIR] Desugar increment/decrement in body resolve phase
The expression needs to be resolved first to determine if there is a
receiver that needs to be extracted to a temporary variable. Also, the
special case for prefix increment/decrement on local variable without
delegates requires resolution to check if the variable is local.

^KT-56771 Fixed
^KT-56659 Fixed
2023-03-02 10:19:57 +00:00
Kirill Rakhman d00513599b [FIR2IR] Expand typealias in callable reference receiver generation
^KT-56750 Fixed
2023-03-02 08:20:04 +00:00
Ivan Kochurkin ee53c5780f [FIR] Extract K2 MPP test data to the separated directory 2023-03-01 22:10:11 +00:00
Ivan Kochurkin f1fef62f76 [FIR] Consider default values from expect function during serialization
It's not possible to unmute some tests for K2 because it causes testData structure changing

If change testData, NATIVE doesn't work even with `IGNORE_BACKEND`
2023-03-01 22:10:07 +00:00
Ivan Kochurkin d87619e06e [FIR & IR] Support of default values for arguments in expect functions
Add FirActualDeclarationChecker that checks expect/actual return types

^KT-56331 Fixed, ^KT-56334 Fixed
2023-03-01 22:10:07 +00:00
Igor Chevdar c038bbde08 [box-tests] Added a reproducer for KT-56965 2023-03-01 08:09:51 +00:00
Kirill Rakhman eee66ab43f [FIR] Remove duplicate annotations from primary ctor params/properties
If an annotation doesn't specify an explicit use-site target,
previously it was added to both, the primary constructor value parameter
and the property in the FIR. Then, in FIR2IR, only the "correct" one was
added to the IR. Move up the deduplication logic into the frontend.

^KT-56177 Fixed
2023-02-28 10:19:17 +00:00
Kirill Rakhman e1c0d2d9c2 [Test] Remove wrong directive 2023-02-28 10:19:15 +00:00
pyos 7420008af9 FIR2IR: load property setter noinline/crossinline flags
#KT-56234 Fixed
2023-02-28 10:07:27 +00:00
Dmitriy Novozhilov e0fa1e64b9 [FIR] Properly setup java parser version for CLI pipeline with light tree
^KT-56549 Fixed
2023-02-28 09:17:41 +00:00
Dmitriy Novozhilov f836d16dc6 [FIR] Don't generate synthetic declarations from java records from binary dependencies
^KT-56548 Fixed
2023-02-28 09:17:40 +00:00
Nikolay Lunyak 72823657c9 [FIR] Assume SafeCallsAreAlwaysNullable is always on 2023-02-27 15:00:30 +00:00
Nikolay Lunyak be5850112a [FIR] KT-56723: Ensure safe access over non-expressions is always Unit
^KT-56723 Fixed
2023-02-27 15:00:30 +00:00
wrongwrong b039f2e574 Fix ArrayStoreException from InlineClassAwareCaller.call
#KT-56650 Fixed
2023-02-27 14:29:51 +01:00
Mikhail Glukhikh f7036aa79c FIR2IR: don't generate default parameters for delegated members
#KT-55465 Fixed
2023-02-27 12:58:27 +00:00
Ilmir Usmanov b3890885c4 JVM: Break infinite loop in finding meaningful instruction
during tail-call optimization.

There can be code, where all next instructions are non-meaningful and
there is a back-edge, for example, while(true){}. Previously, analyzer
incorrectly assumed, that this cannot happen. Now, it keeps track of
visited instructions and says, that there is no meaningful instruction
in such case.
 #KT-56815 Fixed
2023-02-23 17:54:46 +00:00
Igor Chevdar 5d3b61364a Added a test for KT-56500 2023-02-23 15:32:25 +00:00
Alexander Udalov d73d3c46e2 K2 JVM IR: fix access to Java field shadowed by Kotlin property
#KT-56386 Fixed

Co-authored-by: Mikhail Glukhikh <Mikhail.Glukhikh@jetbrains.com>
2023-02-23 12:54:00 +01:00
Alexander Udalov 641d636c45 JVM IR: improve generation of receiver for bound callable references
Trick codegen into generating getfield from the anonymous class instead
of its supertype (e.g. kotlin.jvm.internal.FunctionReference,
PropertyReference or AdaptedFunctionReference). This gets rid of
unnecessary accessors in some cases, and will help in the subsequent
commit that changes logic around access to fields from Java
superclasses.
2023-02-23 12:54:00 +01:00
Alexander Udalov 4ad594a3cd Minor, move tests about Java field and Kotlin property
Because the `fieldRename` directory was originally about cases when
private fields are renamed because of clashes.
2023-02-23 12:54:00 +01:00
Ilmir Usmanov 6be734c27e JVM: Remove inplace arguments before state-machine building
#KT-56258 Fixed
2023-02-22 12:45:03 +00:00
Pavel Mikhailovskii 81746e5aa1 KT-56508 Add a test 2023-02-21 16:22:26 +00:00
Ilmir Usmanov bfa2937fb8 FIR2IR: Do not add fake override if the member is overridden
#KT-56398 Fixed
2023-02-21 17:18:01 +01:00
Denis.Zharkov 0c9fad87c3 K2: Fix deserialization of upper bound of type parameter in nested class
Previously, containingDeclarationSymbol for V was set to the outer class
BaseRoot, so its upper bounds was computed to the ones from TNested
at org.jetbrains.kotlin.fir.resolve.calls.CreateFreshTypeVariableSubstitutorStageKt.getTypeParameterFromExpandedClass

^KT-56706 Fixed
2023-02-21 12:35:34 +00:00
Svyatoslav Scherbina f206ff950c [K2/N] Ignore kt15016.kt test because it fails due to KT-56747 2023-02-21 11:52:06 +00:00
Pavel Mikhailovskii 752ba433cc KT-53846 LT: Copy context receivers to secondary constructors 2023-02-20 18:13:54 +00:00
Ivan Kylchik 477d092bb8 Avoid object's interpretation with nullable type
#KT-56215 Fixed
2023-02-20 15:52:52 +00:00
Denis.Zharkov 05ca001310 FIR2IR: Repeat the K1 behavior: SAM conversion with 'in' projection
It would be more consistently to prohibit the behavior from the unmuted
test (see KT-52428), but it was decided to postpone the breaking change.

Unfortunately, it didn't work to make a test where for computing
star projections we would need to substitute other type parameters
because effectively, it's not allowed to have SAM conversion when
star projections/wildcard is based on a type parameter which bounds
use other type parameters.

^KT-53552 In progress
2023-02-20 14:54:09 +00:00
Dmitriy Novozhilov ae7863518d [Test] Mute tests due to KT-56508 2023-02-20 08:40:33 +00:00
Dmitriy Novozhilov 0d100cf114 [Test] Mute tests due to KT-53846 2023-02-20 08:40:33 +00:00
Dmitriy Novozhilov 49f15a16ce [Test] Mute tests due to KT-56760 2023-02-20 08:40:32 +00:00
Dmitriy Novozhilov 7c84f9a7c2 [Test] Mute test due to KT-56759 2023-02-20 08:40:32 +00:00
Dmitriy Novozhilov 86ee855170 [Test] Mute test due to KT-56756 2023-02-20 08:40:31 +00:00
Dmitriy Novozhilov 30ea4b6b53 [FIR2IR] Adapt IrActualizer to HMPP modules
Previously it collected actual declaration only from platform module
2023-02-17 11:08:51 +00:00
Ilmir Usmanov b262070922 JVM IR: Copy type parameters from outer class to suspendImpl
Previously we copied only type parameters from containing class, but we
need to do that for outer classes as well.
 #KT-55125
2023-02-15 13:43:24 +00:00
Kirill Rakhman 7f8dc56d36 [FIR2IR] Don't generate fake overrides for clashing synthetic properties
If a synthetic prop clashes with a real property (e.g. @JvmField
property from parent Kotlin class), don't generate fake override for the
synthetic property. This fixes a CONFLICTING_INHERITED_JVM_DECLARATIONS
error in a mixed hierarchy.

^KT-56538 Fixed
2023-02-15 10:10:31 +00:00
Denis.Zharkov 33dcbaac16 K2: Change resolution rules of when/if expressions with expected type
When expected type is known, use it as expected type for branch bodies.
While it indeed becomes different from the usual select call resolution,
where expected type is applied only after completion starts,
it helps to support, e.g. callable references resolution just as powerful
as it was in K1.

Also, in some cases where diagnostics have been changed, they become
a bit more helpful since they are reported closer
to the problematic places

cannotCastToFunction.kt test has been removed because it relied
on the case erroneously supported by the hack removed from
the FirCallResolver in this commit.

^KT-45989 Fixed
^KT-55936 Fixed
^KT-56445 Fixed
^KT-54709 Related
^KT-55931 Related
2023-02-15 08:13:46 +00:00
Denis.Zharkov a38040680c K2: Do not use KFunctionN as representation type for adapted references
Beside some corner cases, it's already prohibited in K1 because
adaptation have a bit strange nature
(they don't represent any existing real function exactly)

^KT-55137 Fixed
2023-02-15 08:13:45 +00:00
Dmitriy Novozhilov aef9b129d2 [FIR] Add regression tests for number of issues fixed in K2
List of issues:
KT-4113,  KT-6822,  KT-7389,  KT-17817, KT-20223
KT-21463, KT-24503, KT-24737, KT-24779, KT-24901
KT-27261, KT-28668, KT-30497, KT-30756, KT-36958
KT-37365, KT-37490, KT-38288, KT-41038, KT-41721
KT-42136, KT-42169, KT-42449, KT-42715, KT-43553
KT-43603, KT-43846, KT-43936, KT-46288, KT-46301
KT-47373, KT-47484, KT-47490, KT-47495, KT-47750
KT-47815, KT-47870, KT-48975, KT-49024, KT-49045
KT-50134, KT-50160, KT-50550, KT-51045, KT-51143
KT-51796, KT-52262, KT-52424, KT-52860, KT-52934
KT-53086, KT-53494, KT-53671, KT-53752, KT-53819
KT-54478, KT-54518, KT-54931, KT-54990, KT-55138
KT-55379, KT-55555, KT-56243
2023-02-14 17:08:55 +00:00
Svyatoslav Kuzmich 26c1098a4f [Wasm] Fix inliner issues (KT-56584)
* Fix objects in inline functions and lambdas:
  * Add common lowerings used in K/JS and K/Native
* Fix inline lambda call detection logic in presence of additional casts


Merge-request: KT-MR-8791
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-13 13:14:43 +00:00