Commit Graph

3533 Commits

Author SHA1 Message Date
Alexander Udalov 04998cff8a Kapt+JVM_IR: fix error on delegation to anonymous object
In kapt stub generation mode, psi2ir does not generate bodies of
declarations. This means that the delegate type was translated into an
IrType which is based on a class which is not generated by psi2ir, thus
leading to an unbound symbol error. The fix is to avoid using anonymous
types for delegate fields in this mode.

 #KT-59211 Fixed
2023-06-16 23:03:39 +00:00
Alexander Udalov fd4e59f279 Kapt+JVM_IR: do not generate bodies of enum entries
#KT-59247 Fixed
2023-06-16 22:48:11 +00:00
Mikhail Glukhikh 8e882ea797 K2 plugins: create companions with same expect/actual as their owners
#KT-59299 Fixed
2023-06-16 17:55:45 +00:00
Brian Norman 5fe5113344 [Test] Sort FIR diagnostics by offset for consistent rendering 2023-06-15 13:49:41 +00:00
Bogdan Mukvich b4004763cc [Gradle] Fix pom for kotlin-annotation-processing-gradle
^KTIJ-25586
2023-06-12 11:45:26 +00:00
Sergey.Shanshin 441b22c0fd [KxSerialization] Fixed error accessing the descriptor from companion
Relates #KT-57647

If a serialization descriptor is used in the companion, then when accessing the child elements, an array of cached child serializers may be read.
Since the serialization plugin adds its declarations to the class after the declarations from the source code, the initialization of the array of child serializers occurs after the execution of the user code.
This can lead to N PE errors when trying to access an unfilled cached child serializer.

The solution is to change the order of declarations so that the declaration with the property of cached child serializers comes first.

Merge-request: KT-MR-10545
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-06-09 15:32:28 +00:00
Brian Norman b595328192 [Parcelize] Ignore all sealed classes in Parcelize FIR generator
Sealed classes are inherently abstract and should not have Parcelable
functions added via the FIR declaration generator.

#KT-59112 Fixed
2023-06-08 12:58:32 +00:00
Yahor Berdnikau 4a501a257e [Gradle] Restore Kapt import compatibility with older Kotlin plugin releases
Still supported IDEA/Kotlin plugin releases relies on
'kotlin-annotation-processing-gradle' artifact name in compiler plugins
classpath. I've restored this publication usage until we will stop
support Kotlin plugin versions that doesn't know about
'kotlin-annotation-processing-embeddable' name.

^KTIJ-25586 Fixed
2023-06-07 13:21:57 +00:00
Dmitriy Novozhilov 2290a096d1 [Test] Add JVM platform to name of ..FirLoadCompiledKotlin.. tests
This is needed for further distinguishing them with similar JS tests
2023-06-07 10:58:01 +00:00
Brian Norman 48484368c7 [Test] Support RENDER_DIAGNOSTICS_FULL_TEXT directive for FIR tests 2023-06-06 15:42:21 +00:00
OliverO2 027593cd78 [KxSerialization] Fix NPE when accessing delegated property
Kotlin 1.7.20 added optimizations for delegated properties on the JVM,
which broke serialization for optimized properties. Commit bfeff81
tried to fix that, but broke non-optimized delegated properties. This
commit restores correct serialization for optimized and non-optimized
properties, also ensuring that it only affects the JVM target.

 #KT-58954 Fixed
 #KT-59113 Fixed
2023-06-06 17:17:39 +02:00
Aleksander Kuznetsov 53c488079f [serialization] permit multiple occurrences of lazy function in sources
IDEA projects may have duplicate dependencies on kotlin stdlib. In that case, `IrPluginContext.referenceFunctions` may return more than one copy of each standard function, including three overloads of `kotlin.lazy`. And here's when serialization plugin may fail with an exception.

 It affects Kotlin debugger -- if such a project or module also has serialization plugin enabled, then it completely breaks new evaluation, meaning it's impossible to compute any expression.

Fixes IDEA-314785

Merge-request: KT-MR-10262
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-06-06 12:43:25 +00:00
Nikolay Lunyak 23f87eda1f [FIR] KT-57803: Report the error message for light tree
The renaming prevents the JVM clash.

^KT-57803 Fixed
2023-06-06 07:43:37 +00:00
Vladimir Dolzhenko 7f74950993 Adjust name of IntelliJ Kotlin Plugin team
Merge-request: KT-MR-10425
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-06-06 07:10:22 +00:00
Sergej Jaskiewicz f2031ae642 [IR] Don't print multifile/synthetic facade class names in irText tests
This only applies to JVM and fq-names in declaration references
in IR dumps.

This enables us to run more irText tests on platforms other than JVM
(see KT-58605).
2023-06-05 10:40:17 +00:00
Ilya Kirillov 78f09409b7 [Analysis API] move ClsKotlinBinaryClassCache/FileAttributeService service registration to StandaloneProjectFactory 2023-06-02 09:16:47 +00:00
Sergey.Shanshin 13e2a3ae94 [KxSerialization] Fix NPE if sealed class has self-referencing in generic parameter
Fixes #KT-58918

If the serializable class contains itself as a generic parameter of the 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.

Merge-request: KT-MR-10363
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-06-01 12:01:04 +00:00
Sergej Jaskiewicz fd76a34277 [IR] Don't print flags in declaration references in irText tests
This doesn't reduce the quality of tests, because the flags are still
printed for declarations themselves. We only omit them in references.

However, this makes the tests more compatible with non-JVM backends
(see KT-58605), because flags of referenced stdlib declarations may
differ among target platforms.
2023-05-30 17:26:30 +00:00
Alexander Udalov 60016d3e5b Remove obsolete compiler flag -Xuse-ir 2023-05-30 14:46:09 +00:00
Alexander Udalov bb4bb58453 Remove tests on -Xuse-ir compiler flag
This flag is going to be removed because old backend is not supported
anymore, therefore there's no need to test it.
2023-05-30 14:46:09 +00:00
Andrei Klunnyi 6535278bd3 [KT-58817] Implicit receiver for code completion
Prior to this commit code completion for .kts files was supported only
partially. Script has an implicit receiver - base class representing a
script itself, the point where its basic API resides. The knowledge of
this receiver was missing.

There are at least two context where this knowledge is crucial:
1. Code highlighting (worked fine)
2. Code completion (failed)

`FirScriptConfiguratorExtension` is responsible for filling
`FirScriptBuilder` with base script class (in addition to other
properties). See usages of [1] in its implementation.

The thing is that resolution during the completion works a bit
different. Instead of converting the entire `KtFile` it's interested
in `KtScript` only. See usages of [2].
`RawFirBuilder.Visitor.visitScript` is where implicit receivers were
missing.

Code completion and inspections applied to `.kts` files already have
`FirScript` and don't require its full reconstruction with expensive
`FirScriptConfiguratorExtension`. `RawFirBuilder.Visitor` was modified
to support sometimes already existing `FirElement`.

----------------------------------------------------------------
[1]: ScriptCompilationConfiguration.baseClass
[2]: RawFirBuilder.Visitor.convertScript
2023-05-26 12:55:01 +00:00
Andrei Klunnyi 2a1d4a42ae [KT-58817] Implicit import issues cannot be reported
To be reported with [1] imports require source. It was missing for
implicit script imports.

`FirScriptConfiguratorExtensionImpl` was extended and now adds fake
source elements (users don't see imports in the source code).

Since diagnostics for implicit import statements are meaningless for
IDE, they are suppressed in `LLFirDiagnosticReporter`.

----------------------------------------------------------------------
[1]: DiagnosticReporter.reportOn()
2023-05-26 12:55:00 +00:00
Andrei Klunnyi 28ff94533a [KT-58817] Add script-related extensions for FIR session
The following two registrars were missing:
- FirScriptingCompilerExtensionIdeRegistrar
- FirScriptingSamWithReceiverExtensionRegistrar

`FirScriptingCompilerExtensionIdeRegistrar` was introduced as a copy of
`FirScriptingCompilerExtensionRegistrar` adapted for usage from IDE.

`FirRegisteredPluginAnnotations` and `FirJvmTypeMapper` are mandatory at
`FirExtensionService.registerExtensions` and reported as missing at
runtime.
2023-05-26 12:55:00 +00:00
Andrei Klunnyi 1b8fd01969 [KT-58817] Star-imports are not handled
Default imports coming from script configuration can be of "star" type.
Prior to this commit they were effectively ignored due to a bug at FQN
assembly.

Before: org.gradle.dsl.* => org.gradle.dsl.
After: org.gradle.dsl.* => org.gradle.dsl
2023-05-26 12:55:00 +00:00
Alexander Udalov d32268c5cb JVM: do not assume that methods have body in BridgeLowering
They don't have bodies in the kapt stub generation mode.

 #KT-58787 Fixed
2023-05-25 12:07:58 +00:00
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