7467 Commits

Author SHA1 Message Date
Alexander Udalov 8ad38db2ad JVM IR: do not use JvmMethodParameterKind 2024-03-19 11:12:31 +00:00
Alexander Udalov d9bc714992 JVM IR: remove usages of JvmMethodParameterKind.RECEIVER/CONTEXT_RECEIVER
Also slightly refactor ExpressionCodegen.visitCall.
2024-03-19 11:12:31 +00:00
Wojciech Litewka 6af930fc0e Partially revert "[IR] Hide constructors of implementation classes behind factory functions"
To restore binary compatibility with a compiler plugin used in
one of user projects.

#KT-66636 Fixed
2024-03-18 12:17:52 +00:00
Alexander Udalov 88d159ec65 IR: minor, update the comment about K2 kapt in IrGenerationExtension
K2 kapt does use stub generation in the end after all, but using the
analysis API instead of the IR backend.
2024-03-15 14:32:39 +00:00
Artem Kobzar eb8054ac1e [K/Wasm] Fix object optimization false trigger on non-pure objects ^KT-66471 Fixed 2024-03-14 17:12:45 +00:00
Wojciech Litewka fae50f1258 [tree generator] Drop deprecated IrPackageFragment.fqName 2024-03-14 17:07:02 +00:00
Wojciech Litewka c1266daf73 [tree generator] Remove AbstractField.defaultValueInBase
It is now unneeded, and future needs should be possible to
be resolved otherwise.
Removing it will simplify further changes to tree generator,
especially for IR.
2024-03-14 17:07:02 +00:00
Wojciech Litewka 6b9a671476 [IR] Minor: Specify IrPackageFragment.fqName literally in IrTree
It is not a real field, only a compatibility facade for another one.
Needed for the next commit.
2024-03-14 17:07:02 +00:00
Wojciech Litewka 5e9c3025bb [IR] Move IrValueDeclaration.isAssignable to extension property
to remove custom logic from generated classes, in particular
to simplify source generator itself.
2024-03-14 17:07:02 +00:00
Ivan Kylchik ddcef6396e [IR] Drop inlineArgumentsWithOriginalOffset from inliner
#KT-66509
2024-03-14 16:00:53 +00:00
Ivan Kylchik 3ee126de74 [IR] Drop alwaysCreateTemporaryVariablesForArguments from inliner
This parameter was always set to be true.

#KT-66509
2024-03-14 16:00:53 +00:00
Nikita Bobko a8275c99a3 [FIR, IR] Check for strict subtypes during actualization
^KT-65775 Fixed
Review: https://jetbrains.team/p/kt/reviews/14906/timeline
2024-03-14 10:53:43 +00:00
Wojciech Litewka b032e647f7 [IR] Move assert in IrSetValueImpl to factory function
#KT-65773 In Progress
2024-03-14 10:41:52 +00:00
Wojciech Litewka 62f546ca0c [IR] Hide constructors of implementation classes behind factory functions
This is a step towards generating those classes. The code generator
won't care about default values in parameters,
and secondly, it will reorder some constructor parameters.
To keep source compatibility, new factory functions are created,
with the same signature as the constructor.
They will resist the change in order of constructor parameters.
Eliminating direct calls to constructors should also make further
refactorings a bit easier.

This change omits classes deriving from IrMemberAccessExpression,
as they are a bit more complicated
and will require separate effort.

#KT-65773 In Progress
2024-03-14 10:41:51 +00:00
Dmitriy Dolovov d43db973d4 API 4 ABI: Rename manifest property: wasm_target -> wasm_targets
^KT-66367
2024-03-14 10:33:00 +00:00
Dmitriy Dolovov 25de42b7eb API 4 ABI: Move const val KLIB_PROPERTY_WASM_TARGET to :kotlin-util-klib
^KT-66367
2024-03-14 10:33:00 +00:00
Sonya Valchuk 0005ba47f8 JVM: extract some helpers for SMAP inlining 2024-03-13 21:31:19 +00:00
Artem Kobzar a38d317824 [K/JS] Use globalThis isntead of this for UMD modules ^KT-45604 Fixed 2024-03-13 13:36:55 +00:00
Artem Kobzar 46dc478c03 [K/Wasm] Reduce debug information for the internal Kotlin functions 2024-03-12 17:37:03 +00:00
Igor Yakovlev b839e2680e [Wasm] Fix equality on Nothing type
Fixed #KT-66104
2024-03-12 14:36:45 +00:00
Igor Yakovlev 6b66195afc [Wasm] Enable PL support for lowerings 2024-03-12 14:36:45 +00:00
Igor Yakovlev ec1ade1293 [Wasm] Allow virtual functions signature clash for PL support 2024-03-12 14:36:45 +00:00
Igor Yakovlev 8851ccc35d [Wasm] Allow incomplete implementations for PL 2024-03-12 14:36:45 +00:00
Igor Yakovlev 1e798a2527 [Wasm] Implement IrLinkageError end enable partial linker
KT-58088
2024-03-12 14:36:45 +00:00
Ivan Kylchik e1180adfbd [Native] Always cast expression to the expected type after inline
Right now, during the process of inlining, the compiler erases types.
Because of that, we can end up with some random type
(for example, `Any`) where the concrete type was
expected (for example, `Int`). Compiler must insert a cast in the
required places.

#KT-66017 Fixed
2024-03-12 08:19:50 +00:00
Igor Yakovlev 84a5a9ff53 Revert "[Wasm] Implement IrLinkageError end enable partial linker"
This reverts commit c0f387dbd1.
2024-03-11 19:27:12 +00:00
Sonya Valchuk e5ad035039 JVM: do not write trivial SMAPs to any classes
Even ones inside inline functions. This was a backwards compatibility
hack for Kotlin 1.4, where the inliner would crash if it attempted to
regenerate an anonymous object with no SMAP; that has been fixed in 1.5,
and ever since then trivial SMAPs could be inferred from line number
markers in methods.

There are three kinds of changes to tests in this commit:

  * Some SMAPs are gone entirely - self-explanatory.

  * Some SMAPs have narrower line ranges - that's because the old SMAP
    had the range for the entire file, while the new one only maps up to
    the last line number used in the class. There should be no
    difference in behavior.

  * Some "source file name" markers are removed in continuation objects
    - continuations don't have any line numbers, so there's no debugging
    information anyway. The actual source information is in the
    containing class.
2024-03-11 17:25:50 +00:00
Igor Yakovlev 8fe5cf2641 [WasmJs] Support catching JS exceptions
Fixed #KT-65660
2024-03-11 14:27:12 +00:00
Alexander Udalov ee506c1369 IR: optimize IrAnnotationContainer.copyAnnotations
Annotation arguments cannot contain declarations, so we can use empty
SymbolRemapper instead of DeepCopySymbolRemapper because the latter
introduces some overhead.

 #KT-66281
2024-03-11 11:49:10 +00:00
Alexander Udalov d5c2aa4c0c IR: rename and move deepCopyWithVariables
Rename it to `deepCopyWithoutPatchingParents`, move to
`org.jetbrains.kotlin.ir.util`, make it inline+reified, and extract the
common implementation with `deepCopyWithSymbols` into `deepCopyImpl`.
2024-03-11 11:49:10 +00:00
Alexander Udalov 1d38c01afc IR: remove some usages of deepCopyWithVariables
At this point, `deepCopyWithVariables` is the same as
`deepCopyWithSymbols` except that the former doesn't call
`patchDeclarationParents`, which most likely produces incorrect IR in
some call sites.
2024-03-11 11:49:10 +00:00
Alexander Udalov e7e8cba1b4 IR: slightly simplify deep copy interface
Do not pass TypeRemapper explicitly unless an instance of something
other than DeepCopyTypeRemapper is required.
2024-03-11 11:49:10 +00:00
Alexander Udalov d659b76de5 IR: remove usages of SymbolRenamer
Its only implementation was DEFAULT so now it's inlined.
2024-03-11 11:49:10 +00:00
Wojciech Litewka be4e81fbce [IR] Avoid subclassing IrGetValue in FunctionInlining
to avoid custom IrElement implementations.

#KT-65773 In Progress
2024-03-11 11:35:48 +00:00
Wojciech Litewka 747b69c6c0 [IR] Avoid subclassing IrFileImpl
to avoid custom IrElement implementations.

#KT-65773 In Progress
2024-03-11 11:35:48 +00:00
Wojciech Litewka 1c17219a7b [IR] Mark IrConstructorCall as AnnotationMarker
IrConstructorCall is already used to represent both regular constructor
call and annotations.
Implementing AnnotationMarker avoids 'casting' it to this type later on
 in IrTypeSystemContext, which was done with
 a new IrElement implementation. We'd like to
 avoid such implementations, e.g. as so to make the IR hierarchy sealed.

#KT-65773 In Progress
2024-03-11 11:35:48 +00:00
Wojciech Litewka e9005e4fed [IR] Initialize IrFunction.returnType eagerly, when possible 2024-03-11 09:07:54 +00:00
Wojciech Litewka 392fa8f9bd [IR] Drop ReturnTypeIsNotInitializedException
It was unused since commit a005f2e75d.
2024-03-11 09:07:54 +00:00
Wojciech Litewka a53ba8a47b [IR] Drop IrUninitializedType
#KT-66053 Fixed
2024-03-11 09:07:54 +00:00
Wojciech Litewka d1e8016ab2 [IR] Pass null instead of IrUninitializedType to IrFactory
#KT-66053 In progress
2024-03-11 09:07:54 +00:00
Igor Yakovlev 324d079111 [WasmJs] Prohibit external classes to be a storage of an associated objects
Fix #KT-65355
2024-03-09 10:40:46 +01:00
Igor Yakovlev 6930fc8fed [WasmJs] Add support for external class reflection
Fix #KT-64890
2024-03-09 10:40:46 +01:00
Pavel Kunyavskiy 1222ef7fac [IrFakeOverrideBuilder] Do not compute signatures in Fir2IR
No one need them, while it requires significant time usage

^KT-66281
^KT-66441 Fixed
2024-03-08 21:36:59 +00:00
Alexander Udalov df9d59851d IR: do not use SymbolRemapper in FakeOverrideCopier
It was only used to keep track of mappings from old type/value
parameters to new. We can do it manually instead of inheriting from
DeepCopySymbolRemapper, because the latter does more work than needed,
namely it creates 16 hash maps, and traverses the IR tree looking for
any other declarations.

 #KT-66281
2024-03-07 20:04:38 +00:00
Alexander Udalov 79a224cc0f IR: remove patchDeclarationParents in FakeOverrideCopier
#KT-66281
2024-03-07 20:04:38 +00:00
Alexander Udalov 41a8b02202 IR: do not use DeepCopyIrTreeWithSymbols in FakeOverrideCopier
#KT-66281
2024-03-07 20:04:38 +00:00
Igor Yakovlev 60d425e2c7 [Wasm] Make specialisations for closured primitive values
Fixed KT-66065
2024-03-07 14:51:02 +00:00
Wojciech Litewka 4eba0075bb [IR] Autogenerate IrFileImpl
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka 2ed0ffd123 [IR] Autogenerate IrExternalPackageFragmentImpl
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka f92670024e [IR] Autogenerate IrErrorDeclarationImpl 2024-03-07 14:32:31 +00:00