Commit Graph

7352 Commits

Author SHA1 Message Date
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
Vladimir Sukharev a582bf22e3 [JS] Try remove ScriptRemoveReceiverLowering
^KT-64958
2024-02-27 19:10:03 +00:00
Ivan Kylchik 6ec75a705e [IR] Store original function in the IrInlinedBlock
In Native and JS, there is a special logic where the compiler saves
a copy of inlined function (see `InlineFunctionsSupport`). This copy
is used in the IR inliner. Because of that, we can't really compare
inlined function with other functions directly. We need to
get `originalFunction` first and save it.
2024-02-27 17:41:33 +00:00
Artem Kobzar 3429cbd321 [K/JS] Support companion objects in external and exported declarations 2024-02-27 16:30:13 +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
Alexander Udalov d4278250e6 IR: never check static members for overridability
#KT-66077 Fixed
2024-02-26 20:38:02 +00:00
Nikita Bobko 4c602585b0 [FIR, IR] Cleanup: drop unused allowClassActualizationWithWiderVisibility & allowTransitiveSupertypesActualization
These flags were used when ExpectActualMatchingContext was reused in K1.
2024-02-25 18:18:55 +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
Pavel Kunyavskiy c991535756 [IRFakeOverrides] Fix accessors visibilities
^KT-65801
2024-02-23 16:35:27 +00:00
Sergej Jaskiewicz acee8da283 [IR] Move coroutine-related helpers to a more appropriate place
The `isBuiltInSuspendCoroutine` and
`isBuiltInSuspendCoroutineUninterceptedOrReturn` helpers are not
inherently related to function inlining.
2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 919abe483a [JVM IR] Move CachedSyntheticDeclarations to backend.common
This will allow us to use this class in KLIB-based backends (KT-64865)
2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 25be39dcc6 [JVM IR] Factor out JVM-specific logic from CachedSyntheticDeclarations
This will allow us to use this class in KLIB-based backends (KT-64865)
2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz d137594c77 [JVM IR] Remove JvmLoweredDeclarationOrigin.SYNTHETIC_MARKER_PARAMETER
There is already a similar origin
`IrDeclarationOrigin.DEFAULT_CONSTRUCTOR_MARKER`
2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 4325803262 [JVM IR] Move SYNTHETIC_ACCESSOR origin to IrDeclarationOrigin.Companion
We want to generate synthetic accessors not only on JVM (KT-64865),
so this is one of the prerequisites.
2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 86587a3bf2 [JVM IR] Add KDocs for methods related to synthetic accessor generation 2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 524dd6794a [JVM IR] Use KDoc in JvmSymbols i/o regular comments when possible 2024-02-23 16:26:55 +00:00
Sergej Jaskiewicz 4f44d32cc2 [JVM IR] Avoid hard-coded checks for coroutine intrinsics
Use existing helpers for that instead, and introduce a new one.
2024-02-23 16:26:55 +00:00
Artem Kobzar be47632609 [K/JS] Optimize logical operators generating 2024-02-23 15:16:31 +00:00
xiaozihan.larryxiao cabd9ad1ec IR: Fix missing source in IrClass with DeepCopyIrTreeWithSymbols
When using DeepCopyIrTreeWithSymbols as class transformer to transform
the IrClass, the source element of IrClass was set to
SourceElement.NO_SOURCE after the transform.

^KT-65343 Fixed
2024-02-22 16:14:38 +00:00
Yahor Berdnikau 6b19b8b9d0 [Repo] Don't use kotlinOptions in repo build scripts
^KT-63419 In Progress
2024-02-22 14:48:10 +00:00
Igor Yakovlev eea3c3624c [WasmJs] Generate a wrapper that run in Deno
Fixed #KT-65713
2024-02-22 14:45:09 +00:00
Ivan Kylchik 96b5d47e68 [IR] Move property needsInlining into InlineFunctionResolver
#KT-64807 Fixed
2024-02-22 09:55:58 +00:00
Ivan Kylchik 9e7ddfa191 [IR] Resolve fake overrides inside getFunctionDeclaration function
#KT-64807
2024-02-22 09:55:58 +00:00
Ivan Kylchik 2bfd1c8f23 [IR] Don't pass originalCallee to the inliner
`originalCallee` is supposed to be the owner of the original call.
It can be a fake override, and in the inliner we are using actual
function with body. Apparently we can just stick with the resolved
function.

#KT-64807
2024-02-22 09:55:58 +00:00
Ivan Kylchik 0258927d33 [IR] Forbid to use shouldExcludeFunctionFromInlining as public API
#KT-64807
2024-02-22 09:55:58 +00:00
Ivan Kylchik f1bc542d74 [IR] Change the return type of getFunctionDeclaration to be nullable
#KT-64807
2024-02-22 09:55:58 +00:00
Ivan Kylchik 91f818ba5a [IR] Transformed InlineFunctionResolver into abstract class
#KT-64807
2024-02-22 09:55:58 +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
Pavel Kunyavskiy 9bbf15c14a [IRFakeOverrides] Do not override modality in expect classes
It was a workaround for case, where expect class don't have
override of abstract function. We don't allow it anymore,
so it can be dropped to make correct modality comparation.

^KT-65971
2024-02-21 22:10:30 +00:00
Pavel Kunyavskiy 21ae6e46b7 [IRFakeOverrides] Also replace special symbols in annotations
This fixes some crashes on red code in diagnostic tests.
Also can be useful in the future, when we would allow things like
enum.name in annotation arguments.

^KT-65971
2024-02-21 22:10:29 +00:00
Artem Kobzar 79cce48aa9 [K/Wasm] Add enum entries comparison optimization 2024-02-21 13:30:12 +00:00
Dmitriy Novozhilov 3c86a4f9df [IR] Consider flexibility of the return type for intersection overrides
^KT-65207 Fixed
2024-02-21 12:04:11 +00:00
Sergej Jaskiewicz be1d8e2894 [IR] Delete deprecated IrFactory methods
We no longer care about binary compatibility wrt the Compose IDE plugin,
see the comment in KTIJ-26314.

^KTIJ-26314 Fixed
2024-02-21 12:03:40 +00:00
Ilya Chernikov 3ce2172c79 Scripting: refactor script to class lowering
no functional changes, only refactoring to simplify further
modifications
2024-02-21 07:47:15 +00:00
Dmitrii Gridin 072d191306 [compiler] replace Enum values() with entries
To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
2024-02-20 17:56:46 +00:00
Johan Bay d50b02adaf [K/N] only include bodies inside inlines for headers
Also renames the "header klib serializaion" option to something
that hopefully slightly better reflects its meaning
^KT-65442
2024-02-20 08:03:08 +00:00
Johan Bay ac8aae5da4 [K/N] keep all declarations inside inline functions
^KT-65442
2024-02-20 08:03:08 +00:00
Johan Bay d4abc30096 [K/N] keep coordinates for inline functions
^KT-65442
2024-02-20 08:03:07 +00:00
Johan Bay 446db595ce [K/N] keep internal members in header klibs
This is also the behavior of jvm-abi-gen and desired to support
friend modules.
^KT-65442
2024-02-20 08:03:07 +00:00
Ivan Kylchik b0171dea63 [IR] Move FunctionInlining into separate module
#KT-64806 Fixed
2024-02-19 20:14:16 +00:00
Ivan Kylchik d0b4ca343b [IR] Move some of extensions from FunctionInlining into IrInlineUtils
#KT-64806
2024-02-19 20:14:16 +00:00
Ivan Kylchik 35b13775d8 [IR] Move declaration of origins for IR inliner into LoweredStatementOrigins
#KT-64806
2024-02-19 20:14:16 +00:00
Ivan Kylchik 6dccb60afe [IR] Add new module to keep all IR inline related code
#KT-64806
2024-02-19 20:14:16 +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
Ilya Goncharov abb5f55087 [Wasm] Use static import for wasm imports
^KT-65777 fixed
2024-02-19 10:01:10 +00:00
Pavel Kunyavskiy 0fa42a9c11 [Tests] More conservative stableOrdered dump
Order of enum entries and fields matters, we can't sort them too.

^KT-65460
2024-02-16 10:19:38 +00:00
Pavel Kunyavskiy d100a07981 [K/N] Move ObjCOverridabilityCondition to proper module
It was not active in diagnostic tests otherwise.
2024-02-14 11:44:01 +00:00
Alexander Udalov 41c6cca689 IR: minor, remove unnecessary isFromJava check
This is an addition to b72effab98. For JVM, this code is not supposed
to affect anything, and for non-JVM, declarations from Java are not
possible.
2024-02-14 11:27:09 +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