Commit Graph

88 Commits

Author SHA1 Message Date
Leonid Startsev 472d91e0de Do not return whole list of generated property descriptors for type
arguments' serializers when only one name is needed.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/383
2019-02-25 19:21:29 +03:00
Leonid Startsev 7d2c59fb70 Fix missing optionality of property when generating descriptor in Native 2019-02-19 15:52:04 +03:00
Leonid Startsev 8b16801f0d Insert correct offsets in a lot of places in IR
Use correct type arguments when invoking a generic functions
Fix missing parent in initializer
2019-02-19 15:52:04 +03:00
Leonid Startsev 66272bfa74 Fix impossibility to make @Optional field in a class hierarchy on JS 2019-02-19 15:52:04 +03:00
Leonid Startsev 18667a5a34 Add validator for unique serial names 2019-02-19 15:52:04 +03:00
Leonid Startsev 36e1d6668b Make write$Self a static function 2019-02-19 15:52:04 +03:00
Leonid Startsev 7c942af13d Add synthetic companion with .serializer() getter even if default serializer is overridden. (kotlinx.serialization/228) 2019-02-19 15:52:04 +03:00
Leonid Startsev 1e440efc01 Ban primitive arrays in JVM codegen too (fixes kotlinx.serialization/260) 2019-02-19 15:52:04 +03:00
Leonid Startsev 5231ef9966 Don't generate writeSelf/internal constructor if corresponding serialize/deserialize aren't auto-generated 2019-02-19 15:52:04 +03:00
Leonid Startsev a6651fd6f9 Call superclass deserialization constructor if superclass is also internal serializable or no-arg ctor of non-serializable class on Native and JS 2019-02-19 15:52:04 +03:00
Leonid Startsev e02cfcb8ea Replace @Optional with @Required 2019-02-19 15:52:04 +03:00
Leonid Startsev 04706f4473 Support classes with more than 32 serializable properties
Via increasing count of int bit masks in synthetic constructor
2019-02-19 15:52:04 +03:00
Leonid Startsev 08f983ef52 Semantic change:
Now properties with default values are @Optional by default, and properties without backing fields are @Transient by default.
2019-02-19 15:52:04 +03:00
Leonid Startsev cca03e9586 Make enums and interfaces not serializable internally. However, they
still can be serialized using custom companion object.
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/138 and https://github.com/Kotlin/kotlinx.serialization/issues/304
2019-02-19 15:52:04 +03:00
Mikhael Bogdanov a122cba862 Switch Kotlin project to jvm-target 1.8
#KT-29405
2019-01-31 07:43:05 +01:00
Leonid Startsev 8eeb9d4faa [kx.serialization] Fix serializer resolving for file-level annotations:
Instantiating ContextSerializer for primitives with boxing (fixes https://github.com/Kotlin/kotlinx.serialization/issues/349)
Unwrap nullable type when looking for general-defined serializer (fixes https://github.com/Kotlin/kotlinx.serialization/issues/351)

Add lost java collection types and fix annotation name (fixes https://github.com/Kotlin/kotlinx.serialization/issues/343)
2019-01-30 19:42:08 +03:00
Vyacheslav Gerasimov f58acbeef5 Build: implement useBootstrapStdlib flag
Excludes stdlib projects from build and uses bootstrap stdlib artifacts

 #KT-29205
2019-01-21 21:09:40 +03:00
Alexander Udalov 4daee6d282 Extract JVM IR backend module out of compiler/backend
The old backend does not depend on IR modules anymore
2019-01-21 19:06:41 +01:00
Vyacheslav Gerasimov 13d87e8eae Remove as31 bunch files 2019-01-14 21:29:02 +03:00
Igor Chevdar 9fee03ca81 IR: Fixed some parents 2019-01-10 14:35:10 +03:00
Leonid Startsev 662c1b6d4a Make serialization plugin for Maven consistent with all other plugins:
Use correct import handler because old one was not working in IDE
Change maven artifact id to match pattern from other plugins
2018-12-26 18:53:53 +03:00
Marcin Moskala 686cfa6fd2 Fix common misspellings 2018-12-21 16:13:42 +03:00
Leonid Startsev fdf4f02dde Declare real external symbols for overriden by synthetic function
instead of unbound

Unbound symbols were throwing an exception on attempt to analyze them
in the other parts of compiler and are generally incorrect
2018-12-12 17:26:01 +03:00
Leonid Startsev f2e27da5bb Support @SerialInfo annotation for Native 2018-12-05 15:16:17 +03:00
Leonid Startsev 13af036024 Fix problem with encodeUnitElement : Unit instance is not needed in Native IR 2018-12-05 15:16:16 +03:00
Leonid Startsev b775501042 Translate KClass references to built-in types in serialization plugin correctly.
Add overload with ClassDescriptor to `getPrimitiveClass` translation function and increase it visibility to public to be usable from plugin.
2018-12-05 15:16:15 +03:00
Leonid Startsev 5f2cea917f Remove redundant check for 'all parameters are properties' in a case of fully-customized serializer 2018-12-05 15:16:15 +03:00
Leonid Startsev 7e32e2e9b9 Increase priority of @ContextualSerialization annotation on types 2018-12-05 15:16:14 +03:00
Leonid Startsev f13f54d5ad Fix "kotlin.UninitializedPropertyAccessException: lateinit property typeTranslator has not been initialized" in Native IR serialization plugin 2018-12-05 15:16:13 +03:00
Leonid Startsev 7c8b34fe1c Fix unresolved symbol to SerialDescriptor in KSerializer if it was
referenced from user custom serializer code (kotlinx.serialization/290)
2018-12-05 15:16:12 +03:00
Leonid Startsev 58c145210c Support for @UseSerializers annotation 2018-12-05 15:16:11 +03:00
Sergey Rostov 2fac72cd99 Move resources: remove build code that not required anymore 2018-11-30 15:01:02 +03:00
Sergey Rostov df2e4524d7 Move resources from /src to separate /resources directory.
Previously this files was stored in /src directory and was included in
resources mainly by SourceSet.projectDefault from sourceSets.kt:

val processResources = tasks.getByName(processResourcesTaskName) as ProcessResources
processResources.from("resources") { include("**") }
processResources.from("src") { include("META-INF/**", "**/*.properties") }

Also there are some custom rules like this:

resources.srcDir("../idea-analysis/src").apply { include("**/*.properties") }
resources.srcDirs("idea-repl/src").apply { include("META-INF/**") }

All this rules are synthesized in script
https://github.com/snrostov/kotlin-migrate-resources/blob/master/src/main/kotlin/main.kt

This commit created using that script. See README.md for more details on
 script.
2018-11-30 15:01:01 +03:00
Leonid Startsev 2e83ec1551 Restrict auto-implementing serializers methods to certain type of classes 2018-11-21 16:00:04 +03:00
Leonid Startsev 1535426a11 Don't add GeneratedSerializer as a supertype for user-defined serializers 2018-11-21 16:00:03 +03:00
Leonid Startsev a3e34af2f1 Increase priority of overridden serializer on type
Fixes Kotlin/kotlinx.serialization/252
2018-11-21 16:00:02 +03:00
Leonid Startsev 127ceaca34 Fix commented check when generating descriptor initializer:
It was needed before `save` because save references symbol of initializer,
yet we don't need to generate it if user provided its own getter
2018-11-21 16:00:01 +03:00
Leonid Startsev b76116a077 Do not add any .childSerializers() stuff if user explicitly marked custom serializer as KSerializer
todo: better design for user-provided descriptors and and schema hierarchy
2018-11-21 16:00:00 +03:00
Leonid Startsev 80c262ec66 Fix instantiation of generic serializers on JS
(Kotlin/kotlinx.serialization/244, which was fixed already by lookuping descriptor, but still had a bug)
2018-11-21 15:59:59 +03:00
Leonid Startsev a163e62f5f Rebased on master, adopt to new constant values from deserialized
annotations
Fix issue with generating redundant constructors for custom generic
seralizers
2018-11-21 15:59:58 +03:00
Leonid Startsev 2444a6680e .shouldEncodeElementDefault for JVM 2018-11-21 15:59:57 +03:00
Leonid Startsev 662e918a7b Support skipping values equals to defaults in output stream for JS and IR backends 2018-11-21 15:59:56 +03:00
Leonid Startsev dba6396e95 Support enums according to new design 2018-11-21 15:59:55 +03:00
Leonid Startsev f101e17dfa Support reference array and context serializers
Enum serializers are also instantiated, but won't work on native because of lack of KClass<E: Enum<E>>.enumValues()
2018-11-21 15:59:54 +03:00
Leonid Startsev ef42201b05 Fix order of overriding @Serializable(with) on property: check override, than @ContextualSerialization.
This will apply Context serializer event if class annotated @Serializable
2018-11-21 15:59:53 +03:00
Leonid Startsev abb8e5e914 Support @Transient properties initializers and init blocks in IR plugin 2018-11-21 15:59:52 +03:00
Leonid Startsev 104368de3b Better lookup for serializer() function in companion for generic classes because user can define a parameterless shorthand one
Fixes Kotlin/kotlinx.serialization/#228
2018-11-21 15:59:51 +03:00
Leonid Startsev 077f51e2f4 Generics serialization in IR 2018-11-21 15:59:50 +03:00
Leonid Startsev a4a1df0a81 Add information about secondary constructors to synthetic classes.
Before this, descriptors for such constructors were created in-place where they needed by the codegens.
However, presence of symbol table in IR backend requires the single instance of constructor descriptor across all compilation to be able to reference it and create a symbol. This support of generics in kotlinx.serialization on Kotlin/Native.
2018-11-21 15:59:49 +03:00
Leonid Startsev 01d3c7bdc8 Descriptors for IR 2018-11-21 15:59:48 +03:00