Commit Graph

207 Commits

Author SHA1 Message Date
Mikhail Glukhikh 03f2c6d38a [IR] Unbind construction methods of IrFieldImpl from symbol.descriptor 2020-05-25 15:40:36 +03:00
Mikhail Glukhikh ab15a88ce4 [IR] Unbind construction methods of IrPropertyImpl from symbol.descriptor 2020-05-25 15:40:36 +03:00
Mikhail Glukhikh 262548fd5b [IR] Unbind construction methods of IrFunctionImpl from symbol.descriptor 2020-05-25 15:40:36 +03:00
Roman Artemev 6bdd473eff [JVM IR] Fix plugin API for JVM IR
- Unmute ktx.serialization test
2020-05-12 14:29:55 +03:00
Roman Artemev 1949b11bb2 [KTX.SERIALIZATION] Refactor plugin once again 2020-05-12 14:29:54 +03:00
Mikhail Bogdanov 639af69185 Minor. Fix test data 2020-04-29 12:54:47 +02:00
Leonid Startsev 52933e161e Use AssociatedObjects on JS too
because JS IR now supports them
2020-04-28 20:51:24 +03:00
Leonid Startsev 205f29128a Updated testdata to a new generation strategy
Fix IR generation problems

(partially reverts cd931796bc)

Regenerate diagnostic testdata according to runtime changes
2020-04-28 15:48:14 +03:00
Roman Artemev cd931796bc [SERIALIZATION] Fix kotlinx.serialization plugin 2020-04-14 11:12:08 +03:00
Leonid Startsev 60efab24ea Add @SerializableWith on objects too
to be able to retrieve them via getAssociatedObject and serializer<T>()
function. Now object itself is a SerializerFactory.
2020-04-08 14:12:01 +03:00
Leonid Startsev d4fc6774f3 Support new 'typeParametersSerializers' function
from GeneratedSerializer
2020-04-08 14:12:01 +03:00
Leonid Startsev ceb3cfbfd5 Remove update* calls 2020-04-08 14:12:01 +03:00
Leonid Startsev add0b461ee Refactor calls to beginStructure
typeParams argument has been removed
2020-04-08 14:12:00 +03:00
Leonid Startsev 0054c22ef2 Use correct return type for serializers
from runtime library.
If used unsubstituted, they cause
e: java.lang.IllegalArgumentException: Unbound type parameters are forbidden
because type parameter T from e.g. PolymorphicSerializer<T> leaked outside.
2020-04-03 12:46:44 +03:00
Ilmir Usmanov be87d5fab5 JVM_IR: Serialization: do not mess with return types of call expressions
If return type of IrConstructor is different from containing class, we will
generate call to wrong <init> method, leading to VerifyError.
If we do not specify the type of irNull, it, by default, will be Nothing?,
when really we need Any?. This leads to CCE: cannot cast to Void at runtime.
2020-03-19 15:18:32 +01:00
Leonid Startsev e495c35ad7 Use upper bound as a type for polymorphic serializer
when it is used in sealed class case

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/753
2020-03-11 17:09:05 +03:00
Leonid Startsev 15fa6ea757 Do not insert @SerializableWith marker annotation if already present
Such situation may happen if generic class is customized by user
with object-kind serializer. In such case, both arguments from
generateSerializerGetter and generateSerializerFactory are objects.
See linked issue for details:

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/749
2020-03-11 17:07:17 +03:00
Leonid Startsev e20354926b Do not check 'no ctor parameters' for serializable enums
fixes https://github.com/Kotlin/kotlinx.serialization/issues/742

Do not use serializableIrClass if it is not bound (this may happen
in case we're generating external serializer for library class)

fixes https://github.com/Kotlin/kotlinx.serialization/issues/744
2020-03-11 17:07:16 +03:00
Leonid Startsev a2c24e696f Leverage existing psi2ir function declaration generator in plugin
This seems to be the only reasonable way to provide function declarations with
_correctly_ substituted type parameters without rewriting logic from scratch;
correctly scoped type parameters in IR are now required in serialization
plugin by all backends.

Also fix some missing upper bounds.
2020-03-05 16:40:55 +03:00
Mikhael Bogdanov 9052ef06a7 Introduce configureEnvironment, avoid 'createEnvironment' calls 2020-03-04 14:51:10 +01:00
Stanislav Erokhin 453008e488 Deprecated reportFromPlugin way to report diagnostics from plugin
Originally reportFromPlugin method was introduced to address the problem
with loading of DefaultErrorMessages.Extension vis ServiceLoader.
For some cases this extension was not loaded by ServiceLoader because
classes was loaded via different class loader, common scenario here is
compiler plugins. Ideally we should load such extension point via
getService approach, but unfortunately to do that we need project and
DefaultErrorMessages.render is static method for now.
Also with reportFromPlugin approach is a problem -- all diagnostics
reported via this method has the same id: PLUGIN_[WARNING|ERROR|INFO]
and it isn't possible to suppress only one particular diagnostic.
To bypass this problem the new method
initializeFactoryNamesAndDefaultErrorMessages was introduced.
It basically store DiagnosticRenderer inside DiagnosticFactory.
It is not ideal, because one DiagnosticFactory could have different
renderers for different scenarios -- for compiler and for IDE, but
I think that it is better than reportByPlugin approach.
2020-02-26 12:12:31 +03:00
Leonid Startsev bdf1441c80 Remove special casing for Unit in kotlinx.serialization
Unignore test since it is in muted list and auto-generated
2020-02-14 14:28:51 +03:00
Anton Bannykh e8fba8bcb6 IR API: change val ... : MutableList to var ...: List for most lists
All mutable state for IR declarations should be either:
- var (mutable properties)
- or class member list

Mutable properties are straightforward to persist.

The class member list is handled in a special way.
2020-02-06 21:03:32 +03:00
Leonid Startsev 9e8f21cc20 Search for standard serializers in both internal and root packages
To allow graduate migration of some classes (e.g. IntSerializer)
from kotlinx.serialization.internal.* to kotlinx.serialization.*
2020-01-23 12:40:06 +03:00
Leonid Startsev db4273d677 Pass actual serializable properties count in the generated code
to SerialClassDescImpl.
This is needed to optimize space allocation.
2020-01-23 12:40:04 +03:00
Leonid Startsev 9558538d15 Refactor plugin-generated call to EnumSerializer():
support new values() argument.
Get rid of old @JvmOverloads requirements in runtime.
2020-01-23 12:40:03 +03:00
Dmitriy Novozhilov 5cb7cf040a Update some testdata according switching compiler to 1.4 2020-01-20 16:41:46 +03:00
Leonid Startsev 137c500e3a Support SerializerFactory in Native
kotlinx.serialization plugin now adds additional function to companions
of generic classes in order to overcome lack of reflection. This
helps retrieving generic serializers from KType.
2020-01-20 13:16:17 +03:00
Leonid Startsev 9bd966c123 Supply correct Native platform for module descriptor while compiling from CLI 2020-01-15 12:48:49 +03:00
Leonid Startsev f2026a49bb Support .decodeSequentially call on JVM and Native and remove READ_ALL handling from all platforms
Fix codegen test

Ignore JVM IR codegen test for a while since it requires updated kotlinx-serialization-runtime in classpath
2020-01-15 12:46:25 +03:00
Alexander Udalov 8a4510c21b Regenerate tests 2020-01-02 10:31:00 +01:00
Vyacheslav Gerasimov 68f1d91e1b as40: Upgrade to AS 4.0 C7 2019-12-25 20:19:36 +03:00
Michael Kuzmin 254dc8f71c Build: Drop IntelliJ 2018.3 and Android Studio 3.4 support
Delete *.183 and *.as34 bunch-files
2019-12-19 18:31:07 +03:00
Dmitriy Novozhilov e7f8c8e155 [TEST] Regenerate tests after previous commit 2019-12-12 16:11:45 +03:00
Leonid Startsev 19c28c55c5 Allow serialization plugin to work with inline types which are primitives (e.g. Char in JS IR) 2019-11-26 19:34:49 +03:00
Leonid Startsev 3d2800f99b Move out symbols that do not depend on a BackendContext to a separate BuiltinSymbolsBase class.
The goal was to be able to use such symbols before BackendContext is even created – in psi2ir postprocessing step (i.e., IR compiler plugins).

Remove old code from serialization ir plugin.
2019-11-26 15:26:35 +03:00
Leonid Startsev 3e18350a1f Rewrite IR plugin infrastructure (and serialization plugin) so it won't emit LazyIR.
LazyIR was emitted because plugin was not able to declare symbols, only to reference them.
Moreover, declarations added by frontend plugin were also unbound symbols produced by psi2ir,
and declaration stub generator was stubbing them with LazyIR – therefore access to global symbol table is not enough for plugins. IrProvider won't help here, because some functions produced by plugin have circular dependencies.

By moving compiler plugins step between psi2ir and declaration stub generator, both problems are resolved
– unbound symbols produced by psi2ir and compiler plugins are declared where they would be declared if this was a user code,
and only unbound symbols left are external dependencies, which is a correct input for lazy ir.
2019-11-26 15:26:28 +03:00
Mikhail Zarechenskiy eb73650209 Fix race in IDE: inject proper storage manager for type parameters
With NO_LOCKS strategy we can easily end up in a situation when
 constraint system for a generic call is built incorrectly,
 producing flaky errors (or don't produce errors at all)

 Now proper storage manager is injected for all cases except:
 - IR
 - Codegen
 - Serialization plugin
 - Fake local objects

 Most likely, NO_LOCKS strategy for these cases is fine as at that point
 the compiler works in one thread

 #KT-34786 Fixed
2019-11-26 10:52:45 +03:00
Leonid Startsev b9ac1341ff Export generic serializer constructor from JS module
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/609
2019-11-25 20:06:15 +03:00
Leonid Startsev 73b9d2466a Do not report 'Missing @Serializable on enum with @SerialInfo' if enum
has custom serializer

#KT-34991 Fixed
2019-11-25 20:06:14 +03:00
Alexander Udalov e4afbae954 Minor, fix test data for kotlinx.serialization bytecode text test 2019-11-21 16:44:30 +01:00
Roman Artemev 63110ab636 [IR] Remove deprecated correspondingProperty from IrField 2019-11-12 20:45:11 +03:00
Roman Artemev ed79ab68ab [IR] Remove DeclarationDescriptor from IrExpression* tree API 2019-11-12 20:45:11 +03:00
Roman Artemev b391c066d6 [IR] Pass class Type Parameters into IrConstructorCall factory explicitly
to avoid unexpected crash on uninitialized parent in psi2ir phase
2019-11-12 20:45:11 +03:00
Roman Artemev ba373c67d7 [IR] Remove FunctionDescriptor from IrCall-like node's constructor interface 2019-11-12 20:45:11 +03:00
Alexander Udalov ce09be3f59 Add TargetBackend.isIR, simplify JVM IR test configuration 2019-11-11 12:10:29 +01:00
Alexander Udalov efaf779133 Minor, fix test data for kotlinx.serialization bytecode text test 2019-11-04 16:17:58 +01:00
Alexander Udalov cf61957e3c Minor, fix kotlinx-serialization bytecode test data
After some changes to the JVM IR backend
2019-10-25 11:23:11 +02:00
Vyacheslav Gerasimov 38ea5a85a3 Build: Add maven publication for Kotlin plugin artifacts 2019-10-24 17:06:19 +03:00
Nikolay Krasko 4ed64b0283 Regenerate tests with TargetBackend.ANY remove and using runTest with this 2019-10-23 12:49:48 +03:00