Commit Graph

8267 Commits

Author SHA1 Message Date
Dmitriy Novozhilov dd94de3a34 [FIR2IR] Properly set statement origin for all parts of += calls
^KT-65649 Fixed
2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov 5c632bc78e [FIR2IR] Don't create f/o symbols on smartcasted Nothing in dispatch receiver
^KT-63525 Fixed
2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov 5b01396a11 [FIR] Carefully process constructors of inner and nested classes in the tower
If there is an expression receiver, we should process constructors only
  of inner classes. Constructors of nested classes can be called only
  on classifier

^KT-65333 Fixed
2024-02-28 08:08:32 +00:00
Artem Kobzar 02a78051aa [PSI2IR] Sync start and end offsets on PSI and FIR for an implicit return inside lambdas 2024-02-27 19:25:24 +00:00
Alexander Udalov 5cda3fba12 IR: produce new fake override for each static member
This is an addition to d4278250e6. Apparently we still need to produce
a new fake override for each inherited static member, because otherwise
we would try to determine the most specific return type, maximum
visibility, etc, all of which makes no sense for static members.

 #KT-66152 Fixed
2024-02-27 16:05:52 +00:00
Mikhail Glukhikh 678816f9e8 K1: introduce BUILDER_INFERENCE_STUB_PARAMETER_TYPE to prevent compiler crashes
This diagnostic is reported in rare situations when
StubTypeForBuilderInference is kept as a parameter type
of for loop or lambda. Before this commit, we had in K1
"Could not load module <error module>" from IrLinker instead.

Related to: KT-52757, KT-53109, KT-63841, KT-64066
#KT-53478 Fixed
2024-02-27 10:25:13 +00:00
Alexander Udalov d4278250e6 IR: never check static members for overridability
#KT-66077 Fixed
2024-02-26 20:38:02 +00:00
Dmitriy Novozhilov 6a94a3331f [FIR] Don't create synthetic property if getter and property came from the same class
Usually we create synthetic property in java class if there is a property
  from the base kotlin class and getter/setter with a corresponding name
  in the declared scope or one of supertype scopes. But there is a case,
  where the same supertype contains both property and getter:
```
// FILE: Base.kt
open class Base {
    open val b = "O"

    @JvmName("getBJava")
    fun getB() : String = "K"
}

// FILE: Derived.java
public class Derived extends Base {}
```

In this case we shouldn't create synthetic property, because `getB()`
  function is invisible for `Derived` class

^KT-66020 Fixed
2024-02-26 17:44:30 +00:00
Vladimir Sukharev febac0dd5f [Tests] Migrate backend-independent tests from native to compiler/testData.
^KT-65979
2024-02-26 13:38:49 +00:00
Dmitriy Novozhilov 9857bdc891 [FIR2IR] Unwrap typealiases during applying of suspend conversion
^KT-65002 Fixed
2024-02-26 08:56:24 +00:00
Nikita Nazarov 407448d8e3 [JVM] Implement new inlined variable naming format
^KT-65478 fixed
2024-02-23 23:59:13 +01:00
Ilya Chernikov eab5164993 Scripting: fix script lowering in case of out of order declarations
The problem was that in K2 for some top-level script declarations we
need to add a dispatch receiver parameter (because frontend do not
assign any, but representing script as a class requires it to be the
script class) and at the same time, calls to these declarations rely on
properly set dispatch receiver parameter.
The simplest solution found is to have an additional traversal on the
relevan top-level declarations and assigning the dispatch receiver,
before running the main transformation.

#KT-64502 fixed
2024-02-23 22:03:44 +00:00
Dmitriy Novozhilov fb4b14e250 [FIR2IR] Part 4. Cleanup Fir2IrClassifierStorage API (enum entries)
^KT-65937 Fixed
2024-02-23 16:26:05 +00:00
Dmitriy Novozhilov 3bf0a11ced [Test] Reproduce KT-65937 2024-02-23 16:26:05 +00:00
Ivan Kochurkin 1e388ad7dc [FIR2IR] Remove non-existent accessors from property references on Java fields
Rename `MissingFieldInJavaClass.kt` to `FieldsFromJavaClass.kt` to correspond its content

^KT-65722 Fixed
2024-02-23 11:22:44 +00:00
Alexander Udalov 555b35d894 Minor, add regression test for KT-62788 2024-02-23 09:02:03 +00:00
Ilya Gorbunov 86d5e83f4b [stdlib] Remove bootstrap implementation of enumEntriesIntrinsic
It should have been already implemented as intrinsic in all backends.

Do not test enumEntries intrinsic in the old JVM BE.

KT-53154

Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
2024-02-23 05:50:37 +00:00
Dmitriy Novozhilov e431a96897 [FIR2IR] Properly calculate overridden functions for lazy fake overrides
For detailed explanation see the comment to `computeBaseSymbolsWithContainingClass`
  function in `FakeOverrideGenerator.kt`

^KT-65592
2024-02-22 15:56:57 +00:00
Vladimir Sukharev 1761c8eb25 [K/N][Tests] Ignore test sourceBinarySource.kt for per-file-caches on Linux
^KT-65669
2024-02-22 14:57:15 +00:00
Igor Yakovlev eea3c3624c [WasmJs] Generate a wrapper that run in Deno
Fixed #KT-65713
2024-02-22 14:45:09 +00:00
vladislav.grechko f32367d2c2 Fix IrFunction.isEmptyArray implementation
The previous one was incorrect for K1 since parent of top-level function
is `IrClass`, not `IrPackageFragment`.

The change is non-functional, K1 still worked correctly, but had to do
some extra work when inlining `emptyArray` calls and produces less
performant bytecode.
2024-02-22 07:32:36 +00:00
vladislav.grechko 224a4e1e3c Do not exclude codegen/box/script directory from JVM ABI tests 2024-02-22 07:32:35 +00:00
Nikolay Lunyak ae0d1201c5 [FIR] Add a blackbox test for failure #3 of KT-65972
^KT-65972
2024-02-21 20:24:18 +00:00
Nikolay Lunyak 39cbe3fb35 [FIR] Add a blackbox test for failure #2 of KT-65972
^KT-65972
2024-02-21 20:24:17 +00:00
Nikolay Lunyak e929ed8f8c [FIR] Add a blackbox test for KT-65972 2024-02-21 20:24:15 +00:00
Dmitriy Novozhilov bd66b96f8a [FIR] Set EnhancedNullability attribute for former flexible types
In some cases we transform flexible type into non-flexible during
  enhancement, but don't add `@EnhancedNullability` attribute to them,
  which breaks consistency with K1 on IR level

This commit fixes it

^KT-65302
2024-02-21 12:04:11 +00:00
Ilya Chernikov 10dbe73828 K2 Scripting: report error on attempt to use scripts in common roots
#KT-65967 fixed
2024-02-21 07:47:15 +00:00
Ilya Chernikov 75da89824c Scripting: add a test using synthetic properties in scripts
related to #KT-54770
2024-02-21 07:47:15 +00:00
Ilya Gorbunov c2e28149e6 [stdlib] Enable link-via-signatures to workaround KT-62798 2024-02-20 19:59:16 +00:00
Kirill Rakhman 365973f03a [Tests] Convert diagnostics test for #KT-65555 to box test 2024-02-20 14:10:37 +00:00
Kirill Rakhman 634f0c2ae7 [FIR2IR] Unwrap named arguments for suspend conversion
#KT-65878 Fixed
2024-02-20 12:52:08 +00:00
Kirill Rakhman b054a4481d [FIR2IR] Fix cast insertion in SAM conversion with suspend conversion
#KT-65878
#KT-62855
2024-02-20 12:52:08 +00:00
Dmitriy Novozhilov 3469e3b198 [FIR2IR] Create delegated field for delegation to var property
^KT-65920 Fixed
2024-02-20 09:46:17 +00:00
Kirill Rakhman 26fae9e83a [FIR] Allow declarations to override parts of non-trivial intersection
A class can inherit two declarations that are compatible from the
overridability standpoint and are therefore combined to a non-trivial
intersection.
At the same time, the class can declare a member declaration that
only overrides one of the intersection's members.
In this case, we break up the intersection and only add the overridden
parts to the declared member's direct overridden list.

If the class doesn't override the intersection, it exists as
intersection override, like before.

#KT-65487 Fixed
2024-02-20 09:02:39 +00:00
vladislav.grechko d753a22fc6 [FIR] Handle expect declarations in JVM backend
1. Do not generate bytecode for expect declarations

2. Serialize @OptionalExpectation annotations into .kotlin_module file

^KT-62931: Fixed
2024-02-19 18:17:37 +00:00
vladislav.grechko b74501ee93 Compare module metadata in JVM ABI consistency tests 2024-02-19 18:17:37 +00:00
Ilya Goncharov abb5f55087 [Wasm] Use static import for wasm imports
^KT-65777 fixed
2024-02-19 10:01:10 +00:00
Pavel Kunyavskiy e6f4d6e6fa [Tests] Use stable order for ir/kotlinLike dumps
^KT-65406
2024-02-16 10:19:38 +00:00
Pavel Punegov 8dcb763eca [K/N][test] Reset state in StateMachineChecker before the test
boxInline tests for suspend use StateMachineChecker and share the state
if compiled and run together. The single value accessed from all tests.
It is enough to reset state before the test is run.
2024-02-15 18:07:25 +00:00
Nikolay Lunyak 3b5fff5473 [FIR] Don't copy VP default values for fake overrides
In general, overrides should not
contain default values, and it's
better to make fake overrides be close
to proper overrides as much as
possible. It will be important when
we begin running `FirOverrideChecker`
for fake overrides.

^KT-63879 Fixed
^KT-65534
2024-02-15 16:10:13 +00:00
Dmitriy Novozhilov 84f0f6e099 [FIR] Resolve statuses of supertypes for all non-source classes
Previously we forced computation only for java and precompiled classes,
  assuming, that binary class can not extend source class, but it's not
  true in two cases:
1. Classpath substitution: class with same name declared in library and
   the source (more rare case)
2. Metadata compilation: depends-on dependcies are passed in binary
   format, so `expect class` may be a binary one and corresponding
   `actual class` may be a source. So if some class in `common` module
   extend this expect class, actual class will be substituted instead of it

^KT-65669 Fixed
2024-02-15 12:18:48 +00:00
Vladimir Sukharev bf0150108d [K/N][Tests] Move filecheck and cinterop tests to /native/
^KT-61259
2024-02-14 23:36:34 +00:00
Alexander Udalov 41ef3da5ff Tests: add regression test for KT-63448 2024-02-14 21:44:42 +00:00
Pavel Kunyavskiy 6e8a7d4662 [ObjCInterop] Implement @ObjCSignatureOverride
This annotation leads to conflicting overloads error supression,
in case where several function with the same argument types,
but different argument names are inherited from ObjC class.

We need to implement it in both K1 and K2 to make the IDE experience
better.
But the annotation itself wouldn't be available in K1.

    ^KT-61323
2024-02-14 11:44:01 +00:00
Kirill Rakhman e88865e4c7 [FIR] Fix methods with erased parameters missing from raw collection scope
#KT-65448 Fixed
2024-02-14 09:55:24 +00:00
Alexander Udalov b72effab98 IR: remove isFromJava check from isOverridableMemberOrAccessor
This is needed because in case a static member is inherited via a Kotlin
class (class C in the newly added test), its origin becomes
FAKE_OVERRIDE which is technically not Java anymore. After this change,
we'll build fake overrides for static members from superclasses
regardless of whether they come from Java or Kotlin.

Also, move the previous logic of
isOverridableFunction/isOverridableProperty to the only call site at
IdSignatureFactory.

 #KT-65589 Fixed
2024-02-13 21:03:33 +00:00
Sergej Jaskiewicz 80240198d2 [FIR2IR] Coerce to Unit for last statement in Unit-typed IrBlocks
^KT-59781 Fixed
2024-02-12 21:16:41 +00:00
Sergej Jaskiewicz eec10f3f2c [test] Reproduce KT-59781 2024-02-12 21:16:41 +00:00
Pavel Kunyavskiy 9532172a22 [Fir2IR] Don't use FIR f/o builder when IR f/o builder is enabled
Before this commit, fir f/o builder was inconsistently
disabled in some places, while it should work only for lazy declarations

Attempt to use it for non-lazy declarations, without maintaining
invariant, that it would also be used for super classes
led to unpredictable results.

This commit introduces opt-in, and marks all related API to three types
* Propagate error to user
* Fine to use, as it's checked if ir f/o builder is enabled
* Fine to use, as it is definitely a lazy class.

Several cases of missing checks was fixed.

^KT-65707
2024-02-12 15:02:50 +00:00
Vladimir Sukharev a0ffea48a2 [K/N][Tests] Use runProcess in doFileCheck
^KT-61259
2024-02-11 21:30:03 +00:00