Commit Graph

3569 Commits

Author SHA1 Message Date
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
Leonid Startsev b15da7c63a Deprecate old kotlinx-metadata flags API:
Flag, Flag constants, Flags typealias, flagsOf() function, and
Flag accessors in nodes (such as KmClass.flags, KmClass.jvmFlags, KmProperty.setterFlags, etc)

#KT-59440
2023-06-27 15:12:46 +00:00
Alexander Udalov ecc1f9fb0b Update to kotlinx-metadata-jvm 0.6.2
Migrate to the new API in kotlin-reflect build script, remove obsolete
workarounds.
2023-06-27 14:32:15 +00:00
Alexander Udalov 5451477eb0 Minor, remove useLegacyAbiGen test mode
Legacy jvm-abi-gen was removed in KT-55375.
2023-06-27 14:32:15 +00:00
Troels Bjerre Lund 111bb461a9 CLI: Change kotlin reflection to java reflection
The command line argument parser is using between 0.25s and 0.5s
(depending on platform) on finding annotated properties. This fix
replaces the slow kotlin reflection with java reflection, which is an
order of magnitude faster.

 #KT-58183 Fixed
2023-06-27 08:34:40 +00:00
Alexander Udalov c66bc36382 Build: fix some warnings in buildSrc and build.gradle.kts 2023-06-26 15:42:21 +00:00
Sergej Jaskiewicz 2b4a08524d [IR] Reorder parameters in IrFactory#createTypeParameter
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-26 09:52:11 +00:00
Alexander Udalov 755d140e16 Parcelize: do not copy call in ParcelizeIrTransformer
This is just a refactoring/optimization that makes use of the fact that
IrCall.symbol and IrFunctionReference.symbol are now mutable.
2023-06-22 17:19:00 +00:00
Sergej Jaskiewicz 0b7db067e6 [IR] Reorder parameters in IrFactory#createField
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 15:55:02 +00:00
Alexander.Likhachev 01276bbe49 [Build] Fix buildscripts deprecation warnings
#KTI-1221 In Progress
2023-06-22 15:16:08 +00:00
Alexander Udalov 4ac6f01d31 Add ReplaceWithSupertypeAnonymousTypeTransformer to light analysis tests
To make these tests behave closer to kapt, since kapt is the primary use
case for the light analysis mode.

AbstractLightAnalysisModeTest compares the text dump of bytecode
obtained with full analysis and light analysis, removing things like
anonymous/synthetic entities. In the light analysis mode anonymous
objects in supertypes are always approximated, and in the full analysis
mode they are always present as is in signatures. So we're transforming
the text dump in the same way, by approximating anonymous objects in
signatures (more precisely, in return types of methods and fields) to
the supertype.
2023-06-22 17:10:51 +02:00
Alexander Udalov c5f44486a9 Rename KaptAnonymousTypeTransformer and move to frontend.java
This is needed in order to run light analysis mode tests for JVM IR
backend. In the subsequent commit, this extension is added to light
analysis mode tests.

Kapt stub generation uses this extension to transform local types to
non-local:

    private val x = object {}

With this extension, x's type will be `Any`. Without it, it will be an
anonymous type. This anonymous type was not a problem for the old JVM
backend, but it's difficult to translate it in the IR infrastructure in
the light analysis mode where bodies are not resolved.

When kapt stub generation works with JVM IR enabled,
KaptAnonymousTypeTransformer ensured that backend would not crash and
stubs would contain something useful.

However, this is not happening in light analysis mode tests, which are
supposed to check how compiler behaves in the light analysis mode which
is used in kapt.
2023-06-22 17:10:50 +02:00
Alexander Udalov 8653992ffc K2 CLI: wrap module name into angle brackets
This is not a user-visible change, so no issue is created and no tests
are added.

K1 uses angle brackets, and it will be very convenient to have the same
module names in K1 and K2, in particular to compare IR dumps where
almost everything is the same (up to a certain point) except the module
name.
2023-06-21 14:16:42 +00:00
Dmitriy Novozhilov 5717b59f52 [FIR/IR] Introduce an ability to propagate generated IR annotation to metadata
^KT-58638 Fixed
2023-06-21 06:56:59 +00:00
Dmitriy Novozhilov 24e07fdfe0 [FIR plugin] Add test for plugin which generates annotations on IR
^KT-58638
2023-06-21 06:56:59 +00:00
Dmitriy Novozhilov fd670d33cb [FIR plugin] Compile annotations in plugin sandbox to jvm and js
This is needed for further testing of plugins with JS backend
2023-06-21 06:56:59 +00:00
Ilya Chernikov ae10eebc84 minor: scripting: fix processing of externally provided options 2023-06-20 16:38:32 +00:00
Ilya Chernikov 30131e289f minor: improve tests failure reporting 2023-06-20 16:38:32 +00:00
Ilya Chernikov 7db9f9c3ae minor: script some test cases to speedup parallel execution 2023-06-20 16:38:32 +00:00
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