Commit Graph

7357 Commits

Author SHA1 Message Date
Sergej Jaskiewicz 61e957fc00 [JS] Mute the EXPORTING_JS_NAME_CLASH_ES diagnostic in TS export tests
This diagnostic started to appear after
51c920af01e3d583c552224a529abe1f6e5fcf16.
2024-01-12 15:59:28 +00:00
Sergej Jaskiewicz eda30ff704 [klib] Implement diagnostics for clashing KLIB signatures
Now, we detect clashing signatures during serialization to KLIB and
report a compiler error if two or more declarations have the same
`IdSignature`

For example, for the following code:
```kotlin
@Deprecated("", level = DeprecationLevel.HIDDEN)
fun foo(): String = ""

fun foo(): Int = 0
```

the compiler will produce this diagnostic:
```
e: main.kt:1:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
e: main.kt:4:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
```

Note that we report this diagnostic during serialization and not earlier
(e.g., in fir2ir) for more robustness, so ensure that we check
exactly the signatures that will be written to a KLIB.
If we later introduce some annotation for customizing a declaration's
signature (e.g., for preserving binary compatibility), this
diagnostic will continue to work as expected.

^KT-63670 Fixed
2024-01-12 15:59:28 +00:00
Dmitriy Novozhilov 8300ad76d0 [FIR2IR] Remember overridden symbols if f/o contains error types
^KT-64837 Fixed
2024-01-12 15:32:25 +00:00
Dmitriy Novozhilov 50abaaff7e [Test] Reproduce KT-64466 2024-01-12 15:01:33 +00:00
Nikolay Lunyak cf4c55e02d [FIR JS] Create an LT diagnostics with BE runner 2024-01-12 13:42:23 +00:00
Nikolay Lunyak 8a4212f140 [FIR JS] Create an LT diagnostics runner 2024-01-12 13:42:23 +00:00
Nikolay Lunyak f7f5ac080f [FIR JS] Create an LT Box runner 2024-01-12 13:42:23 +00:00
Nikolay Lunyak 9a598026c8 [FIR JS] Reproduce KT-64548
Running the FIR tests leads to the
crash.

^KT-64548
2024-01-12 13:42:23 +00:00
Vladimir Sukharev 9f2558f640 [K/N][Tests] Patch package names also for .def files
To separate interop modules to different packages,
.def files should be treated similarly to .kt files:
1) package directive should be prepended with test-specific synthetic package,
or, if, absent, package directive with synthetic package should be added.
2) in .kt files, import directives and fully-qualified import from interop modules
should be prepended with same test-specific synthetic package.
2024-01-11 23:30:07 +00:00
Vladimir Sukharev bf01cb16b4 [K/N][Tests] Migrate some cinterop tests to new infra
^KT-61259
2024-01-11 23:30:06 +00:00
Denis.Zharkov 72b0372927 K2: Allow PCLA inference when a value parameter has a TV type
^KT-64877 Fixed
2024-01-11 10:32:12 +00:00
Alexander Korepanov 6df0e0c847 [JS FIR] Enable FirJsLineNumberTests for FIR
^KT-64426 Fixed
2024-01-10 19:02:15 +00:00
Alexander Korepanov ac30911497 [JS tests] Split FIR and IR output test dirs 2024-01-10 19:02:15 +00:00
Denis.Zharkov 7e4d9d9f64 K2: Add new tests for PCLA implementation
Many of them have been found & minimized at FP tests/user projects

^KT-59791 Fixed
2024-01-10 14:56:31 +00:00
Alexander.Likhachev 60080e8bb8 [Build] Remove redundant trove4j compileOnly dependencies
^KTI-1135 In Progress
2024-01-10 11:29:25 +00:00
Alexander.Likhachev 21b438f55d Replace the trove4j collections usages with the fastutil ones
The trove4j library is licensed under LGPL, and that causes some troubles while working with it. The fastutil library provides the same functionality in the context of our needs, and is licensed under the Apache license.
^KTI-1135 In Progress
2024-01-10 11:29:25 +00:00
Pavel Kunyavskiy 9374cacdd6 [IrActualizer] Don't actualize expect types
This was never semantically correct, but was not important
before KT-63644, as they were immediately dropped after that anyway.

After KT-63644, they were used to compute fake overrides inside them,
which were later matched against actual class, which can
produce false-positive matching errors.

^KT-64835
2024-01-09 17:53:06 +00:00
Nikolay Lunyak f52648af5f [FIR] Support CHECK_TYPE in K2 JS tests
^KT-60056
2024-01-09 10:47:13 +00:00
Alexander Udalov d08c9ba222 JVM IR: transform fake override properties in SAM adapters
Replace every property with its getter and setter. This is needed
because later on, JVM backend assumes that all properties have been
lowered (by JvmPropertiesLowering) to this state.

 #KT-64116 Fixed
2024-01-08 21:31:13 +00:00
Alexander Korepanov 6556acabba [JS FIR] Enable FIR JS stepping tests
^KT-64422 Fixed
2024-01-08 12:38:37 +00:00
Pavel Kunyavskiy f45d92eebc [K/N, K/JS, K/WASM] Enable FakeOverrideRebuilder by default
While not beeing final solution, this is closer to what
we want to have in the end. Enabling on non-JVM targets
would help better testing.

Enabling in JVM is now not possible yet, as some of the bugs are
not fixed yet (check KT-61360 for details)

^KT-62476
2024-01-08 07:46:07 +00:00
Pavel Kunyavskiy c6e32571d6 [FakeOverrideBuilder] Workaround KT-64743
Because of KT-64743 there is unexpanded type-alias in a place we don't
expect it to occur. To workaround this, we just expand typialiases in
one more place.

^KT-64743
2024-01-08 07:46:07 +00:00
Artem Kobzar 567433cc12 [K/Wasm, K/JS] Unmute explicit backing fields tests 2024-01-05 17:27:31 +00:00
Marco Pennekamp 5797b4877c [FIR/AA decompiler] Add tests for sealed interfaces
^KT-62895
2024-01-05 15:55:29 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Pavel Kunyavskiy 32de968531 [Names] Avoid deadlock in initialization of classId constants
StandardClassIds was using Annotations subclass in its initialization.
At the same time, Annotations subclass was using StandardClassIds in its
initialization implicitly through baseId() method.

This leads to a rare deadlock on CI in case where two different threads
tried to initialize both classes at the same time.

It can't be reproduced robustly, as a single thread was able to
successfully initialize both, and will do it on an attempt to
initialize any of them.

^KT-64720 Fixed
2024-01-05 09:53:05 +00:00
Pavel Kunyavskiy 4080776fe3 [Fir2IR] Set correct module descriptors for builtins
^KT-64420
2024-01-04 17:29:58 +00:00
Alexander Korepanov d5aaa29a7f [JS FIR] Implement FirJsReflectionAPICallChecker diagnostic
^KT-60899 Fixed
2024-01-02 16:45:12 +00:00
Alexander Korepanov 4609b11102 [JS FIR] Add JsName clash test
^KT-64364
2024-01-02 10:15:02 +00:00
Alexander Korepanov 89e2af2047 [JS FIR] Fix the JsExport diagnostic for nullable primitive types
- Correctly handle nullable primitive types.
- Unsigned primitive arrays are not exportable.

^KT-64366 Fixed
2024-01-02 10:14:46 +00:00
Artem Kobzar 327085e026 [K/Wasm] Unmute most of the stepping tests for Wasm in K1 2023-12-28 16:32:10 +00:00
Kirill Rakhman 49ae1b8d01 [FIR2IR] Consolidate type approximation
This commit gets rid of the redundant typeApproximatorConfiguration
in Fir2IrTypeConverter and uses the type approximator for captured
types instead of the manual approximation used before.

This fixes the nullability of approximated captured types, which fixes
a runtime error in WASM.

This also brings K2 IR closer to K1 IR in one test.

#KT-64261 Fixed
2023-12-21 15:56:49 +00:00
Kirill Rakhman f47705f123 [Tests] Add box tests for #KT-59904 2023-12-21 12:03:48 +00:00
Alexander Korepanov 4a04a2fc4b [JS FIR] Enable invalidation with PL test for FIR
^KT-64446 Fixed
2023-12-20 19:04:31 +00:00
Mads Ager e41a1247e2 JVM_IR: Generate more line numbers for intrinsic comparisons.
Otherwise, if complex expressions such as when expressions are
used in combination with the intrinsics we get incorrect stepping
behavior.

^KT-64341 Fixed
2023-12-20 15:39:03 +00:00
Dmitriy Dolovov 61282fcaeb IR text tests: New tests specifically for main functions mangling
^KT-57755
2023-12-19 14:24:16 +00:00
Marco Pennekamp 76a4b32c1f [Test] JS backend recompilation tests: Dispose the test root disposable of the subordinate incremental configuration
- The incremental configuration for JS recompilation tests creates its
  own test root disposable. It needs to be properly handled to avoid
  disposable leaks.
- The incremental configuration's disposable is registered with the
  parent configuration's disposable because it lives in its scope and
  should thus not be a root disposable. It's also disposed at the end of
  `transform` because the incremental configuration's lifetime ends
  there.

^KT-64099 fixed
2023-12-19 11:12:23 +00:00
Marco Pennekamp a4fc658fb3 [Test] Use testRootDisposable instead of leaking test disposable in ApiTest
- `testDisposable` is already managed by `KtUsefulTestCase`, so disposal
  support comes for free. This replaces the previous `TestDisposable`,
  which was never disposed properly.

^KT-64099
2023-12-19 11:12:23 +00:00
Marco Pennekamp 3497809ebd [Test] Add missing disposal for test root disposables
^KT-64099
2023-12-19 11:12:23 +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 c09e8909d4 [K/N] Move cinterop tests from standalone to codegen/box
^KT-61259
2023-12-18 18:04:27 +00:00
Artem Kobzar 2530cba82a [K/JS] Compile Kotlin coroutines as JS generator ^KT-63038 Fixed 2023-12-18 17:13:07 +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
Igor Chevdar 7907231bf2 [box-tests] Added a reproducer for #KT-64139 2023-12-18 12:55:51 +00:00
Dmitriy Novozhilov 94c46d384a [FIR2IR] Properly calculate the type of delegated function call
```
interface A {
    fun <T> foo(): T
}

class B(val a: A) : A by A {
    generated fun <T'> foo(): T' {
        return a.foo() // <------
    }
}
```

There was a problem that type of generated delegated call used
  an unsubstituted type of the original delegated declaration, which led
  to a situation when (see example) type of call `a.foo()` was not `T'`
  but `T`, which led to incorrect IR and further exceptions on backend

^KT-64257 Fixed
^KT-64284 Obsolete
2023-12-18 12:45:28 +00:00
Dmitriy Novozhilov 7813bb35cf [FIR2IR] Provide remapped f/o symbols to declaration storage
After a generation of fake overrides some code may still to refer old
  symbols from declaration storage (like computation of overridden
  symbols for lazy functions), so we need to remap those symbols using
  information from IR f/o generator
2023-12-15 15:38:10 +00:00
Dmitriy Novozhilov 28f0f1ea88 [FIR2IR] Properly set isAssignable flag for parameters of tailrec functions
^KT-63973 Fixed
2023-12-14 09:58:03 +00:00
Pavel Kunyavskiy 8e047e6d8a [FIR2IR] Make all source sets friends for IrFakeOverrideBuilder
^KT-63644
2023-12-14 08:32:58 +00:00
Dmitriy Dolovov cbf21acede IR text tests: Don't dump signature mangled names for IR-based descriptors
^KT-57788
2023-12-13 21:33:26 +00:00
Dmitriy Novozhilov b4947e6cfe [Test] Exclude K2 MPP codegen box tests from K1 generated suites
Those tests always were muted for K1 because of incompatible module
  structure in testdata, so there is no actual sense to even generate
  them for K1
2023-12-13 16:47:42 +00:00