Commit Graph

109383 Commits

Author SHA1 Message Date
Kirill Rakhman cba65d7186 [Test gen] Reduce string copying 2024-02-28 15:20:30 +00:00
Kirill Rakhman 7ca6624af4 [Test gen] Reduce Kotlin reflection usage 2024-02-28 15:20:30 +00:00
Dmitriy Novozhilov 6cfe81de50 [FIR] Properly reports about conflicts in MPP setup
Checker for conflicting declarations will now check for the following
  scenarios too
- two expect declarations in different modules
- actual and non-expect declarations in different modules

^KT-63826 Fixed
2024-02-28 13:45:29 +00:00
Dmitriy Novozhilov 2febc807a1 Revert "[FIR2IR] Remove non-existent accessors from property references on Java fields"
This reverts commit 1e388ad7dc.
2024-02-28 13:26:25 +00:00
Dmitriy Novozhilov d899618f9a Advance bootstrap to 2.0.0-dev-17175 2024-02-28 13:02:11 +00:00
Roman Efremov 18176cb5ee Fix crash when compiler plugin generates top-level private suspend
...function.

^KT-61993 Fixed
2024-02-28 12:25:12 +00:00
Roman Efremov b2a2d32d70 [Test] Reproduce crash when plugin generates top-level private suspend
...function.

^KT-61993
2024-02-28 12:25:12 +00:00
Timofey Solonin bba39dd4fe Add an IT for publication of multiplatform resources in Android target
^KT-65540
2024-02-28 10:37:16 +00:00
Timofey Solonin a2989a3711 Publish multiplatform resources and assets for Android target
^KT-65540
2024-02-28 10:37:16 +00:00
Timofey Solonin 43a4fd5ddf Add an API for KotlinAndroidTarget to publish assets
^KT-65540
2024-02-28 10:37:16 +00:00
Timofey Solonin bf6a82fdc1 Bump AGP compile-time dependency to 7.3.0
In this version addGeneratedSourceDirectory API used available to
publish assets in the aar

^KT-65540
2024-02-28 10:37:16 +00:00
Artem Olkov ff5098d716 Refactor sir from psi builder, in order to check transatability of psi element
Merge-request: KT-MR-14555
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2024-02-28 10:32:11 +00:00
Alexander Udalov 9d1d01d1eb jvm-abi-gen: Minor, deduplicate newField/newMethod calls 2024-02-28 10:19:45 +00:00
Vladimir Tagakov d2792533b8 jvm-abi-gen: Remove internal declarations from ABI
#KT-65690 Fixed
2024-02-28 10:19:45 +00:00
Alexander Udalov ebc2a18da5 IR: do not build fake overrides for code fragments
Code fragment is a class that extends from Any, so technically it can
have fake overrides for equals/hashCode/toString. However, K1 does not
build them, and it's already checked in IR text tests in
`analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments`,
so don't build them in K2 as well. Also, the code in
`KtFirCompilerFacility.createJvmIrCodegenFactory` looks for a single
function defined in the code fragment.
2024-02-28 09:32:34 +00:00
Alexander Udalov b88ce50500 IR: do not visit function body at all in IrFakeOverrideBuilder
This change fixes FIR tests with JVM IR serialization enabled, some of
which start to fail after enabling IR fake override builder mode by
default.

In this case, even accessing the function body with `IrFunction.body`
does not work in some cases because it tries to load IR and ends up with
unbound symbols for some reason (most likely related to KT-63509). So we
avoid accessing the body by copying the `IrFunction.acceptChildren`
implementation and removing the `body.accept` call.

Using deep-copy to create a fake override is questionable here, but it
will need to be refactored separately.
2024-02-28 09:32:34 +00:00
Wojciech Litewka 0b78cf9aa3 [IR] Autogenerate IrTypeAliasImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 1008fa566f [IR] Autogenerate IrModuleFragmentImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 97e2dab9f0 [IR] Autogenerate IrScriptImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka f30f2216cc [IR] Autogenerate IrEnumEntryImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 401113cc27 [IR] Autogenerate IrClassImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka fde3ea14ae [IR] Autogenerate IrVariableImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 222268b6f9 [IR] Autogenerate IrValueParameterImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka e23aff7256 [IR] Autogenerate IrTypeParameterImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 6de200dea1 [IR] Autogenerate IrPropertyWithLateBindingImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 5aedc24f00 [IR] Autogenerate IrLocalDelegatedProperty
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 87f5d3901c [IR] Autogenerate IrPropertyImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 541a0f4bec [IR] Autogenerate IrFieldImpl
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka f2af1bc04a [IR] Autogenerate IrConstructorImpl
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka d97681f2a9 [IR] Autogenerate IrFunctionWithLateBindingImpl
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka d5b78c0cdc [IR] Autogenerate IrFunctionImpl
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 518aee693e [IR] Autogenerate IrAnonymousInitializerImpl
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 6cdddaacb0 [IR] Final preparation to autogenerate IR declaration implementations
IR expressions are left out for now, because unlike declarations,
which are mostly created via IrFactory, expressions' constructors are
widely used, and it's hard to replicate the exact signatures of those
constructors with the tree generator.

Therefore, some other approach is expected to be taken when generating
them in the future.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 451c51c849 [IR] Temporarily move to-be-autogenerated files under gen directory
so that git recognizes them as moved.
2024-02-28 09:29:56 +00:00
Wojciech Litewka 4d9d1974ec [IR generator] Better support for fields' default value in base classes
- Allows using those with the incoming IR implementation printer.
- Moves the logic to common tree generator, so other trees can specify
default values in base classes as well, if needed.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 288351d733 [tree generator] Rename AbstractImplementation.fieldsWith(out)Default
to better describe their intended usage, see also next commit.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 6fadc51856 [tree generator] Minor: pass model inside ImplementationConfigurator
Needed for config across many elements in subsequent commits.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka e737320d01 [FIR generator] Specify Field.isChild in base tree configuration
instead of inside implementation configuration.

Whether a field is a child element is a core concept of the tree,
not a matter of particular implementation class.

It is especially visible in IR tree, where the base classes implement the
acceptChildren method. It will also be more relevant in the future.

This also aligns the config style between IR and FIR tree generators.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 6d5b07ebe9 [tree generator] Add AbstractElement#subElements, drop semantic leaves
The notion of IR element class being 'semantically leaf' is rather hacky.
Instead, now we only distinguish whether an element has its
implementation class, which is what this notion was actually trying to
represent.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 7e01fc5906 [IR] Drop "leaf/non-leaf" comment from generated IR classes
As it is not much useful, and the current wording does not represent its
intended wording.
2024-02-28 09:29:56 +00:00
Wojciech Litewka d904ce0939 [tree generator] Merge default and custom implementations 2024-02-28 09:29:56 +00:00
Wojciech Litewka 665bd5153a [tree generator] Make defaultEmptyList#withGetter false by default
to align it with other default* methods.

This will be helpful for configuring IR implementation,
where there are many such empty lists.
2024-02-28 09:29:56 +00:00
Wojciech Litewka 5d7a5245ff [tree generator] Extract printPropertyDeclaration util
analogous to printFunctionDeclaration.

This decouples the printing logic from handling IR elements' fields,
and makes it easier to directly print arbitrary fields.
2024-02-28 09:29:56 +00:00
Wojciech Litewka 92ff782815 [IR] Call IR declaration constructors with named parameters
When those classes become auto-generated, the order of constructor
parameters will differ.
This commit ensures they will still be resolved correctly.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka a005f2e75d [IR] Make IrFunction.returnType lateinit
to replace custom logic that would throw in case of IrUninitialized.

This is to remove custom logic from those classes,
so that source generator will be able to generate
them in a straight-forward way.
Otherwise, it would need to be thought about those special cases, which
is better to be avoided.

There are two consequences:
- The error message will be more generic, and won't contain reference
to the element.
- It becomes possible to reassign returnType
property with IrUninitializedType
and read it afterward.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 92c56d0535 [IR] Remove custom error messages for missing IrDeclaration.parent
This is to remove custom logic from those classes,
so that source generator will be able to generate
them in a straight-forward way.
Otherwise, it would need to be thought about those special cases, which
is better to be avoided.

It is also a small step for future work,
which likely involves making parent property nullable.

Unfortunately, this change causes a loss of some details from exception
messages.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka f6b2a5915e [IR] Remove some default values from implementation classes' constructors
To make it a bit easier and cleaner to autogenerate them.
Those default values were mostly unused anyway.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 2a5b4ae652 [IR] Remove files parameter from IrModuleFragmentImpl
This commit removes the default parameter in constructor,
as well as custom logic in this class, which would
make it harder for its subsequent auto-generation.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 83bc12949b [IR] Push default values from base to implementation classes
The default value of those properties is a detail that should be handled
 by implementation or builder layer.

 This change will also simplify auto-generating and reasoning about
 generated implementation classes, and allow for potential further
 enhancements like intercepting all mutations.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 5921706a15 [IR generator] Minor: split Model.kt into Element.kt and Field.kt
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00