Commit Graph

3601 Commits

Author SHA1 Message Date
Alexander Udalov 7f5bc94117 Jvm-abi-gen: do not treat KmProperty.hasConstant as part of ABI
... for non-const properties.

The meaning of this flag for non-const properties is in reality not
well-established, and it can vary from one release to another. In
particular, it's different in K2.

This commit has two parts:
1) The test (added in 5891617674) about clinit is changed. Original
   motivation was to check that presence or absence of `<clinit>` is not
   a part of the ABI. However, in addition to that, the test also
   involuntarily checked that the aforementioned "hasConstant" flag for
   the property y/Object.y is the same in both cases (which I believe
   was not the intention) because these tests check that Kotlin metadata
   is _exactly the same_ after applying jvm-abi-gen. So I've changed it
   to be more straightforward: one version declares an obvious constant,
   while another declares an obvious non-constant. After this change,
   the test started to fail (even on K1) because the value of the
   "hasConstant" flag was different between two versions.
2) Remove "hasConstant" flag for non-const properties when transforming
   metadata via jvm-abi-gen. This fixes the test and assures it won't
   fail when the project is migrated to LV 2.0.

 #KT-60849 Fixed
2023-08-10 20:24:17 +00:00
Yahor Berdnikau 380062c511 [repo] Update the shadow version to 8.1.1 release
https://github.com/johnrengelman/shadow/releases/tag/8.1.1
2023-08-09 08:36:46 +00:00
Yahor Berdnikau c701677e45 [repo] Remove the shadow version from version.properties 2023-08-09 08:36:45 +00:00
Alexander Udalov 5b0c075c8d Rework list of dependencies of kotlin-annotation-processing 2023-08-09 01:17:21 +00:00
Pavel Mikhailovskii 2002542ad2 Stub generation infrastructure (except for metadata generation) for KAPT+K2
This commit includes the basic Java stubs generation infrastructure and
the corresponding tests. The main entry point is called
Kapt4StubGenerator. Calls to it from production code will be added in a
separate commit.

 #KT-51982
2023-08-09 01:17:21 +00:00
Aleksei.Cherepanov 7a97a43036 Fix JPS import after bed16f92 (KT-58358)
Some native test dependencies were excluded from JPS import of `:kotlin-atomicfu-compiler-pligin`


Merge-request: KT-MR-11477
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-08-07 15:06:01 +00:00
Leonid Startsev 7f795f212f Support instantiation of Java annotations with defaults
For annotations defined in Java, IrProperties do not contain initializers in backing fields,
as annotation properties are represented as Java methods.
Therefore, it is not possible to use initializer values as default values for constructor parameters.

However, K2 stores default values in annotation's constructor parameters,
so it is possible to fix this issue if they're properly transfered to the IR
and inspected in JvmAnnotationImplementationTransformer

#KT-47702 Fixed
#KT-47702 tag fixed-in-k2
2023-08-03 10:25:13 +00:00
Dmitrii Gridin 35b0cd65e9 [FIR] PsiRawFirBuilder: add missing script configurator
PsiRawFirBuilder#visitScript didn't work because it didn't
have a configurator
Now FirScriptConfiguratorExtension split into two parts:
* File
* Script

^KT-60728
2023-08-02 16:50:45 +00:00
mvicsokolova bed16f92b1 [atomicfu-K/N]: Support Native backend in atomicfu compiler plugin
Atomicfu compiler plugin supported transformations for K/N:
* atomic properties are replaced with volatile properties and all the operations are delegated to native atomic intrinsics
* atomic arrays are replaced with kotlin.concurrent.Atomic*Arrays
* all other features available on JVM are covered as well (custom atomic extensions, delegated properties, debug tracing)

See (KT-58358, https://github.com/Kotlin/kotlinx-atomicfu/issues/261)

Merge-request: KT-MR-11253
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-31 14:48:28 +00:00
Sergey.Shanshin 6417f6456f [KxSerialization] Implemented addition of annotations to the named companion
For a more efficient lookup of a companion with the functions of obtaining a serializer, a special annotation is added to the named companions.


Merge-request: KT-MR-11003
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-28 15:53:09 +00:00
Andrei Klunnyi 419381af7f KT-60749 Scripting: default definition as a fallback
This commit effectively reverts changes made in the scope of KT-60193,
namely c9eebffb and 2d50bd68.

^KT-60749 fixed
2023-07-28 15:46:45 +00:00
Alexander Udalov 72d048bd62 JVM: introduce JvmBackendConfig
Move language version settings, compiler configuration and different
flags there, and use this config everywhere in both backends instead of
GenerationState.

This will hopefully make GenerationState less of a "god object" and
remove the need to have it available everywhere, in particular in JVM IR
lowerings code, in the future.

Also, future refactorings will make it easier to inject backend-specific
behavior into common code, so that we would not need to handle support
of new features in the old backend.
2023-07-28 12:19:32 +00:00
mvicsokolova b6f8991072 [atomicfu-JVM]: Commonization of K/N and JVM (part 2)
The following transformations were commonized:

* generation of the transformed atomic extension signature
* building atomic array fields (arrays are now supported on both backends JVM and K/N)
* transformation of function calls on atomic array elements
* Generation and invocation of atomic extensions (the only difference is generation of synthetic value parameters)
* Changed synthetic parameters passed to the generated atomic extensions

See, KT-60528

Merge-request: KT-MR-11249
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-28 11:45:10 +00:00
Ivan Kochurkin 2eba7da5eb [FIR] Rename FirArrayOfCall to FirArrayLiteral 2023-07-27 17:53:44 +00:00
Pavel Mikhailovskii 7ecd7b8e61 [KAPT] Refactor Kapt 3 components for reuse in Kapt 4 (KT-51982)
- make some utility functions and classes public
- split some classes into common and Kapt 3 - specific parts
- use Kapt 4-ready filtering of @Metadata annotations in tests
2023-07-26 14:03:14 +00:00
Ilya Chernikov 895a811b47 K2 Scripting: fix capturing from the imported scripts 2023-07-26 08:49:27 +00:00
Ilya Chernikov 020a590df7 K2 Scripting: fix order of arguments processing
and base class handling:
Since in K2 we do not distinguish between script arguments taken from
the base class and provided properties, we need this extra functionality
to preserve the argument order of K1 scripts.
This is a temporary measure, since we're going to deprecate base class
usage at some point (KT-60449), so the relevant constructor arguments
should disappear too.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 96bde033e1 K2 Scripting: add support for imported scripts 2023-07-26 08:49:26 +00:00
Ilya Chernikov d24fc3b581 K2 Scripting: add support for result field 2023-07-26 08:49:26 +00:00
Ilya Chernikov 480ea80fc4 Enable K2 scripting tests 2023-07-26 08:49:26 +00:00
Ilya Chernikov 0d7a5c6b1b Scripting: fix string script source location
fixes proper script definition discovery for expressions and other
scripts created from a string.
2023-07-26 08:49:26 +00:00
mvicsokolova 5c5367d377 [atomicfu-JVM] Preparation for commonization of JVM and K/N transformers
The following updates in the JVM/IR plugin were made:
* Lots of refactoring with preparation for K/N support: commonization of transformations.
* Improved error handling (checks for visibility constraints, appending message about usage constraints in case of an error).
* Explicit requirements for the visibility of atomic properties: to prevent leaking they should be private/internal or be members of private/internal classes.
* Fixed visibility of generated properties: volatile properties are always private and atomic updaters have the same visibility as the original atomic property.
* Volatile fields are generated from scratch and original atomic properties are removed.
* Delegated properties support is fixed (only declaration in the same scope is allowed).
* Non-inline atomic extensions are forbidden.
* For top-level atomics: only one wrapper class per file (with corresponding visibility) is generated.
* Bug fixes.

The corresponding tickets: 
https://github.com/Kotlin/kotlinx-atomicfu/issues/322
KT-60528



Merge-request: KT-MR-10579
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-20 13:59:23 +00:00
Ivan Kylchik 1dec9fc675 [JVM_IR] Move methods that generate LN into LineNumberMapper class 2023-07-20 09:01:43 +00:00
Mikhail Glukhikh 66bbb9582c K1/K2: split incremental compilation tests properly (relates to KT-59171) 2023-07-19 09:34:58 +00:00
Dmitrii Gridin 7620289f6f [FIR] fix contract violation from meta annotations
^KT-60448 Fixed
2023-07-18 16:50:25 +00:00
Dmitriy Novozhilov 8ad202eb8b [IR] Remove descriptor-related methods from SymbolTable
Replace them with calls to SymbolTableExtension
2023-07-17 21:02:39 +00:00
Sergey.Shanshin a45fe2d8a8 [KxSerialization] Implemented generation of companions for interfaces
For interfaces with custom serializer (@Serializer(`SerializerType::class)`) now the `serializer()` function is generated in the companion so that user can get a serializer by type

Merge-request: KT-MR-11040
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-17 19:44:01 +00:00
Brian Norman 70662007a5 [AllOpen] Private properties can be considered stable even when open
The AllOpen plugin can make private members open. But for private
properties, they can be considered stable for smart-casting if they do
not have a custom getter.

#KT-58049 Fixed
2023-07-17 11:49:24 +00:00
Sergey.Shanshin 5ba1b36796 [KxSerialization] Change visibility for synthetic functions
- synthetic constructor became internal for final classes
- write$Self became internal for final classes

Resolves https://github.com/Kotlin/kotlinx.serialization/issues/2209

Merge-request: KT-MR-9068
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-14 17:36:22 +00:00
Andrei Klunnyi 2d50bd6857 KT-60193 scripts: configuration discovery might fail silently (2)
This commit covers one more case similar to what is described
in the previous commit of the series (c9eebffb).
2023-07-13 13:31:52 +02:00
Mikhail Glukhikh 9d9d7880af K2: render types in quotes in diagnostic messages 2023-07-13 09:07:39 +00:00
Mikhail Glukhikh c839cd3c11 K2: don't use debugging type renderer in error messages 2023-07-13 09:07:39 +00:00
Pavel Mikhailovskii 6e6a4d6411 KT-59836 [SLC] Copy type parameters from the parent interface to DefaultImpls methods 2023-07-10 13:11:21 +00:00
Andrei Klunnyi 527d20c7be KT-60171 K2-scripting: CLI specific providers are used in IDE context
^KT-60171 fixed

Merge-request: KT-MR-10987
Merged-by: Andrei Klunnyi <andrei.klunnyi@jetbrains.com>
2023-07-10 11:03:11 +00:00
Andrei Klunnyi c9eebffbfa KT-60193 K2 scripts: configuration discovery might fail silently
Due to possible data races configuration discovery might fail. So far,
it happened silently and we used so-called default one. This
configuration is unaware of specific implicit imports, receivers, base
class, etc. Hence, broken highlighting and navigation.

This commit introduces the following changes:
1. Having default configuration for building `FirScript` is no longer an
   option. Missing configuration means error reported via exception.
2. Every configuration usage is now logged in DEBUG mode.
   Troubleshooting becomes easier.

^KT-60193 fixed
2023-07-07 14:50:35 +02:00
Dmitriy Novozhilov 8e73d5a54a [FIR] Run irGenerationExtensions after IR actualization
^KT-56173 Fixed
2023-07-07 11:26:15 +00:00
Dmitriy Novozhilov 81da96fed3 [FIR Plugin] Reproduce KT-56173 2023-07-07 11:26:15 +00:00
Pavel Mikhailovskii 083f54aceb [KAPT4] Create basic infrastructure for KAPT4 2023-07-07 11:09:16 +00:00
Leonid Startsev f3833fdcf8 Add serializer(vararg KSerializer<*>) override from SerializerFactory when necessary
SerializerFactory is an implementation detail for Kotlin/JS and Native:
it should be added as a supertype to a companion object of certain serializable classes
and `serializer(vararg KSerializer<*>)` function from it should be implemented.
Existing implementation added the supertype, but did not add proper override to FirClass
of a companion, which led to various warnings and errors like 'Abstract function 'serializer' is not implemented in non-abstract companion object'.

Also implemented the addition of SerializerFactory supertype to user-defined companions within @Serializable and @MetaSerializable when necessary.

Also set up proper box tests for FIR+Kotlin/JS combination.

#KT-58501 Fixed
#KT-59768 Fixed
2023-07-06 11:38:51 +00:00
Dmitriy Novozhilov 037572ee9f [FIR] Create FirExtensionSyntheticFunctionInterfaceProvider only once for all sessions
This is needed to avoid duplication of symbols for the same classIds

^KT-58539 Fixed
2023-07-06 11:00:38 +00:00
Dmitriy Novozhilov d46f697cf8 [Test] Reproduce KT-58539 2023-07-06 11:00:38 +00:00
Dmitriy Novozhilov 1212128f04 [FIR plugin] Replace composable functions with regular kotlin functions 2023-07-06 11:00:38 +00:00
Ilya Chernikov 02e2438d37 K2 Scripting: fix script this receiver handling in IR
also fix accessor lowering
2023-07-05 19:46:04 +00:00
Ilya Goncharov 148d8c9246 [Gradle, JS] Migrate JS cli tests to ir backend 2023-07-05 07:10:06 +00:00
Sergey.Shanshin 3629a9db30 [KxSerialization] Added inspection on abstract custom serializer
Serialization requires an instance of the serializer, which cannot be obtained with the passed interface, abstract or sealed class.
Therefore, the specifying of such classes in `Serializable` annotation must be prohibited.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2173
Relates #KT-58036

Merge-request: KT-MR-10753
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-04 18:31:35 +00:00
Sergej Jaskiewicz 6281faa063 [IR] Move IrFactory#createBlockBody overloads to extension methods
This is to prepare for IrFactory auto-generation (KT-59308).
2023-07-04 15:19:28 +00:00
Mads Ager 607d38f96f [K2 plugin] Support simple arguments in annotation metadata extension.
^KT-58968
^KT-60051 Fixed
2023-07-04 14:11:26 +00:00
Sergej Jaskiewicz 9fcdc10019 [IR] Reorder parameters in IrFactory#createValueParameter
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 12:41:02 +00:00
Nikolay Krasko 7f751c5d61 Fix signing in :kotlin-annotation-processing-embeddable
Problem is reproducible only when singing is enabled.
Register dependencies between publication and signing tasks.
It looks like signing tasks have same output and need to be registered
in all publications.

Error:

* What went wrong:
Some problems were found with the configuration of task ':kotlin-annotation-processing-embeddable:publishMainPublicationToMavenLocal' (type 'PublishToMavenLocal').
  - Gradle detected a problem with the following location: '/Users/Shared/Projects/kotlin/plugins/kapt3/kotlin-annotation-processing-embeddable/build/libs/kotlin-annotation-processing-embeddable-1.9.255-SNAPSHOT-sources.jar.asc'.

    Reason: Task ':kotlin-annotation-processing-embeddable:publishMainPublicationToMavenLocal' uses this output of task ':kotlin-annotation-processing-embeddable:signGradleCompatPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Reproduce:

gradle :kotlin-annotation-processing-embeddable:publishToMavenLocal -Psigning.gnupg.keyName=* -Psigning.gnupg.passphrase=* -PsigningRequired=true

KTI-1282
2023-06-28 18:00:14 +00:00
Leonid Startsev 283f816320 Use source-version of kotlinx-metadata-jvm for embedding
Embedding published version while using source one can lead to runtime errors like NoClassDefFound
if a new (not yet published) declaration was used in implementation.
2023-06-27 15:12:46 +00:00