Commit Graph

3267 Commits

Author SHA1 Message Date
Sergey.Shanshin 339b152390 Implemented caching of child serializers
Resolves Kotlin/kotlinx.serialization#1918

Merge-request: KT-MR-7578
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2022-11-23 19:53:44 +00:00
Nikolay Lunyak 4b3dc008f0 [FIR] KT-54260: Fix the compiler crash
AllOpen plugin makes the properties all-open, but the annotation class
is left closed, because allopen for k2 literally checks
`classKind == CLASS`.

Since the properties are open, a
`NON_FINAL_MEMBER_IN_FINAL_CLASS` diagnostic is reported for them. It's
positioning strategy seeks for the explicit `open` modifier which is
not present.

The added test should not crash the compiler.

^KT-54260 Fixed
2022-11-22 20:25:38 +00:00
Ilya Kirillov 7781ad67d4 [FIR] introduce FirValueParameter.containingFunctionSymbol
^KT-55034 fixed
2022-11-22 18:25:30 +01:00
Leonid Startsev f627d81d53 Make diagnostic for @MetaSerializable on nested annotation
K2 plugin API has a limitation that meta annotations from plugin predicates
can't be used on nested annotations because their resolve process includes supertypes
resolve, that can be affected by the plugin itself. Therefore, @MetaSerializable
can't be applied to nested annotation classes in K2, which is reflected by
this diagnostic.

For old FE, diagnostic is lowered to WARNING with deprecation message.
2022-11-22 10:53:28 +00:00
Leonid Startsev 9586bf74e0 Use .fullyExpandedType to get serializable annotation from inside typealias
to correctly handle 'global customization via typealias' feature
in K2 serialization plugin.
2022-11-22 10:53:28 +00:00
Leonid Startsev 76fc7ce0ad Fix creating FirSerializableProperties for external classes.
External classes do not have primary constructor, so we need to use 0 as
value parameter count for them to be externally serializable when possible.
2022-11-22 10:53:27 +00:00
Leonid Startsev 56cd150554 Enable FIR plugin in SerializationComponentRegistrar
so real projects can be built with K2 and serialization.

Correctly register renderer for serialization plugin errors.
2022-11-22 10:53:27 +00:00
Leonid Startsev 1b9fdeadfe Do not enable serialization plugin intrinsics in K2
because they lead to an unbound symbol errors
2022-11-21 16:15:46 +00:00
Leonid Startsev 715a730819 Insert a runtime exception if star-projection type is encountered in serializer<T>() intrinsic
This makes behavior consistent with non-intrinsified version of this function and serializer(KType).

#KT-54878 Fixed
2022-11-21 16:15:46 +00:00
Jaebaek Seo 1a5a6474d6 Support TargetPlatform.isJs() for FIR 2022-11-15 16:50:17 +01:00
Nikolay Lunyak e34dd49872 [FIR] Get rid of the argumentMapping function.
It's just a duplicate of `resolvedArgumentMapping`. Plus there is a
member with the same name inside `FirAnnotationCall`.
2022-11-14 22:40:41 +02:00
mvicsokolova 9bd17f628d Atomicfu-compiler plugin: update test text files. 2022-11-13 21:58:25 +00:00
mvicsokolova 5708b2229a Atomicfu plugin (JS IR): fix for private delegated properties
Fixes https://github.com/Kotlin/kotlinx-atomicfu/issues/260
2022-11-13 21:58:25 +00:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
Alexander Udalov beb3759f5a Add jvm-abi-gen test on inline class with private ctor
KT-54897
2022-11-11 16:28:37 +00:00
Yan Zhulanow 6b198fd85f [Pill] Support 'java-test-fixtures' plugin 2022-11-11 11:28:33 +00:00
Yan Zhulanow 47b5ea0fc7 [Pill] Fix unit test running 2022-11-11 11:28:33 +00:00
Yan Zhulanow 8e494ceb99 [Pill] Update default run configurations 2022-11-11 11:28:32 +00:00
Leonid Startsev 474ef921d8 Use standard @Deprecated in place of special opt-in annotation
Remove @DeprecatedVisitor
2022-11-10 13:30:10 +00:00
Leonid Startsev 471882b743 Introduce @DeprecatedVisitor; mark up visitor-related declarations with it.
Provide convenient JVM writing API.

Get rid of ExperimentalUnsignedTypes.
2022-11-10 13:30:09 +00:00
Sergey.Shanshin af4308e634 Fixed replacing serializer origin for generated classes
Do not use plugin origin for user-written classes that have @Serializer annotation for some reason. Plugin origin makes them synthetic which is incorrect because they're available in source code. Example of such class: @Serializer(JsonElement::class) class JsonElementSerializer

Merge-request: KT-MR-7627
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2022-11-09 17:11:40 +00:00
Alexander Korepanov d5e9e87538 [JS BE] Drop JS scripting support
JS scripting uses the old IR to JS transformer.
 The new IR to JS transformer can not be used for
 JS scripting out of the box. Patching the new transformer for
 JS scripting is potentially dangerous and requires a lot of effort.
 Dropping JS scripting and the old IR to JS transformer allows to
 refactor and simplify JS BE codebase.
2022-11-04 14:15:15 +00:00
pyos a30d19b655 jvm-abi-gen: consider private type aliases to be public API
They can be referenced from public declarations right now.

^KT-54500 Fixed
2022-10-31 22:13:21 +01:00
Pavel Mikhailovskii 1215ae0fe7 KT-1436 Nicer compiler errors when the feature isn't supported 2022-10-31 13:49:57 +00:00
Ilya Chernikov 5d968bc2f4 Fix gradle scripts detection in the sources
#KT-54325 fixed
2022-10-31 09:30:13 +00:00
Sergey.Shanshin d4cfb002d0 Added support of named companion in serializable class to the FIR
Merge-request: KT-MR-7472
2022-10-27 12:48:29 +00:00
pyos b23de16b06 FIR Parcelize: register the error message factory 2022-10-27 10:19:21 +03:00
mvicsokolova 6a4e9f1d0f Atomicfu JVM IR: fixed visibility modifiers of generated declarations, should be private.
Fix for: https://github.com/Kotlin/kotlinx-atomicfu/issues/258
2022-10-26 12:59:25 +00:00
Alexander Udalov c813e03c1e Kapt+JVM_IR: do not generate nested enum as final
#KT-54187 Fixed
2022-10-24 12:48:22 +00:00
Ilya Chernikov b50a803b6f Make jdk root processing more robust
#KT-54337 fixed
2022-10-21 06:11:42 +00:00
Leonid Startsev 4cf50d7d23 Add checker for companion objects inside serializable class:
Warning for old FE, error in FIR

#KT-54441 Fixed

Merged-by: Leonid Startsev <leonid.startsev@jetbrains.com>
2022-10-20 10:18:04 +00:00
Dmitriy Dolovov 15635482aa [IR] Partial linkage: Enable it by just passing a boolean flag to IR linker constructor 2022-10-19 13:46:22 +00:00
Dmitriy Novozhilov 8fbb605034 [FIR] Rename containingClass function to containingClassLookupTag
Since this function returns lookup tag instead of FirClass or symbol
  the old name may lead to misunderstanding
2022-10-19 11:09:34 +00:00
Dmitriy Novozhilov 0eb34983cb [Assign plugin] Fix experimentality warning message 2022-10-19 11:09:33 +00:00
Ilya Chernikov 6627b62c21 Fix sources extraction when processing extension is on
The latter is used e.g. for scripts in source roots handling
as implemented in the commit
"Scripting: update scripts in source roots handling"
The former implementation did not covered all the cases.

#KT-54355 fixed
2022-10-18 16:29:06 +00:00
Leonid Startsev f1b1837f40 Rework SerialInfo$Impl annotation implementation to be available in FIR:
- IR plugin does not use it anymore,
regular annotation instantiation feature is used
(insertion of IrConstructorCall(annotationCtorSymbol)).

- IR plugin still generates `SerialInfo$Impl` class to be compatible
with previously compiled code & libraries.

- Custom implementation over descriptors in IR plugin is removed;
plugin now delegates to the existing lowering with some tweaks.

- $Impl descriptor is removed from FE 1.0 because it is no longer needed
for IR plugin; it shouldn't be exposed to users so FIR doesn't need it either.

- Since language lowering is now used, it is possible to correctly instantiate
SerialInfo annotations with default values even if they are from other modules
and even if they were not processed by the plugin.

#KT-48733 Fixed
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1574
2022-10-17 16:10:42 +00:00
Leonid Startsev 242b83edbd Prioritize @Serializable annotation on type usage over class usage
In `val p: @Serializable(X) Foo` and `@Serializable(Y) class Foo` situation,
now X would be chosen as serializer.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1895
2022-10-14 14:15:37 +00:00
Sergey.Shanshin 5a1c2c56bd Added support of external serializers to the FIR
Co-authored-by: Leonid Startsev <leonid.startsev@jetbrains.com>
Merge-request: KT-MR-7334
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2022-10-13 15:25:39 +00:00
Sergey.Shanshin 503f4d924d Added support of MetaSerializable to the FIR 2022-10-12 20:10:58 +00:00
Nikolay Krasko f43ad1cb7a Remove packed stdlib from Kotlin compiler plugin artefacts
Remove annotations, kotlin-stdlib-common, kotlin-stdlib.

Packing those libraries is wrong and probably unexpected. It leads to
artifacts size increase. Can be dangerous because of bad classpath.
And also have a reproducibility issue because of caching tricks around
KotlinVersionCurrentValue class.

KTI-942
2022-10-12 13:44:30 +00:00
Leonid Startsev 090aec6b3b Prohibit Array<T> in @Serializable classes
because it's impossible to correctly create array reflectively without
knowing correct KClass.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1243
2022-10-12 11:48:21 +00:00
Leonid Startsev 596949a501 Correctly handle star projections according to logic of the old FE.
#KT-54297 Fixed

Properly substitute surrogate UnitSerializer in the Companion.serializer()
function generated on classes that use polymorphic or sealed serializer
by default. (Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1692)
2022-10-12 10:36:26 +00:00
Leonid Startsev 2a626b27d3 Correctly determine the type of serializable property
when supertype of serializable class is generic and also serializable,
and contains the property with type with its generic parameter.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1264
#KT-43910 Fixed
#KT-49660 Fixed
2022-10-12 10:34:53 +00:00
Daniel Santiago 189be2b117 [KAPT] Setup KaptJavaLog writers during initialization.
Migrate KaptJavaLog to not used deprecated constructor in newer JDKs and instead set up the writers during initialization. This enables us to get rid of KaptJavaLog17.

Fixes KT-54030
2022-10-11 23:48:18 +02:00
Sergey.Shanshin f4845b8dd9 Marked write$Self and $serializer from serialization as synthetic 2022-10-11 17:05:03 +00:00
Ilya Muradyan 7f6bd2ab1e Fix compatibility issue for kotlin.jupyter 2022-10-08 04:02:39 +02:00
mvicsokolova cb23dbb492 atomicfu-compiler-plugin: support declaration of properties in objects for JVM IR
Fix: https://github.com/Kotlin/kotlinx-atomicfu/issues/241
Merge-request: KT-MR-6871
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2022-10-07 17:10:41 +00:00
pyos 8d33de4297 JVM: partially reify typeOf and signatures as soon as possible
E.g. when substituting T -> Array<T>, write the bytecode for the
Array<...> part for typeOf.

This fixes various issues where either Array nesting levels, nullability
information (for typeOf), or entire reification markers were missing,
causing incorrect outputs ranging from missing `?`s to missing `[]`s to
just reified types not really being reified.

^KT-53761 Fixed
2022-10-06 00:58:25 +02:00
Dmitriy Novozhilov c543a2e6d5 [Assign plugin] Publish embeddable version of assign plugin 2022-10-04 19:47:34 +00:00
Simon Ogorodnik 0fea8073ef Scripting Plugin. Update CoreFileTypeRegistry under lock
CoreFileTypeRegistry isn't thread-safe, so it should be updated under
application lock, to avoid concurrently mutating underlying structure
2022-10-03 13:36:06 +00:00