Commit Graph

100026 Commits

Author SHA1 Message Date
Sergej Jaskiewicz 3713d95bb1 [klib] Don't deserialize the list of sealed subclasses from klibs
tl;dr the current design of klibs does not allow to properly deserialize
the list of sealed subclasses in a sound way. It is possible that
a subclass of a sealed class is declared in a different file, AND is
private in that file.

A more detailed explanation:

Right now we don't serialize file signatures at all.
However, a private declaration's signature must necessarily include
the file signature.

How do we serialize a private declaration's signature into a klib
and deserialize it later?

**Serialization** is simple: we just serialize the file signature as
an empty protobuf message.

When we are **deserializing** a private declaration, we look at the file
that is being deserialized right now, and construct the file signature
based on that.

This logic, however, doesn't always work. An example is KT-54028.

Basically, if we have a sealed interface with a private implementor
declared in a different file, this breaks:

1. We are deserializing the sealed interface. The deserializer knows
that we are now in the file in which the sealed interface is declared.
2. As part of deserializing the interface, we deserialize its sealed
subclasses.
3. Naturally, we come to deserializing the private implementor that is
declared in another file, but the deserializer still thinks that we are
in the file in which the interface is declared. A wrong signature is
created, which leads to linkage failure.

We *could* fix this by properly serializing the file signature,
i.e. instead of an empty protobuf message we could write the file path
and its package to the klib. However, there a problems with this
approach:

- The current design of signatures allows a situation where two
different files can have the same relative path
(for example, with the help of the `-Xklib-relative-path-base` compiler
flag) *and* the same package, which would introduce ambiguity during
linkage.
- Most importantly, this appoach won't work well with incremental
compilation of klibs. Currently we rely on the assumption that all
cross-file references are handled with public signatures, and private
signatures are only used inside a single file. This allows to move
declarations across files without recompiling it's use sites.

It has been decided to apply the following hacky solution: we just don't
deserialize the list of sealed subclasses from klibs.
The list of sealed subclasses is not used in lowerings, so it should be
safe.

#KT-54028 Fixed
2023-04-05 15:51:54 +00:00
Sergej Jaskiewicz 2f99ac1cc0 [test] Fix handling files with the same names in tests 2023-04-05 15:51:54 +00:00
Sergej Jaskiewicz 7e8874095a [klib] Add documentation comments for IdSignatureComputer 2023-04-05 15:51:53 +00:00
Sergey Bogolepov d87f3cb9cd [K/N] Fix coverage phase condition 2023-04-05 15:46:08 +00:00
Roman Efremov b368b78faa [FE] Prohibit protected members in final expected or actual classes
^KT-28850 Fixed
2023-04-05 15:25:46 +00:00
Nikolay Lunyak 2f5b1dff16 [FIR] Ensure parent checkers are always called 2023-04-05 15:16:31 +00:00
Sergej Jaskiewicz 78d19e143c [JS IR] Don't use JVM-specific mangler in JS IR backend
^KT-54638 Fixed
2023-04-05 14:23:51 +00:00
Vladimir Sukharev 185097f82e [K2/N] Enable tests fixed by KT-56030
^KT-56030

Merge-request: KT-MR-9456
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-04-05 14:21:16 +00:00
Alexander Shabalin 759d5009d6 [K/N] Fix combination of aggressive GC and state check
Merge-request: KT-MR-9483
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2023-04-05 13:16:01 +00:00
Nikolay Lunyak 3987efa036 [FIR] Remove the fast path if as insignificant
This if is a bit inconsistent with the
LUB checking approach, so if it doesn't
improve performance it's better to remove it.
2023-04-05 11:13:25 +00:00
Alexander Korepanov 4813b659ab [JS IR] Control an inheritance of non-external entity from external
Add a special annotation @JsExternalInheritorsOnly for marking
 external interfaces and classes. The marked interface or class
 can’t be a parent for non external interfaces, classes or objects.

^KT-57423 Fixed
2023-04-05 09:00:45 +00:00
Kirill Rakhman 6e7b078873 [IR] Refactor IrActualizerUtils to use buildString 2023-04-05 08:44:57 +00:00
Kirill Rakhman 4dfef6ba6f [IR] Fix arguments of backend error messages
#KT-57662 Fixed
2023-04-05 08:44:56 +00:00
Kirill Rakhman 674397be82 [FIR] Trim rendered symbols in diagnostic messages 2023-04-05 08:44:56 +00:00
Roman Efremov 456d3e0f42 [FE] Prohibit expect fun interface to have non-fun actual counterpart
In K1 .isFun is always false for Java classes, so extra check
is added for that. This is not needed for K2, because .isFun is
true for all Java classes. Here it is not necessary to check
that interface has only one method, because such check will be
done in the place where interface implementation is created.

^KT-39362 Fixed
2023-04-05 07:31:58 +00:00
Dmitriy Novozhilov 59d126abc5 [Native] Rename FirSerializer.kt to FirNativeSerializer.kt
This is needed to avoid confusion with files with common parts of
  FIR serialization
2023-04-05 07:31:34 +00:00
Dmitriy Novozhilov 92a59279d5 [FIR] Properly implement serializer extension for klib compilation
^KT-57654 Fixed
2023-04-05 07:31:33 +00:00
Justin Paupore 6604627fa8 Use registered FIR compiler extensions in Analysis API.
This will allow IDE plugins to contribute compiler plugins to analysis,
above and beyond those used for the actual compilation step. These
plugins can be used to, for example, provide declarations for code that
is generated during build by an external tool.

^KT-57763 fixed
2023-04-05 07:31:08 +00:00
Justin Paupore acca7de42d Fix extension point name for FirExtensionRegistrar.
This changes the declared entry point name to match that actually
defined in FirExtensionRegistrarAdapter.

^KT-57763
2023-04-05 07:31:08 +00:00
Dmitriy Dolovov b2e58096c0 [Native][tests] Generate missing codegen/box tests 2023-04-04 23:02:44 +02:00
Dmitriy Dolovov 31ed97e4ad [PL][tests] Mark K/N codegen/box tests with disabled PL with a special tag
Using this tag such tests may be excluded at the buildserver from slow configurations.
2023-04-04 22:24:02 +02:00
Dmitriy Dolovov 846f704713 [PL][tests] Use the proper cache configuration in cache tests 2023-04-04 22:24:02 +02:00
Dmitriy Dolovov f86fa807cf [PL][Native] Propagate PL configuration to cache compilation 2023-04-04 22:24:02 +02:00
Dmitriy Dolovov f22bbb5a39 [PL][tests] Add K/N codegen test variants to run w/o PL 2023-04-04 22:24:02 +02:00
Dmitriy Dolovov 5db6158b47 [PL][tests] Mark K/N tests that should be executed without PL or with always some predefined mode
#KT-57378
2023-04-04 22:24:02 +02:00
Dmitriy Dolovov cb071028f6 [PL][tests] Run K/N tests (new infra) with PL enabled (where possible)
#KT-57378
2023-04-04 22:24:01 +02:00
Dmitriy Dolovov f1a97ed4b8 Minor. Comment updated 2023-04-04 20:18:18 +00:00
Dmitriy Dolovov b08d805f1e [JS][tests] Support FIR for KLIB evolution tests 2023-04-04 20:18:18 +00:00
Dmitriy Dolovov 5970cfff75 [JS][tests] Rename KLIB binary compatibility tests to KLIB evolution tests 2023-04-04 20:18:17 +00:00
Dmitriy Dolovov bd4acfc4dc [JS][tests] Remove unused AbstractJsKlibBinaryCompatibilityErrorTest 2023-04-04 20:18:17 +00:00
Dmitriy Dolovov 17c5f5d5a2 [Native][tests] Support FIR for KLIB evolution tests 2023-04-04 20:18:17 +00:00
Dmitriy Dolovov 3506e0c20f [Native][tests] Rename KLIB binary compatibility tests to KLIB evolution tests 2023-04-04 20:18:16 +00:00
Igor Yakovlev 49beec33b4 [Wasm] Replace ClassId and InterfaceId with single TypeId 2023-04-04 18:39:18 +00:00
Igor Yakovlev 5a46cb1c40 [Wasm] Fix invalid float and double sign parser for '-Infinity' value 2023-04-04 18:39:18 +00:00
Igor Yakovlev 44190937b0 [Wasm] Fix generic call return type for functions with default parameters 2023-04-04 18:39:18 +00:00
Igor Yakovlev b8f797af00 [Wasm] Support for Associated Objects feature 2023-04-04 18:39:17 +00:00
Igor Yakovlev 993334e5e4 [Wasm] Support feature InstantiationOfAnnotationClasses 2023-04-04 18:39:17 +00:00
Anton Lakotka fac90070bc [Gradle] Add smoke test for appleGradlePlugin
^KT-57668 Verification Pending
2023-04-04 18:37:30 +00:00
Anton Lakotka fd63aee3e5 [Gradle] Test that binary frameworks can be consumed
^KT-57668 Verification Pending
2023-04-04 18:37:30 +00:00
Anton Lakotka ad9b34653a [Gradle] Add kotlinNativeFrameworkNameAttribute for binary frameworks
^KT-57668 Verification Pending
2023-04-04 18:37:29 +00:00
Pavel Kargashinsky ae228ece8a [Gradle][Tests][MPP] Fix test-data for MPP tests 2023-04-04 18:33:33 +00:00
Pavel Kargashinsky 5c56145a19 [Gradle][Tests][MPP] Use MAX_SUPPORTED AGP/Gradle versions for MPP tests 2023-04-04 18:33:33 +00:00
Artem Daugel-Dauge 4b66160afb [Gradle] Support dependencies between pods in CocoaPods plugin
^KT-38749 Verification Pending
2023-04-04 14:13:44 +00:00
Ilmir Usmanov b36e1f1a5b Do not reference object's toString result in exception messages
Since we put object's hash code in toString, we end up in putting
non-stable hash code to constant table, which leads to unstable
binaries.

 #KTI-1193 Fixed
2023-04-04 13:41:03 +00:00
Marco Pennekamp c2acb77b84 [LL FIR] KT-57220 LLFirSessionCache: Clean up symbol provider merging
- `SymbolProviderMerger` encapsulates some boilerplate, which should
  make `mergeDependencySymbolProvidersInto` easier to read and also much
  easier to extend.
2023-04-04 12:45:33 +00:00
Marco Pennekamp 87bcc3ad08 [LL FIR] KT-57220 Don't merge empty synthetic function symbol providers 2023-04-04 12:45:32 +00:00
Marco Pennekamp eac6458500 [LL FIR] KT-57314 Add cache to combined Kotlin symbol providers
- This Caffeine cache is limited to classes for now, but may also be
  tried with callables.
- The cache has a small memory footprint, but still avoids most of the
  unnecessary index accesses. In my local tests, this approach takes 50%
  of the time compared to no caches. A full cache has no performance
  advantage over the limited-size cache in my local tests.
2023-04-04 12:45:32 +00:00
Marco Pennekamp 375288539e [LL FIR] Add NullableCaffeineCache
- `NullableCaffeineCache` wraps a Caffeine cache and allows storing
  `null` values returned by the computation in the form of explicit
  `NullValue`s in the cache.
2023-04-04 12:45:32 +00:00
Marco Pennekamp b805c6e32b [LL FIR] Add Caffeine library dependency
- Our current FIR caches are based on `ConcurrentMap` and thereby do not
  support size and lifetime limits out of the box. For example,
  first-layer caches with a limited size can speed up access of the most
  frequently used elements, while having a small memory footprint.
- Caffeine is a modern and well optimized caching library that allows us
  to create thread-safe and performant caches with various size or
  lifetime limits.
- The cache must support concurrency because session components such as
  symbol providers may be accessed concurrently once parallel resolve in
  the Analysis API has been implemented (see KT-55750). Caffeine caches
  support concurrency.
2023-04-04 12:45:31 +00:00
Marco Pennekamp a7360a54fe [LL FIR] KT-57314 Prepare for getting top-level names from index
- Getting top-level names from `declarationProvider` directly instead of
  from subordinate symbol providers has a lot of potential for
  performance, but the current performance of the index access is worse
  than the iterative version because scopes aren't optimized yet.
- This commit prepares `LLFirCombinedKotlinSymbolProvider` for the
  switch to getting top-level names from `declarationProvider`.
2023-04-04 12:45:31 +00:00