Commit Graph

47819 Commits

Author SHA1 Message Date
Wojciech Litewka 4d2aadb925 [IR] Remove old @IDEAPluginsCompatibilityAPI constructor 2024-02-29 11:22:57 +00:00
Alexander Udalov 939a74add3 CLI: improve error message for -Xjdk-release=1.6/1.7
#KT-66174 Fixed
2024-02-29 11:05:20 +00:00
Alexander Udalov 5f261d3ad0 CLI: fix "unknown JVM target version" error message
Do not list 1.6 as supported because it was removed in KT-45165.

 #KT-66175 Fixed
2024-02-29 11:05:20 +00:00
Alexander Udalov dfd9aabf8e JVM: update test data after enabling IR fake override builder
#KT-61514 Fixed
2024-02-29 10:14:31 +00:00
Alexander Udalov f98a22e8e4 Fir2Ir: enable IR-based fake override builder
Invert the logic of IR/FIR2IR-based generators: change the CLI argument
to -Xuse-fir-fake-override-builder, test directive to
USE_FIR_BASED_FAKE_OVERRIDE_GENERATOR, etc.

The changes in test data caused by using IR fake override builder by
default are in the subsequent commit.

 #KT-61514
2024-02-29 10:14:31 +00:00
Mikhail Glukhikh 09db7dbd22 K2: add tests to confirm current behavior of KT-65679 examples 2024-02-29 10:02:06 +00:00
Artem Kobzar 4f4c98ec73 [K/JS] Allow parameter properties inside external declarations ^KT-65965 Fixed 2024-02-29 09:46:59 +00:00
Kirill Rakhman 5e83350576 [Infrastructure] Assert dumps don't exist without directive
#KT-58697 Fixed
2024-02-29 08:36:16 +00:00
Jaebaek Seo a17ad6bc55 Fix K2 CodeGen annotation parameter resolution failure
When we have parameters of annotation like
```
// FILE: Anno.kt
package p3

@Target(AnnotationTarget.FUNCTION)
annotation class Anno(vararg val x: String)

// FILE: main.kt
import p3.Anno

@Anno("A", "B")
fun foo(): Int = 10
```
the K2 CodeGen causes an exception reporting the unresolved type
reference. A lazy resolution call fixes the issue.

In addition, FIR for the value parameter to IR conversion fails because
`Fir2IrLazyProperty` for the value parameter tries to resolve the
initializer before creating the `IrParameterSymbol`. When it checks the
`localStorage`, it reports an error for the missing `IrParameterSymbol`.
This commit adds `IrParameterSymbol` before resolving the initializer.

^KT-65099 Fixed
2024-02-29 06:44:05 +00:00
Yahor Berdnikau 2f70478e67 [Gradle] Deprecate kotlinOptions DSL in KotlinCompile DSL
^KT-63419 In Progress
2024-02-28 21:20:18 +00:00
Sonya Valchuk 4c8febf10d FIR DFA: slightly refactor smart cast state tracking
Instead of always looking up smart casts on `lastNode` and separately
tracking the receiver state, simply track which flow the smart casts
belong to right now. This tracked flow is auto-advanced when new
`lastNode`s are created, but can be manually rolled back for things like
KT-63709.
2024-02-28 18:36:08 +00:00
Nikita Bobko 052baf1b04 Revert "[FIR] Enable ForbidInferringTypeVariablesIntoEmptyIntersection in 2.0"
^KT-66196 Fixed
Keep it a warning in 2.0

This reverts commit be232d3e6f.
2024-02-28 18:08:11 +00:00
Artem Kobzar 6a2e785abd [K/JS, TEST] Enable TS export tests for FIR ^KT-64421 Fixed 2024-02-28 16:52:27 +00:00
Igor Yakovlev a5ef668e3c [Wasm] Boolean boxed instances are the same
Fixed #KT-65411
2024-02-28 15:23:21 +00:00
Kirill Rakhman 5bbec23123 [Test gen] Consolidate file reads for checking directives 2024-02-28 15:20:30 +00:00
Kirill Rakhman 3c23319f70 [Test gen] Remove duplicate checks if file is equal to some string 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
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
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 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 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