Commit Graph

2480 Commits

Author SHA1 Message Date
Nikita Nazarov 407448d8e3 [JVM] Implement new inlined variable naming format
^KT-65478 fixed
2024-02-23 23:59:13 +01: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 e5a6900458 K2 scripting: separate scripts compilation into another session
when scripts are compiled along with other sources.
#KT-65865 fixed
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
Alexander Udalov 90ff8f0e64 JVM: support -Xjdk-release=7/1.7
#KT-59098 Fixed
2024-02-19 11:44:58 +00:00
Alexander Udalov 12f393791b JVM: allow -jvm-target 1.8 with -Xjdk-release=1.6
#KT-59098
2024-02-19 11:44:58 +00:00
Alexander Udalov 1bc08fc5b8 JVM: report error on -Xjdk-release=6 without -jvm-target
#KT-59098
2024-02-19 11:44:58 +00:00
Pavel Mikhailovskii 7ab9e03347 KT-65684: KAPT: (Re)enable fallback to K1 KAPT and make it default
[KAPT] KT-65684 Set languageVersion=1.9 in KaptToolIntegrationTestGenerated

[KAPT] KT-65684 Re-enable a few now-passing tests in Kapt4IT

[KAPT] KT-65684 Fix the logic setting -Xuse-kapt4 flag in Kapt4IT.forceKapt4()

The change is needed to make sure that all the tests have the flag set,
 otherwise some of them would silently switch to the fallback node.
Also disables a few now failing tests.

[KAPT] KT-65684 Revert "KT-64385 Enable K2 KAPT by default"

This reverts commit 7e9d6e60


Merge-request: KT-MR-14291
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-09 12:54:28 +00:00
Evgeniy.Zhelenskiy 7eab4b672d [K1, K2, CLI] Mark whole position range of compiler diagnostics in CLI
#KT-64989
2024-02-08 12:59:31 +00:00
Alexander Udalov 28797a31b4 JVM: refactor JvmDefaultMode, remove/rename some entries
- remove ENABLE/COMPATIBILITY because they can no longer be used
- remove forAllMethodsWithBody because its behavior is now equivalent to
  isEnabled
- inline isCompatibility
- inline DEFAULT
- rename ALL_INCOMPATIBLE -> ALL
2024-02-06 17:18:44 +00:00
Evgeniy.Zhelenskiy f05c972efb [K2, CLI] Support endOffset in Kotlin CLI
Duplicated messages in testdata appeared because default renderer
renders diagnostic spans ambiguously. It shows only start position.
In fact, there are 3 failures, 2 of them distinguish only by the
diagnostic end offset. See youtrack for more information.

The issue about inconvenient rendering is KT-64989.

#KT-64608
2024-02-05 13:26:13 +00:00
Alexander Udalov 49c659b379 CLI: remove obsolete -Xdump-declarations-to
It was only used in the very old version of binary compatibility
validator. It was never supported in the JVM IR backend.
2024-02-01 23:37:23 +00:00
Dmitriy Novozhilov ed874262e3 [FIR] Part 3. Setup running platform checkers in CLI
^KT-58881
2024-01-24 10:45:00 +02:00
Sergej Jaskiewicz bc5810ee67 [FIR2IR] Don't use descriptor manglers in FIR2IR
They don't do anything, only complicate the initial configuration.

KT-64990
2024-01-19 13:36:00 +00:00
Sergej Jaskiewicz 8b4cc050eb [FIR2IR] Remove linkViaSignatures from Fir2IrConfiguration
^KT-64809 Fixed
2024-01-19 13:36:00 +00:00
Dmitriy Novozhilov 0741250b12 [FIR] Use proper FirProvider in the FirKLibSerializerExtension
3aa84906 changed native metadata serialization to use proper platform
  session, but it caused a new bug: FirKLibSerializerExtension uses
  FirProvider from the passed session to get a containing file of
  serialized declaration to put some extension into the metadata. And
  platform session doesn't contain information about any declarations
  except platform ones

So it's needed to use the proper FirProvider in it, which can be
  extracted from Fir2IrComponents. This provider contains providers from
  all sessions that are being compiled plus providers for top-level
  declarations generated by compiler plugins

^KT-65024 Fixed
2024-01-17 17:38:44 +00:00
strangepleasures 7e9d6e601d KT-64385 Enable K2 KAPT by default
Also adds support for front-end compiler plugins in Kapt
2024-01-15 10:22:32 +00:00
Sergej Jaskiewicz a0ba878b1d [FIR2IR] De-duplicate creation of Fir2IrConfiguration
This will help to prevent inconsistencies between creating
the configuration in the actual compiler pipeline and in compiler tests.
2024-01-11 12:16:54 +00:00
Dmitriy Dolovov e92017f64e [KLIB Resolver] Deprecate Logger.fatal()
Invocation of Logger.fatal() may cause severe side effects such as
throwing an exception or even terminating the current JVM process
(check various implementations of this function for details).

The code that uses Logger.fatal() sometimes expects a particular kind
of side effect. This is totally a design flaw. And it's definitely not
a responsibility of Logger to influence the execution flow of
the program.
2024-01-08 13:26:24 +00:00
Dmitriy Novozhilov 8ff869a08c [FIR] Unregister FirJavaElementFinder at the Project disposing
^KT-64433 Fixed
2024-01-05 10:23:04 +00:00
Marco Pennekamp 32fe29b8cc [Test] Add debug names to unnamed test disposables
- This helps to track down disposables which are never disposed, and
  reduces confusion when printing disposables in general (the names will
  now be meaningful, instead of endless lists of "newDisposable" and
  "TestDisposable").

^KT-64099
2023-12-19 11:12:23 +00:00
Dmitriy Dolovov b1093d8082 [KLIB Resolver] Don't discriminate KLIBs by duplicated unique_name in K2 metadata compiler
Use the same approach as in K1 metadata compiler: resolve each library
separately from others, don't attempt to resolve them all at once.

^KT-63573
2023-12-18 13:03:40 +00:00
Dmitriy Dolovov 46081f968d [KLIB Resolver] Report KLIB resolver issues as compiler messages
The reason of this change is to make messages (especially warnings)
that are reported by the KLIB resolver become visible to the end user.
This can be achieved to forwarding such messages to the appropriate
compiler's components such as
`org.jetbrains.kotlin.cli.common.messages.MessageCollector` and
`org.jetbrains.kotlin.ir.util.IrMessageLogger`.

Also: The default `DummyLogger` should be used as minimal as possible.
Because it just forwards messages to the standard output (console)
where they can remain unattended. When the compiler is executed
from the Gradle plugin such messages appear only in DEBUG Gradle's log.

^KT-63573
2023-12-18 13:03:40 +00:00
Dmitriy Novozhilov f4e3203cd8 [FIR] Unregister java element finders from previous sessions
The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
2023-12-14 09:51:15 +00:00
Dmitriy Novozhilov 1cdc8361d6 [IR] Rename IrAnnotationsFromPluginRegistrar to IrGeneratedDeclarationsRegistrar
In further commits, this service will be used not only for registering
  annotations, but newly generated IR declarations too
2023-12-05 10:21:27 +02:00
Svyatoslav Kuzmich e901629cf0 [Wasm] Support WASI target in K2
- Support WASI mode in CLI and test infrastructure
- Add external declaration checker
- Split Fir diagnostic lists into Base, JS and WASI

#KT-56849 Fixed
2023-11-28 11:51:53 +00:00
Pavel Kunyavskiy 021a00f4ff [IR] Avoid depending from fir2ir on ir.actualization module
^KT-62292
2023-11-20 08:31:41 +00:00
Kirill Rakhman 4964ee12a9 [CLI] Update CLI argument descriptions after review 2023-11-17 14:36:28 +00:00
Alexander Udalov 4fca52b66c FIR entrypoint: deduplicate some code and remove JVM dependency
Deduplicate Fir2IrExtensions creation and move the
convertToIrAndActualizeForJvm function to 'cli', which allows to remove
the dependency of 'fir.entrypoint' on 'backend.jvm'.

Note that behavior slightly changes in IncrementalFirJvmCompilerRunner:
previously the value of linkViaSignatures was always false, now it is
taken from the compiler configuration, which seems more correct.
2023-11-06 08:49:04 +00:00
Ilya Chernikov b3d33aee19 HMPP, IC: Implement shared provider for IC class files
#KT-61942 fixed
temporary solution, see comments for details
2023-11-02 11:03:37 +00:00
Ilya Chernikov 76eda0095e HMPP: Fix isCommon calculation for the K2 HMPP case 2023-11-02 11:03:37 +00:00
Alexander Udalov 4f96171716 K2: report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
Also, remove setting the value of allowUnstableDependencies to true if
K2 is used because we want K2 to report errors (as K1 does) on
unstable-ABI dependencies.

 #KT-61598 Fixed
2023-10-31 10:39:43 +00:00
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +00:00
Ivan Kylchik 2af73c2b13 [FIR] Add FirJavaElementFinder to session's components
This change allows us to use `IrInterpreter` to evaluate Kotlin's
const properties that were called from Java world

#KT-57802
2023-10-20 16:33:20 +00:00
Simon Ogorodnik 024e94a479 [K2] Document KMP implementation in the K2 Compiler
Add comprehensive documentation explaining the implementation and
functions of the Kotlin multiplatform (KMP) support in the K2 Compiler.
2023-10-12 12:27:54 +00:00
Alexander Udalov 9164b7d405 K2 kapt: remove reference to "kapt 4" from the warning
#KT-62438 Fixed
2023-10-09 16:08:45 +00:00
Dmitriy Dolovov 78a962f6d2 [KLIB] Deprecate -Xexpect-actual-linker CLI argument
This argument has been finally superseded by `-Xmetadata-klib`.

^KT-61136
2023-10-02 16:21:17 +00:00
Mikhail Glukhikh a77b758efa LV 2.0: drop reporting FIR_COMPILED_CLASS and relevant stuff
#KT-62056 Fixed
Related to KT-59171, KT-61951
2023-09-21 11:14:09 +00:00
Dmitriy Dolovov 38a67f3d30 [KLIB] Use -Xmetadata-klib to produce metadata KLIBs
With this change a new `-Xmetadata-klib` CLI flag becomes the
preferable way to instruct K2MetadataCompiler to produce metadata
KLIBs. The old `-Xexpect-actual-linker` flag still works for
K2MetadataCompiler, but that would last just for a short transition
period until the necessary changes are made in the Gradle plugin.

The K2NativeCompiler does not work anymore with `-Xexpect-actual-linker`
and respects only the `-Xmetadata-klib` flag. This is not an
issue since the Gradle plugin anyway supplies both flags for Native
metadata compilations.

^KT-61136
2023-09-20 22:26:36 +00:00
Dmitriy Dolovov 848c88b1a5 [KLIB] Lift up -Xmetadata-klib CLI key from Native to Common args
This is a precondition for obsoleting and finally removing
`-Xexpect-actual-linker` CLI key, which became useless since
the removal of ExpectActualTable.

^KT-61136
2023-09-20 22:26:36 +00:00
Ilya Chernikov e5ee364419 IC: Implement expect/actual tracking
fixes NewMultiplatformIT.testIncrementalCompilation
also #KT-61590 fixed
2023-09-19 15:46:30 +00:00
Pavel Kunyavskiy 9a9598c16b [Klib] Run prerelease checker in all backends
The checker also checks the metadata version, which
would be handled separately. Now it would never
emmit this error for klib-based backends.

^KT-61773
^KT-61596
^KT-55809
2023-09-15 09:48:42 +00:00
Alexander Udalov fd68b9f49c CLI: add -Xuse-ir-fake-override-builder
To be able to test IR fake override builder (KT-61514) outside of
compiler tests.
2023-09-13 15:01:52 +02:00
strangepleasures 52b0ea65d2 [KAPT4] KT-61761 Prevent Kapt from reporting unsupported plugin in K2/PSI
Also:
- remove the redundant KaptOptions.USE_K2
- prevent registration of Kapt4AnalysisHandlerExtension in K1
2023-09-12 16:58:38 +00:00
Mikhail Glukhikh b0b6a6a05a K1/K2: deduplicate/simplify the code around JVM CLI
Related to KT-61510, KT-61745
2023-09-08 13:20:47 +00:00
Mikhail Glukhikh 3561054998 K1/K2: partially share code for multi-module chunks building
#KT-61510 Fixed
Related to KT-61716
2023-09-08 13:20:47 +00:00
Rustam Musin 1efa9abf57 Add missing space in GradleStyleMessagerRenderer.render()
In `GradleStyleMessagerRenderer.render` method, when there is `location` pointing to some file and coordinates `line:column = 0:0`, then a space between the location and the message was not printed.
#KT-61737 Fixed
2023-09-07 13:34:59 +00:00
Alexander Udalov fec2d063c1 K2: report PRE_RELEASE_CLASS on JVM
Note that 3 tests are still muted, but for another reason: for FIR
versions of the tests, we need to compile the "pre-release library" with
the next language version which is 2.1. But since currently
LanguageVersion.LATEST_STABLE is 1.9, the compiler refuses to read
metadata of version 2.1, regardless of its own language version. Which
is correct, but it leads to irrelevant errors in the test output -- the
ones about the incompatible metadata version, NOT about the
prereleaseness.

These 3 tests can be unmuted once the default language version is
switched to 2.0.

 #KT-60780 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 7d60b5df43 K2: report INCOMPATIBLE_CLASS in JVM
#KT-60795
2023-09-06 08:05:34 +00:00
Dmitriy Novozhilov fa4c6d55c1 [FIR] Store mapped jvm declarations in session component, share it between MPP modules
^KT-61640 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.testJavaMethodWithTypeParameter
2023-09-05 14:43:43 +00:00