Commit Graph

3508 Commits

Author SHA1 Message Date
Dmitrii Gridin 5b3f617378 [FIR] add memberRequiredPhase to declaredMemberScope
^KT-56551
2023-05-19 12:43:45 +00:00
Vladimir Dolzhenko 4a1552e907 Use nameSequence instead of file extensions to reduce memory allocations
#KTIJ-25470
2023-05-17 12:45:19 +00:00
Sergej Jaskiewicz 56f977f70c [IR] Don't render facade classes in JVM fq-names in irText tests
This makes the tests more compatible with non-JVM backends
(see KT-58605)
2023-05-17 12:43:35 +00:00
Mads Ager 6117f76a8c Discourage the use of LANGUAGE_VERSION directive.
Pinning the language version is rarely the right thing to do.
This changes makes it harder to do so by requiring an additional
directive with a name that indicates to developers that they are
likely doing something dangerous.
2023-05-15 14:29:48 +00:00
Vladimir Dolzhenko 8ad781987e Optimize file extensions usage
#KTIJ-25470

Merge-request: KT-MR-10135
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-05-15 13:59:24 +00:00
Alexander Udalov d757847ed6 JVM: enable -Xlambdas=class for some backend tests
These tests are checking the specifics of the class-generated lambdas.
2023-05-12 15:21:00 +00:00
Bogdan Mukvich 3de59e3f17 Fix kotlinx-atomicfu-runtime sonatype publication
^KT-56400
2023-05-12 12:54:52 +00:00
Mads Ager 089928ba2b [K2] Support legacy serialization for custom function type extensions.
For Compose libraries, it is important that libraries built with
K2 in version 2.0 can be read and used by a version 1.9 K1
compiler. That is not possible if custom function types are
in the metadata.

^KT-58456 Fixed
2023-05-12 10:49:43 +00:00
Yahor Berdnikau eef7c3e834 Publish serialization plugin as kotlin-serialization-compiler-plugin
With this change it will have consistent naming with other compiler plugins.

'-embeddable' was also renamed.

'dist' should contain two identical jar files:
- 'serialization-compiler-plugin.jar'
- 'kotlinx-serialization-compiler-plugin.jar'

^KT-58530 In Progress
2023-05-12 09:31:41 +00:00
mvicsokolova 0d7625a262 Atomicfu-runtime: changed kotlin.js.compiler option to IR
Fixes KT-56400

Merge-request: KT-MR-10103
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-05-11 18:12:24 +00:00
Sergej Jaskiewicz 1a371350ea [IR] Make IrClassifierSymbol a sealed interface 2023-05-10 11:51:25 +00:00
Dmitriy Novozhilov d579798169 [Serialization] Ensure that KT-57770 is fixed
^KT-57770 Fixed
2023-05-10 07:30:29 +00:00
Alexander Udalov c06ec84bb1 JVM: fix type mapping of big arity suspend function types
The code in IrTypeMapper was incorrectly translated from
KotlinTypeMapper during the development of JVM IR. The
`classDescriptor.hasBigArity` condition in KotlinTypeMapper was checking
if the class represents a function or a suspend function with big arity,
and the suspend function part was lost during conversion.

This resulted in incorrect generic signature being generated, which led
to malformed type exceptions from reflection, and compilation errors
from kapt stub generation.

Also, change a comment in irCodegenUtils to avoid confusion of numbered
function types (kotlin.jvm.functions.Function1, ...) with the big-arity
type kotlin.jvm.functions.FunctionN.

 #KT-58375 Fixed
2023-05-09 12:57:07 +00:00
Sergey.Shanshin c9bde57e44 [KxSerialization] Fix NPE if sealed class has self-referencing property
Fixes Kotlin/kotlinx.serialization#2294

If the serializable class contains itself as a property, and its serializer is not an object (for example, for a sealed class), in this case there is a race in the initialization of the serializer and child serializers.

To avoid this the serialization class should not cache its own serializer as a child.

Merge-request: KT-MR-10019
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-05-09 09:59:11 +00:00
Alexander Udalov 530725c6bf Kapt+JVM_IR: do not generate secondary constructor bodies
In addition to ceedad40f3, do not generate bodies of constructors which
delegate to super.

 #KT-58226 Fixed
2023-05-08 09:08:07 +00:00
Andrei Klunnyi 1e0115aef8 KT-57468 Kotlin assignment plugin: operation name cannot be found
The problem results in broken import quick fix and import optimizer on
the IDE side [1].

`AssignResolutionAltererExtension` introduced a possibility to override
 resolution of assignment statements. The inconsistency though is
 that `KtSimpleNameReference.getResolvesByNames` doesn't return a name
 for the overridden `=`. Kotlin as a language doesn't support this [2].

This commit eliminates the drawback above:
1. It fixes the name `assign` the `=` can be resolved to [3].
   This eliminates the need to search for the name, bypassing the
   plugins.
2. `KtSimpleNameReference.getResolvesByNames` returns `assign` among
   other names in case it deals with binary `=` and assignment is
   resolved.
3. `KtCompilerPluginsProvider` was extended to check plugins' presence.
   K1 implementation added.

----------------------------------------------------------------
[1]: https://youtrack.jetbrains.com/issue/KTIJ-24390
[2]: OperatorConventions.getNameForOperationSymbol
     https://kotlinlang.org/docs/operator-overloading.html#augmented-assignments
[3]: OperatorConventions#ASSIGN_METHOD + AssignmentPluginNames
2023-04-27 14:05:02 +00:00
Kirill Rakhman a818c543a9 [FIR] Verify diagnostic messages don't reference non-existent parameters 2023-04-27 12:54:31 +00:00
Bogdan Mukvich b0d964ec8b Use JDK 8 as JAVA_HOME for kapt tests
* kapt tests launch scripts in a child process relied on JAVA_HOME
* tests fail under JDK 11 due to illegal reflexive access
2023-04-27 12:25:20 +00:00
AngryGami bfeff81867 Presence of (transient) delegated field in the serialized class breaks deserialization (#5103)
Do not include delegated field into generated constructor even though it
might have backing field.

Test that shows issue was added. Properties that are explicitly marked
as delegated are now excluded.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2091
2023-04-26 12:28:57 +02:00
Alexander Udalov 3120a35a88 JvmDefault: remove most tests on @JvmDefault
The tests are removed because JvmDefault is going to be deprecated with
error in KT-54746 and removed later in KT-57696.

Many of the removed tests already had existing counterparts with the new
modes `all` and `all-compatibility`. In this change, I've added such
tests where they were missing, and removed tests which were testing
behavior specific to the JvmDefault annotation, such as some
diagnostics.

 #KT-54746
2023-04-25 14:33:00 +00:00
Mikhail Glukhikh dc38ce24f7 K2: fix field annotation splitting and frontend checks
Related to KT-57135
2023-04-25 12:18:26 +00:00
Nikolay Lunyak e3d313dd02 [FIR] Introduce the proper Fir2IrResultsConverter
Sometimes when running MPP tests we may
observe js-specific modules running with
the jvm-specific fir2ir converter
(probably because the name didn't contain
the JVM affix).
2023-04-25 11:29:34 +00:00
Yahor Berdnikau eb4e96a113 Add kotlin-build-tools-enum-compat workaround
It acts as a workaround for the case when build tools or dependencies
are compiled with latest 'kotlin-stdlib' version, but at a runtime older
 'kotlin-stdlib' is provided, which does not know about new
 `EnumEntries`.

 ^KT-57317 Fixed
2023-04-21 14:57:17 +00:00
Nikolay Krasko 9e00bb8a21 [213] More dependencies aalto + stax2
KTI-1114
2023-04-21 13:19:05 +00:00
Roman Golyshev 83f9e0f87e [213] Add more missing runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev ac388010b1 [213] Add missing test runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Sergey.Shanshin d8d643b7d7 [KxSerialization] Fix "IllegalAccessError: Update to static final field"
Fixes #KT-57647

For value classes, if you add code to companion anonymous init block in IR, it will be executed in the instance constructor. This causes an error when initializing static fields, because writing to them can only occur from the <clinit> method.

The solution is to transfer the static field initialization code from an anonymous init block to the IR initializer of this field

Merge-request: KT-MR-9633
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-04-21 12:37:32 +00:00
Pavel Mikhailovskii 58143a2006 KT-57598 Run Kapt with K1 even when the compiler is run with K2 2023-04-20 09:30:38 +00:00
Alexander Udalov bc7aea1426 Kapt+JVM_IR: generate delegated members correctly
Generate a declaration for each delegated member without body. If we
don't generate delegated declarations, subclasses will have incorrect IR
with unbound symbols in fake overrides.

 #KT-58027 Fixed
2023-04-19 23:04:45 +00:00
Leonid Startsev f29e505bd3 Use correct check in FirSerializationPluginClassChecker to determine if the given type is a enum class.
Otherwise, findTypeSerializerOrContextUnchecked works incorrectly when analyzing code
compiled with Kotlin 1.7.20 and serialization 1.4.1.

#KT-57704 Fixed
2023-04-19 16:13:28 +00:00
Leonid Startsev ef9074e24d Correctly support nullability in type arguments for serializer<T>() intrinsic.
Nullability info should be added to TYPE_OF operation marker.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2265
2023-04-19 12:31:19 +00:00
Leonid Startsev fa8f38c2c8 Don't fail if there is no serializer for type parameters of contextual serializer
Return null instead.
Such behaviour is needed to support cachedChildSerializers logic.
Since this field creator doesn't provide genericGetter (because it's
static),
type param serializer can't be retrieved, and the whole contextual
serializer shouldn't be cached.

#KT-58067 Fixed
2023-04-19 10:09:06 +00:00
Leonid Startsev d9e16fb76e Do not create cacheableChildSerializers unless it is necessary
Creation of this property in the SerializerIrGenerator.<init> can lead to
a 'Serializer not found' internal error when generator is applied to a fully-customized external serializer.
In that case, generator is still created, but none of the generateSave/Load functions are called,
so cacheableChildSerializers(Property) is not necessary.

#KT-57730 Fixed
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2260
2023-04-18 11:04:56 +00:00
Sebastian Sellmair 5d0bf2de24 [CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2

Reverts:
- 9dcd40d7b7
- fb66764c4d

KTIJ-25227
2023-04-18 09:18:10 +00:00
Mads Ager 699ad87be2 [KAPT+IR] Use ErrorType for unresolved delegate class.
^KT-57946
2023-04-17 16:49:11 +02:00
Yahor Berdnikau 1eb27f2aac Update publishing and usage of kotlin-annotation-processing plugin
- removed 'kotlin-annotation-processing-gradle' publication as it
duplicated 'kotlin-annotation-processing-embeddable'
- removed 'kotlin-annotation-processing-maven' as it is embedded into
  'kotlin-maven-plugin'. Instead 'kotlin-maven-plugin' now depends on
  'kotlin-annotation-processing' directly.

^KT-52811 In Progress
2023-04-17 14:40:51 +00:00
Yahor Berdnikau a58d6fd13a Publish 'kotlinx-serialization-compiler-plugin' separately
- Also publish 'kotlinx-serialization-compiler-plugin-embeddable' to be
used with 'kotlin-compiler-embeddable'.
- Now Serialization Maven and Gradle plugins do not embed plugin into
itself, but declare on published one normal dependency.
- 'kotlin-serialization-unshaded' publication is deprecated.

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 78c94b65b9 Change sam-with-receiver plugin to use published compiler plugin
- also publish 'kotlin-sam-with-receiver-compiler-plugin-embeddable' to
  be used with 'kotlin-compiler-embeddable'
- 'kotlin-maven-sam-with-receiver' now just adds
  'kotlin-sam-with-receiver-compiler-plugin' as normal dependency
  instead of embedding it into itself

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau a58266050f Publish noarg compiler plugin separately
- also publish 'kotlin-noarg-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-embeddable'
- 'kotlin-noarg-maven' plugin now just adds
  'kotlin-noarg-compiler-plugin' as normal dependency instead embedding
  it into itself

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 1a4d203d1c Publish lombok compiler plugin separately
- also add 'kotlin-lombok-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-emebeddable'
- 'kotlin-maven-lombok' does not try to embed plugin into itself and
  just depends on compiler plugin as normal dependency

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 5e41cbda75 Change kotlin-assignment plugin to use published compiler plugin
^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Yahor Berdnikau 1ccd7afde7 Publish allopen compiler plugin separately
- added also 'kotlin-allopen-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-embeddable'
- 'kotlin-maven-allopen' now just depends on
  'kotlin-allopen-compiler-plugin' instead of "embeding" it into itself

^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Yahor Berdnikau 64f8b87b66 Publish atomicfu compiler plugin separately
- rename plugin into 'kotlin-atomicfu-compiler-plugin'
- add 'kotlin-atomicfu-compiler-plugin-embeddable' to be used with
  'kotlin-comiler-embeddable'

^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Alexander Udalov 287e0909cc Kapt+JVM_IR: do not generate super constructor call
#KT-57699 Fixed
 #KT-57939 Fixed
2023-04-17 10:40:15 +00:00
Nikolay Lunyak 20786bb35a [FIR] Refactor the default messages presence checking
Forbid calling `checkMissingMessages` accidentally
outside tests.

Checking Parcelize default messages inside a test.
2023-04-14 13:07:03 +00:00
Artem Kobzar f0aa6c6d32 [K/JS Gradle] Remove forceLegacyBackendUsage from KotlinGradlePlugin previously added with the compiler flags refactoring, also fix bootstrap compilation of atomicfu plugin 2023-04-12 14:04:34 +00:00
Dmitriy Novozhilov 94f77add49 [FIR] Try to load properties in order according to kotlinx.serialization metadata extension
Move metadata extension with property order from kotlinx.serialization to core

After fix of KT-54792 properties will be deserialized in declaration order
  if corresponding class was compiled with modern compiler. But this order
  is needed for kotlinx.serialization for binaries compiled with any
  kotlin compiler >= 1.4. Since we don't plan to add any extension points
  into (de)serialization into FIR, we need to take into account existing
  metadata extension from kotlinx.serialization in compiler itself

^KT-57769 Fixed
2023-04-11 13:43:39 +00:00
Dmitriy Novozhilov 839026b6fe [FIR2IR] Generate IR declarations in classes in strict order
Order is following:
- declared declarations in declaration (in source) order
- generated declarations in sorted order
2023-04-11 13:43:38 +00:00
Sebastian Sellmair 9dcd40d7b7 [CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE

KTIJ-24976
2023-04-06 16:03:03 +00:00