Commit Graph

220 Commits

Author SHA1 Message Date
Mikhail Bogdanov
929bb0e8d1 Move common logic from CodegenTestCase to KotlinBaseTest 2020-06-19 11:57:36 +02:00
Ilya Muradyan
8c2baf0704 Add missing definitelyDoesNotContainName methods 2020-06-18 09:51:16 +02:00
Mikhail Glukhikh
175e94c0aa Revert kotlinx-serialization-compiler-plugin OptIn dependency 2020-06-16 19:17:18 +03:00
Mikhail Glukhikh
ab5cb13dae Rename: DescriptorBasedIr -> ObsoleteDescriptorBasedAPI 2020-06-16 19:17:14 +03:00
Mikhail Glukhikh
cbbb497edf Make descriptor-based API in ir:tree more granular 2020-06-16 19:17:12 +03:00
Mikhail Glukhikh
1c2fbb61fe [IR] Introduce & use declaration-based SymbolTable.withReferenceScope 2020-06-16 19:17:04 +03:00
Vyacheslav Gerasimov
4aa3040550 Build: Use runtimeOnly instead of deprecated runtime
maven-publish plugin uses `runtimeOnly` for runtime scope instead of
`runtime`
2020-06-14 20:31:26 +03:00
Mads Ager
dc34d355bc [JVM_IR] Generate line numbers and nops for init blocks.
This seems to be what JVM does and it allows you to set a
breakpoint on the init line.
2020-06-10 08:05:52 +02:00
Dmitry Gridin
3fdf048e51 Regenerate Serialization* tests 2020-06-05 17:13:28 +07:00
Yunir Salimzyanov
7ab7ca5ff0 Cleanup as35 extension files (KTI-240) 2020-06-01 18:43:10 +03:00
Leonid Startsev
1d589e3f56 Rework access to properties in IR plugin
use accessors instead of fields whenever possible
2020-06-01 17:48:17 +03:00
Leonid Startsev
7c8c5b057f Extensible mechanism for plugin metadata during descriptor serialization
A mechanism that allows kotlinx.serialization plugin to preserve the
correct (program) order of properties after serializing/deserializing
descriptors to kotlin metadata, which is needed for correct and stable
json serialization of class hierarchies in incremental/multi-module scenario.
It uses protobuf extensions.
2020-06-01 17:48:16 +03:00
Vyacheslav Gerasimov
af2dce0549 as41: Build against AS 4.1 C10 2020-05-27 18:46:57 +03:00
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