6850 Commits

Author SHA1 Message Date
Iaroslav Postovalov 9a2e4c6b41 [Tests] FIR support in JUnit 3 tests, port necessary subclasses
^KT-64404 Fixed
^KT-64438 Fixed
^KT-64407 Fixed
2024-03-19 17:56:29 +00:00
Alexander Udalov 621fe41b17 JVM: restore incorrect DFS logic in JavaModuleGraph for compatibility
The problem is tracked in KT-66622. It should be fixed later, with a
proper deprecation, because otherwise it can potentially break a lot of
code.
2024-03-19 15:51:01 +00:00
Alexander Udalov 94e5cafb61 JVM: fix "module reads" check in JavaModuleGraph
There was a bug in the DFS. Whenever we encountered a "requires
transitive X" directive in some module, we recursively invoked DFS not
on X but on `dependencyName`, which is the target module that we're
trying to find the path to. And that always failed, because no module
requires itself.

 #KT-66275 Fixed
2024-03-19 15:51:01 +00:00
Alexander Udalov 32c8664f71 Tests: remove JVM diagnostics from AbstractDiagnosticsTest
There's no behavior specific for JVM backend diagnostics in any of the
affected tests, and this code is using an incorrect way to obtain those
diagnostics, so it should be removed anyway.
2024-03-15 14:39:56 +00:00
Mikhail Glukhikh 8ac576614f Revert "Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551)"
This reverts commit 893e5cac
2024-03-15 11:33:10 +00:00
Dmitriy Novozhilov cc6e0eb218 [Test] Unmute passing test about binary poisoning (KT-66551) 2024-03-14 19:53:25 +00:00
Dmitriy Novozhilov f288163cbc [Test] Use rethrow for checked exception in java-written tests
In 9b5a9ccb `throws Exception` was removed from java test sources and
  all checked exceptions were wrapped with `RuntimeException`

But it was forgotten that there is a `rethrow` utility, which doesn't
  wrap exception but makes the javac happy at the same time
2024-03-14 11:04:02 +00:00
Mikhail Glukhikh 893e5cac94 Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551) 2024-03-13 20:38:44 +00:00
Mikhail Glukhikh 93a796b635 Temporarily unmute passing test around IS_PRE_RELEASE (related to KT-62063)
This test (probably) should be muted again after bootstrapping
2024-03-13 20:38:44 +00:00
Mikhail Glukhikh f37347ddb7 Temporarily mute failing test around IS_PRE_RELEASE (related to KT-62063)
This test should be fixed by bootstrapping or in KT-66551
2024-03-13 20:38:44 +00:00
Ilya Chernikov 0fe793943d K2, REPL: Display a warning that LV 1.9 is used for REPL in K2
#KT-64384 fixed
2024-03-12 15:57:00 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Vladimir Sukharev 64d4b61628 [Tests] Drop obsolete KotlinJavascriptSerializerTest.kt 2024-03-11 15:12:44 +00:00
Vladimir Sukharev 9b4f503fbe [Tests] Port KotlinKlibSerializerTest to K2
^KT-64440 Fixed
2024-03-11 15:12:44 +00:00
Vladimir Sukharev 1ad0872958 [Tests] Port FilePathsInKlibTest to K2 ^KT-64452
Used frontend changed for K2
It turned out test was compiling only one source file (a.kt). Test adjusted, so all three source files(a.kt, b/c.kt, c/d/e.kt) are now compiled into klib, so more usecases are tested
^KT-64452 Fixed

Merge-request: KT-MR-14700
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2024-03-07 10:49:07 +00:00
Alexander Udalov 3bb2ea10b6 K2: add inline JVM target version checker
#KT-60777 Fixed
2024-03-04 22:25:36 +00:00
Alexander Udalov 5ca7ab9801 K2 JVM: implement Java modules-related checkers
All existing tests use custom test data for FIR because the diagnostic
text in FIR has to have a dot at the end. Also, the K2 checker doesn't
check usages in imports because there are no "import checkers" in K2
right now, this will need to be fixed later if necessary.

 #KT-60797 Fixed
2024-02-21 14:10:44 +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 cdcb65c749 Tests: minor, slightly move JDK path substitution logic
It will be used in other CLI tests in subsequent commits.
2024-02-19 11:44:58 +00:00
Dmitriy Novozhilov 9b5a9ccba8 [Test] Don't generate throws Exception on methods of generated tests
This is needed to reduce the size of generated test files, which started
 to exceed default IDE limit
Also update some (mostly old) test utilities to remove exceptions from
 java signatures
2024-02-16 12:48:24 +00:00
Alexander Udalov 9fcf6c5f89 JVM: add tests on some JPMS-related diagnostics
Somehow we ended up in the state where we have two diagnostics which are
not covered by any tests in the project. This commit adds simple tests
for them.

 #KT-60797
2024-02-09 18:06:02 +00:00
Mikhail Glukhikh 78876b32e9 K2: unmute testInnerClassPackageConflict2 thus fixing current K2 behavior
Related to KT-63070, KT-60792
2024-02-07 11:36:53 +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
Sergej Jaskiewicz f39335b3f7 [klib] Don't pass around metadata serialization closure
Pass the metadata serializer instance instead. This allows to further
reduce code duplication by introducing the common interface
`KlibSingleFileMetadataSerializer` for abstracting away K1 and K2
representation of a source file, as well as reusing
`Fir2KlibMetadataSerializer` across different backends.

KT-64392
2024-01-29 21:07:43 +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
Vladimir Sukharev dd0cc7089a Add unittests for FqNameUnsafe.startsWith(FqNameUnsafe) 2023-12-08 16:27:18 +00:00
Vladimir Sukharev 1387e077e9 Improve unittests for FqNameUnsafe.startsWith(Name) 2023-12-08 16:27:18 +00:00
Vladimir Sukharev 93af9f33e4 Fix FqNameUnsafe.startsWith() when first segment of fqName is shorter than given segment
FqNameUnsafe("c.C").startsWith("cnames")
must return false
It's a refix of fdf826208f
2023-12-08 16:27:18 +00:00
Ilya Goncharov 093f51c89a [JS] Removing usage of legacy JS compiler #1 2023-11-28 13:44:37 +00:00
Svyatoslav Kuzmich 62ebb9932f [Wasm] Port external declaration checker to K2 (KT-56849)
Share common code with FirJsExternalChecker using
FirWebCommonExternalChecker
2023-11-16 14:27:49 +00:00
Brian Norman 1bb5e97b62 [FIR] Improve performance of missing supertype detection
^KT-62619 Fixed
2023-11-03 13:28:02 +00:00
Alexander Udalov 6a1c210cd1 Minor, remove obsolete mention of issue in previously muted test
The test was fixed for K2 in 365ce2a6a5.
2023-10-31 10:39:43 +00:00
Dmitriy Novozhilov 8b03636b3b [Test] Unmute test due to KT-62058 2023-10-20 14:32:43 +00:00
Ivan Kylchik 70f195598e [FIR2IR] Don't run interpreter's preprocessors on fir2ir stage
In IR interpreter we have "preprocessors". Preprocessor is a
transformer that changes IR expressions in a way that we can
interpret them at least partially.

We have two places where interpretation is happening:
1. Right after fir2ir where we evaluate only strictly necessary
expression for `const val` and annotations.
2. In lowering for every backend where we are doing some
constant folding.

Earlier, to avoid double work, we didn't launch preprocessors
in backend if we were using K2. But this approach breaks compilation
for MPP projects where one module is compiled with K1 into klib
and the overall project is compiled with K2. On the backend side,
we are mistakenly assuming that preprocessors were launched, but they
were not.

The solution is to run preprocessors only on the backend side. If we
think about it, interpretation on fir2ir doesn't require any
preprocessing because we are working only with expressions that are
correct and must be fully evaluated.

#KT-62126 Fixed
2023-10-19 12:29:32 +00:00
Ilya Goncharov a79324037d [JS] Fix JPS artifacts cordinates 2023-10-16 13:34:37 +00:00
Alexander Udalov 9fd1445631 JVM: use metadata version 1.9 for .kotlin_module if LV=2.0
See the comment in the code for more info.

No proper test added because the compiler test infrastructure lacks the
ability to run old compiler versions, however I've verified manually
that the change fixes the issue.

 #KT-62531 Fixed
2023-10-16 12:45:47 +00:00
Mikhail Glukhikh 52010e38e3 Temporarily mute failing tests around IS_PRE_RELEASE (related to KT-62058)
These tests should be fixed by bootstrapping
2023-10-05 09:58:29 +00:00
Brian Norman 365ce2a6a5 [FIR] Implement checker for missing dependency supertypes
#KT-60778 Fixed
2023-10-04 21:57:43 +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
Alexander Korepanov 522952db1f [JS IR] Run diagnostics by IR before the klib serialization
Implement an infrastructure for checking IR before JS klib serialization.
Implement the EXPORTING_JS_NAME_CLASH and EXPORTING_JS_NAME_CLASH_ES checks.

^KT-61710 Fixed
2023-09-23 19:49:17 +02:00
Mikhail Glukhikh 2603077db9 Move independent pre-release tests to K2 group to avoid duplication
Without this commit these tests are run twice without any reason for it.
Related to KT-62058
2023-09-21 20:09:25 +00:00
Mikhail Glukhikh 156097fe17 Restore KotlinCompilerVersion.IS_PRE_RELEASE
This commit is a slightly modified revert of 4f29c113.
IS_PRE_RELEASE allows to make LATEST_STABLE version behave as
experimental when this flag is set to true.
The general goal is to prepare fix of KT-62058; after this commit
one can do it by changing IS_PRE_RELEASE flag to true.
The fix of KT-62058 is planned to be done during bootstrapping.
This preparation and the future fix are parts of umbrella KT-61951.
2023-09-21 20:09:25 +00:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Mikhail Glukhikh 37ef18548e Fix KotlinVersionsTest.testVersionsAreConsistent after TC version increase
Related to KT-59171, KT-61951
2023-09-21 12:38:22 +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
Mikhail Glukhikh 46093c686e KotlinVersionsTest: temporary convert to language update state
#KT-59171 Fixed
2023-09-19 15:46:31 +00:00
Mikhail Glukhikh a40951d65d Reformat KotlinVersionsTest 2023-09-19 15:46:31 +00:00
Mikhail Glukhikh d1e4e6cc2e LV 2.0: drop wrong comment on testRawTypes (KT-62043) 2023-09-19 15:46:31 +00:00
Mikhail Glukhikh 96ea0c2eb8 LV 2.0: move testStrictMetadataVersionSemanticsOldVersion to pure K2 tests 2023-09-19 15:46:29 +00:00