summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Startsev <sandwwraith@gmail.com>2023-08-03 18:53:17 +0200
committerLeonid Startsev <sandwwraith@gmail.com>2023-08-03 18:53:40 +0200
commitd83496de2ca23faaef23edf8f3cc3faef45ac8a0 (patch)
tree7ee87dfd50bd24ce32dbbfb0a0b402eaad4c3d69
parente3b7e2b05ab5dc275896a59f90881c542c110b8d (diff)
parent72d88fcbf06be0764d9c96fcc729fe044eee876d (diff)
downloadkotlinx.serialization-d83496de2ca23faaef23edf8f3cc3faef45ac8a0.tar.gz
Merge branch 'dev' into master
-rw-r--r--CHANGELOG.md32
-rw-r--r--README.md24
-rw-r--r--benchmark/build.gradle14
-rw-r--r--build.gradle29
-rw-r--r--buildSrc/build.gradle.kts12
-rw-r--r--buildSrc/src/main/kotlin/Java9Modularity.kt171
-rw-r--r--buildSrc/src/main/kotlin/setupJavaPlugin.kt42
-rw-r--r--core/api/kotlinx-serialization-core.api4
-rw-r--r--core/build.gradle6
-rw-r--r--core/commonMain/src/kotlinx/serialization/Serializers.kt8
-rw-r--r--core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt2
-rw-r--r--core/commonMain/src/kotlinx/serialization/internal/NamedCompanion.kt15
-rw-r--r--core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt1
-rw-r--r--core/commonMain/src/kotlinx/serialization/internal/PluginHelperInterfaces.kt1
-rw-r--r--core/commonMain/src/kotlinx/serialization/internal/Primitives.kt1
-rw-r--r--core/commonMain/src/kotlinx/serialization/internal/Tuples.kt1
-rw-r--r--core/commonMain/src/kotlinx/serialization/modules/SerializersModule.kt1
-rw-r--r--core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt10
-rw-r--r--core/commonTest/src/kotlinx/serialization/InheritableSerialInfoTest.kt2
-rw-r--r--core/commonTest/src/kotlinx/serialization/MetaSerializableTest.kt6
-rw-r--r--core/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt1
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerialDescriptorAnnotationsTest.kt2
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerializersLookupEnumTest.kt18
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerializersLookupInterfaceTest.kt3
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerializersLookupNamedCompanionTest.kt100
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerializersLookupObjectTest.kt13
-rw-r--r--core/commonTest/src/kotlinx/serialization/SerializersModuleTest.kt35
-rw-r--r--core/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt1
-rw-r--r--core/commonTest/src/kotlinx/serialization/features/SealedInterfacesSerializationTest.kt2
-rw-r--r--core/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt180
-rw-r--r--core/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt6
-rw-r--r--core/commonTest/src/kotlinx/serialization/test/TestHelpers.kt4
-rw-r--r--core/jsMain/src/kotlinx/serialization/SerializersJs.kt (renamed from core/jsMain/src/kotlinx/serialization/Serializers.kt)0
-rw-r--r--core/jsMain/src/kotlinx/serialization/internal/Platform.kt11
-rw-r--r--core/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt7
-rw-r--r--core/jvmMain/src/kotlinx/serialization/internal/Platform.kt46
-rw-r--r--core/nativeMain/src/kotlinx/serialization/internal/Platform.kt5
-rw-r--r--core/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt2
-rw-r--r--docs/building.md2
-rw-r--r--docs/builtin-classes.md2
-rw-r--r--docs/json.md65
-rw-r--r--docs/polymorphism.md2
-rw-r--r--docs/serialization-guide.md1
-rw-r--r--formats/cbor/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt1
-rw-r--r--formats/hocon/build.gradle12
-rw-r--r--formats/json-okio/gradle.properties1
-rw-r--r--formats/json-tests/build.gradle.kts8
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt1
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/SerializableOnPropertyTypeAndTypealiasTest.kt3
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/SerializerForNullableTypeTest.kt4
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt58
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt1
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonClassDiscriminatorTest.kt13
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonEnumsCaseInsensitiveTest.kt170
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamesTest.kt8
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamingStrategyTest.kt7
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt33
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphicOnClassesTest.kt2
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphismTest.kt38
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/SkipDefaults.kt3
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/EncodeInlineElementTest.kt4
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesCompleteTest.kt18
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesTest.kt20
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineMapQuotedTest.kt4
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/ValueClassesInSealedHierarchyTest.kt12
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/features/sealed/SealedInterfacesJsonSerializationTest.kt2
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonExponentTest.kt79
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonMapKeysTest.kt12
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonModesTest.kt10
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonTreeDecoderPolymorphicTest.kt43
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/PolymorphicClasses.kt3
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt43
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt5
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/test/TestHelpers.kt4
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/test/TestingFramework.kt4
-rw-r--r--formats/json-tests/jsTest/src/kotlinx/serialization/json/DynamicPolymorphismTest.kt3
-rw-r--r--formats/json-tests/jsTest/src/kotlinx/serialization/json/JsonNamesDynamicTest.kt8
-rw-r--r--formats/json-tests/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt7
-rw-r--r--formats/json-tests/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt3
-rw-r--r--formats/json/api/kotlinx-serialization-json.api4
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/Json.kt33
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt6
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt38
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt10
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/JsonNamingStrategy.kt13
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonNamesMap.kt37
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonDecoder.kt2
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt1
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/StringOps.kt4
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/TreeJsonDecoder.kt15
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt51
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/JsonLexer.kt2
-rw-r--r--formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/StringJsonLexer.kt19
-rw-r--r--formats/json/jsMain/src/kotlinx/serialization/json/internal/FormatLanguageJs.kt17
-rw-r--r--formats/json/jsMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt35
-rw-r--r--formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt20
-rw-r--r--formats/json/nativeMain/src/kotlinx/serialization/json/JsonSchemaCache.kt2
-rw-r--r--formats/json/nativeMain/src/kotlinx/serialization/json/internal/FormatLanguage.kt17
-rw-r--r--formats/json/nativeMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt35
-rw-r--r--formats/protobuf/api/kotlinx-serialization-protobuf.api1
-rw-r--r--formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/SuppressAnimalSniffer.kt14
-rw-r--r--formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt1
-rw-r--r--formats/protobuf/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt1
-rw-r--r--formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNothingTest.kt29
-rw-r--r--formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNullAndDefaultTest.kt3
-rw-r--r--formats/protobuf/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt6
-rw-r--r--formats/protobuf/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt7
-rw-r--r--formats/protobuf/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt4
-rw-r--r--gradle.properties12
-rw-r--r--gradle/configure-source-sets.gradle22
-rw-r--r--gradle/native-targets.gradle23
-rw-r--r--guide/build.gradle11
-rw-r--r--guide/example/example-json-12.kt11
-rw-r--r--guide/example/example-json-13.kt11
-rw-r--r--guide/example/example-json-14.kt10
-rw-r--r--guide/example/example-json-15.kt23
-rw-r--r--guide/example/example-json-16.kt18
-rw-r--r--guide/example/example-json-17.kt20
-rw-r--r--guide/example/example-json-18.kt6
-rw-r--r--guide/example/example-json-19.kt30
-rw-r--r--guide/example/example-json-20.kt17
-rw-r--r--guide/example/example-json-21.kt26
-rw-r--r--guide/example/example-json-22.kt16
-rw-r--r--guide/example/example-json-23.kt28
-rw-r--r--guide/example/example-json-24.kt36
-rw-r--r--guide/example/example-json-25.kt59
-rw-r--r--guide/example/example-json-26.kt58
-rw-r--r--guide/example/example-json-27.kt37
-rw-r--r--guide/test/JsonTest.kt53
-rw-r--r--integration-test/gradle.properties4
-rw-r--r--integration-test/kotlin-js-store/yarn.lock436
-rw-r--r--kotlin-js-store/yarn.lock441
-rw-r--r--settings.gradle4
133 files changed, 1772 insertions, 1604 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48ca837d..8f844438 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,36 @@
+1.6.0-RC / 2023-08-03
+==================
+
+This release is based on the Kotlin 1.9.0.
+
+### Removal of Legacy JS target
+Some time ago, in Kotlin 1.8, [JS IR compiler was promoted to stable and old JS compiler was deprecated](https://kotlinlang.org/docs/whatsnew18.html#stable-js-ir-compiler-backend).
+Kotlin 1.9 promotes the usage of deprecated JS compiler to an error. As a result, kotlinx.serialization no longer builds with the legacy compiler
+and does not distribute artifacts for it. You can read the migration guide for JS IR compiler [here](https://kotlinlang.org/docs/js-ir-migration.html).
+
+Also pay attention to the fact that Kotlin/Native also has some [deprecated targets](https://kotlinlang.org/docs/native-target-support.html#deprecated-targets)
+that are going to be removed in the Kotlin 1.9.20. Therefore, kotlinx.serialization 1.6.0-RC and 1.6.0 are likely the last releases that support these targets.
+
+### Case insensitivity for enums in Json
+
+This release features a new configuration flag for Json: `decodeEnumsCaseInsensitive`
+that allows you to decode enum values in a case-insensitive manner.
+For example, when decoding `enum class Foo { VALUE_A , VALUE_B}` both inputs `"value_a"` and `"value_A"` will yield `Foo.VALUE_A`.
+You can read more about this feature in the documentation and corresponding [PR](https://github.com/Kotlin/kotlinx.serialization/pull/2345).
+
+### Other bugfixes and enhancements
+
+ * Add support to decode numeric literals containing an exponent (#2227) (thanks to [Roberto Blázquez](https://github.com/xBaank))
+ * Fix NoSuchMethodError related to Java 8 API compatibility (#2328, #2350) (thanks to [Björn Kautler](https://github.com/Vampire))
+ * Changed actual FormatLanguage annotation for JS and Native to avoid problems with duplicating org.intellij.lang.annotations.Language (#2390, #2379)
+ * Fix error triggered by 'consume leading class discriminator' polymorphic parsing optimization (#2362)
+ * Fix runtime error with Serializer for Nothing on the JS target (#2330) (thanks to [Shreck Ye](https://github.com/ShreckYe))
+ * Fix beginStructure in JsonTreeDecoder when inner structure descriptor is same as outer (#2346) (thanks to [Ugljesa Jovanovic](https://github.com/ionspin))
+ * Actualize 'serializer not found' platform-specific message (#2339)
+ * Fixed regression with serialization using a list parametrized with contextual types (#2331)
+
+
1.5.1 / 2023-05-11
==================
This release contains an important Native targets overhaul, as well as numerous enhancements and bugfixes.
diff --git a/README.md b/README.md
index 420bbf7a..7e6daccc 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@
[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![TeamCity build](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/KotlinTools_KotlinxSerialization_Ko.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxSerialization_Ko&guest=1)
-[![Kotlin](https://img.shields.io/badge/kotlin-1.8.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
-[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-serialization-core/1.5.1)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.5.1)
+[![Kotlin](https://img.shields.io/badge/kotlin-1.9.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
+[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-serialization-core/1.6.0-RC)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.6.0-RC)
[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlinlang.org/api/kotlinx.serialization/)
[![Slack channel](https://img.shields.io/badge/chat-slack-blue.svg?logo=slack)](https://kotlinlang.slack.com/messages/serialization/)
@@ -92,8 +92,8 @@ Kotlin DSL:
```kotlin
plugins {
- kotlin("jvm") version "1.8.21" // or kotlin("multiplatform") or any other kotlin plugin
- kotlin("plugin.serialization") version "1.8.21"
+ kotlin("jvm") version "1.9.0" // or kotlin("multiplatform") or any other kotlin plugin
+ kotlin("plugin.serialization") version "1.9.0"
}
```
@@ -101,8 +101,8 @@ Groovy DSL:
```gradle
plugins {
- id 'org.jetbrains.kotlin.multiplatform' version '1.8.21'
- id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.21'
+ id 'org.jetbrains.kotlin.multiplatform' version '1.9.0'
+ id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
}
```
@@ -119,7 +119,7 @@ buildscript {
repositories { mavenCentral() }
dependencies {
- val kotlinVersion = "1.8.21"
+ val kotlinVersion = "1.9.0"
classpath(kotlin("gradle-plugin", version = kotlinVersion))
classpath(kotlin("serialization", version = kotlinVersion))
}
@@ -130,7 +130,7 @@ Groovy DSL:
```gradle
buildscript {
- ext.kotlin_version = '1.8.21'
+ ext.kotlin_version = '1.9.0'
repositories { mavenCentral() }
dependencies {
@@ -159,7 +159,7 @@ repositories {
}
dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0-RC")
}
```
@@ -171,7 +171,7 @@ repositories {
}
dependencies {
- implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0-RC"
}
```
@@ -261,8 +261,8 @@ Ensure the proper version of Kotlin and serialization version:
```xml
<properties>
- <kotlin.version>1.8.21</kotlin.version>
- <serialization.version>1.5.1</serialization.version>
+ <kotlin.version>1.9.0</kotlin.version>
+ <serialization.version>1.6.0-RC</serialization.version>
</properties>
```
diff --git a/benchmark/build.gradle b/benchmark/build.gradle
index 04dde008..751ad78c 100644
--- a/benchmark/build.gradle
+++ b/benchmark/build.gradle
@@ -1,3 +1,5 @@
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@@ -25,6 +27,18 @@ jmhJar {
destinationDirectory = file("$rootDir")
}
+// to include benchmark-module jmh source set compilation during build to verify that it is also compiled succesfully
+assemble.dependsOn jmhClasses
+
+tasks.withType(KotlinCompile).configureEach {
+ kotlinOptions {
+ if (rootProject.ext.kotlin_lv_override != null) {
+ languageVersion = rootProject.ext.kotlin_lv_override
+ freeCompilerArgs += "-Xsuppress-version-warnings"
+ }
+ }
+}
+
dependencies {
implementation 'org.openjdk.jmh:jmh-core:1.35'
implementation 'com.google.guava:guava:31.1-jre'
diff --git a/build.gradle b/build.gradle
index 56f3f0a0..73b566ae 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,20 @@
*/
buildscript {
- if (project.hasProperty("bootstrap")) {
+ /**
+ * Overrides for Teamcity 'K2 User Projects' + 'Aggregate build / Kotlinx libraries compilation' configuration:
+ * kotlin_repo_url - local repository with snapshot Kotlin compiler
+ * kotlin_version - kotlin version to use
+ * kotlin_language_version - LV to use
+ */
+ ext.snapshotRepoUrl = rootProject.properties["kotlin_repo_url"]
+ ext.kotlin_lv_override = rootProject.properties["kotlin_language_version"]
+ if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
+ ext.kotlin_version = rootProject.properties["kotlin_version"]
+ repositories {
+ maven { url snapshotRepoUrl }
+ }
+ } else if (project.hasProperty("bootstrap")) {
ext.kotlin_version = property('kotlin.version.snapshot')
ext["kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
} else {
@@ -125,6 +138,13 @@ allprojects {
}
}
+ if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
+ // Snapshot-specific for K2 CI configurations
+ repositories {
+ maven { url snapshotRepoUrl }
+ }
+ }
+
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.jetbrains.kotlin') {
@@ -171,6 +191,11 @@ subprojects {
if (excludedFromBomProjects.contains(project.name)) return
// Animalsniffer setup
+ // Animalsniffer requires java plugin to be applied, but Kotlin 1.9.20
+ // relies on `java-base` for Kotlin Multiplatforms `withJava` implementation
+ // https://github.com/xvik/gradle-animalsniffer-plugin/issues/84
+ // https://youtrack.jetbrains.com/issue/KT-59595
+ JavaPluginUtil.applyJavaPlugin(project)
apply plugin: 'ru.vyarus.animalsniffer'
afterEvaluate { // Can be applied only when the project is evaluated
@@ -184,6 +209,8 @@ subprojects {
case "kotlinx-serialization-hocon":
annotationValue = "kotlinx.serialization.hocon.internal.SuppressAnimalSniffer"
break
+ case "kotlinx-serialization-protobuf":
+ annotationValue = "kotlinx.serialization.protobuf.internal.SuppressAnimalSniffer"
}
annotation = annotationValue
}
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 73a4e815..c999bcd2 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -12,6 +12,11 @@ plugins {
repositories {
mavenCentral()
mavenLocal()
+ if (project.hasProperty("kotlin_repo_url")) {
+ maven(project.properties["kotlin_repo_url"] as String)
+ }
+ // kotlin-dev with space redirector
+ maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}
val kotlinVersion = run {
@@ -20,9 +25,14 @@ val kotlinVersion = run {
require(!ver.isNullOrBlank()) {"kotlin_snapshot_version must be present if build_snapshot_train is used" }
return@run ver
}
+ if (project.hasProperty("kotlin_repo_url")) {
+ val ver = project.properties["kotlin_version"] as? String
+ require(!ver.isNullOrBlank()) {"kotlin_version must be present if kotlin_repo_url is used" }
+ return@run ver
+ }
val targetProp = if (project.hasProperty("bootstrap")) "kotlin.version.snapshot" else "kotlin.version"
FileInputStream(file("../gradle.properties")).use { propFile ->
- val ver = Properties().apply { load(propFile) }[targetProp]
+ val ver = project.findProperty("kotlin.version")?.toString() ?: Properties().apply { load(propFile) }[targetProp]
require(ver is String) { "$targetProp must be string in ../gradle.properties, got $ver instead" }
ver
}
diff --git a/buildSrc/src/main/kotlin/Java9Modularity.kt b/buildSrc/src/main/kotlin/Java9Modularity.kt
index 54a09016..99b17401 100644
--- a/buildSrc/src/main/kotlin/Java9Modularity.kt
+++ b/buildSrc/src/main/kotlin/Java9Modularity.kt
@@ -3,15 +3,22 @@
*/
import org.gradle.api.*
+import org.gradle.api.file.*
+import org.gradle.api.provider.*
+import org.gradle.api.tasks.*
import org.gradle.api.tasks.bundling.*
import org.gradle.api.tasks.compile.*
+import org.gradle.jvm.toolchain.*
import org.gradle.kotlin.dsl.*
+import org.gradle.language.base.plugins.LifecycleBasePlugin.*
+import org.gradle.process.*
import org.jetbrains.kotlin.gradle.dsl.*
+import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
-import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.*
import org.jetbrains.kotlin.gradle.targets.jvm.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.io.*
object Java9Modularity {
@@ -42,70 +49,154 @@ object Java9Modularity {
// derive the names of the source set and compile module task
val sourceSetName = defaultSourceSet.name + "Module"
- val compileModuleTaskName = compileKotlinTask.name + "Module"
kotlin.sourceSets.create(sourceSetName) {
val sourceFile = this.kotlin.find { it.name == "module-info.java" }
- val targetFile = compileKotlinTask.destinationDirectory.file("../module-info.class").get().asFile
+ val targetDirectory = compileKotlinTask.destinationDirectory.map {
+ it.dir("../${it.asFile.name}Module")
+ }
// only configure the compilation if necessary
if (sourceFile != null) {
- // the default source set depends on this new source set
- defaultSourceSet.dependsOn(this)
+ // register and wire a task to verify module-info.java content
+ //
+ // this will compile the whole sources again with a JPMS-aware target Java version,
+ // so that the Kotlin compiler can do the necessary verifications
+ // while compiling with `jdk-release=1.8` those verifications are not done
+ //
+ // this task is only going to be executed when running with `check` or explicitly,
+ // not during normal build operations
+ val verifyModuleTask = registerVerifyModuleTask(
+ compileKotlinTask,
+ sourceFile
+ )
+ tasks.named("check") {
+ dependsOn(verifyModuleTask)
+ }
// register a new compile module task
- val compileModuleTask = registerCompileModuleTask(compileModuleTaskName, compileKotlinTask, sourceFile, targetFile)
+ val compileModuleTask = registerCompileModuleTask(
+ compileKotlinTask,
+ sourceFile,
+ targetDirectory
+ )
// add the resulting module descriptor to this target's artifact
- artifactTask.dependsOn(compileModuleTask)
- artifactTask.from(targetFile) {
+ artifactTask.from(compileModuleTask) {
if (multiRelease) {
into("META-INF/versions/9/")
}
}
} else {
logger.info("No module-info.java file found in ${this.kotlin.srcDirs}, can't configure compilation of module-info!")
- // remove the source set to prevent Gradle warnings
- kotlin.sourceSets.remove(this)
}
+
+ // remove the source set to prevent Gradle warnings
+ kotlin.sourceSets.remove(this)
}
}
}
}
- private fun Project.registerCompileModuleTask(taskName: String, compileTask: KotlinCompile, sourceFile: File, targetFile: File) =
- tasks.register(taskName, JavaCompile::class) {
- // Also add the module-info.java source file to the Kotlin compile task;
- // the Kotlin compiler will parse and check module dependencies,
- // but it currently won't compile to a module-info.class file.
- compileTask.source(sourceFile)
+ /**
+ * Add a Kotlin compile task that compiles `module-info.java` source file and Kotlin sources together,
+ * the Kotlin compiler will parse and check module dependencies,
+ * but it currently won't compile to a module-info.class file.
+ */
+ private fun Project.registerVerifyModuleTask(
+ compileTask: KotlinCompile,
+ sourceFile: File
+ ): TaskProvider<out KotlinJvmCompile> {
+ apply<KotlinBaseApiPlugin>()
+ val verifyModuleTaskName = "verify${compileTask.name.removePrefix("compile").capitalize()}Module"
+ // work-around for https://youtrack.jetbrains.com/issue/KT-60542
+ val verifyModuleTask = plugins
+ .findPlugin(KotlinBaseApiPlugin::class)!!
+ .registerKotlinJvmCompileTask(verifyModuleTaskName)
+ verifyModuleTask {
+ group = VERIFICATION_GROUP
+ description = "Verify Kotlin sources for JPMS problems"
+ libraries.from(compileTask.libraries)
+ source(compileTask.sources)
+ source(compileTask.javaSources)
+ // part of work-around for https://youtrack.jetbrains.com/issue/KT-60541
+ @Suppress("INVISIBLE_MEMBER")
+ source(compileTask.scriptSources)
+ source(sourceFile)
+ destinationDirectory.set(temporaryDir)
+ multiPlatformEnabled.set(compileTask.multiPlatformEnabled)
+ kotlinOptions {
+ moduleName = compileTask.kotlinOptions.moduleName
+ jvmTarget = "9"
+ freeCompilerArgs += "-Xjdk-release=9"
+ }
+ // work-around for https://youtrack.jetbrains.com/issue/KT-60583
+ inputs.files(
+ libraries.asFileTree.elements.map { libs ->
+ libs
+ .filter { it.asFile.exists() }
+ .map {
+ zipTree(it.asFile).filter { it.name == "module-info.class" }
+ }
+ }
+ ).withPropertyName("moduleInfosOfLibraries")
+ this as KotlinCompile
+ // part of work-around for https://youtrack.jetbrains.com/issue/KT-60541
+ @Suppress("DEPRECATION")
+ ownModuleName.set(compileTask.kotlinOptions.moduleName)
+ // part of work-around for https://youtrack.jetbrains.com/issue/KT-60541
+ @Suppress("INVISIBLE_MEMBER")
+ commonSourceSet.from(compileTask.commonSourceSet)
+ // part of work-around for https://youtrack.jetbrains.com/issue/KT-60541
+ // and work-around for https://youtrack.jetbrains.com/issue/KT-60582
+ incremental = false
+ }
+ return verifyModuleTask
+ }
+
+ private fun Project.registerCompileModuleTask(
+ compileTask: KotlinCompile,
+ sourceFile: File,
+ targetDirectory: Provider<out Directory>
+ ) = tasks.register("${compileTask.name}Module", JavaCompile::class) {
+ // Configure the module compile task.
+ source(sourceFile)
+ classpath = files()
+ destinationDirectory.set(targetDirectory)
+ // use a Java 11 toolchain with release 9 option
+ // because for some OS / architecture combinations
+ // there are no Java 9 builds available
+ javaCompiler.set(
+ this@registerCompileModuleTask.the<JavaToolchainService>().compilerFor {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+ )
+ options.release.set(9)
+ options.compilerArgumentProviders.add(object : CommandLineArgumentProvider {
+ @get:CompileClasspath
+ val compileClasspath = compileTask.libraries
- // Configure the module compile task.
- dependsOn(compileTask)
- source(sourceFile)
- outputs.file(targetFile)
- classpath = files()
- destinationDirectory.set(compileTask.destinationDirectory)
- sourceCompatibility = JavaVersion.VERSION_1_9.toString()
- targetCompatibility = JavaVersion.VERSION_1_9.toString()
+ @get:CompileClasspath
+ val compiledClasses = compileTask.destinationDirectory
- doFirst {
+ @get:Input
+ val moduleName = sourceFile
+ .readLines()
+ .single { it.contains("module ") }
+ .substringAfter("module ")
+ .substringBefore(' ')
+ .trim()
+
+ override fun asArguments() = mutableListOf(
// Provide the module path to the compiler instead of using a classpath.
// The module path should be the same as the classpath of the compiler.
- options.compilerArgs = listOf(
- "--release", "9",
- "--module-path", compileTask.libraries.asPath,
- "-Xlint:-requires-transitive-automatic"
- )
- }
-
- doLast {
- // Move the compiled file out of the Kotlin compile task's destination dir,
- // so it won't disturb Gradle's caching mechanisms.
- val compiledFile = destinationDirectory.file(targetFile.name).get().asFile
- targetFile.parentFile.mkdirs()
- compiledFile.renameTo(targetFile)
- }
- }
+ "--module-path",
+ compileClasspath.asPath,
+ "--patch-module",
+ "$moduleName=${compiledClasses.get()}",
+ "-Xlint:-requires-transitive-automatic"
+ )
+ })
+ }
}
diff --git a/buildSrc/src/main/kotlin/setupJavaPlugin.kt b/buildSrc/src/main/kotlin/setupJavaPlugin.kt
new file mode 100644
index 00000000..40db563d
--- /dev/null
+++ b/buildSrc/src/main/kotlin/setupJavaPlugin.kt
@@ -0,0 +1,42 @@
+import org.gradle.api.*
+import org.gradle.api.file.*
+import org.gradle.api.plugins.*
+import org.gradle.api.tasks.*
+import org.gradle.api.tasks.testing.*
+import org.gradle.jvm.tasks.*
+import org.jetbrains.kotlin.gradle.plugin.*
+
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+object JavaPluginUtil {
+
+ @JvmStatic
+ fun Project.applyJavaPlugin() {
+ plugins.apply("java")
+
+ plugins.withId("org.jetbrains.kotlin.multiplatform") {
+ listOf(
+ JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME,
+ JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME
+ ).forEach { outputConfigurationName ->
+ configurations.findByName(outputConfigurationName)?.isCanBeConsumed = false
+ }
+
+ disableJavaPluginTasks(extensions.getByName("sourceSets") as SourceSetContainer)
+ }
+ }
+}
+
+private fun Project.disableJavaPluginTasks(javaSourceSet: SourceSetContainer) {
+ project.tasks.withType(Jar::class.java).named(javaSourceSet.getByName("main").jarTaskName).configure {
+ dependsOn("jvmTest")
+ enabled = false
+ }
+
+ project.tasks.withType(Test::class.java).named(JavaPlugin.TEST_TASK_NAME) {
+ dependsOn("jvmJar")
+ enabled = false
+ }
+}
diff --git a/core/api/kotlinx-serialization-core.api b/core/api/kotlinx-serialization-core.api
index ea4b50e7..4b46dcca 100644
--- a/core/api/kotlinx-serialization-core.api
+++ b/core/api/kotlinx-serialization-core.api
@@ -26,6 +26,7 @@ public abstract interface annotation class kotlinx/serialization/EncodeDefault :
public final class kotlinx/serialization/EncodeDefault$Mode : java/lang/Enum {
public static final field ALWAYS Lkotlinx/serialization/EncodeDefault$Mode;
public static final field NEVER Lkotlinx/serialization/EncodeDefault$Mode;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lkotlinx/serialization/EncodeDefault$Mode;
public static fun values ()[Lkotlinx/serialization/EncodeDefault$Mode;
}
@@ -891,6 +892,9 @@ public abstract class kotlinx/serialization/internal/MapLikeSerializer : kotlinx
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
}
+public abstract interface annotation class kotlinx/serialization/internal/NamedCompanion : java/lang/annotation/Annotation {
+}
+
public abstract class kotlinx/serialization/internal/NamedValueDecoder : kotlinx/serialization/internal/TaggedDecoder {
public fun <init> ()V
protected fun composeName (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
diff --git a/core/build.gradle b/core/build.gradle
index 064b6d4c..a561b029 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -65,10 +65,4 @@ tasks.withType(Jar).named(kotlin.jvm().artifactsTaskName) {
}
}
-tasks.withType(Kotlin2JsCompile.class).configureEach {
- if (it.name == "compileTestKotlinJsLegacy") {
- it.exclude("**/SerializersModuleTest.kt")
- }
-}
-
Java9Modularity.configureJava9ModuleInfo(project)
diff --git a/core/commonMain/src/kotlinx/serialization/Serializers.kt b/core/commonMain/src/kotlinx/serialization/Serializers.kt
index 54becdad..1892f6a7 100644
--- a/core/commonMain/src/kotlinx/serialization/Serializers.kt
+++ b/core/commonMain/src/kotlinx/serialization/Serializers.kt
@@ -193,13 +193,7 @@ private fun SerializersModule.serializerByKTypeImpl(
val cachedSerializer = if (typeArguments.isEmpty()) {
findCachedSerializer(rootClass, isNullable)
} else {
- val cachedResult = findParametrizedCachedSerializer(rootClass, typeArguments, isNullable)
- if (failOnMissingTypeArgSerializer) {
- cachedResult.getOrNull()
- } else {
- // return null if error occurred - serializer for parameter(s) was not found
- cachedResult.getOrElse { return null }
- }
+ findParametrizedCachedSerializer(rootClass, typeArguments, isNullable).getOrNull()
}
cachedSerializer?.let { return it }
diff --git a/core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt b/core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt
index a6e1dab0..4bd81012 100644
--- a/core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt
+++ b/core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt
@@ -34,7 +34,7 @@ public fun <K, V> PairSerializer(
* Returns built-in serializer for [Map.Entry].
* Resulting serializer represents entry as a structure with a single key-value pair.
* E.g. `Pair(1, 2)` and `Map.Entry(1, 2)` will be serialized to JSON as
- * `{"first": 1, "second": 2}` and {"1": 2} respectively.
+ * `{"first": 1, "second": 2}` and `{"1": 2}` respectively.
*/
public fun <K, V> MapEntrySerializer(
keySerializer: KSerializer<K>,
diff --git a/core/commonMain/src/kotlinx/serialization/internal/NamedCompanion.kt b/core/commonMain/src/kotlinx/serialization/internal/NamedCompanion.kt
new file mode 100644
index 00000000..0756dc62
--- /dev/null
+++ b/core/commonMain/src/kotlinx/serialization/internal/NamedCompanion.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.internal
+
+import kotlinx.serialization.*
+
+/**
+ * An annotation added by the compiler to the companion object of [Serializable] class, if it has a non-default name.
+ */
+@InternalSerializationApi
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.RUNTIME)
+public annotation class NamedCompanion
diff --git a/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt b/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt
index e9351853..c16945c9 100644
--- a/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt
+++ b/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt
@@ -65,7 +65,6 @@ internal fun SerialDescriptor.cachedSerialNames(): Set<String> {
return result
}
-@SharedImmutable
private val EMPTY_DESCRIPTOR_ARRAY: Array<SerialDescriptor> = arrayOf()
/**
diff --git a/core/commonMain/src/kotlinx/serialization/internal/PluginHelperInterfaces.kt b/core/commonMain/src/kotlinx/serialization/internal/PluginHelperInterfaces.kt
index f613c2ad..61272d29 100644
--- a/core/commonMain/src/kotlinx/serialization/internal/PluginHelperInterfaces.kt
+++ b/core/commonMain/src/kotlinx/serialization/internal/PluginHelperInterfaces.kt
@@ -8,7 +8,6 @@ import kotlinx.serialization.*
import kotlin.jvm.*
import kotlin.native.concurrent.*
-@SharedImmutable
@JvmField
internal val EMPTY_SERIALIZER_ARRAY: Array<KSerializer<*>> = arrayOf()
diff --git a/core/commonMain/src/kotlinx/serialization/internal/Primitives.kt b/core/commonMain/src/kotlinx/serialization/internal/Primitives.kt
index fad4bfc6..2d9c5285 100644
--- a/core/commonMain/src/kotlinx/serialization/internal/Primitives.kt
+++ b/core/commonMain/src/kotlinx/serialization/internal/Primitives.kt
@@ -16,7 +16,6 @@ import kotlin.reflect.*
import kotlin.time.Duration
@OptIn(ExperimentalUnsignedTypes::class)
-@SharedImmutable
private val BUILTIN_SERIALIZERS = mapOf(
String::class to String.serializer(),
Char::class to Char.serializer(),
diff --git a/core/commonMain/src/kotlinx/serialization/internal/Tuples.kt b/core/commonMain/src/kotlinx/serialization/internal/Tuples.kt
index 88e25179..1bd21cbe 100644
--- a/core/commonMain/src/kotlinx/serialization/internal/Tuples.kt
+++ b/core/commonMain/src/kotlinx/serialization/internal/Tuples.kt
@@ -11,7 +11,6 @@ import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlin.native.concurrent.*
-@SharedImmutable
private val NULL = Any()
private const val deprecationMessage =
"This class is used only by the plugin in generated code and should not be used directly. Use corresponding factory functions instead"
diff --git a/core/commonMain/src/kotlinx/serialization/modules/SerializersModule.kt b/core/commonMain/src/kotlinx/serialization/modules/SerializersModule.kt
index d022d121..f01f952a 100644
--- a/core/commonMain/src/kotlinx/serialization/modules/SerializersModule.kt
+++ b/core/commonMain/src/kotlinx/serialization/modules/SerializersModule.kt
@@ -73,7 +73,6 @@ public sealed class SerializersModule {
/**
* A [SerializersModule] which is empty and always returns `null`.
*/
-@SharedImmutable
@Deprecated("Deprecated in the favour of 'EmptySerializersModule()'",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("EmptySerializersModule()"))
diff --git a/core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt b/core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt
index e07efac1..212169e6 100644
--- a/core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt
@@ -38,27 +38,27 @@ class CachedSerializersTest {
}
@Test
- fun testObjectSerializersAreSame() = noJsLegacy {
+ fun testObjectSerializersAreSame() {
assertSame(Object.serializer(), Object.serializer())
}
@Test
- fun testSerializableEnumSerializersAreSame() = noJsLegacy {
+ fun testSerializableEnumSerializersAreSame() {
assertSame(SerializableEnum.serializer(), SerializableEnum.serializer())
}
@Test
- fun testSerializableMarkedEnumSerializersAreSame() = noJsLegacy {
+ fun testSerializableMarkedEnumSerializersAreSame() {
assertSame(SerializableMarkedEnum.serializer(), SerializableMarkedEnum.serializer())
}
@Test
- fun testSealedSerializersAreSame() = noJsLegacy {
+ fun testSealedSerializersAreSame() {
assertSame(SealedParent.serializer(), SealedParent.serializer())
}
@Test
- fun testAbstractSerializersAreSame() = noJsLegacy {
+ fun testAbstractSerializersAreSame() {
assertSame(Abstract.serializer(), Abstract.serializer())
}
diff --git a/core/commonTest/src/kotlinx/serialization/InheritableSerialInfoTest.kt b/core/commonTest/src/kotlinx/serialization/InheritableSerialInfoTest.kt
index a117ad48..cd5b7a0d 100644
--- a/core/commonTest/src/kotlinx/serialization/InheritableSerialInfoTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/InheritableSerialInfoTest.kt
@@ -1,7 +1,6 @@
package kotlinx.serialization
import kotlinx.serialization.descriptors.SerialDescriptor
-import kotlinx.serialization.test.isJsLegacy
import kotlin.test.*
@@ -33,7 +32,6 @@ class InheritableSerialInfoTest {
class E3: A, B
private fun doTest(descriptor: SerialDescriptor) {
- if (isJsLegacy()) return // Unsupported
val list = descriptor.annotations.filterIsInstance<InheritableDiscriminator>()
assertEquals(1, list.size)
assertEquals("a", list.first().discriminator)
diff --git a/core/commonTest/src/kotlinx/serialization/MetaSerializableTest.kt b/core/commonTest/src/kotlinx/serialization/MetaSerializableTest.kt
index 24763285..071045a8 100644
--- a/core/commonTest/src/kotlinx/serialization/MetaSerializableTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/MetaSerializableTest.kt
@@ -34,20 +34,20 @@ class MetaSerializableTest {
)
@Test
- fun testMetaSerializable() = noJsLegacy {
+ fun testMetaSerializable() {
val serializer = serializer<Project1>()
assertNotNull(serializer)
}
@Test
- fun testMetaSerializableWithInfo() = noJsLegacy {
+ fun testMetaSerializableWithInfo() {
val info = serializer<Project2>().descriptor.annotations.filterIsInstance<MySerializableWithInfo>().first()
assertEquals(123, info.value)
assertEquals(String::class, info.kclass)
}
@Test
- fun testMetaSerializableOnProperty() = noJsLegacy {
+ fun testMetaSerializableOnProperty() {
val info = serializer<Wrapper>().descriptor
.getElementAnnotations(0).filterIsInstance<MySerializableWithInfo>().first()
assertEquals(234, info.value)
diff --git a/core/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt b/core/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
index 393e2b59..22de3a4d 100644
--- a/core/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
+++ b/core/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
@@ -30,7 +30,6 @@ open class PolyBase(val id: Int) {
@Serializable
data class PolyDerived(val s: String) : PolyBase(1)
-@SharedImmutable
val BaseAndDerivedModule = SerializersModule {
polymorphic(PolyBase::class, PolyBase.serializer()) {
subclass(PolyDerived.serializer())
diff --git a/core/commonTest/src/kotlinx/serialization/SerialDescriptorAnnotationsTest.kt b/core/commonTest/src/kotlinx/serialization/SerialDescriptorAnnotationsTest.kt
index f2010a2d..770ac50b 100644
--- a/core/commonTest/src/kotlinx/serialization/SerialDescriptorAnnotationsTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/SerialDescriptorAnnotationsTest.kt
@@ -5,7 +5,6 @@
package kotlinx.serialization
import kotlinx.serialization.descriptors.*
-import kotlinx.serialization.test.isJsLegacy
import kotlin.test.*
class SerialDescriptorAnnotationsTest {
@@ -103,7 +102,6 @@ class SerialDescriptorAnnotationsTest {
class Holder(val r: Result, val a: AbstractResult, val o: ObjectResult, @Contextual val names: WithNames)
private fun doTest(position: Int, expected: String) {
- if (isJsLegacy()) return // Unsupported
val desc = Holder.serializer().descriptor.getElementDescriptor(position)
assertEquals(expected, desc.annotations.getCustom())
}
diff --git a/core/commonTest/src/kotlinx/serialization/SerializersLookupEnumTest.kt b/core/commonTest/src/kotlinx/serialization/SerializersLookupEnumTest.kt
index 8241b7e4..5f5a6f7b 100644
--- a/core/commonTest/src/kotlinx/serialization/SerializersLookupEnumTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/SerializersLookupEnumTest.kt
@@ -54,11 +54,7 @@ class SerializersLookupEnumTest {
@Test
fun testPlainEnum() {
- if (isJsLegacy()) {
- assertSame(PlainEnum.serializer()::class, serializer<PlainEnum>()::class)
- } else {
- assertSame(PlainEnum.serializer(), serializer<PlainEnum>())
- }
+ assertSame(PlainEnum.serializer(), serializer<PlainEnum>())
if (!isJs()) {
assertIs<EnumSerializer<PlainEnum>>(serializer<PlainEnum>())
@@ -69,22 +65,14 @@ class SerializersLookupEnumTest {
fun testSerializableEnumSerializer() {
assertIs<EnumSerializer<SerializableEnum>>(SerializableEnum.serializer())
- if (isJsLegacy()) {
- assertSame(SerializableEnum.serializer()::class, serializer<SerializableEnum>()::class)
- } else {
- assertSame(SerializableEnum.serializer(), serializer<SerializableEnum>())
- }
+ assertSame(SerializableEnum.serializer(), serializer<SerializableEnum>())
}
@Test
fun testSerializableMarkedEnumSerializer() {
assertIs<EnumSerializer<SerializableMarkedEnum>>(SerializableMarkedEnum.serializer())
- if (isJsLegacy()) {
- assertSame(SerializableMarkedEnum.serializer()::class, serializer<SerializableMarkedEnum>()::class)
- } else {
- assertSame(SerializableMarkedEnum.serializer(), serializer<SerializableMarkedEnum>())
- }
+ assertSame(SerializableMarkedEnum.serializer(), serializer<SerializableMarkedEnum>())
}
@Test
diff --git a/core/commonTest/src/kotlinx/serialization/SerializersLookupInterfaceTest.kt b/core/commonTest/src/kotlinx/serialization/SerializersLookupInterfaceTest.kt
index 75e6cbe5..15c0351e 100644
--- a/core/commonTest/src/kotlinx/serialization/SerializersLookupInterfaceTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/SerializersLookupInterfaceTest.kt
@@ -26,7 +26,6 @@ class SerializersLookupInterfaceTest {
@Test
fun testSealedInterfaceLookup() {
- if (currentPlatform == Platform.JS_LEGACY) return
val serializer = serializer<S>()
assertTrue(serializer is SealedClassSerializer)
assertEquals("S", serializer.descriptor.serialName)
@@ -35,7 +34,7 @@ class SerializersLookupInterfaceTest {
@Test
fun testInterfaceLookup() {
// Native does not have KClass.isInterface
- if (currentPlatform == Platform.NATIVE || currentPlatform == Platform.JS_LEGACY) return
+ if (isNative()) return
val serializer1 = serializer<I>()
assertTrue(serializer1 is PolymorphicSerializer)
diff --git a/core/commonTest/src/kotlinx/serialization/SerializersLookupNamedCompanionTest.kt b/core/commonTest/src/kotlinx/serialization/SerializersLookupNamedCompanionTest.kt
new file mode 100644
index 00000000..6c429dbd
--- /dev/null
+++ b/core/commonTest/src/kotlinx/serialization/SerializersLookupNamedCompanionTest.kt
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
+
+package kotlinx.serialization
+
+import kotlinx.serialization.builtins.*
+import kotlinx.serialization.descriptors.*
+import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
+import kotlinx.serialization.encoding.*
+import kotlinx.serialization.internal.*
+import kotlinx.serialization.test.*
+import kotlin.reflect.*
+import kotlin.test.*
+
+class SerializersLookupNamedCompanionTest {
+ @Serializable
+ class Plain(val i: Int) {
+ companion object Named
+ }
+
+ @Serializable
+ class Parametrized<T>(val value: T) {
+ companion object Named
+ }
+
+
+ @Serializer(forClass = PlainWithCustom::class)
+ object PlainSerializer
+
+ @Serializable(PlainSerializer::class)
+ class PlainWithCustom(val i: Int) {
+ companion object Named
+ }
+
+ class ParametrizedSerializer<T : Any>(val serializer: KSerializer<T>) : KSerializer<ParametrizedWithCustom<T>> {
+ override val descriptor: SerialDescriptor =
+ PrimitiveSerialDescriptor("parametrized (${serializer.descriptor})", PrimitiveKind.STRING)
+
+ override fun deserialize(decoder: Decoder): ParametrizedWithCustom<T> = TODO("Not yet implemented")
+ override fun serialize(encoder: Encoder, value: ParametrizedWithCustom<T>) = TODO("Not yet implemented")
+ }
+
+ @Serializable(ParametrizedSerializer::class)
+ class ParametrizedWithCustom<T>(val i: T) {
+ companion object Named
+ }
+
+ @Serializable
+ sealed interface SealedInterface {
+ companion object Named
+ }
+
+ @Serializable
+ sealed interface SealedInterfaceWithExplicitAnnotation {
+ @NamedCompanion
+ companion object Named
+ }
+
+
+ @Test
+ fun test() {
+ assertSame<KSerializer<*>>(Plain.serializer(), serializer(typeOf<Plain>()))
+
+ shouldFail<SerializationException>(beforeKotlin = "1.9.20", onJs = false, onNative = false) {
+ assertSame<KSerializer<*>>(PlainSerializer, serializer(typeOf<PlainWithCustom>()))
+ }
+
+ shouldFail<SerializationException>(beforeKotlin = "1.9.20", onJs = false, onNative = false) {
+ assertEquals(
+ Parametrized.serializer(Int.serializer()).descriptor.toString(),
+ serializer(typeOf<Parametrized<Int>>()).descriptor.toString()
+ )
+ }
+
+ shouldFail<SerializationException>(beforeKotlin = "1.9.20", onJs = false, onNative = false) {
+ assertEquals(
+ ParametrizedWithCustom.serializer(Int.serializer()).descriptor.toString(),
+ serializer(typeOf<ParametrizedWithCustom<Int>>()).descriptor.toString()
+ )
+ }
+
+ shouldFail<SerializationException>(beforeKotlin = "1.9.20", onJs = false, onNative = false) {
+ assertEquals(
+ SealedInterface.serializer().descriptor.toString(),
+ serializer(typeOf<SealedInterface>()).descriptor.toString()
+ )
+ }
+
+ // should fail because annotation @NamedCompanion will be placed again by the compilation plugin
+ // and they both will be placed into @Container annotation - thus they will be invisible to the runtime
+ shouldFail<SerializationException>(sinceKotlin = "1.9.20", onJs = false, onNative = false) {
+ serializer(typeOf<SealedInterfaceWithExplicitAnnotation>())
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/core/commonTest/src/kotlinx/serialization/SerializersLookupObjectTest.kt b/core/commonTest/src/kotlinx/serialization/SerializersLookupObjectTest.kt
index 4fb6d701..38d2fbf8 100644
--- a/core/commonTest/src/kotlinx/serialization/SerializersLookupObjectTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/SerializersLookupObjectTest.kt
@@ -46,26 +46,19 @@ class SerializersLookupObjectTest {
@Test
fun testPlainObject() {
- if (!isJsLegacy()) {
- assertSame(PlainObject.serializer(), serializer<PlainObject>())
- }
+ assertSame(PlainObject.serializer(), serializer<PlainObject>())
}
@Test
fun testObjectExternalObject() {
assertSame(ObjectCustomObjectSerializer, ObjectExternalObject.serializer())
- if (!isJsLegacy()) {
- assertSame(ObjectCustomObjectSerializer, serializer<ObjectExternalObject>())
- }
+ assertSame(ObjectCustomObjectSerializer, serializer<ObjectExternalObject>())
}
@Test
fun testObjectExternalClass() {
assertIs<ObjectCustomClassSerializer>(ObjectExternalClass.serializer())
-
- if (!isJsLegacy()) {
- assertIs<ObjectCustomClassSerializer>(serializer<ObjectExternalClass>())
- }
+ assertIs<ObjectCustomClassSerializer>(serializer<ObjectExternalClass>())
}
}
diff --git a/core/commonTest/src/kotlinx/serialization/SerializersModuleTest.kt b/core/commonTest/src/kotlinx/serialization/SerializersModuleTest.kt
index 75da6033..9e255f27 100644
--- a/core/commonTest/src/kotlinx/serialization/SerializersModuleTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/SerializersModuleTest.kt
@@ -37,21 +37,19 @@ class SerializersModuleTest {
@Serializable
class Parametrized<T : Any>(val a: T)
- class ContextualType(val i: Int)
+ @Serializable
+ class ParametrizedOfNullable<T>(val a: T)
- class ParametrizedContextual<T : Any>(val a: T)
+ class ContextualType(val i: Int)
@Serializer(forClass = ContextualType::class)
object ContextualSerializer
- @Serializer(forClass = ParametrizedContextual::class)
- object ParametrizedContextualSerializer
-
@Serializable
class ContextualHolder(@Contextual val contextual: ContextualType)
@Test
- fun testCompiled() = noJsLegacy {
+ fun testCompiled() {
assertSame<KSerializer<*>>(Object.serializer(), serializer(Object::class, emptyList(), false))
assertSame<KSerializer<*>>(SealedParent.serializer(), serializer(SealedParent::class, emptyList(), false))
assertSame<KSerializer<*>>(
@@ -86,6 +84,27 @@ class SerializersModuleTest {
assertEquals(PrimitiveKind.INT, mapSerializer.descriptor.getElementDescriptor(1).kind)
}
+ @Suppress("UNCHECKED_CAST")
+ @Test
+ fun testNothingAndParameterizedOfNothing() {
+ assertEquals(NothingSerializer, Nothing::class.serializer())
+ //assertEquals(NothingSerializer, serializer<Nothing>()) // prohibited by compiler
+ assertEquals(NothingSerializer, serializer(Nothing::class, emptyList(), false) as KSerializer<Nothing>)
+ //assertEquals(NullableSerializer(NothingSerializer), serializer<Nothing?>()) // prohibited by compiler
+ assertEquals(
+ NullableSerializer(NothingSerializer),
+ serializer(Nothing::class, emptyList(), true) as KSerializer<Nothing?>
+ )
+
+ val parameterizedNothingSerializer = serializer<Parametrized<Nothing>>()
+ val nothingDescriptor = parameterizedNothingSerializer.descriptor.getElementDescriptor(0)
+ assertEquals(NothingSerialDescriptor, nothingDescriptor)
+
+ val parameterizedNullableNothingSerializer = serializer<ParametrizedOfNullable<Nothing?>>()
+ val nullableNothingDescriptor = parameterizedNullableNothingSerializer.descriptor.getElementDescriptor(0)
+ assertEquals(SerialDescriptorForNullable(NothingSerialDescriptor), nullableNothingDescriptor)
+ }
+
@Test
fun testUnsupportedArray() {
assertFails {
@@ -98,7 +117,6 @@ class SerializersModuleTest {
fun testContextual() {
val m = SerializersModule {
contextual<ContextualType>(ContextualSerializer)
- contextual<ParametrizedContextual<*>>(ParametrizedContextualSerializer as KSerializer<ParametrizedContextual<*>>)
contextual(ContextualGenericsTest.ThirdPartyBox::class) { args -> ContextualGenericsTest.ThirdPartyBoxSerializer(args[0]) }
}
@@ -109,9 +127,6 @@ class SerializersModuleTest {
assertIs<ContextualGenericsTest.ThirdPartyBoxSerializer<Int>>(boxSerializer)
assertEquals(PrimitiveKind.INT, boxSerializer.descriptor.getElementDescriptor(0).kind)
- val parametrizedSerializer = m.serializer(ParametrizedContextual::class, listOf(Int.serializer()), false)
- assertSame<KSerializer<*>>(ParametrizedContextualSerializer, parametrizedSerializer)
-
val holderSerializer = m.serializer(ContextualHolder::class, emptyList(), false)
assertSame<KSerializer<*>>(ContextualHolder.serializer(), holderSerializer)
}
diff --git a/core/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt b/core/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
index 61e42f61..24e4c520 100644
--- a/core/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
+++ b/core/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
@@ -67,7 +67,6 @@ data class ArraysUmbrella(
arrIntData.contentEquals(other.arrIntData)
}
-@SharedImmutable
val umbrellaInstance = TypesUmbrella(
Unit, true, 10, 20, 30, 40, 50.1f, 60.1, 'A', "Str0", Attitude.POSITIVE, IntData(70),
null, null, 11, 21, 31, 41, 51.1f, 61.1, 'B', "Str1", Attitude.NEUTRAL, null,
diff --git a/core/commonTest/src/kotlinx/serialization/features/SealedInterfacesSerializationTest.kt b/core/commonTest/src/kotlinx/serialization/features/SealedInterfacesSerializationTest.kt
index 008706dc..433f9baf 100644
--- a/core/commonTest/src/kotlinx/serialization/features/SealedInterfacesSerializationTest.kt
+++ b/core/commonTest/src/kotlinx/serialization/features/SealedInterfacesSerializationTest.kt
@@ -92,7 +92,7 @@ class SealedInterfacesSerializationTest {
}
@Test
- fun testResolved() = noJsLegacy {
+ fun testResolved() {
serializer<C>().descriptor.haveSealedSubclasses()
}
diff --git a/core/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt b/core/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt
new file mode 100644
index 00000000..e9c7670a
--- /dev/null
+++ b/core/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.test
+
+import kotlin.test.*
+
+private val currentKotlinVersion = KotlinVersion.CURRENT
+
+private fun String.toKotlinVersion(): KotlinVersion {
+ val parts = split(".")
+ val intParts = parts.mapNotNull { it.toIntOrNull() }
+ if (parts.size != 3 || intParts.size != 3) error("Illegal kotlin version, expected format is 1.2.3")
+
+ return KotlinVersion(intParts[0], intParts[1], intParts[2])
+}
+
+internal fun runSince(kotlinVersion: String, test: () -> Unit) {
+ if (currentKotlinVersion >= kotlinVersion.toKotlinVersion()) {
+ test()
+ }
+}
+
+
+internal inline fun <reified T : Throwable> shouldFail(
+ sinceKotlin: String? = null,
+ beforeKotlin: String? = null,
+ onJvm: Boolean = true,
+ onJs: Boolean = true,
+ onNative: Boolean = true,
+ test: () -> Unit
+) {
+ val args = mapOf(
+ "since" to sinceKotlin,
+ "before" to beforeKotlin,
+ "onJvm" to onJvm,
+ "onJs" to onJs,
+ "onNative" to onNative
+ )
+
+ val sinceVersion = sinceKotlin?.toKotlinVersion()
+ val beforeVersion = beforeKotlin?.toKotlinVersion()
+
+ val version = (sinceVersion != null && currentKotlinVersion >= sinceVersion)
+ || (beforeVersion != null && currentKotlinVersion < beforeVersion)
+
+ val platform = (isJvm() && onJvm) || (isJs() && onJs) || (isNative() && onNative)
+
+ var error: Throwable? = null
+ try {
+ test()
+ } catch (e: Throwable) {
+ error = e
+ }
+
+ if (version && platform) {
+ if (error == null) {
+ throw AssertionError("Exception with type '${T::class.simpleName}' expected for $args")
+ }
+ if (error !is T) throw AssertionError(
+ "Illegal exception type, expected '${T::class.simpleName}' actual '${error::class.simpleName}' for $args",
+ error
+ )
+ } else {
+ if (error != null) throw AssertionError(
+ "Unexpected error for $args",
+ error
+ )
+ }
+}
+
+internal class CompilerVersionTest {
+ @Test
+ fun testSince() {
+ var executed = false
+
+ runSince("1.0.0") {
+ executed = true
+ }
+ assertTrue(executed)
+
+ executed = false
+ runSince("255.255.255") {
+ executed = true
+ }
+ assertFalse(executed)
+ }
+
+ @Test
+ fun testFailBefore() {
+ // ok if there is no exception if current version greater is before of the specified
+ shouldFail<IllegalArgumentException>(beforeKotlin = "0.0.0") {
+ // no-op
+ }
+
+ // error if there is no exception and if current version is before of the specified
+ assertFails {
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255") {
+ // no-op
+ }
+ }
+
+ // ok if thrown expected exception if current version is before of the specified
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255") {
+ throw IllegalArgumentException()
+ }
+
+ // ok if thrown unexpected exception if current version is before of the specified
+ assertFails {
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255") {
+ throw Exception()
+ }
+ }
+
+ }
+
+ @Test
+ fun testFailSince() {
+ // ok if there is no exception if current version less then specified
+ shouldFail<IllegalArgumentException>(sinceKotlin = "255.255.255") {
+ // no-op
+ }
+
+ // error if there is no exception and if current version is greater or equals specified
+ assertFails {
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0") {
+ // no-op
+ }
+ }
+
+ // ok if thrown expected exception if current version is greater or equals specified
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0") {
+ throw IllegalArgumentException()
+ }
+
+ // ok if thrown unexpected exception if current version is greater or equals specified
+ assertFails {
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0") {
+ throw Exception()
+ }
+ }
+ }
+
+ @Test
+ fun testExcludePlatform() {
+ if (isJvm()) {
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255", onJvm = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", onJvm = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", beforeKotlin = "255.255.255", onJvm = false) {
+ // no-op
+ }
+ } else if (isJs()) {
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255", onJs = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", onJs = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", beforeKotlin = "255.255.255", onJs = false) {
+ // no-op
+ }
+ } else if (isNative()) {
+ shouldFail<IllegalArgumentException>(beforeKotlin = "255.255.255", onNative = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", onNative = false) {
+ // no-op
+ }
+ shouldFail<IllegalArgumentException>(sinceKotlin = "0.0.0", beforeKotlin = "255.255.255", onNative = false) {
+ // no-op
+ }
+ }
+ }
+
+}
diff --git a/core/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt b/core/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
index c47252d7..92cf087f 100644
--- a/core/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
+++ b/core/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
@@ -5,13 +5,11 @@
package kotlinx.serialization.test
enum class Platform {
- JVM, JS_LEGACY, JS_IR, NATIVE
+ JVM, JS, NATIVE
}
public expect val currentPlatform: Platform
-public fun isJs(): Boolean = currentPlatform == Platform.JS_LEGACY || currentPlatform == Platform.JS_IR
-public fun isJsLegacy(): Boolean = currentPlatform == Platform.JS_LEGACY
-public fun isJsIr(): Boolean = currentPlatform == Platform.JS_IR
+public fun isJs(): Boolean = currentPlatform == Platform.JS
public fun isJvm(): Boolean = currentPlatform == Platform.JVM
public fun isNative(): Boolean = currentPlatform == Platform.NATIVE
diff --git a/core/commonTest/src/kotlinx/serialization/test/TestHelpers.kt b/core/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
index 660d1ef1..86974506 100644
--- a/core/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
+++ b/core/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
@@ -34,10 +34,6 @@ inline fun noJs(test: () -> Unit) {
if (!isJs()) test()
}
-inline fun noJsLegacy(test: () -> Unit) {
- if (!isJsLegacy()) test()
-}
-
inline fun jvmOnly(test: () -> Unit) {
if (isJvm()) test()
}
diff --git a/core/jsMain/src/kotlinx/serialization/Serializers.kt b/core/jsMain/src/kotlinx/serialization/SerializersJs.kt
index 6f7547db..6f7547db 100644
--- a/core/jsMain/src/kotlinx/serialization/Serializers.kt
+++ b/core/jsMain/src/kotlinx/serialization/SerializersJs.kt
diff --git a/core/jsMain/src/kotlinx/serialization/internal/Platform.kt b/core/jsMain/src/kotlinx/serialization/internal/Platform.kt
index ed88ca35..6bd63391 100644
--- a/core/jsMain/src/kotlinx/serialization/internal/Platform.kt
+++ b/core/jsMain/src/kotlinx/serialization/internal/Platform.kt
@@ -16,9 +16,12 @@ internal actual fun BooleanArray.getChecked(index: Int): Boolean {
if (index !in indices) throw IndexOutOfBoundsException("Index $index out of bounds $indices")
return get(index)
}
-@Suppress("UNCHECKED_CAST")
+
internal actual fun <T : Any> KClass<T>.compiledSerializerImpl(): KSerializer<T>? =
- this.constructSerializerForGivenTypeArgs() ?: this.js.asDynamic().Companion?.serializer() as? KSerializer<T>
+ this.constructSerializerForGivenTypeArgs() ?: (
+ if (this === Nothing::class) NothingSerializer // Workaround for KT-51333
+ else this.js.asDynamic().Companion?.serializer()
+ ) as? KSerializer<T>
internal actual fun <T> createCache(factory: (KClass<*>) -> KSerializer<T>?): SerializerCache<T> {
return object: SerializerCache<T> {
@@ -40,8 +43,8 @@ internal actual fun <T : Any, E : T?> ArrayList<E>.toNativeArrayImpl(eClass: KCl
internal actual fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing {
throw SerializationException(
- "${notRegisteredMessage()}\n" +
- "On Kotlin/JS explicitly declared serializer should be used for interfaces and enums without @Serializable annotation"
+ notRegisteredMessage() +
+ "To get enum serializer on Kotlin/JS, it should be annotated with @Serializable annotation."
)
}
diff --git a/core/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/core/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index b87276e8..23627d17 100644
--- a/core/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/core/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -4,9 +4,4 @@
package kotlinx.serialization.test
-public actual val currentPlatform: Platform = if (isLegacyBackend()) Platform.JS_LEGACY else Platform.JS_IR
-
-// from https://github.com/JetBrains/kotlin/blob/569187a7516e2e5ab217158a3170d4beb0c5cb5a/js/js.translator/testData/_commonFiles/testUtils.kt#L3
-private fun isLegacyBackend(): Boolean =
- // Using eval to prevent DCE from thinking that following code depends on Kotlin module.
- eval("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")").unsafeCast<Boolean>()
+public actual val currentPlatform: Platform = Platform.JS
diff --git a/core/jvmMain/src/kotlinx/serialization/internal/Platform.kt b/core/jvmMain/src/kotlinx/serialization/internal/Platform.kt
index 67a735c9..399dbb23 100644
--- a/core/jvmMain/src/kotlinx/serialization/internal/Platform.kt
+++ b/core/jvmMain/src/kotlinx/serialization/internal/Platform.kt
@@ -35,7 +35,6 @@ internal actual fun <T : Any> KClass<T>.constructSerializerForGivenTypeArgs(vara
return java.constructSerializerForGivenTypeArgs(*args)
}
-@Suppress("UNCHECKED_CAST")
internal fun <T: Any> Class<T>.constructSerializerForGivenTypeArgs(vararg args: KSerializer<Any?>): KSerializer<T>? {
if (isEnum && isNotAnnotated()) {
return createEnumSerializer()
@@ -43,18 +42,13 @@ internal fun <T: Any> Class<T>.constructSerializerForGivenTypeArgs(vararg args:
// Fall-through if the serializer is not found -- lookup on companions (for sealed interfaces) or fallback to polymorphic if applicable
if (isInterface) interfaceSerializer()?.let { return it }
// Search for serializer defined on companion object.
- val serializer = invokeSerializerOnCompanion<T>(this, *args)
+ val serializer = invokeSerializerOnDefaultCompanion<T>(this, *args)
if (serializer != null) return serializer
// Check whether it's serializable object
findObjectSerializer()?.let { return it }
// Search for default serializer if no serializer is defined in companion object.
// It is required for named companions
- val fromNamedCompanion = try {
- declaredClasses.singleOrNull { it.simpleName == ("\$serializer") }
- ?.getField("INSTANCE")?.get(null) as? KSerializer<T>
- } catch (e: NoSuchFieldException) {
- null
- }
+ val fromNamedCompanion = findInNamedCompanion(*args)
if (fromNamedCompanion != null) return fromNamedCompanion
// Check for polymorphic
return if (isPolymorphicSerializer()) {
@@ -64,6 +58,30 @@ internal fun <T: Any> Class<T>.constructSerializerForGivenTypeArgs(vararg args:
}
}
+@Suppress("UNCHECKED_CAST")
+private fun <T: Any> Class<T>.findInNamedCompanion(vararg args: KSerializer<Any?>): KSerializer<T>? {
+ val namedCompanion = findNamedCompanionByAnnotation()
+ if (namedCompanion != null) {
+ invokeSerializerOnCompanion<T>(namedCompanion, *args)?.let { return it }
+ }
+
+ // fallback strategy for old compiler - try to locate plugin-generated singleton (without type parameters) serializer
+ return try {
+ declaredClasses.singleOrNull { it.simpleName == ("\$serializer") }
+ ?.getField("INSTANCE")?.get(null) as? KSerializer<T>
+ } catch (e: NoSuchFieldException) {
+ null
+ }
+}
+
+private fun <T: Any> Class<T>.findNamedCompanionByAnnotation(): Any? {
+ val companionClass = declaredClasses.firstOrNull { clazz ->
+ clazz.getAnnotation(NamedCompanion::class.java) != null
+ } ?: return null
+
+ return companionOrNull(companionClass.simpleName)
+}
+
private fun <T: Any> Class<T>.isNotAnnotated(): Boolean {
/*
* For annotated enums search serializer directly (or do not search at all?)
@@ -100,9 +118,13 @@ private fun <T: Any> Class<T>.interfaceSerializer(): KSerializer<T>? {
return null
}
+private fun <T : Any> invokeSerializerOnDefaultCompanion(jClass: Class<*>, vararg args: KSerializer<Any?>): KSerializer<T>? {
+ val companion = jClass.companionOrNull("Companion") ?: return null
+ return invokeSerializerOnCompanion(companion, *args)
+}
+
@Suppress("UNCHECKED_CAST")
-private fun <T : Any> invokeSerializerOnCompanion(jClass: Class<*>, vararg args: KSerializer<Any?>): KSerializer<T>? {
- val companion = jClass.companionOrNull() ?: return null
+private fun <T : Any> invokeSerializerOnCompanion(companion: Any, vararg args: KSerializer<Any?>): KSerializer<T>? {
return try {
val types = if (args.isEmpty()) emptyArray() else Array(args.size) { KSerializer::class.java }
companion.javaClass.getDeclaredMethod("serializer", *types)
@@ -115,9 +137,9 @@ private fun <T : Any> invokeSerializerOnCompanion(jClass: Class<*>, vararg args:
}
}
-private fun Class<*>.companionOrNull() =
+private fun Class<*>.companionOrNull(companionName: String) =
try {
- val companion = getDeclaredField("Companion")
+ val companion = getDeclaredField(companionName)
companion.isAccessible = true
companion.get(null)
} catch (e: Throwable) {
diff --git a/core/nativeMain/src/kotlinx/serialization/internal/Platform.kt b/core/nativeMain/src/kotlinx/serialization/internal/Platform.kt
index 8995f173..2c91769a 100644
--- a/core/nativeMain/src/kotlinx/serialization/internal/Platform.kt
+++ b/core/nativeMain/src/kotlinx/serialization/internal/Platform.kt
@@ -19,8 +19,9 @@ internal actual inline fun BooleanArray.getChecked(index: Int): Boolean {
internal actual fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing {
throw SerializationException(
- "${notRegisteredMessage()}\n" +
- "On Kotlin/Native explicitly declared serializer should be used for interfaces and enums without @Serializable annotation"
+ notRegisteredMessage() +
+ "To get enum serializer on Kotlin/Native, it should be annotated with @Serializable annotation.\n" +
+ "To get interface serializer on Kotlin/Native, use PolymorphicSerializer() constructor function.\n"
)
}
diff --git a/core/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/core/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index 9e51d7f4..2691ce04 100644
--- a/core/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/core/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -5,7 +5,5 @@
package kotlinx.serialization.test
import kotlinx.serialization.test.Platform
-import kotlin.native.concurrent.SharedImmutable
-@SharedImmutable
public actual val currentPlatform: Platform = Platform.NATIVE
diff --git a/docs/building.md b/docs/building.md
index 840fae08..e9d00a07 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -11,7 +11,7 @@ completely with `disableJPMS` property: add `disableJPMS=true` to gradle.propert
## Runtime library
Kotlin Serialization runtime library itself is a [multiplatform](http://kotlinlang.org/docs/reference/multiplatform.html) project.
-To build library from the source and run all tests, use `./gradlew build`. Corresponding platform tasks like `jvmTest`, `jsIrTest`, `nativeTest` and so on are also available.
+To build library from the source and run all tests, use `./gradlew build`. Corresponding platform tasks like `jvmTest`, `jsTest`, `nativeTest` and so on are also available.
Project can be opened in in Intellij IDEA without additional prerequisites.
In case you want to work with Protobuf tests, you may need to run `./gradlew generateTestProto` beforehand.
diff --git a/docs/builtin-classes.md b/docs/builtin-classes.md
index 18319632..8671dc70 100644
--- a/docs/builtin-classes.md
+++ b/docs/builtin-classes.md
@@ -166,6 +166,8 @@ In JSON an enum gets encoded as a string.
{"name":"kotlinx.serialization","status":"SUPPORTED"}
```
+> Note: On Kotlin/JS and Kotlin/Native, `@Serializable` annotation is needed for enum class if you want to use it as a root object — i.e. use `encodeToString<Status>(Status.SUPPORTED)`.
+
<!--- TEST -->
### Serial names of enum entries
diff --git a/docs/json.md b/docs/json.md
index 9fd8cac4..07476f97 100644
--- a/docs/json.md
+++ b/docs/json.md
@@ -20,6 +20,7 @@ In this chapter, we'll walk through features of [JSON](https://www.json.org/json
* [Allowing structured map keys](#allowing-structured-map-keys)
* [Allowing special floating-point values](#allowing-special-floating-point-values)
* [Class discriminator for polymorphism](#class-discriminator-for-polymorphism)
+ * [Decoding enums in a case-insensitive manner](#decoding-enums-in-a-case-insensitive-manner)
* [Global naming strategy](#global-naming-strategy)
* [Json elements](#json-elements)
* [Parsing to Json element](#parsing-to-json-element)
@@ -469,6 +470,39 @@ As you can see, discriminator from the `Base` class is used:
<!--- TEST -->
+### Decoding enums in a case-insensitive manner
+
+[Kotlin's naming policy recommends](https://kotlinlang.org/docs/coding-conventions.html#property-names) naming enum values
+using either uppercase underscore-separated names or upper camel case names.
+[Json] uses exact Kotlin enum values names for decoding by default.
+However, sometimes third-party JSONs have such values named in lowercase or some mixed case.
+In this case, it is possible to decode enum values in a case-insensitive manner using [JsonBuilder.decodeEnumsCaseInsensitive] property:
+
+```kotlin
+val format = Json { decodeEnumsCaseInsensitive = true }
+
+enum class Cases { VALUE_A, @JsonNames("Alternative") VALUE_B }
+
+@Serializable
+data class CasesList(val cases: List<Cases>)
+
+fun main() {
+ println(format.decodeFromString<CasesList>("""{"cases":["value_A", "alternative"]}"""))
+}
+```
+
+> You can get the full code [here](../guide/example/example-json-12.kt).
+
+It affects serial names as well as alternative names specified with [JsonNames] annotation, so both values are successfully decoded:
+
+```text
+CasesList(cases=[VALUE_A, VALUE_B])
+```
+
+This property does not affect encoding in any way.
+
+<!--- TEST -->
+
### Global naming strategy
If properties' names in Json input are different from Kotlin ones, it is recommended to specify the name
@@ -489,7 +523,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-12.kt).
+> You can get the full code [here](../guide/example/example-json-13.kt).
As you can see, both serialization and deserialization work as if all serial names are transformed from camel case to snake case:
@@ -541,7 +575,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-13.kt).
+> You can get the full code [here](../guide/example/example-json-14.kt).
A `JsonElement` prints itself as a valid JSON:
@@ -584,7 +618,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-14.kt).
+> You can get the full code [here](../guide/example/example-json-15.kt).
The above example sums `votes` in all objects in the `forks` array, ignoring the objects that have no `votes`:
@@ -624,7 +658,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-15.kt).
+> You can get the full code [here](../guide/example/example-json-16.kt).
As a result, you get a proper JSON string:
@@ -653,7 +687,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-16.kt).
+> You can get the full code [here](../guide/example/example-json-17.kt).
The result is exactly what you would expect:
@@ -699,7 +733,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-17.kt).
+> You can get the full code [here](../guide/example/example-json-18.kt).
Even though `pi` was defined as a number with 30 decimal places, the resulting JSON does not reflect this.
The [Double] value is truncated to 15 decimal places, and the String is wrapped in quotes - which is not a JSON number.
@@ -739,7 +773,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-18.kt).
+> You can get the full code [here](../guide/example/example-json-19.kt).
`pi_literal` now accurately matches the value defined.
@@ -779,7 +813,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-19.kt).
+> You can get the full code [here](../guide/example/example-json-20.kt).
The exact value of `pi` is decoded, with all 30 decimal places of precision that were in the source JSON.
@@ -801,7 +835,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-20.kt).
+> You can get the full code [here](../guide/example/example-json-21.kt).
```text
Exception in thread "main" kotlinx.serialization.json.internal.JsonEncodingException: Creating a literal unquoted value of 'null' is forbidden. If you want to create JSON null literal, use JsonNull object, otherwise, use JsonPrimitive
@@ -877,7 +911,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-21.kt).
+> You can get the full code [here](../guide/example/example-json-22.kt).
The output shows that both cases are correctly deserialized into a Kotlin [List].
@@ -929,7 +963,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-22.kt).
+> You can get the full code [here](../guide/example/example-json-23.kt).
You end up with a single JSON object, not an array with one element:
@@ -974,7 +1008,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-23.kt).
+> You can get the full code [here](../guide/example/example-json-24.kt).
See the effect of the custom serializer:
@@ -1047,7 +1081,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-24.kt).
+> You can get the full code [here](../guide/example/example-json-25.kt).
No class discriminator is added in the JSON output:
@@ -1143,7 +1177,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-25.kt).
+> You can get the full code [here](../guide/example/example-json-26.kt).
This gives you fine-grained control on the representation of the `Response` class in the JSON output:
@@ -1208,7 +1242,7 @@ fun main() {
}
```
-> You can get the full code [here](../guide/example/example-json-26.kt).
+> You can get the full code [here](../guide/example/example-json-27.kt).
```text
UnknownProject(name=example, details={"type":"unknown","maintainer":"Unknown","license":"Apache 2.0"})
@@ -1262,6 +1296,7 @@ The next chapter covers [Alternative and custom formats (experimental)](formats.
[JsonBuilder.allowSpecialFloatingPointValues]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/allow-special-floating-point-values.html
[JsonBuilder.classDiscriminator]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/class-discriminator.html
[JsonClassDiscriminator]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-class-discriminator/index.html
+[JsonBuilder.decodeEnumsCaseInsensitive]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/decode-enums-case-insensitive.html
[JsonBuilder.namingStrategy]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/naming-strategy.html
[JsonNamingStrategy]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-naming-strategy/index.html
[JsonElement]: https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html
diff --git a/docs/polymorphism.md b/docs/polymorphism.md
index 9ee5c5ec..29d023b6 100644
--- a/docs/polymorphism.md
+++ b/docs/polymorphism.md
@@ -408,6 +408,8 @@ fun main() {
{"type":"owned","name":"kotlinx.coroutines","owner":"kotlin"}
```
+> Note: On Kotlin/Native, you should use `format.encodeToString(PolymorphicSerializer(Project::class), data))` instead due to limited reflection capabilities.
+
<!--- TEST LINES_START -->
### Property of an interface type
diff --git a/docs/serialization-guide.md b/docs/serialization-guide.md
index 7048206a..445d32e3 100644
--- a/docs/serialization-guide.md
+++ b/docs/serialization-guide.md
@@ -119,6 +119,7 @@ Once the project is set up, we can start serializing some classes.
* <a name='allowing-structured-map-keys'></a>[Allowing structured map keys](json.md#allowing-structured-map-keys)
* <a name='allowing-special-floating-point-values'></a>[Allowing special floating-point values](json.md#allowing-special-floating-point-values)
* <a name='class-discriminator-for-polymorphism'></a>[Class discriminator for polymorphism](json.md#class-discriminator-for-polymorphism)
+ * <a name='decoding-enums-in-a-case-insensitive-manner'></a>[Decoding enums in a case-insensitive manner](json.md#decoding-enums-in-a-case-insensitive-manner)
* <a name='global-naming-strategy'></a>[Global naming strategy](json.md#global-naming-strategy)
* <a name='json-elements'></a>[Json elements](json.md#json-elements)
* <a name='parsing-to-json-element'></a>[Parsing to Json element](json.md#parsing-to-json-element)
diff --git a/formats/cbor/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt b/formats/cbor/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
index 86aafe42..b4d3c53a 100644
--- a/formats/cbor/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
+++ b/formats/cbor/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
@@ -19,7 +19,6 @@ data class SimpleStringInheritor(val s: String, val i: Int) : SimpleAbstract()
@Serializable
data class PolyBox(@Polymorphic val boxed: SimpleAbstract)
-@SharedImmutable
val SimplePolymorphicModule = SerializersModule {
polymorphic(SimpleAbstract::class) {
subclass(SimpleIntInheritor.serializer())
diff --git a/formats/hocon/build.gradle b/formats/hocon/build.gradle
index 4e2def9c..c5fae36e 100644
--- a/formats/hocon/build.gradle
+++ b/formats/hocon/build.gradle
@@ -1,3 +1,6 @@
+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@@ -12,6 +15,15 @@ compileKotlin {
}
}
+tasks.withType(KotlinCompile).configureEach {
+ kotlinOptions {
+ if (rootProject.ext.kotlin_lv_override != null) {
+ languageVersion = rootProject.ext.kotlin_lv_override
+ freeCompilerArgs += "-Xsuppress-version-warnings"
+ }
+ }
+}
+
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
diff --git a/formats/json-okio/gradle.properties b/formats/json-okio/gradle.properties
deleted file mode 100644
index 9965c652..00000000
--- a/formats/json-okio/gradle.properties
+++ /dev/null
@@ -1 +0,0 @@
-kotlin.mpp.enableCompatibilityMetadataVariant=false
diff --git a/formats/json-tests/build.gradle.kts b/formats/json-tests/build.gradle.kts
index f84336ca..9ae4247b 100644
--- a/formats/json-tests/build.gradle.kts
+++ b/formats/json-tests/build.gradle.kts
@@ -12,14 +12,6 @@ plugins {
apply(from = rootProject.file("gradle/native-targets.gradle"))
apply(from = rootProject.file("gradle/configure-source-sets.gradle"))
-tasks.withType<Kotlin2JsCompile> {
- if (this.name == "compileTestKotlinJsLegacy") {
- this.exclude("**/PropertyInitializerTest.kt")
- // Partially custom serializers without 'implicit customisation by companion' annotation are not supported on Legacy JS
- this.exclude("**/PartiallyCustomSerializerTest.kt", "**/JsonCustomSerializersTest.kt")
- }
-}
-
// disable kover tasks because there are no non-test classes in the project
tasks.named("koverHtmlReport") {
enabled = false
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
index 6d4d42f2..a185ccb7 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
@@ -37,7 +37,6 @@ class PolyDefaultWithId(id: Int) : PolyBase(id)
@Serializable
data class PolyDerived(val s: String) : PolyBase(1)
-@SharedImmutable
val BaseAndDerivedModule = SerializersModule {
polymorphic(PolyBase::class, PolyBase.serializer()) {
subclass(PolyDerived.serializer())
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializableOnPropertyTypeAndTypealiasTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializableOnPropertyTypeAndTypealiasTest.kt
index 505cb48d..7c7133c7 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializableOnPropertyTypeAndTypealiasTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializableOnPropertyTypeAndTypealiasTest.kt
@@ -3,7 +3,6 @@ package kotlinx.serialization
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
-import kotlinx.serialization.test.runSince
import kotlin.test.*
@Serializable
@@ -83,7 +82,7 @@ class SerializableOnPropertyTypeAndTypealiasTest : JsonTestBase() {
}
@Test
- fun testWithoutDefault() = runSince("1.8.20") { // Ignored by #1895
+ fun testWithoutDefault() { // Ignored by #1895
val t = TesterWithoutDefault(WithoutDefault("a"), WithoutDefault("b"), WithoutDefault("c"), WithoutDefault("d"))
assertJsonFormAndRestored(
TesterWithoutDefault.serializer(),
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializerForNullableTypeTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializerForNullableTypeTest.kt
index 89ae8bb0..98f3f5e0 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializerForNullableTypeTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializerForNullableTypeTest.kt
@@ -112,7 +112,6 @@ public class SerializerForNullableTypeTest : JsonTestBase() {
@Test
fun testGenericBoxNullable() {
- if (isJsLegacy()) return
val data = GenericBox<StringHolder?>(null)
val json = Json.encodeToString(data)
assertEquals("""{"value":"nullable"}""", Json.encodeToString(data))
@@ -121,13 +120,11 @@ public class SerializerForNullableTypeTest : JsonTestBase() {
@Test
fun testGenericNullableBoxFromNull() {
- if (isJsLegacy()) return
assertEquals(GenericBox(StringHolder("nullable")), Json.decodeFromString("""{"value":null}"""))
}
@Test
fun testGenericNullableBoxNullable() {
- if (isJsLegacy()) return
val data = GenericNullableBox<StringHolder>(null)
val json = Json.encodeToString(data)
assertEquals("""{"value":"nullable"}""", Json.encodeToString(data))
@@ -136,7 +133,6 @@ public class SerializerForNullableTypeTest : JsonTestBase() {
@Test
fun testGenericBoxNullableFromNull() {
- if (isJsLegacy()) return
assertEquals(GenericNullableBox(StringHolder("nullable")), Json.decodeFromString("""{"value":null}"""))
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt
index 89e53a7a..4b4aebfd 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt
@@ -53,12 +53,13 @@ class SerializersLookupTest : JsonTestBase() {
}
@Test
- fun testUnsigned() = noLegacyJs {
+ fun testUnsigned() {
assertSame(UByte.serializer(), serializer<UByte>())
assertSame(UShort.serializer(), serializer<UShort>())
assertSame(UInt.serializer(), serializer<UInt>())
assertSame(ULong.serializer(), serializer<ULong>())
}
+
@Test
@OptIn(ExperimentalUnsignedTypes::class)
fun testUnsignedArrays() {
@@ -129,19 +130,19 @@ class SerializersLookupTest : JsonTestBase() {
}
@Test
- fun testTriple() = noLegacyJs { // because of Box
+ fun testTriple() {
val myTriple = Triple("1", 2, Box(42))
assertSerializedWithType("""{"first":"1","second":2,"third":{"boxed":42}}""", myTriple)
}
@Test
- fun testLookupDuration() = noLegacyJs {
+ fun testLookupDuration() {
assertNotNull(serializerOrNull(typeOf<Duration>()))
assertSame(Duration.serializer(), serializer<Duration>())
}
@Test
- fun testCustomGeneric() = noLegacyJs {
+ fun testCustomGeneric() {
val intBox = Box(42)
val intBoxSerializer = serializer<Box<Int>>()
assertEquals(Box.serializer(Int.serializer()).descriptor, intBoxSerializer.descriptor)
@@ -151,13 +152,13 @@ class SerializersLookupTest : JsonTestBase() {
}
@Test
- fun testRecursiveGeneric() = noLegacyJs {
+ fun testRecursiveGeneric() {
val boxBox = Box(Box(Box(IntData(42))))
assertSerializedWithType("""{"boxed":{"boxed":{"boxed":{"intV":42}}}}""", boxBox)
}
@Test
- fun testMixedGeneric() = noLegacyJs {
+ fun testMixedGeneric() {
val listOfBoxes = listOf(Box("foo"), Box("bar"))
assertSerializedWithType("""[{"boxed":"foo"},{"boxed":"bar"}]""", listOfBoxes)
val boxedList = Box(listOf("foo", "bar"))
@@ -169,10 +170,8 @@ class SerializersLookupTest : JsonTestBase() {
assertSerializedWithType("[1,2,3]", Array<Int>(3) { it + 1 }, default)
assertSerializedWithType("""["1","2","3"]""", Array<String>(3) { (it + 1).toString() }, default)
assertSerializedWithType("[[0],[1],[2]]", Array<Array<Int>>(3) { cnt -> Array(1) { cnt } }, default)
- noLegacyJs {
- assertSerializedWithType("""[{"boxed":"foo"}]""", Array(1) { Box("foo") }, default)
- assertSerializedWithType("""[[{"boxed":"foo"}]]""", Array(1) { Array(1) { Box("foo") } }, default)
- }
+ assertSerializedWithType("""[{"boxed":"foo"}]""", Array(1) { Box("foo") }, default)
+ assertSerializedWithType("""[[{"boxed":"foo"}]]""", Array(1) { Array(1) { Box("foo") } }, default)
}
@Test
@@ -186,7 +185,7 @@ class SerializersLookupTest : JsonTestBase() {
}
@Test
- fun testSerializableObject() = noLegacyJs {
+ fun testSerializableObject() {
assertSerializedWithType("{}", SampleObject)
}
@@ -210,6 +209,24 @@ class SerializersLookupTest : JsonTestBase() {
}
}
+ class GenericHolder<T>(value: T)
+
+ class GenericSerializer<T>(typeSerializer: KSerializer<T>) : KSerializer<GenericHolder<T>> {
+ override val descriptor: SerialDescriptor =
+ PrimitiveSerialDescriptor(
+ "Generic Serializer parametrized by ${typeSerializer.descriptor}",
+ PrimitiveKind.STRING
+ )
+
+ override fun deserialize(decoder: Decoder): GenericHolder<T> {
+ TODO()
+ }
+
+ override fun serialize(encoder: Encoder, value: GenericHolder<T>) {
+ TODO()
+ }
+ }
+
@Test
fun testContextualLookup() {
val module = SerializersModule { contextual(CustomIntSerializer(false).cast<IntBox>()) }
@@ -219,6 +236,25 @@ class SerializersLookupTest : JsonTestBase() {
}
@Test
+ fun testGenericOfContextual() {
+ val module = SerializersModule {
+ contextual(CustomIntSerializer(false).cast<IntBox>())
+ contextual(GenericHolder::class) { args -> GenericSerializer(args[0]) }
+ }
+
+ val listSerializer = module.serializerOrNull(typeOf<List<IntBox>>())
+ assertNotNull(listSerializer)
+ assertEquals("kotlin.collections.ArrayList(PrimitiveDescriptor(CIS))", listSerializer.descriptor.toString())
+
+ val genericSerializer = module.serializerOrNull(typeOf<GenericHolder<IntBox>>())
+ assertNotNull(genericSerializer)
+ assertEquals(
+ "PrimitiveDescriptor(Generic Serializer parametrized by PrimitiveDescriptor(CIS))",
+ genericSerializer.descriptor.toString()
+ )
+ }
+
+ @Test
fun testContextualLookupNullable() {
val module = SerializersModule { contextual(CustomIntSerializer(true).cast<IntBox>()) }
val serializer = module.serializer<List<List<IntBox?>>>()
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
index 5e6432ea..52ab0f27 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/UmbrellaTypes.kt
@@ -64,7 +64,6 @@ data class ArraysUmbrella(
arrIntData.contentEquals(other.arrIntData)
}
-@SharedImmutable
val umbrellaInstance = TypesUmbrella(
Unit, true, 10, 20, 30, 40, 50.1f, 60.1, 'A', "Str0", Attitude.POSITIVE, IntData(70),
null, null, 11, 21, 31, 41, 51.1f, 61.1, 'B', "Str1", Attitude.NEUTRAL, null,
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonClassDiscriminatorTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonClassDiscriminatorTest.kt
index 93719c31..5eebe218 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonClassDiscriminatorTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonClassDiscriminatorTest.kt
@@ -8,7 +8,6 @@ import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
-import kotlinx.serialization.test.noLegacyJs
import kotlin.test.*
class JsonClassDiscriminatorTest : JsonTestBase() {
@@ -38,7 +37,7 @@ class JsonClassDiscriminatorTest : JsonTestBase() {
@Test
- fun testSealedClassesHaveCustomDiscriminator() = noLegacyJs {
+ fun testSealedClassesHaveCustomDiscriminator() {
val messages = listOf(
SealedMessage.StringMessage("string message", "foo"),
SealedMessage.EOF
@@ -53,7 +52,7 @@ class JsonClassDiscriminatorTest : JsonTestBase() {
}
@Test
- fun testAbstractClassesHaveCustomDiscriminator() = noLegacyJs {
+ fun testAbstractClassesHaveCustomDiscriminator() {
val messages = listOf(
AbstractMessage.StringMessage("string message", "foo"),
AbstractMessage.IntMessage("int message", 42),
@@ -67,7 +66,11 @@ class JsonClassDiscriminatorTest : JsonTestBase() {
val json = Json { serializersModule = module }
val expected =
"""[{"abstractType":"Message.StringMessage","description":"string message","message":"foo"},{"abstractType":"Message.IntMessage","description":"int message","message":42}]"""
- assertJsonFormAndRestored(ListSerializer(AbstractMessage.serializer()), messages, expected, json)
+ assertJsonFormAndRestored(
+ ListSerializer(
+ AbstractMessage.serializer()
+ ), messages, expected, json
+ )
}
@Serializable
@@ -90,7 +93,7 @@ class JsonClassDiscriminatorTest : JsonTestBase() {
@Test
- fun testDocumentationInheritanceSample() = noLegacyJs {
+ fun testDocumentationInheritanceSample() {
val module = SerializersModule {
polymorphic(Base::class) {
subclass(BaseMessage.serializer())
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonEnumsCaseInsensitiveTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonEnumsCaseInsensitiveTest.kt
new file mode 100644
index 00000000..0e802c19
--- /dev/null
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonEnumsCaseInsensitiveTest.kt
@@ -0,0 +1,170 @@
+package kotlinx.serialization.features
+
+import kotlinx.serialization.*
+import kotlinx.serialization.json.*
+import kotlinx.serialization.test.*
+import kotlin.test.*
+
+@Suppress("EnumEntryName")
+class JsonEnumsCaseInsensitiveTest: JsonTestBase() {
+ @Serializable
+ data class Foo(
+ val one: Bar = Bar.BAZ,
+ val two: Bar = Bar.QUX,
+ val three: Bar = Bar.QUX
+ )
+
+ enum class Bar { BAZ, QUX }
+
+ // It seems that we no longer report a warning that @Serializable is required for enums with @SerialName.
+ // It is still required for them to work at top-level.
+ @Serializable
+ enum class Cases {
+ ALL_CAPS,
+ MiXed,
+ all_lower,
+
+ @JsonNames("AltName")
+ hasAltNames,
+
+ @SerialName("SERIAL_NAME")
+ hasSerialName
+ }
+
+ @Serializable
+ data class EnumCases(val cases: List<Cases>)
+
+ val json = Json(default) { decodeEnumsCaseInsensitive = true }
+
+ @Test
+ fun testCases() = parametrizedTest { mode ->
+ val input =
+ """{"cases":["ALL_CAPS","all_caps","mixed","MIXED","miXed","all_lower","ALL_LOWER","all_Lower","hasAltNames","HASALTNAMES","altname","ALTNAME","AltName","SERIAL_NAME","serial_name"]}"""
+ val target = listOf(
+ Cases.ALL_CAPS,
+ Cases.ALL_CAPS,
+ Cases.MiXed,
+ Cases.MiXed,
+ Cases.MiXed,
+ Cases.all_lower,
+ Cases.all_lower,
+ Cases.all_lower,
+ Cases.hasAltNames,
+ Cases.hasAltNames,
+ Cases.hasAltNames,
+ Cases.hasAltNames,
+ Cases.hasAltNames,
+ Cases.hasSerialName,
+ Cases.hasSerialName
+ )
+ val decoded = json.decodeFromString<EnumCases>(input, mode)
+ assertEquals(EnumCases(target), decoded)
+ val encoded = json.encodeToString(decoded, mode)
+ assertEquals(
+ """{"cases":["ALL_CAPS","ALL_CAPS","MiXed","MiXed","MiXed","all_lower","all_lower","all_lower","hasAltNames","hasAltNames","hasAltNames","hasAltNames","hasAltNames","SERIAL_NAME","SERIAL_NAME"]}""",
+ encoded
+ )
+ }
+
+ @Test
+ fun testTopLevelList() = parametrizedTest { mode ->
+ val input = """["all_caps","serial_name"]"""
+ val decoded = json.decodeFromString<List<Cases>>(input, mode)
+ assertEquals(listOf(Cases.ALL_CAPS, Cases.hasSerialName), decoded)
+ assertEquals("""["ALL_CAPS","SERIAL_NAME"]""", json.encodeToString(decoded, mode))
+ }
+
+ @Test
+ fun testTopLevelEnum() = parametrizedTest { mode ->
+ val input = """"altName""""
+ val decoded = json.decodeFromString<Cases>(input, mode)
+ assertEquals(Cases.hasAltNames, decoded)
+ assertEquals(""""hasAltNames"""", json.encodeToString(decoded, mode))
+ }
+
+ @Test
+ fun testSimpleCase() = parametrizedTest { mode ->
+ val input = """{"one":"baz","two":"Qux","three":"QUX"}"""
+ val decoded = json.decodeFromString<Foo>(input, mode)
+ assertEquals(Foo(), decoded)
+ assertEquals("""{"one":"BAZ","two":"QUX","three":"QUX"}""", json.encodeToString(decoded, mode))
+ }
+
+ enum class E { VALUE_A, @JsonNames("ALTERNATIVE") VALUE_B }
+
+ @Test
+ fun testDocSample() {
+
+ val j = Json { decodeEnumsCaseInsensitive = true }
+ @Serializable
+ data class Outer(val enums: List<E>)
+
+ println(j.decodeFromString<Outer>("""{"enums":["value_A", "alternative"]}""").enums)
+ }
+
+ @Test
+ fun testCoercingStillWorks() = parametrizedTest { mode ->
+ val withCoercing = Json(json) { coerceInputValues = true }
+ val input = """{"one":"baz","two":"unknown","three":"Que"}"""
+ assertEquals(Foo(), withCoercing.decodeFromString<Foo>(input, mode))
+ }
+
+ @Test
+ fun testCaseInsensitivePriorityOverCoercing() = parametrizedTest { mode ->
+ val withCoercing = Json(json) { coerceInputValues = true }
+ val input = """{"one":"QuX","two":"Baz","three":"Que"}"""
+ assertEquals(Foo(Bar.QUX, Bar.BAZ, Bar.QUX), withCoercing.decodeFromString<Foo>(input, mode))
+ }
+
+ @Test
+ fun testCoercingStillWorksWithNulls() = parametrizedTest { mode ->
+ val withCoercing = Json(json) { coerceInputValues = true }
+ val input = """{"one":"baz","two":"null","three":null}"""
+ assertEquals(Foo(), withCoercing.decodeFromString<Foo>(input, mode))
+ }
+
+ @Test
+ fun testFeatureDisablesProperly() = parametrizedTest { mode ->
+ val disabled = Json(json) {
+ coerceInputValues = true
+ decodeEnumsCaseInsensitive = false
+ }
+ val input = """{"one":"BAZ","two":"BAz","three":"baz"}""" // two and three should be coerced to QUX
+ assertEquals(Foo(), disabled.decodeFromString<Foo>(input, mode))
+ }
+
+ @Test
+ fun testFeatureDisabledThrowsWithoutCoercing() = parametrizedTest { mode ->
+ val disabled = Json(json) {
+ coerceInputValues = false
+ decodeEnumsCaseInsensitive = false
+ }
+ val input = """{"one":"BAZ","two":"BAz","three":"baz"}"""
+ assertFailsWithMessage<SerializationException>("does not contain element with name 'BAz'") {
+ disabled.decodeFromString<Foo>(input, mode)
+ }
+ }
+
+ @Serializable enum class BadEnum { Bad, BAD }
+
+ @Serializable data class ListBadEnum(val l: List<BadEnum>)
+
+ @Test
+ fun testLowercaseClashThrowsException() = parametrizedTest { mode ->
+ assertFailsWithMessage<SerializationException>("""The suggested name 'bad' for enum value BAD is already one of the names for enum value Bad""") {
+ json.decodeFromString<Box<BadEnum>>("""{"boxed":"bad"}""", mode)
+ }
+ assertFailsWithMessage<SerializationException>("""The suggested name 'bad' for enum value BAD is already one of the names for enum value Bad""") {
+ json.decodeFromString<Box<BadEnum>>("""{"boxed":"unrelated"}""", mode)
+ }
+ }
+
+ @Test
+ fun testLowercaseClashHandledWithoutFeature() = parametrizedTest { mode ->
+ val disabled = Json(json) {
+ coerceInputValues = false
+ decodeEnumsCaseInsensitive = false
+ }
+ assertEquals(ListBadEnum(listOf(BadEnum.Bad, BadEnum.BAD)), disabled.decodeFromString("""{"l":["Bad","BAD"]}""", mode))
+ }
+}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamesTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamesTest.kt
index 6a4e33ad..34044191 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamesTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamesTest.kt
@@ -54,7 +54,7 @@ class JsonNamesTest : JsonTestBase() {
}
@Test
- fun testEnumSupportsAlternativeNames() = noLegacyJs {
+ fun testEnumSupportsAlternativeNames() {
val input = """{"enumList":["VALUE_A", "someValue", "some_value", "VALUE_B"], "checkCoercion":"someValue"}"""
val expected = WithEnumNames(
listOf(
@@ -70,14 +70,14 @@ class JsonNamesTest : JsonTestBase() {
}
@Test
- fun topLevelEnumSupportAlternativeNames() = noLegacyJs {
+ fun topLevelEnumSupportAlternativeNames() {
parameterizedCoercingTest { json, streaming, msg ->
assertEquals(AlternateEnumNames.VALUE_A, json.decodeFromString("\"someValue\"", streaming), msg)
}
}
@Test
- fun testParsesAllAlternativeNames() = noLegacyJs {
+ fun testParsesAllAlternativeNames() {
for (input in listOf(inputString1, inputString2)) {
parameterizedCoercingTest { json, streaming, _ ->
val data = json.decodeFromString(WithNames.serializer(), input, jsonTestingMode = streaming)
@@ -87,7 +87,7 @@ class JsonNamesTest : JsonTestBase() {
}
@Test
- fun testThrowsAnErrorOnDuplicateNames() = noLegacyJs {
+ fun testThrowsAnErrorOnDuplicateNames() {
val serializer = CollisionWithAlternate.serializer()
parameterizedCoercingTest { json, streaming, _ ->
assertFailsWithMessage<SerializationException>(
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamingStrategyTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamingStrategyTest.kt
index 330d5d2b..28a4d121 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamingStrategyTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/JsonNamingStrategyTest.kt
@@ -24,6 +24,7 @@ class JsonNamingStrategyTest : JsonTestBase() {
val jsonWithNaming = Json(default) {
namingStrategy = JsonNamingStrategy.SnakeCase
+ decodeEnumsCaseInsensitive = true // check that related feature does not break anything
}
@Test
@@ -131,7 +132,7 @@ class JsonNamingStrategyTest : JsonTestBase() {
data class CollisionCheckAlternate(val testCase: String, @JsonNames("test_case") val testCase2: String)
@Test
- fun testNamingStrategyPrioritizesOverAlternative() = noLegacyJs { // @JsonNames not supported on legacy
+ fun testNamingStrategyPrioritizesOverAlternative() {
val json = Json(jsonWithNaming) {
ignoreUnknownKeys = true
}
@@ -152,7 +153,7 @@ class JsonNamingStrategyTest : JsonTestBase() {
data class OriginalAsFallback(@JsonNames("testCase") val testCase: String)
@Test
- fun testCanUseOriginalNameAsAlternative() = noLegacyJs { // @JsonNames not supported on legacy
+ fun testCanUseOriginalNameAsAlternative() {
val json = Json(jsonWithNaming) {
ignoreUnknownKeys = true
}
@@ -180,7 +181,7 @@ class JsonNamingStrategyTest : JsonTestBase() {
data class Holder(val testBase: SealedBase, val testMid: SealedBase.SealedMid)
@Test
- fun testNamingStrategyDoesNotAffectPolymorphism() = noLegacyJs { // @JsonClassDiscriminator
+ fun testNamingStrategyDoesNotAffectPolymorphism() {
val json = Json(jsonWithNaming) {
classDiscriminator = "typeBase"
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt
index b20c7193..82a5ca64 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt
@@ -1,16 +1,11 @@
package kotlinx.serialization.features
import kotlinx.serialization.*
-import kotlinx.serialization.descriptors.PrimitiveKind
-import kotlinx.serialization.descriptors.SerialDescriptor
-import kotlinx.serialization.descriptors.buildSerialDescriptor
-import kotlinx.serialization.encoding.Decoder
-import kotlinx.serialization.encoding.Encoder
-import kotlinx.serialization.json.Json
-import kotlinx.serialization.test.jvmOnly
-import kotlinx.serialization.test.noLegacyJs
-import kotlin.test.Test
-import kotlin.test.assertEquals
+import kotlinx.serialization.descriptors.*
+import kotlinx.serialization.encoding.*
+import kotlinx.serialization.json.*
+import kotlinx.serialization.test.*
+import kotlin.test.*
class LocalClassesTest {
object ObjectCustomSerializer: KSerializer<Any?> {
@@ -42,10 +37,8 @@ class LocalClassesTest {
val origin = Local(42)
- noLegacyJs {
- val decoded: Local = Json.decodeFromString(Json.encodeToString(origin))
- assertEquals(origin, decoded)
- }
+ val decoded: Local = Json.decodeFromString(Json.encodeToString(origin))
+ assertEquals(origin, decoded)
}
@Test
@@ -56,10 +49,8 @@ class LocalClassesTest {
val origin = Local(it)
- noLegacyJs {
- val decoded: Local = Json.decodeFromString(Json.encodeToString(origin))
- assertEquals(origin, decoded)
- }
+ val decoded: Local = Json.decodeFromString(Json.encodeToString(origin))
+ assertEquals(origin, decoded)
}
}
@@ -71,10 +62,8 @@ class LocalClassesTest {
val origin: Local? = null
- noLegacyJs {
- val decoded: Local? = Json.decodeFromString(Json.encodeToString(origin))
- assertEquals(origin, decoded)
- }
+ val decoded: Local? = Json.decodeFromString(Json.encodeToString(origin))
+ assertEquals(origin, decoded)
}
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphicOnClassesTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphicOnClassesTest.kt
index 8e859ee2..ea59f32a 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphicOnClassesTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphicOnClassesTest.kt
@@ -136,7 +136,7 @@ class PolymorphicOnClassesTest {
fun testSerializerLookupForInterface() {
// On JVM and JS IR it can be supported via reflection/runtime hacks
// on Native, unfortunately, only with intrinsics.
- if (currentPlatform == Platform.NATIVE || currentPlatform == Platform.JS_LEGACY) return
+ if (isNative()) return
val msgSer = serializer<IMessage>()
assertEquals(IMessage::class, (msgSer as AbstractPolymorphicSerializer).baseClass)
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphismTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphismTest.kt
index d05403b8..c4938871 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphismTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/PolymorphismTest.kt
@@ -143,4 +143,42 @@ class PolymorphismTest : JsonTestBase() {
val s = json.encodeToString(Wrapper.serializer(), obj, jsonTestingMode)
assertEquals("""{"polyBase1":{"type":"even","parity":"even"},"polyBase2":{"type":"odd","parity":"odd"}}""", s)
}
+
+ @Serializable
+ sealed class Conf {
+ @Serializable
+ @SerialName("empty")
+ object Empty : Conf() // default
+
+ @Serializable
+ @SerialName("simple")
+ data class Simple(val value: String) : Conf()
+ }
+
+ private val jsonForConf = Json {
+ isLenient = false
+ ignoreUnknownKeys = true
+ serializersModule = SerializersModule {
+ polymorphicDefaultDeserializer(Conf::class) { Conf.Empty.serializer() }
+ }
+ }
+
+ @Test
+ fun defaultSerializerWithEmptyBodyTest() = parametrizedTest { mode ->
+ assertEquals(Conf.Simple("123"), jsonForConf.decodeFromString<Conf>("""{"type": "simple", "value": "123"}""", mode))
+ assertEquals(Conf.Empty, jsonForConf.decodeFromString<Conf>("""{"type": "default"}""", mode))
+ assertEquals(Conf.Empty, jsonForConf.decodeFromString<Conf>("""{"unknown": "Meow"}""", mode))
+ assertEquals(Conf.Empty, jsonForConf.decodeFromString<Conf>("""{}""", mode))
+ }
+
+ @Test
+ fun testTypeKeysInLenientMode() = parametrizedTest { mode ->
+ val json = Json(jsonForConf) { isLenient = true }
+
+ assertEquals(Conf.Simple("123"), json.decodeFromString<Conf>("""{type: simple, value: 123}""", mode))
+ assertEquals(Conf.Empty, json.decodeFromString<Conf>("""{type: default}""", mode))
+ assertEquals(Conf.Empty, json.decodeFromString<Conf>("""{unknown: Meow}""", mode))
+ assertEquals(Conf.Empty, json.decodeFromString<Conf>("""{}""", mode))
+
+ }
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/SkipDefaults.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/SkipDefaults.kt
index ee37b4b8..a7fea75f 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/SkipDefaults.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/SkipDefaults.kt
@@ -7,7 +7,6 @@ package kotlinx.serialization.features
import kotlinx.serialization.*
import kotlinx.serialization.EncodeDefault.Mode.*
import kotlinx.serialization.json.*
-import kotlinx.serialization.test.noLegacyJs
import kotlin.test.*
class SkipDefaultsTest {
@@ -59,7 +58,7 @@ class SkipDefaultsTest {
}
@Test
- fun encodeDefaultsAnnotationWithFlag() = noLegacyJs {
+ fun encodeDefaultsAnnotationWithFlag() {
val data = DifferentModes()
assertEquals("""{"a":"a","b":"b","c":"c"}""", jsonEncodeDefaults.encodeToString(data))
assertEquals("""{"b":"b","c":"c"}""", jsonDropDefaults.encodeToString(data))
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/EncodeInlineElementTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/EncodeInlineElementTest.kt
index 56a7f3d2..aa4866f4 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/EncodeInlineElementTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/EncodeInlineElementTest.kt
@@ -41,8 +41,8 @@ object WithUnsignedSerializer : KSerializer<WithUnsigned> {
class EncodeInlineElementTest {
@Test
- fun wrapper() = noLegacyJs {
+ fun wrapper() {
val w = WithUnsigned(Int.MAX_VALUE.toUInt() + 1.toUInt())
- assertStringFormAndRestored("""{"u":2147483648}""", w, WithUnsignedSerializer, printResult = true)
+ assertStringFormAndRestored<WithUnsigned>("""{"u":2147483648}""", w, WithUnsignedSerializer, printResult = true)
}
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesCompleteTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesCompleteTest.kt
index 363bdaf9..96972f92 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesCompleteTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesCompleteTest.kt
@@ -61,7 +61,7 @@ data class WithGenerics(
class InlineClassesCompleteTest {
@Test
- fun testAllVariantsWithoutNull() = noLegacyJs {
+ fun testAllVariantsWithoutNull() {
val withAll = WithAll(
MyInt(1),
MyInt(2),
@@ -72,15 +72,15 @@ class InlineClassesCompleteTest {
OverSerializableNullable(IntData(7)),
OverSerializableNullable(IntData(8)),
WithT(Box(9)),
- WithT<Int>(Box(10)),
- WithT<Int?>(Box(11)),
- WithTNullable<Int?>(Box(12))
+ WithT(Box(10)),
+ WithT(Box(11)),
+ WithTNullable(Box(12))
)
assertSerializedAndRestored(withAll, WithAll.serializer())
}
@Test
- fun testAllVariantsWithNull() = noLegacyJs {
+ fun testAllVariantsWithNull() {
assertSerializedAndRestored(
WithAll(
MyInt(1),
@@ -93,14 +93,14 @@ class InlineClassesCompleteTest {
null,
WithT(Box(9)),
null,
- WithT<Int?>(Box(null)),
- WithTNullable<Int?>(Box(null))
+ WithT(Box(null)),
+ WithTNullable(Box(null))
), WithAll.serializer()
)
}
@Test
- fun testAllGenericVariantsWithoutNull() = noLegacyJs {
+ fun testAllGenericVariantsWithoutNull() {
assertSerializedAndRestored(
WithGenerics(
Box(MyInt(1)),
@@ -117,7 +117,7 @@ class InlineClassesCompleteTest {
}
@Test
- fun testAllGenericVariantsWithNull() = noLegacyJs {
+ fun testAllGenericVariantsWithNull() {
assertSerializedAndRestored(
WithGenerics(
Box(MyInt(1)),
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesTest.kt
index 0d30fc11..f3eb9511 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineClassesTest.kt
@@ -95,25 +95,25 @@ class InlineClassesTest : JsonTestBase() {
private val precedent: UInt = Int.MAX_VALUE.toUInt() + 10.toUInt()
@Test
- fun withList() = noLegacyJs {
+ fun withList() {
val withList = WithList(listOf(1, 2, 3))
assertJsonFormAndRestored(WithList.serializer(), withList, """[1,2,3]""")
}
@Test
- fun testOuterInner() = noLegacyJs {
+ fun testOuterInner() {
val o = Outer(Inner(10))
assertJsonFormAndRestored(Outer.serializer(), o, """{"n":10}""")
}
@Test
- fun testOuterOuterInner() = noLegacyJs {
+ fun testOuterOuterInner() {
val o = OuterOuter(Outer(Inner(10)))
assertJsonFormAndRestored(OuterOuter.serializer(), o, """{"outer":{"n":10}}""")
}
@Test
- fun testTopLevel() = noLegacyJs {
+ fun testTopLevel() {
assertJsonFormAndRestored(
ResourceType.serializer(),
ResourceType("foo"),
@@ -122,7 +122,7 @@ class InlineClassesTest : JsonTestBase() {
}
@Test
- fun testTopLevelOverEnum() = noLegacyJs {
+ fun testTopLevelOverEnum() {
assertJsonFormAndRestored(
ResourceKind.serializer(),
ResourceKind(SampleEnum.OptionC),
@@ -131,7 +131,7 @@ class InlineClassesTest : JsonTestBase() {
}
@Test
- fun testTopLevelWrapper() = noLegacyJs {
+ fun testTopLevelWrapper() {
assertJsonFormAndRestored(
ValueWrapper.serializer(),
ValueWrapper(ResourceType("foo")),
@@ -140,7 +140,7 @@ class InlineClassesTest : JsonTestBase() {
}
@Test
- fun testTopLevelContextual() = noLegacyJs {
+ fun testTopLevelContextual() {
val module = SerializersModule {
contextual<ResourceType>(ResourceType.serializer())
}
@@ -155,7 +155,7 @@ class InlineClassesTest : JsonTestBase() {
@Test
- fun testSimpleContainer() = noLegacyJs {
+ fun testSimpleContainer() {
assertJsonFormAndRestored(
SimpleContainerForUInt.serializer(),
SimpleContainerForUInt(precedent),
@@ -171,7 +171,7 @@ class InlineClassesTest : JsonTestBase() {
)
@Test
- fun testSimpleContainerForList() = noLegacyJs {
+ fun testSimpleContainerForList() {
assertJsonFormAndRestored(
ContainerForList.serializer(UInt.serializer()),
ContainerForList(MyList(listOf(precedent))),
@@ -180,7 +180,7 @@ class InlineClassesTest : JsonTestBase() {
}
@Test
- fun testInlineClassesWithStrings() = noLegacyJs {
+ fun testInlineClassesWithStrings() {
assertJsonFormAndRestored(
ResourceIdentifier.serializer(),
ResourceIdentifier(ResourceId("resId"), ResourceType("resType"), ValueWrapper(ResourceType("wrappedType"))),
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineMapQuotedTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineMapQuotedTest.kt
index 53461bfd..63157d12 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineMapQuotedTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/InlineMapQuotedTest.kt
@@ -48,7 +48,7 @@ class InlineMapQuotedTest : JsonTestBase() {
)
@Test
- fun testInlineClassAsMapKey() = noLegacyJs {
+ fun testInlineClassAsMapKey() {
println(Long.MAX_VALUE.toULong() + 2UL)
val c = Carrier(
mapOf(1L to 1L),
@@ -58,7 +58,7 @@ class InlineMapQuotedTest : JsonTestBase() {
mapOf(CustomULong(Long.MAX_VALUE.toULong() + 5UL) to 5L)
)
assertJsonFormAndRestored(
- serializer(),
+ serializer<Carrier>(),
c,
"""{"mapLong":{"1":1},"mapULong":{"9223372036854775809":2},"wrappedLong":{"3":3},"mapWrappedU":{"9223372036854775811":4},"mapCustom":{"9223372036854775812":5}}"""
)
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/ValueClassesInSealedHierarchyTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/ValueClassesInSealedHierarchyTest.kt
index f3b482f1..ed968298 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/ValueClassesInSealedHierarchyTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/ValueClassesInSealedHierarchyTest.kt
@@ -12,7 +12,7 @@ import kotlin.test.*
class ValueClassesInSealedHierarchyTest : JsonTestBase() {
@Test
- fun testSingle() = noLegacyJs {
+ fun testSingle() {
val single = "foo"
assertJsonFormAndRestored(
AnyValue.serializer(),
@@ -22,7 +22,7 @@ class ValueClassesInSealedHierarchyTest : JsonTestBase() {
}
@Test
- fun testComplex() = noLegacyJs {
+ fun testComplex() {
val complexJson = """{"id":"1","name":"object"}"""
assertJsonFormAndRestored(
AnyValue.serializer(),
@@ -32,9 +32,13 @@ class ValueClassesInSealedHierarchyTest : JsonTestBase() {
}
@Test
- fun testMulti() = noLegacyJs {
+ fun testMulti() {
val multiJson = """["list","of","strings"]"""
- assertJsonFormAndRestored(AnyValue.serializer(), AnyValue.Multi(listOf("list", "of", "strings")), multiJson)
+ assertJsonFormAndRestored(
+ AnyValue.serializer(),
+ AnyValue.Multi(listOf("list", "of", "strings")),
+ multiJson
+ )
}
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/sealed/SealedInterfacesJsonSerializationTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/sealed/SealedInterfacesJsonSerializationTest.kt
index da05cc0e..a2e6bb67 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/sealed/SealedInterfacesJsonSerializationTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/sealed/SealedInterfacesJsonSerializationTest.kt
@@ -29,7 +29,7 @@ class SealedInterfacesJsonSerializationTest : JsonTestBase() {
object NoResponse: I
@Test
- fun testSealedInterfaceJson() = noLegacyJs {
+ fun testSealedInterfaceJson() {
val messages = listOf(Response.ResponseInt(10), NoResponse, Response.ResponseString("foo"))
assertJsonFormAndRestored(
serializer(),
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonExponentTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonExponentTest.kt
new file mode 100644
index 00000000..0f31ac50
--- /dev/null
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonExponentTest.kt
@@ -0,0 +1,79 @@
+package kotlinx.serialization.json
+
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.test.*
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class JsonExponentTest : JsonTestBase() {
+ @Serializable
+ data class SomeData(val count: Long)
+ @Serializable
+ data class SomeDataDouble(val count: Double)
+
+ @Test
+ fun testExponentDecodingPositive() = parametrizedTest {
+ val decoded = Json.decodeFromString<SomeData>("""{ "count": 23e11 }""", it)
+ assertEquals(2300000000000, decoded.count)
+ }
+
+ @Test
+ fun testExponentDecodingNegative() = parametrizedTest {
+ val decoded = Json.decodeFromString<SomeData>("""{ "count": -10E1 }""", it)
+ assertEquals(-100, decoded.count)
+ }
+
+ @Test
+ fun testExponentDecodingPositiveDouble() = parametrizedTest {
+ val decoded = Json.decodeFromString<SomeDataDouble>("""{ "count": 1.5E1 }""", it)
+ assertEquals(15.0, decoded.count)
+ }
+
+ @Test
+ fun testExponentDecodingNegativeDouble() = parametrizedTest {
+ val decoded = Json.decodeFromString<SomeDataDouble>("""{ "count": -1e-1 }""", it)
+ assertEquals(-0.1, decoded.count)
+ }
+
+ @Test
+ fun testExponentDecodingErrorTruncatedDecimal() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeData>("""{ "count": -1E-1 }""", it) }
+ }
+
+ @Test
+ fun testExponentDecodingErrorExponent() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeData>("""{ "count": 1e-1e-1 }""", it) }
+ }
+
+ @Test
+ fun testExponentDecodingErrorExponentDouble() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeDataDouble>("""{ "count": 1e-1e-1 }""", it) }
+ }
+
+ @Test
+ fun testExponentOverflowDouble() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeDataDouble>("""{ "count": 10000e10000 }""", it) }
+ }
+
+ @Test
+ fun testExponentUnderflowDouble() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeDataDouble>("""{ "count": -100e2222 }""", it) }
+ }
+
+ @Test
+ fun testExponentOverflow() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeData>("""{ "count": 10000e10000 }""", it) }
+ }
+
+ @Test
+ fun testExponentUnderflow() = parametrizedTest {
+ assertFailsWithSerial("JsonDecodingException")
+ { Json.decodeFromString<SomeData>("""{ "count": -10000e10000 }""", it) }
+ }
+} \ No newline at end of file
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonMapKeysTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonMapKeysTest.kt
index 868e3adc..61f31de9 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonMapKeysTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonMapKeysTest.kt
@@ -71,10 +71,8 @@ class JsonMapKeysTest : JsonTestBase() {
@Test
fun testStructuredMapKeysShouldBeProhibitedByDefault() = parametrizedTest { streaming ->
- noLegacyJs {
- verifyProhibition(WithComplexKey(mapOf(IntData(42) to "42")), streaming)
- verifyProhibition(WithComplexValueKey(mapOf(ComplexCarrier(IntData(42)) to "42")), streaming)
- }
+ verifyProhibition(WithComplexKey(mapOf(IntData(42) to "42")), streaming)
+ verifyProhibition(WithComplexValueKey(mapOf(ComplexCarrier(IntData(42)) to "42")), streaming)
}
private inline fun <reified T: Any> verifyProhibition(value: T, streaming: JsonTestingMode) {
@@ -92,7 +90,7 @@ class JsonMapKeysTest : JsonTestBase() {
)
@Test
- fun testStructuredValueMapKeysAllowedWithFlag() = noLegacyJs {
+ fun testStructuredValueMapKeysAllowedWithFlag() {
assertJsonFormAndRestored(
WithComplexValueKey.serializer(),
WithComplexValueKey(mapOf(ComplexCarrier(IntData(42)) to "42")),
@@ -110,7 +108,7 @@ class JsonMapKeysTest : JsonTestBase() {
)
@Test
- fun testPrimitivesAreAllowedAsValueMapKeys() = noLegacyJs {
+ fun testPrimitivesAreAllowedAsValueMapKeys() {
assertJsonFormAndRestored(
WithValueKeyMap.serializer(),
WithValueKeyMap(mapOf(PrimitiveCarrier("fooKey") to 1)),
@@ -120,7 +118,7 @@ class JsonMapKeysTest : JsonTestBase() {
}
@Test
- fun testContextualValuePrimitivesAreAllowedAsValueMapKeys() = noLegacyJs {
+ fun testContextualValuePrimitivesAreAllowedAsValueMapKeys() {
assertJsonFormAndRestored(
WithContextualValueKey.serializer(),
WithContextualValueKey(mapOf(PrimitiveCarrier("fooKey") to 1)),
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonModesTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonModesTest.kt
index 97993802..e7f107c8 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonModesTest.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonModesTest.kt
@@ -120,11 +120,9 @@ class JsonModesTest : JsonTestBase() {
@Test
fun testIgnoreUnknownKeysObject() = parametrizedTest { jsonTestingMode ->
- noLegacyJs {
- assertEquals(Holder(Object), lenient.decodeFromString("""{"o":{}}""", jsonTestingMode))
- assertEquals(Holder(Object), lenient.decodeFromString("""{"o":{"unknown":{"b":"c"}}}""", jsonTestingMode))
- assertEquals(Object, lenient.decodeFromString("""{}""", jsonTestingMode))
- assertEquals(Object, lenient.decodeFromString("""{"o":{"unknown":{"b":"c"}}}""", jsonTestingMode))
- }
+ assertEquals(Holder(Object), lenient.decodeFromString("""{"o":{}}""", jsonTestingMode))
+ assertEquals(Holder(Object), lenient.decodeFromString("""{"o":{"unknown":{"b":"c"}}}""", jsonTestingMode))
+ assertEquals(Object, lenient.decodeFromString("""{}""", jsonTestingMode))
+ assertEquals(Object, lenient.decodeFromString("""{"o":{"unknown":{"b":"c"}}}""", jsonTestingMode))
}
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonTreeDecoderPolymorphicTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonTreeDecoderPolymorphicTest.kt
new file mode 100644
index 00000000..9d8e861d
--- /dev/null
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonTreeDecoderPolymorphicTest.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.json.polymorphic
+
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.json.*
+import kotlin.test.*
+
+class JsonTreeDecoderPolymorphicTest : JsonTestBase() {
+
+ @Serializable
+ sealed class Sealed
+
+ @Serializable
+ data class ClassContainingItself(
+ val a: String,
+ val b: String,
+ val c: ClassContainingItself? = null,
+ val d: String?
+ ) : Sealed()
+
+ val inner = ClassContainingItself(
+ "InnerA",
+ "InnerB",
+ null,
+ "InnerC"
+ )
+ val outer = ClassContainingItself(
+ "OuterA",
+ "OuterB",
+ inner,
+ "OuterC"
+ )
+
+ @Test
+ fun testDecodingWhenClassContainsItself() = parametrizedTest { jsonTestingMode ->
+ val encoded = default.encodeToString(outer as Sealed, jsonTestingMode)
+ val decoded: Sealed = Json.decodeFromString(encoded, jsonTestingMode)
+ assertEquals(outer, decoded)
+ }
+}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/PolymorphicClasses.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/PolymorphicClasses.kt
index e46de17a..e70d89c3 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/PolymorphicClasses.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/PolymorphicClasses.kt
@@ -38,7 +38,6 @@ internal data class OuterBox(@Polymorphic val outerBase: OuterBase, @Polymorphic
@Serializable
internal data class OuterNullableBox(@Polymorphic val outerBase: OuterBase?, @Polymorphic val innerBase: InnerBase?)
-@SharedImmutable
internal val polymorphicTestModule = SerializersModule {
polymorphic(InnerBase::class) {
subclass(InnerImpl.serializer())
@@ -51,13 +50,11 @@ internal val polymorphicTestModule = SerializersModule {
}
}
-@SharedImmutable
internal val polymorphicJson = Json {
serializersModule = polymorphicTestModule
encodeDefaults = true
}
-@SharedImmutable
internal val polymorphicRelaxedJson = Json {
isLenient = true
serializersModule = polymorphicTestModule
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt
deleted file mode 100644
index 9a524054..00000000
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/test/CompilerVersions.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.serialization.test
-
-import kotlin.test.Test
-import kotlin.test.assertFalse
-import kotlin.test.assertTrue
-
-private val currentKotlinVersion = KotlinVersion.CURRENT
-
-private fun String.toKotlinVersion(): KotlinVersion {
- val parts = split(".")
- val intParts = parts.mapNotNull { it.toIntOrNull() }
- if (parts.size != 3 || intParts.size != 3) error("Illegal kotlin version, expected format is 1.2.3")
-
- return KotlinVersion(intParts[0], intParts[1], intParts[2])
-}
-
-internal fun runSince(kotlinVersion: String, test: () -> Unit) {
- if (currentKotlinVersion >= kotlinVersion.toKotlinVersion()) {
- test()
- }
-}
-
-internal class CompilerVersionTest {
- @Test
- fun testSince() {
- var executed = false
-
- runSince("1.0.0") {
- executed = true
- }
- assertTrue(executed)
-
- executed = false
- runSince("255.255.255") {
- executed = true
- }
- assertFalse(executed)
- }
-}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
index c4a6b986..92cf087f 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
@@ -5,12 +5,11 @@
package kotlinx.serialization.test
enum class Platform {
- JVM, JS_LEGACY, JS_IR, NATIVE
+ JVM, JS, NATIVE
}
public expect val currentPlatform: Platform
-public fun isJs(): Boolean = currentPlatform == Platform.JS_LEGACY || currentPlatform == Platform.JS_IR
-public fun isJsLegacy(): Boolean = currentPlatform == Platform.JS_LEGACY
+public fun isJs(): Boolean = currentPlatform == Platform.JS
public fun isJvm(): Boolean = currentPlatform == Platform.JVM
public fun isNative(): Boolean = currentPlatform == Platform.NATIVE
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestHelpers.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
index 04af40c6..27ac19f1 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestHelpers.kt
@@ -34,10 +34,6 @@ inline fun noJs(test: () -> Unit) {
if (!isJs()) test()
}
-inline fun noLegacyJs(test: () -> Unit) {
- if (!isJsLegacy()) test()
-}
-
inline fun jvmOnly(test: () -> Unit) {
if (isJvm()) test()
}
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestingFramework.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestingFramework.kt
index b46afe69..e941f047 100644
--- a/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestingFramework.kt
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/test/TestingFramework.kt
@@ -78,7 +78,7 @@ inline fun assertFailsWithSerialMessage(
)
assertTrue(
exception.message!!.contains(message),
- "expected:<${exception.message}> but was:<$message>"
+ "expected:<$message> but was:<${exception.message}>"
)
}
inline fun <reified T : Throwable> assertFailsWithMessage(
@@ -89,6 +89,6 @@ inline fun <reified T : Throwable> assertFailsWithMessage(
val exception = assertFailsWith(T::class, assertionMessage, block)
assertTrue(
exception.message!!.contains(message),
- "expected:<${exception.message}> but was:<$message>"
+ "expected:<$message> but was:<${exception.message}>"
)
}
diff --git a/formats/json-tests/jsTest/src/kotlinx/serialization/json/DynamicPolymorphismTest.kt b/formats/json-tests/jsTest/src/kotlinx/serialization/json/DynamicPolymorphismTest.kt
index 0af00c66..3ff05ba0 100644
--- a/formats/json-tests/jsTest/src/kotlinx/serialization/json/DynamicPolymorphismTest.kt
+++ b/formats/json-tests/jsTest/src/kotlinx/serialization/json/DynamicPolymorphismTest.kt
@@ -8,7 +8,6 @@ import kotlinx.serialization.*
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic
import kotlinx.serialization.modules.subclass
-import kotlinx.serialization.test.noLegacyJs
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -85,7 +84,7 @@ class DynamicPolymorphismTest {
}
@Test
- fun testCustomClassDiscriminator() = noLegacyJs {
+ fun testCustomClassDiscriminator() {
val value = SealedCustom.DataClassChild("custom-discriminator-test")
encodeAndDecode(SealedCustom.serializer(), value, objectJson) {
assertEquals("data_class", this["sealed_custom"])
diff --git a/formats/json-tests/jsTest/src/kotlinx/serialization/json/JsonNamesDynamicTest.kt b/formats/json-tests/jsTest/src/kotlinx/serialization/json/JsonNamesDynamicTest.kt
index 09cf3d4a..0c519fc2 100644
--- a/formats/json-tests/jsTest/src/kotlinx/serialization/json/JsonNamesDynamicTest.kt
+++ b/formats/json-tests/jsTest/src/kotlinx/serialization/json/JsonNamesDynamicTest.kt
@@ -29,7 +29,7 @@ class JsonNamesDynamicTest {
}
@Test
- fun testParsesAllAlternativeNamesDynamic() = noLegacyJs {
+ fun testParsesAllAlternativeNamesDynamic() {
for (input in listOf(inputString1, inputString2)) {
parameterizedCoercingTest { json, msg ->
val data = json.decodeFromDynamic(JsonNamesTest.WithNames.serializer(), input)
@@ -39,7 +39,7 @@ class JsonNamesDynamicTest {
}
@Test
- fun testEnumSupportsAlternativeNames() = noLegacyJs {
+ fun testEnumSupportsAlternativeNames() {
val input = js("""{"enumList":["VALUE_A", "someValue", "some_value", "VALUE_B"], "checkCoercion":"someValue"}""")
val expected = JsonNamesTest.WithEnumNames(
listOf(
@@ -55,14 +55,14 @@ class JsonNamesDynamicTest {
}
@Test
- fun topLevelEnumSupportAlternativeNames() = noLegacyJs {
+ fun topLevelEnumSupportAlternativeNames() {
parameterizedCoercingTest { json, msg ->
assertEquals(JsonNamesTest.AlternateEnumNames.VALUE_A, json.decodeFromDynamic(js("\"someValue\"")), msg)
}
}
@Test
- fun testThrowsAnErrorOnDuplicateNames2() = noLegacyJs {
+ fun testThrowsAnErrorOnDuplicateNames2() {
val serializer = JsonNamesTest.CollisionWithAlternate.serializer()
parameterizedCoercingTest { json, _ ->
assertFailsWithMessage<SerializationException>(
diff --git a/formats/json-tests/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/formats/json-tests/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index b87276e8..23627d17 100644
--- a/formats/json-tests/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/formats/json-tests/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -4,9 +4,4 @@
package kotlinx.serialization.test
-public actual val currentPlatform: Platform = if (isLegacyBackend()) Platform.JS_LEGACY else Platform.JS_IR
-
-// from https://github.com/JetBrains/kotlin/blob/569187a7516e2e5ab217158a3170d4beb0c5cb5a/js/js.translator/testData/_commonFiles/testUtils.kt#L3
-private fun isLegacyBackend(): Boolean =
- // Using eval to prevent DCE from thinking that following code depends on Kotlin module.
- eval("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")").unsafeCast<Boolean>()
+public actual val currentPlatform: Platform = Platform.JS
diff --git a/formats/json-tests/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/formats/json-tests/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index 32806c1f..58249044 100644
--- a/formats/json-tests/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/formats/json-tests/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -4,8 +4,5 @@
package kotlinx.serialization.test
-import kotlin.native.concurrent.SharedImmutable
-
-@SharedImmutable
public actual val currentPlatform: Platform = Platform.NATIVE
diff --git a/formats/json/api/kotlinx-serialization-json.api b/formats/json/api/kotlinx-serialization-json.api
index 663bd997..3b97d174 100644
--- a/formats/json/api/kotlinx-serialization-json.api
+++ b/formats/json/api/kotlinx-serialization-json.api
@@ -2,6 +2,7 @@ public final class kotlinx/serialization/json/DecodeSequenceMode : java/lang/Enu
public static final field ARRAY_WRAPPED Lkotlinx/serialization/json/DecodeSequenceMode;
public static final field AUTO_DETECT Lkotlinx/serialization/json/DecodeSequenceMode;
public static final field WHITESPACE_SEPARATED Lkotlinx/serialization/json/DecodeSequenceMode;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lkotlinx/serialization/json/DecodeSequenceMode;
public static fun values ()[Lkotlinx/serialization/json/DecodeSequenceMode;
}
@@ -88,6 +89,7 @@ public final class kotlinx/serialization/json/JsonBuilder {
public final fun getAllowStructuredMapKeys ()Z
public final fun getClassDiscriminator ()Ljava/lang/String;
public final fun getCoerceInputValues ()Z
+ public final fun getDecodeEnumsCaseInsensitive ()Z
public final fun getEncodeDefaults ()Z
public final fun getExplicitNulls ()Z
public final fun getIgnoreUnknownKeys ()Z
@@ -102,6 +104,7 @@ public final class kotlinx/serialization/json/JsonBuilder {
public final fun setAllowStructuredMapKeys (Z)V
public final fun setClassDiscriminator (Ljava/lang/String;)V
public final fun setCoerceInputValues (Z)V
+ public final fun setDecodeEnumsCaseInsensitive (Z)V
public final fun setEncodeDefaults (Z)V
public final fun setExplicitNulls (Z)V
public final fun setIgnoreUnknownKeys (Z)V
@@ -129,6 +132,7 @@ public final class kotlinx/serialization/json/JsonConfiguration {
public final fun getAllowStructuredMapKeys ()Z
public final fun getClassDiscriminator ()Ljava/lang/String;
public final fun getCoerceInputValues ()Z
+ public final fun getDecodeEnumsCaseInsensitive ()Z
public final fun getEncodeDefaults ()Z
public final fun getExplicitNulls ()Z
public final fun getIgnoreUnknownKeys ()Z
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/Json.kt b/formats/json/commonMain/src/kotlinx/serialization/json/Json.kt
index 443f1dc3..40dcc23e 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/Json.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/Json.kt
@@ -288,7 +288,7 @@ public class JsonBuilder internal constructor(json: Json) {
/**
* Enables coercing incorrect JSON values to the default property value in the following cases:
- * 1. JSON value is `null` but property type is non-nullable.
+ * 1. JSON value is `null` but the property type is non-nullable.
* 2. Property type is an enum type, but JSON value contains unknown enum member.
*
* `false` by default.
@@ -336,6 +336,35 @@ public class JsonBuilder internal constructor(json: Json) {
public var namingStrategy: JsonNamingStrategy? = json.configuration.namingStrategy
/**
+ * Enables decoding enum values in a case-insensitive manner.
+ * Encoding is not affected.
+ *
+ * This affects both enum serial names and alternative names (specified with the [JsonNames] annotation).
+ * In the following example, string `[VALUE_A, VALUE_B]` will be printed:
+ * ```
+ * enum class E { VALUE_A, @JsonNames("ALTERNATIVE") VALUE_B }
+ *
+ * @Serializable
+ * data class Outer(val enums: List<E>)
+ *
+ * val j = Json { decodeEnumsCaseInsensitive = true }
+ * println(j.decodeFromString<Outer>("""{"enums":["value_A", "alternative"]}""").enums)
+ * ```
+ *
+ * If this feature is enabled,
+ * it is no longer possible to decode enum values that have the same name in a lowercase form.
+ * The following code will throw a serialization exception:
+ *
+ * ```
+ * enum class BadEnum { Bad, BAD }
+ * val j = Json { decodeEnumsCaseInsensitive = true }
+ * j.decodeFromString<Box<BadEnum>>("""{"boxed":"bad"}""")
+ * ```
+ */
+ @ExperimentalSerializationApi
+ public var decodeEnumsCaseInsensitive: Boolean = json.configuration.decodeEnumsCaseInsensitive
+
+ /**
* Module with contextual and polymorphic serializers to be used in the resulting [Json] instance.
*
* @see SerializersModule
@@ -367,7 +396,7 @@ public class JsonBuilder internal constructor(json: Json) {
allowStructuredMapKeys, prettyPrint, explicitNulls, prettyPrintIndent,
coerceInputValues, useArrayPolymorphism,
classDiscriminator, allowSpecialFloatingPointValues, useAlternativeNames,
- namingStrategy
+ namingStrategy, decodeEnumsCaseInsensitive
)
}
}
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt b/formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt
index d17d0fcc..ea653a64 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt
@@ -9,7 +9,7 @@ import kotlinx.serialization.*
* Can be used for debug purposes and for custom Json-specific serializers
* via [JsonEncoder] and [JsonDecoder].
*
- * Standalone configuration object is meaningless and can nor be used outside of the
+ * Standalone configuration object is meaningless and can nor be used outside the
* [Json], neither new [Json] instance can be created from it.
*
* Detailed description of each property is available in [JsonBuilder] class.
@@ -31,6 +31,8 @@ public class JsonConfiguration @OptIn(ExperimentalSerializationApi::class) inter
public val useAlternativeNames: Boolean = true,
@ExperimentalSerializationApi
public val namingStrategy: JsonNamingStrategy? = null,
+ @ExperimentalSerializationApi
+ public val decodeEnumsCaseInsensitive: Boolean = false
) {
/** @suppress Dokka **/
@@ -40,6 +42,6 @@ public class JsonConfiguration @OptIn(ExperimentalSerializationApi::class) inter
"allowStructuredMapKeys=$allowStructuredMapKeys, prettyPrint=$prettyPrint, explicitNulls=$explicitNulls, " +
"prettyPrintIndent='$prettyPrintIndent', coerceInputValues=$coerceInputValues, useArrayPolymorphism=$useArrayPolymorphism, " +
"classDiscriminator='$classDiscriminator', allowSpecialFloatingPointValues=$allowSpecialFloatingPointValues, useAlternativeNames=$useAlternativeNames, " +
- "namingStrategy=$namingStrategy)"
+ "namingStrategy=$namingStrategy, decodeEnumsCaseInsensitive=$decodeEnumsCaseInsensitive)"
}
}
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt b/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt
index a325f76f..74abf34a 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt
@@ -11,7 +11,6 @@ import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.internal.InlinePrimitiveDescriptor
import kotlinx.serialization.json.internal.*
-import kotlin.native.concurrent.SharedImmutable
/**
* Class representing single JSON element.
@@ -134,7 +133,6 @@ public fun JsonUnquotedLiteral(value: String?): JsonPrimitive {
}
/** Used as a marker to indicate during encoding that the [JsonEncoder] should use `encodeInline()` */
-@SharedImmutable
internal val jsonUnquotedLiteralDescriptor: SerialDescriptor =
InlinePrimitiveDescriptor("kotlinx.serialization.json.JsonUnquotedLiteral", String.serializer())
@@ -255,23 +253,35 @@ public val JsonElement.jsonNull: JsonNull
* Returns content of the current element as int
* @throws NumberFormatException if current element is not a valid representation of number
*/
-public val JsonPrimitive.int: Int get() = content.toInt()
+public val JsonPrimitive.int: Int
+ get() {
+ val result = mapExceptions { StringJsonLexer(content).consumeNumericLiteral() }
+ if (result !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException("$content is not an Int")
+ return result.toInt()
+ }
/**
* Returns content of the current element as int or `null` if current element is not a valid representation of number
*/
-public val JsonPrimitive.intOrNull: Int? get() = content.toIntOrNull()
+public val JsonPrimitive.intOrNull: Int?
+ get() {
+ val result = mapExceptionsToNull { StringJsonLexer(content).consumeNumericLiteral() } ?: return null
+ if (result !in Int.MIN_VALUE..Int.MAX_VALUE) return null
+ return result.toInt()
+ }
/**
* Returns content of current element as long
* @throws NumberFormatException if current element is not a valid representation of number
*/
-public val JsonPrimitive.long: Long get() = content.toLong()
+public val JsonPrimitive.long: Long get() = mapExceptions { StringJsonLexer(content).consumeNumericLiteral() }
/**
* Returns content of current element as long or `null` if current element is not a valid representation of number
*/
-public val JsonPrimitive.longOrNull: Long? get() = content.toLongOrNull()
+public val JsonPrimitive.longOrNull: Long?
+ get() =
+ mapExceptionsToNull { StringJsonLexer(content).consumeNumericLiteral() }
/**
* Returns content of current element as double
@@ -315,6 +325,22 @@ public val JsonPrimitive.contentOrNull: String? get() = if (this is JsonNull) nu
private fun JsonElement.error(element: String): Nothing =
throw IllegalArgumentException("Element ${this::class} is not a $element")
+private inline fun <T> mapExceptionsToNull(f: () -> T): T? {
+ return try {
+ f()
+ } catch (e: JsonDecodingException) {
+ null
+ }
+}
+
+private inline fun <T> mapExceptions(f: () -> T): T {
+ return try {
+ f()
+ } catch (e: JsonDecodingException) {
+ throw NumberFormatException(e.message)
+ }
+}
+
@PublishedApi
internal fun unexpectedJson(key: String, expected: String): Nothing =
throw IllegalArgumentException("Element $key is not a $expected")
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt b/formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt
index 83c23660..269f68b4 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt
@@ -14,7 +14,7 @@ import kotlinx.serialization.json.internal.JsonDecodingException
/**
* Serializer object providing [SerializationStrategy] and [DeserializationStrategy] for [JsonElement].
- * It can only be used by with [Json] format an its input ([JsonDecoder] and [JsonEncoder]).
+ * It can only be used by with [Json] format and its input ([JsonDecoder] and [JsonEncoder]).
* Currently, this hierarchy has no guarantees on descriptor content.
*
* Example usage:
@@ -117,7 +117,9 @@ private object JsonLiteralSerializer : KSerializer<JsonLiteral> {
return encoder.encodeInline(value.coerceToInlineType).encodeString(value.content)
}
- value.longOrNull?.let { return encoder.encodeLong(it) }
+ // use .content instead of .longOrNull as latter can process exponential notation,
+ // and it should be delegated to double when encoding.
+ value.content.toLongOrNull()?.let { return encoder.encodeLong(it) }
// most unsigned values fit to .longOrNull, but not ULong
value.content.toULongOrNull()?.let {
@@ -125,8 +127,8 @@ private object JsonLiteralSerializer : KSerializer<JsonLiteral> {
return
}
- value.doubleOrNull?.let { return encoder.encodeDouble(it) }
- value.booleanOrNull?.let { return encoder.encodeBoolean(it) }
+ value.content.toDoubleOrNull()?.let { return encoder.encodeDouble(it) }
+ value.content.toBooleanStrictOrNull()?.let { return encoder.encodeBoolean(it) }
encoder.encodeString(value.content)
}
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/JsonNamingStrategy.kt b/formats/json/commonMain/src/kotlinx/serialization/json/JsonNamingStrategy.kt
index 060572af..64b4e0b7 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/JsonNamingStrategy.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/JsonNamingStrategy.kt
@@ -7,10 +7,11 @@ import kotlinx.serialization.descriptors.*
/**
* Represents naming strategy — a transformer for serial names in a [Json] format.
* Transformed serial names are used for both serialization and deserialization.
- * Actual transformation happens in the [serialNameForJson] function.
* A naming strategy is always applied globally in the Json configuration builder
* (see [JsonBuilder.namingStrategy]).
- * However, it is possible to apply additional filtering inside the transformer using the `descriptor` parameter in [serialNameForJson].
+ *
+ * Actual transformation happens in the [serialNameForJson] function.
+ * It is possible to apply additional filtering inside the transformer using the `descriptor` parameter in [serialNameForJson].
*
* Original serial names are never used after transformation, so they are ignored in a Json input.
* If the original serial name is present in the Json input but transformed is not,
@@ -21,7 +22,7 @@ import kotlinx.serialization.descriptors.*
*
* * Due to the nature of kotlinx.serialization framework, naming strategy transformation is applied to all properties regardless
* of whether their serial name was taken from the property name or provided by @[SerialName] annotation.
- * Effectively it means one cannot avoid transformation by explicitly specifying the serial name.
+ * Effectively, it means one cannot avoid transformation by explicitly specifying the serial name.
*
* * Collision of the transformed name with any other (transformed) properties serial names or any alternative names
* specified with [JsonNames] will lead to a deserialization exception.
@@ -40,7 +41,7 @@ import kotlinx.serialization.descriptors.*
* changing one without the other may introduce bugs in many unexpected ways.
* The lack of a single place of definition, the inability to use automated tools, and more error-prone code lead
* to greater maintenance efforts for code with global naming strategies.
- * However, there are cases where usage of naming strategies is inevitable, such as interop with existing API or migrating a large codebase.
+ * However, there are cases where usage of naming strategies is inevitable, such as interop with an existing API or migrating a large codebase.
* Therefore, one should carefully weigh the pros and cons before considering adding global naming strategies to an application.
*/
@ExperimentalSerializationApi
@@ -56,7 +57,7 @@ public fun interface JsonNamingStrategy {
* annotations (see [SerialDescriptor.getElementAnnotations]) or element optionality (see [SerialDescriptor.isElementOptional]).
*
* Note that invocations of this function are cached for performance reasons.
- * Caching strategy is an implementation detail and shouldn't be assumed as a part of the public API contract, as it may be changed in future releases.
+ * Caching strategy is an implementation detail and should not be assumed as a part of the public API contract, as it may be changed in future releases.
* Therefore, it is essential for this function to be pure: it should not have any side effects, and it should
* return the same String for a given [descriptor], [elementIndex], and [serialName], regardless of the number of invocations.
*/
@@ -74,7 +75,7 @@ public fun interface JsonNamingStrategy {
*
* **Transformation rules**
*
- * Words bounds are defined by uppercase characters. If there is a single uppercase char, it is transformed into lowercase one with underscore in front:
+ * Words' bounds are defined by uppercase characters. If there is a single uppercase char, it is transformed into lowercase one with underscore in front:
* `twoWords` -> `two_words`. No underscore is added if it was a beginning of the name: `MyProperty` -> `my_property`. Also, no underscore is added if it was already there:
* `camel_Case_Underscores` -> `camel_case_underscores`.
*
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonNamesMap.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonNamesMap.kt
index 762bacd9..8acd8fc4 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonNamesMap.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonNamesMap.kt
@@ -11,17 +11,16 @@ import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
import kotlin.native.concurrent.*
-@SharedImmutable
internal val JsonDeserializationNamesKey = DescriptorSchemaCache.Key<Map<String, Int>>()
-@SharedImmutable
internal val JsonSerializationNamesKey = DescriptorSchemaCache.Key<Array<String>>()
private fun SerialDescriptor.buildDeserializationNamesMap(json: Json): Map<String, Int> {
fun MutableMap<String, Int>.putOrThrow(name: String, index: Int) {
+ val entity = if (kind == SerialKind.ENUM) "enum value" else "property"
if (name in this) {
throw JsonException(
- "The suggested name '$name' for property ${getElementName(index)} is already one of the names for property " +
+ "The suggested name '$name' for $entity ${getElementName(index)} is already one of the names for $entity " +
"${getElementName(getValue(name))} in ${this@buildDeserializationNamesMap}"
)
}
@@ -30,12 +29,19 @@ private fun SerialDescriptor.buildDeserializationNamesMap(json: Json): Map<Strin
val builder: MutableMap<String, Int> =
mutableMapOf() // can be not concurrent because it is only read after creation and safely published to concurrent map
- val strategy = namingStrategy(json)
+ val useLowercaseEnums = json.decodeCaseInsensitive(this)
+ val strategyForClasses = namingStrategy(json)
for (i in 0 until elementsCount) {
getElementAnnotations(i).filterIsInstance<JsonNames>().singleOrNull()?.names?.forEach { name ->
- builder.putOrThrow(name, i)
+ builder.putOrThrow(if (useLowercaseEnums) name.lowercase() else name, i)
+ }
+ val nameToPut = when {
+ // the branches do not intersect because useLowercase = true for enums only, and strategy != null for classes only.
+ useLowercaseEnums -> getElementName(i).lowercase()
+ strategyForClasses != null -> strategyForClasses.serialNameForJson(this, i, getElementName(i))
+ else -> null
}
- strategy?.let { builder.putOrThrow(it.serialNameForJson(this, i, getElementName(i)), i) }
+ nameToPut?.let { builder.putOrThrow(it, i) }
}
return builder.ifEmpty { emptyMap() }
}
@@ -63,17 +69,24 @@ internal fun SerialDescriptor.getJsonElementName(json: Json, index: Int): String
internal fun SerialDescriptor.namingStrategy(json: Json) =
if (kind == StructureKind.CLASS) json.configuration.namingStrategy else null
+private fun SerialDescriptor.getJsonNameIndexSlowPath(json: Json, name: String): Int =
+ json.deserializationNamesMap(this)[name] ?: CompositeDecoder.UNKNOWN_NAME
+
+private fun Json.decodeCaseInsensitive(descriptor: SerialDescriptor) =
+ configuration.decodeEnumsCaseInsensitive && descriptor.kind == SerialKind.ENUM
+
/**
- * Serves same purpose as [SerialDescriptor.getElementIndex] but respects
- * [JsonNames] annotation and [JsonConfiguration.useAlternativeNames] state.
+ * Serves same purpose as [SerialDescriptor.getElementIndex] but respects [JsonNames] annotation
+ * and [JsonConfiguration] settings.
*/
@OptIn(ExperimentalSerializationApi::class)
internal fun SerialDescriptor.getJsonNameIndex(json: Json, name: String): Int {
- fun getJsonNameIndexSlowPath(): Int =
- json.deserializationNamesMap(this)[name] ?: CompositeDecoder.UNKNOWN_NAME
+ if (json.decodeCaseInsensitive(this)) {
+ return getJsonNameIndexSlowPath(json, name.lowercase())
+ }
val strategy = namingStrategy(json)
- if (strategy != null) return getJsonNameIndexSlowPath()
+ if (strategy != null) return getJsonNameIndexSlowPath(json, name)
val index = getElementIndex(name)
// Fast path, do not go through ConcurrentHashMap.get
// Note, it blocks ability to detect collisions between the primary name and alternate,
@@ -81,7 +94,7 @@ internal fun SerialDescriptor.getJsonNameIndex(json: Json, name: String): Int {
if (index != CompositeDecoder.UNKNOWN_NAME) return index
if (!json.configuration.useAlternativeNames) return index
// Slow path
- return getJsonNameIndexSlowPath()
+ return getJsonNameIndexSlowPath(json, name)
}
/**
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonDecoder.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonDecoder.kt
index 2d4517d9..6cedabce 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonDecoder.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonDecoder.kt
@@ -71,7 +71,7 @@ internal open class StreamingJsonDecoder(
}
val discriminator = deserializer.descriptor.classDiscriminator(json)
- val type = lexer.consumeLeadingMatchingValue(discriminator, configuration.isLenient)
+ val type = lexer.peekLeadingMatchingValue(discriminator, configuration.isLenient)
var actualSerializer: DeserializationStrategy<Any>? = null
if (type != null) {
actualSerializer = deserializer.findPolymorphicSerializerOrNull(this, type)
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt
index 10a464d0..c6f76cb3 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt
@@ -12,7 +12,6 @@ import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
import kotlin.native.concurrent.*
-@SharedImmutable
private val unsignedNumberDescriptors = setOf(
UInt.serializer().descriptor,
ULong.serializer().descriptor,
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StringOps.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StringOps.kt
index 21bb8af9..f488d903 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/StringOps.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/StringOps.kt
@@ -13,7 +13,6 @@ private fun toHexChar(i: Int) : Char {
}
@PublishedApi
-@SharedImmutable
internal val ESCAPE_STRINGS: Array<String?> = arrayOfNulls<String>(93).apply {
for (c in 0..0x1f) {
val c1 = toHexChar(c shr 12)
@@ -31,7 +30,6 @@ internal val ESCAPE_STRINGS: Array<String?> = arrayOfNulls<String>(93).apply {
this[0x0c] = "\\f"
}
-@SharedImmutable
internal val ESCAPE_MARKERS: ByteArray = ByteArray(93).apply {
for (c in 0..0x1f) {
this[c] = 1.toByte()
@@ -70,4 +68,4 @@ internal fun String.toBooleanStrictOrNull(): Boolean? = when {
this.equals("true", ignoreCase = true) -> true
this.equals("false", ignoreCase = true) -> false
else -> null
-}
+} \ No newline at end of file
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/TreeJsonDecoder.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/TreeJsonDecoder.kt
index 2ffe8648..365ad2ec 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/TreeJsonDecoder.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/TreeJsonDecoder.kt
@@ -44,7 +44,7 @@ private sealed class AbstractJsonTreeDecoder(
@JvmField
protected val configuration = json.configuration
- private fun currentObject() = currentTagOrNull?.let { currentElement(it) } ?: value
+ protected fun currentObject() = currentTagOrNull?.let { currentElement(it) } ?: value
override fun decodeJsonElement(): JsonElement = currentObject()
@@ -256,11 +256,14 @@ private open class JsonTreeDecoder(
override fun currentElement(tag: String): JsonElement = value.getValue(tag)
override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder {
- /*
- * For polymorphic serialization we'd like to avoid excessive decoder creating in
- * beginStructure to properly preserve 'polyDiscriminator' field and filter it out.
- */
- if (descriptor === polyDescriptor) return this
+ // polyDiscriminator needs to be preserved so the check for unknown keys
+ // in endStructure can filter polyDiscriminator out.
+ if (descriptor === polyDescriptor) {
+ return JsonTreeDecoder(
+ json, cast(currentObject(), polyDescriptor), polyDiscriminator, polyDescriptor
+ )
+ }
+
return super.beginStructure(descriptor)
}
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt
index 99afc4b3..3e2c6ad4 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt
@@ -8,6 +8,7 @@ import kotlinx.serialization.json.internal.CharMappings.CHAR_TO_TOKEN
import kotlinx.serialization.json.internal.CharMappings.ESCAPE_2_CHAR
import kotlin.js.*
import kotlin.jvm.*
+import kotlin.math.*
internal const val lenientHint = "Use 'isLenient = true' in 'Json {}` builder to accept non-compliant JSON."
internal const val coerceInputValuesHint = "Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values."
@@ -285,7 +286,7 @@ internal abstract class AbstractJsonLexer {
return current
}
- abstract fun consumeLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String?
+ abstract fun peekLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String?
fun peekString(isLenient: Boolean): String? {
val token = peekNextToken()
@@ -300,6 +301,10 @@ internal abstract class AbstractJsonLexer {
return string
}
+ fun discardPeeked() {
+ peekedString = null
+ }
+
open fun indexOf(char: Char, startPos: Int) = source.indexOf(char, startPos)
open fun substring(startPos: Int, endPos: Int) = source.substring(startPos, endPos)
@@ -601,11 +606,32 @@ internal abstract class AbstractJsonLexer {
false
}
var accumulator = 0L
+ var exponentAccumulator = 0L
var isNegative = false
+ var isExponentPositive = false
+ var hasExponent = false
val start = current
- var hasChars = true
- while (hasChars) {
+ while (current != source.length) {
val ch: Char = source[current]
+ if ((ch == 'e' || ch == 'E') && !hasExponent) {
+ if (current == start) fail("Unexpected symbol $ch in numeric literal")
+ isExponentPositive = true
+ hasExponent = true
+ ++current
+ continue
+ }
+ if (ch == '-' && hasExponent) {
+ if (current == start) fail("Unexpected symbol '-' in numeric literal")
+ isExponentPositive = false
+ ++current
+ continue
+ }
+ if (ch == '+' && hasExponent) {
+ if (current == start) fail("Unexpected symbol '+' in numeric literal")
+ isExponentPositive = true
+ ++current
+ continue
+ }
if (ch == '-') {
if (current != start) fail("Unexpected symbol '-' in numeric literal")
isNegative = true
@@ -615,12 +641,16 @@ internal abstract class AbstractJsonLexer {
val token = charToTokenClass(ch)
if (token != TC_OTHER) break
++current
- hasChars = current != source.length
val digit = ch - '0'
if (digit !in 0..9) fail("Unexpected symbol '$ch' in numeric literal")
+ if (hasExponent) {
+ exponentAccumulator = exponentAccumulator * 10 + digit
+ continue
+ }
accumulator = accumulator * 10 - digit
if (accumulator > 0) fail("Numeric value overflow")
}
+ val hasChars = current != start
if (start == current || (isNegative && start == current - 1)) {
fail("Expected numeric literal")
}
@@ -630,6 +660,19 @@ internal abstract class AbstractJsonLexer {
++current
}
currentPosition = current
+
+ fun calculateExponent(exponentAccumulator: Long, isExponentPositive: Boolean): Double = when (isExponentPositive) {
+ false -> 10.0.pow(-exponentAccumulator.toDouble())
+ true -> 10.0.pow(exponentAccumulator.toDouble())
+ }
+
+ if (hasExponent) {
+ val doubleAccumulator = accumulator.toDouble() * calculateExponent(exponentAccumulator, isExponentPositive)
+ if (doubleAccumulator > Long.MAX_VALUE || doubleAccumulator < Long.MIN_VALUE) fail("Numeric value overflow")
+ if (floor(doubleAccumulator) != doubleAccumulator) fail("Can't convert $doubleAccumulator to Long")
+ accumulator = doubleAccumulator.toLong()
+ }
+
return when {
isNegative -> accumulator
accumulator != Long.MIN_VALUE -> -accumulator
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/JsonLexer.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/JsonLexer.kt
index 2881fd79..85ef13ab 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/JsonLexer.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/JsonLexer.kt
@@ -179,7 +179,7 @@ internal class ReaderJsonLexer(
}
// Can be carefully implemented but postponed for now
- override fun consumeLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String? = null
+ override fun peekLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String? = null
fun release() {
CharArrayPoolBatchSize.release(buffer)
diff --git a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/StringJsonLexer.kt b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/StringJsonLexer.kt
index 24c9a67c..717932c7 100644
--- a/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/StringJsonLexer.kt
+++ b/formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/StringJsonLexer.kt
@@ -101,21 +101,20 @@ internal class StringJsonLexer(override val source: String) : AbstractJsonLexer(
(if (isLenient) consumeStringLenient() else consumeString()).chunked(BATCH_SIZE).forEach(consumeChunk)
}
- override fun consumeLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String? {
+ override fun peekLeadingMatchingValue(keyToMatch: String, isLenient: Boolean): String? {
val positionSnapshot = currentPosition
try {
- // Malformed JSON, bailout
- if (consumeNextToken() != TC_BEGIN_OBJ) return null
- val firstKey = if (isLenient) consumeKeyString() else consumeStringLenientNotNull()
- if (firstKey == keyToMatch) {
- if (consumeNextToken() != TC_COLON) return null
- val result = if (isLenient) consumeString() else consumeStringLenientNotNull()
- return result
- }
- return null
+ if (consumeNextToken() != TC_BEGIN_OBJ) return null // Malformed JSON, bailout
+ val firstKey = peekString(isLenient)
+ if (firstKey != keyToMatch) return null
+ discardPeeked() // consume firstKey
+ if (consumeNextToken() != TC_COLON) return null
+ return peekString(isLenient)
} finally {
// Restore the position
currentPosition = positionSnapshot
+ discardPeeked()
}
}
}
+
diff --git a/formats/json/jsMain/src/kotlinx/serialization/json/internal/FormatLanguageJs.kt b/formats/json/jsMain/src/kotlinx/serialization/json/internal/FormatLanguageJs.kt
index 6804859d..176771fd 100644
--- a/formats/json/jsMain/src/kotlinx/serialization/json/internal/FormatLanguageJs.kt
+++ b/formats/json/jsMain/src/kotlinx/serialization/json/internal/FormatLanguageJs.kt
@@ -7,4 +7,19 @@ package kotlinx.serialization.json.internal;
import kotlinx.serialization.InternalSerializationApi
@InternalSerializationApi
-public actual typealias FormatLanguage = org.intellij.lang.annotations.Language
+@Retention(AnnotationRetention.BINARY)
+@Target(
+ AnnotationTarget.FUNCTION,
+ AnnotationTarget.PROPERTY_GETTER,
+ AnnotationTarget.PROPERTY_SETTER,
+ AnnotationTarget.FIELD,
+ AnnotationTarget.VALUE_PARAMETER,
+ AnnotationTarget.LOCAL_VARIABLE,
+ AnnotationTarget.ANNOTATION_CLASS
+)
+public actual annotation class FormatLanguage(
+ public actual val value: String,
+ // default parameters are not used due to https://youtrack.jetbrains.com/issue/KT-25946/
+ public actual val prefix: String,
+ public actual val suffix: String,
+)
diff --git a/formats/json/jsMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt b/formats/json/jsMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt
deleted file mode 100644
index ab81e5be..00000000
--- a/formats/json/jsMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("PackageDirectoryMismatch")
-
-package org.intellij.lang.annotations
-
-import kotlinx.serialization.InternalSerializationApi
-
-/**
- * JS implementation of JVM-only `org.intellij.lang.annotations.Language` class, adds syntax support by IDE.
- *
- * This class is missing from the Kotlin/JS targets, so it needs to be distributed along with the serialization runtime.
- *
- * Copy-paste from [https://github.com/JetBrains/java-annotations](https://github.com/JetBrains/java-annotations).
- *
- * @see [kotlinx.serialization.json.internal.FormatLanguage]
- */
-@InternalSerializationApi
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.FUNCTION,
- AnnotationTarget.PROPERTY_GETTER,
- AnnotationTarget.PROPERTY_SETTER,
- AnnotationTarget.FIELD,
- AnnotationTarget.VALUE_PARAMETER,
- AnnotationTarget.LOCAL_VARIABLE,
- AnnotationTarget.ANNOTATION_CLASS,
-)
-public annotation class Language(
- val value: String,
- val prefix: String = "",
- val suffix: String = "",
-)
diff --git a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt
index 61fc7910..0f8a566c 100644
--- a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt
+++ b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt
@@ -20,20 +20,7 @@ internal class CharsetReader(
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
byteBuffer = ByteBuffer.wrap(ByteArrayPool8k.take())
- // An explicit cast is needed here due to an API change in Java 9, see #2218.
- //
- // In Java 8 and earlier, the `flip` method was final in `Buffer`, and returned a `Buffer`.
- // In Java 9 and later, the method was opened, and `ByteFuffer` overrides it, returning a `ByteBuffer`.
- //
- // You could observe this by decompiling this call with `javap`:
- // Compiled with Java 8 it produces `INVOKEVIRTUAL java/nio/ByteBuffer.flip ()Ljava/nio/Buffer;`
- // Compiled with Java 9+ it produces `INVOKEVIRTUAL java/nio/ByteBuffer.flip ()Ljava/nio/ByteBuffer;`
- //
- // This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8.
- //
- // To mitigate that, `--bootclasspath` / `--release` options were introduced in `javac`, but there are no
- // counterparts for these options in `kotlinc`, so an explicit cast is required.
- (byteBuffer as Buffer).flip() // Make empty
+ byteBuffer.flip() // Make empty
}
@Suppress("NAME_SHADOWING")
@@ -103,9 +90,10 @@ internal class CharsetReader(
val remaining = if (position <= limit) limit - position else 0
val bytesRead = inputStream.read(byteBuffer.array(), byteBuffer.arrayOffset() + position, remaining)
if (bytesRead < 0) return bytesRead
- byteBuffer.position(position + bytesRead)
+ // Method `position(I)LByteBuffer` does not exist in Java 8. For details, see comment for `flip` in `init` method
+ (byteBuffer as Buffer).position(position + bytesRead)
} finally {
- (byteBuffer as Buffer).flip() // see the `init` block in this class for the reasoning behind the cast
+ byteBuffer.flip()
}
return byteBuffer.remaining()
}
diff --git a/formats/json/nativeMain/src/kotlinx/serialization/json/JsonSchemaCache.kt b/formats/json/nativeMain/src/kotlinx/serialization/json/JsonSchemaCache.kt
index 520a3b6d..49619979 100644
--- a/formats/json/nativeMain/src/kotlinx/serialization/json/JsonSchemaCache.kt
+++ b/formats/json/nativeMain/src/kotlinx/serialization/json/JsonSchemaCache.kt
@@ -5,6 +5,7 @@
package kotlinx.serialization.json
import kotlinx.serialization.json.internal.*
+import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.ref.*
import kotlin.random.*
import kotlin.native.concurrent.*
@@ -26,6 +27,7 @@ private val jsonToCache: MutableMap<WeakJson, DescriptorSchemaCache> = mutableMa
/**
* Because WeakReference itself does not have proper equals/hashCode
*/
+@OptIn(ExperimentalNativeApi::class)
private class WeakJson(json: Json) {
private val ref = WeakReference(json)
private val initialHashCode = json.hashCode()
diff --git a/formats/json/nativeMain/src/kotlinx/serialization/json/internal/FormatLanguage.kt b/formats/json/nativeMain/src/kotlinx/serialization/json/internal/FormatLanguage.kt
index 9eedf1b8..4f2fff0c 100644
--- a/formats/json/nativeMain/src/kotlinx/serialization/json/internal/FormatLanguage.kt
+++ b/formats/json/nativeMain/src/kotlinx/serialization/json/internal/FormatLanguage.kt
@@ -7,4 +7,19 @@ package kotlinx.serialization.json.internal;
import kotlinx.serialization.InternalSerializationApi
@InternalSerializationApi
-public actual typealias FormatLanguage = org.intellij.lang.annotations.Language \ No newline at end of file
+@Retention(AnnotationRetention.BINARY)
+@Target(
+ AnnotationTarget.FUNCTION,
+ AnnotationTarget.PROPERTY_GETTER,
+ AnnotationTarget.PROPERTY_SETTER,
+ AnnotationTarget.FIELD,
+ AnnotationTarget.VALUE_PARAMETER,
+ AnnotationTarget.LOCAL_VARIABLE,
+ AnnotationTarget.ANNOTATION_CLASS
+)
+public actual annotation class FormatLanguage(
+ public actual val value: String,
+ // default parameters are not used due to https://youtrack.jetbrains.com/issue/KT-25946/
+ public actual val prefix: String,
+ public actual val suffix: String,
+) \ No newline at end of file
diff --git a/formats/json/nativeMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt b/formats/json/nativeMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt
deleted file mode 100644
index 8bf11d37..00000000
--- a/formats/json/nativeMain/src/kotlinx/serialization/json/internal/IntelliJAnnotation.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("PackageDirectoryMismatch")
-
-package org.intellij.lang.annotations
-
-import kotlinx.serialization.InternalSerializationApi
-
-/**
- * Native implementation of JVM-only `org.intellij.lang.annotations.Language` class, adds syntax support by IDE.
- *
- * This class is missing from the Kotlin/Native targets, so it needs to be distributed along with the serialization runtime.
- *
- * Copy-paste from [https://github.com/JetBrains/java-annotations](https://github.com/JetBrains/java-annotations).
- *
- * @see [kotlinx.serialization.json.internal.FormatLanguage]
- */
-@InternalSerializationApi
-@Retention(AnnotationRetention.BINARY)
-@Target(
- AnnotationTarget.FUNCTION,
- AnnotationTarget.PROPERTY_GETTER,
- AnnotationTarget.PROPERTY_SETTER,
- AnnotationTarget.FIELD,
- AnnotationTarget.VALUE_PARAMETER,
- AnnotationTarget.LOCAL_VARIABLE,
- AnnotationTarget.ANNOTATION_CLASS,
-)
-public annotation class Language(
- val value: String,
- val prefix: String = "",
- val suffix: String = "",
-) \ No newline at end of file
diff --git a/formats/protobuf/api/kotlinx-serialization-protobuf.api b/formats/protobuf/api/kotlinx-serialization-protobuf.api
index 4a369a0f..c0d61b9f 100644
--- a/formats/protobuf/api/kotlinx-serialization-protobuf.api
+++ b/formats/protobuf/api/kotlinx-serialization-protobuf.api
@@ -25,6 +25,7 @@ public final class kotlinx/serialization/protobuf/ProtoIntegerType : java/lang/E
public static final field DEFAULT Lkotlinx/serialization/protobuf/ProtoIntegerType;
public static final field FIXED Lkotlinx/serialization/protobuf/ProtoIntegerType;
public static final field SIGNED Lkotlinx/serialization/protobuf/ProtoIntegerType;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lkotlinx/serialization/protobuf/ProtoIntegerType;
public static fun values ()[Lkotlinx/serialization/protobuf/ProtoIntegerType;
}
diff --git a/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/SuppressAnimalSniffer.kt b/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/SuppressAnimalSniffer.kt
new file mode 100644
index 00000000..35607ec9
--- /dev/null
+++ b/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/SuppressAnimalSniffer.kt
@@ -0,0 +1,14 @@
+/*
+ * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.protobuf.internal
+
+/**
+ * Suppresses Animal Sniffer plugin errors for certain methods.
+ * Such methods include references to Java 8 methods that are not
+ * available in Android API, but can be desugared by R8.
+ */
+@Retention(AnnotationRetention.BINARY)
+@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
+internal annotation class SuppressAnimalSniffer \ No newline at end of file
diff --git a/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt b/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt
index 8f326939..b22df626 100644
--- a/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt
+++ b/formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt
@@ -433,6 +433,7 @@ public object ProtoBufSchemaGenerator {
}
}
+ @SuppressAnimalSniffer // Boolean.hashCode(boolean) in compiler-generated hashCode implementation
private data class TypeDefinition(
val descriptor: SerialDescriptor,
val isSynthetic: Boolean = false,
diff --git a/formats/protobuf/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt b/formats/protobuf/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
index 7ef97293..eb6ebe7e 100644
--- a/formats/protobuf/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
+++ b/formats/protobuf/commonTest/src/kotlinx/serialization/PolymorphismTestData.kt
@@ -46,7 +46,6 @@ data class SimpleStringInheritor(val s: String, val i: Int) : SimpleAbstract()
@Serializable
data class PolyBox(@Polymorphic val boxed: SimpleAbstract)
-@SharedImmutable
val SimplePolymorphicModule = SerializersModule {
polymorphic(SimpleAbstract::class) {
subclass(SimpleIntInheritor.serializer())
diff --git a/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNothingTest.kt b/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNothingTest.kt
new file mode 100644
index 00000000..e90ff2be
--- /dev/null
+++ b/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNothingTest.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.protobuf
+
+import kotlinx.serialization.*
+import kotlinx.serialization.test.*
+import kotlin.test.*
+
+class ProtobufNothingTest {
+ @Serializable
+ /*private*/ data class NullableNothingBox(val value: Nothing?) // `private` doesn't work on the JS legacy target
+
+ @Serializable
+ private data class ParameterizedBox<T : Any>(val value: T?)
+
+ private inline fun <reified T> testConversion(data: T, expectedHexString: String) {
+ val string = ProtoBuf.encodeToHexString(data).uppercase()
+ assertEquals(expectedHexString, string)
+ assertEquals(data, ProtoBuf.decodeFromHexString(string))
+ }
+
+ @Test
+ fun testNothing() {
+ testConversion(NullableNothingBox(null), "")
+ testConversion(ParameterizedBox(null), "")
+ }
+}
diff --git a/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNullAndDefaultTest.kt b/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNullAndDefaultTest.kt
index 88450aad..da7521ce 100644
--- a/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNullAndDefaultTest.kt
+++ b/formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufNullAndDefaultTest.kt
@@ -5,7 +5,6 @@
package kotlinx.serialization.protobuf
import kotlinx.serialization.*
-import kotlinx.serialization.test.isJsLegacy
import kotlin.test.*
class ProtobufNullAndDefaultTest {
@@ -22,7 +21,6 @@ class ProtobufNullAndDefaultTest {
fun testProtobufDropDefaults() {
val proto = ProtoBuf { encodeDefaults = false }
assertEquals(0, proto.encodeToByteArray(ProtoWithNullDefault()).size)
- if (isJsLegacy()) return // because of @EncodeDefault
assertFailsWith<SerializationException> { proto.encodeToByteArray(ProtoWithNullDefaultAlways()) }
assertEquals(0, proto.encodeToByteArray(ProtoWithNullDefaultNever()).size)
}
@@ -31,7 +29,6 @@ class ProtobufNullAndDefaultTest {
fun testProtobufEncodeDefaults() {
val proto = ProtoBuf { encodeDefaults = true }
assertFailsWith<SerializationException> { proto.encodeToByteArray(ProtoWithNullDefault()) }
- if (isJsLegacy()) return // because of @EncodeDefault
assertFailsWith<SerializationException> { proto.encodeToByteArray(ProtoWithNullDefaultAlways()) }
assertEquals(0, proto.encodeToByteArray(ProtoWithNullDefaultNever()).size)
}
diff --git a/formats/protobuf/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt b/formats/protobuf/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
index c4a6b986..2652d5c7 100644
--- a/formats/protobuf/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
+++ b/formats/protobuf/commonTest/src/kotlinx/serialization/test/CurrentPlatform.common.kt
@@ -5,12 +5,12 @@
package kotlinx.serialization.test
enum class Platform {
- JVM, JS_LEGACY, JS_IR, NATIVE
+ JVM, JS, NATIVE
}
public expect val currentPlatform: Platform
-public fun isJs(): Boolean = currentPlatform == Platform.JS_LEGACY || currentPlatform == Platform.JS_IR
-public fun isJsLegacy(): Boolean = currentPlatform == Platform.JS_LEGACY
+public fun isJs(): Boolean = currentPlatform == Platform.JS
+
public fun isJvm(): Boolean = currentPlatform == Platform.JVM
public fun isNative(): Boolean = currentPlatform == Platform.NATIVE
diff --git a/formats/protobuf/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/formats/protobuf/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index abbac9d0..0cde6998 100644
--- a/formats/protobuf/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/formats/protobuf/jsTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -4,9 +4,4 @@
package kotlinx.serialization.test
-public actual val currentPlatform: Platform = if (isLegacyBackend()) Platform.JS_LEGACY else Platform.JS_IR
-
-// from https://github.com/JetBrains/kotlin/blob/569187a7516e2e5ab217158a3170d4beb0c5cb5a/js/js.translator/testData/_commonFiles/testUtils.kt#L3
-private fun isLegacyBackend(): Boolean =
- // Using eval to prevent DCE from thinking that following code depends on Kotlin module.
- eval("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")").unsafeCast<Boolean>()
+public actual val currentPlatform: Platform = Platform.JS
diff --git a/formats/protobuf/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt b/formats/protobuf/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
index 36221960..badc7b03 100644
--- a/formats/protobuf/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
+++ b/formats/protobuf/nativeTest/src/kotlinx/serialization/test/CurrentPlatform.kt
@@ -5,8 +5,4 @@
package kotlinx.serialization.test
-import kotlin.native.concurrent.SharedImmutable
-
-
-@SharedImmutable
public actual val currentPlatform: Platform = Platform.NATIVE
diff --git a/gradle.properties b/gradle.properties
index 00388236..8ee9a182 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,9 +3,9 @@
#
group=org.jetbrains.kotlinx
-version=1.5.2-SNAPSHOT
+version=1.6.0-SNAPSHOT
-kotlin.version=1.8.21
+kotlin.version=1.9.0
# This version takes precedence if 'bootstrap' property passed to project
kotlin.version.snapshot=1.9.255-SNAPSHOT
@@ -15,7 +15,7 @@ junit_version=4.12
jackson_version=2.10.0.pr1
dokka_version=1.8.10
native.deploy=
-validator_version=0.11.0
+validator_version=0.13.2
knit_version=0.4.0
# Only for tests
coroutines_version=1.6.4
@@ -24,12 +24,6 @@ okio_version=3.1.0
kover.enabled=true
-kotlin.mpp.enableCompatibilityMetadataVariant=true
-kotlin.mpp.stability.nowarn=true
-
-kotlin.js.compiler=both
-kotlin.incremental.multiplatform=true
-
org.gradle.parallel=true
org.gradle.caching=true
diff --git a/gradle/configure-source-sets.gradle b/gradle/configure-source-sets.gradle
index 6356668f..56a2239e 100644
--- a/gradle/configure-source-sets.gradle
+++ b/gradle/configure-source-sets.gradle
@@ -2,12 +2,23 @@
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+}
+
+tasks.withType(JavaCompile).configureEach {
+ options.release = 8
+}
+
kotlin {
jvm {
withJava()
- configure([compilations.main, compilations.test]) {
+ compilations.configureEach {
kotlinOptions {
jvmTarget = '1.8'
+ freeCompilerArgs += '-Xjdk-release=1.8'
}
}
}
@@ -95,6 +106,14 @@ kotlin {
}
targets.all {
+ compilations.all {
+ kotlinOptions {
+ if (rootProject.ext.kotlin_lv_override != null) {
+ languageVersion = rootProject.ext.kotlin_lv_override
+ freeCompilerArgs += "-Xsuppress-version-warnings"
+ }
+ }
+ }
compilations.main {
kotlinOptions {
allWarningsAsErrors = true
@@ -102,6 +121,7 @@ kotlin {
}
}
+ // TODO: Remove deprecated linuxArm32Hfp and mingwX86 targets in 1.9.20.
def targetsWithoutTestRunners = ["linuxArm32Hfp", "linuxArm64", "mingwX86"]
configure(targets) {
// Configure additional binaries to run tests in the background
diff --git a/gradle/native-targets.gradle b/gradle/native-targets.gradle
index da954faa..880b4b64 100644
--- a/gradle/native-targets.gradle
+++ b/gradle/native-targets.gradle
@@ -96,6 +96,13 @@ kotlin {
targets {
if (project.ext.nativeState == NativeState.DISABLED) return
+
+ String[] versionComponents = (~/[.-]/).split(compilerVersion, 4)
+ String[] versionComponents1920 = ["1", "9", "20"]
+ def isAtLeast1920 = Arrays.compare(versionComponents, versionComponents1920) { lhs, rhs ->
+ (lhs as int) <=> (rhs as int)
+ } >= 0
+
if (project.ext.singleTargetMode) {
fromPreset(project.ext.ideaPreset, 'native')
} else {
@@ -131,20 +138,22 @@ kotlin {
addTarget(presets.mingwX64)
- // Deprecated, but were provided by kotlinx.serialization; can be removed only when K/N drops the target
- addTarget(presets.watchosX86)
+ // Deprecated, but were provided by kotlinx.serialization; can be removed only in 1.9.20 release.
+ if (!isAtLeast1920) {
+ addTarget(presets.watchosX86)
- if (doesNotDependOnOkio(project)) {
- addTarget(presets.iosArm32)
- addTarget(presets.linuxArm32Hfp)
- addTarget(presets.mingwX86)
+ if (doesNotDependOnOkio(project)) {
+ addTarget(presets.iosArm32)
+ addTarget(presets.linuxArm32Hfp)
+ addTarget(presets.mingwX86)
+ }
}
}
if (project.ext.nativeState == NativeState.HOST) {
// linux targets that can cross-compile on all three hosts
- def linuxCrossCompileTargets = [linuxX64, linuxArm32Hfp, linuxArm64]
+ def linuxCrossCompileTargets = isAtLeast1920 ? [presets.linuxX64] : [presets.linuxX64, presets.linuxArm32Hfp, presets.linuxArm64]
if (getHostName() != "linux") {
disableCompilation(linuxCrossCompileTargets)
}
diff --git a/guide/build.gradle b/guide/build.gradle
index f61a4e6c..b4261e81 100644
--- a/guide/build.gradle
+++ b/guide/build.gradle
@@ -1,3 +1,5 @@
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@@ -9,6 +11,15 @@ kotlin {
jvmToolchain(8)
}
+tasks.withType(KotlinCompile).configureEach {
+ kotlinOptions {
+ if (rootProject.ext.kotlin_lv_override != null) {
+ languageVersion = rootProject.ext.kotlin_lv_override
+ freeCompilerArgs += "-Xsuppress-version-warnings"
+ }
+ }
+}
+
dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
testImplementation "org.jetbrains.kotlinx:kotlinx-knit-test:$knit_version"
diff --git a/guide/example/example-json-12.kt b/guide/example/example-json-12.kt
index 5a2cbbe4..1a37516b 100644
--- a/guide/example/example-json-12.kt
+++ b/guide/example/example-json-12.kt
@@ -4,12 +4,13 @@ package example.exampleJson12
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-@Serializable
-data class Project(val projectName: String, val projectOwner: String)
+val format = Json { decodeEnumsCaseInsensitive = true }
+
+enum class Cases { VALUE_A, @JsonNames("Alternative") VALUE_B }
-val format = Json { namingStrategy = JsonNamingStrategy.SnakeCase }
+@Serializable
+data class CasesList(val cases: List<Cases>)
fun main() {
- val project = format.decodeFromString<Project>("""{"project_name":"kotlinx.coroutines", "project_owner":"Kotlin"}""")
- println(format.encodeToString(project.copy(projectName = "kotlinx.serialization")))
+ println(format.decodeFromString<CasesList>("""{"cases":["value_A", "alternative"]}"""))
}
diff --git a/guide/example/example-json-13.kt b/guide/example/example-json-13.kt
index 86a57c82..cd7cf7f2 100644
--- a/guide/example/example-json-13.kt
+++ b/guide/example/example-json-13.kt
@@ -4,9 +4,12 @@ package example.exampleJson13
import kotlinx.serialization.*
import kotlinx.serialization.json.*
+@Serializable
+data class Project(val projectName: String, val projectOwner: String)
+
+val format = Json { namingStrategy = JsonNamingStrategy.SnakeCase }
+
fun main() {
- val element = Json.parseToJsonElement("""
- {"name":"kotlinx.serialization","language":"Kotlin"}
- """)
- println(element)
+ val project = format.decodeFromString<Project>("""{"project_name":"kotlinx.coroutines", "project_owner":"Kotlin"}""")
+ println(format.encodeToString(project.copy(projectName = "kotlinx.serialization")))
}
diff --git a/guide/example/example-json-14.kt b/guide/example/example-json-14.kt
index 8025e58b..98464dcd 100644
--- a/guide/example/example-json-14.kt
+++ b/guide/example/example-json-14.kt
@@ -6,13 +6,7 @@ import kotlinx.serialization.json.*
fun main() {
val element = Json.parseToJsonElement("""
- {
- "name": "kotlinx.serialization",
- "forks": [{"votes": 42}, {"votes": 9000}, {}]
- }
+ {"name":"kotlinx.serialization","language":"Kotlin"}
""")
- val sum = element
- .jsonObject["forks"]!!
- .jsonArray.sumOf { it.jsonObject["votes"]?.jsonPrimitive?.int ?: 0 }
- println(sum)
+ println(element)
}
diff --git a/guide/example/example-json-15.kt b/guide/example/example-json-15.kt
index 2f2b33a4..72fd23eb 100644
--- a/guide/example/example-json-15.kt
+++ b/guide/example/example-json-15.kt
@@ -5,19 +5,14 @@ import kotlinx.serialization.*
import kotlinx.serialization.json.*
fun main() {
- val element = buildJsonObject {
- put("name", "kotlinx.serialization")
- putJsonObject("owner") {
- put("name", "kotlin")
+ val element = Json.parseToJsonElement("""
+ {
+ "name": "kotlinx.serialization",
+ "forks": [{"votes": 42}, {"votes": 9000}, {}]
}
- putJsonArray("forks") {
- addJsonObject {
- put("votes", 42)
- }
- addJsonObject {
- put("votes", 9000)
- }
- }
- }
- println(element)
+ """)
+ val sum = element
+ .jsonObject["forks"]!!
+ .jsonArray.sumOf { it.jsonObject["votes"]?.jsonPrimitive?.int ?: 0 }
+ println(sum)
}
diff --git a/guide/example/example-json-16.kt b/guide/example/example-json-16.kt
index d502c864..cff8ec7d 100644
--- a/guide/example/example-json-16.kt
+++ b/guide/example/example-json-16.kt
@@ -4,14 +4,20 @@ package example.exampleJson16
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-@Serializable
-data class Project(val name: String, val language: String)
-
fun main() {
val element = buildJsonObject {
put("name", "kotlinx.serialization")
- put("language", "Kotlin")
+ putJsonObject("owner") {
+ put("name", "kotlin")
+ }
+ putJsonArray("forks") {
+ addJsonObject {
+ put("votes", 42)
+ }
+ addJsonObject {
+ put("votes", 9000)
+ }
+ }
}
- val data = Json.decodeFromJsonElement<Project>(element)
- println(data)
+ println(element)
}
diff --git a/guide/example/example-json-17.kt b/guide/example/example-json-17.kt
index b51b48c5..25be7584 100644
--- a/guide/example/example-json-17.kt
+++ b/guide/example/example-json-17.kt
@@ -4,20 +4,14 @@ package example.exampleJson17
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-import java.math.BigDecimal
-
-val format = Json { prettyPrint = true }
+@Serializable
+data class Project(val name: String, val language: String)
fun main() {
- val pi = BigDecimal("3.141592653589793238462643383279")
-
- val piJsonDouble = JsonPrimitive(pi.toDouble())
- val piJsonString = JsonPrimitive(pi.toString())
-
- val piObject = buildJsonObject {
- put("pi_double", piJsonDouble)
- put("pi_string", piJsonString)
+ val element = buildJsonObject {
+ put("name", "kotlinx.serialization")
+ put("language", "Kotlin")
}
-
- println(format.encodeToString(piObject))
+ val data = Json.decodeFromJsonElement<Project>(element)
+ println(data)
}
diff --git a/guide/example/example-json-18.kt b/guide/example/example-json-18.kt
index fbbbffe3..2a1add45 100644
--- a/guide/example/example-json-18.kt
+++ b/guide/example/example-json-18.kt
@@ -10,15 +10,11 @@ val format = Json { prettyPrint = true }
fun main() {
val pi = BigDecimal("3.141592653589793238462643383279")
-
- // use JsonUnquotedLiteral to encode raw JSON content
- val piJsonLiteral = JsonUnquotedLiteral(pi.toString())
-
+
val piJsonDouble = JsonPrimitive(pi.toDouble())
val piJsonString = JsonPrimitive(pi.toString())
val piObject = buildJsonObject {
- put("pi_literal", piJsonLiteral)
put("pi_double", piJsonDouble)
put("pi_string", piJsonString)
}
diff --git a/guide/example/example-json-19.kt b/guide/example/example-json-19.kt
index 2ed79cb2..d59bf26b 100644
--- a/guide/example/example-json-19.kt
+++ b/guide/example/example-json-19.kt
@@ -6,18 +6,22 @@ import kotlinx.serialization.json.*
import java.math.BigDecimal
+val format = Json { prettyPrint = true }
+
fun main() {
- val piObjectJson = """
- {
- "pi_literal": 3.141592653589793238462643383279
- }
- """.trimIndent()
-
- val piObject: JsonObject = Json.decodeFromString(piObjectJson)
-
- val piJsonLiteral = piObject["pi_literal"]!!.jsonPrimitive.content
-
- val pi = BigDecimal(piJsonLiteral)
-
- println(pi)
+ val pi = BigDecimal("3.141592653589793238462643383279")
+
+ // use JsonUnquotedLiteral to encode raw JSON content
+ val piJsonLiteral = JsonUnquotedLiteral(pi.toString())
+
+ val piJsonDouble = JsonPrimitive(pi.toDouble())
+ val piJsonString = JsonPrimitive(pi.toString())
+
+ val piObject = buildJsonObject {
+ put("pi_literal", piJsonLiteral)
+ put("pi_double", piJsonDouble)
+ put("pi_string", piJsonString)
+ }
+
+ println(format.encodeToString(piObject))
}
diff --git a/guide/example/example-json-20.kt b/guide/example/example-json-20.kt
index 638ccde9..2f481daa 100644
--- a/guide/example/example-json-20.kt
+++ b/guide/example/example-json-20.kt
@@ -4,7 +4,20 @@ package example.exampleJson20
import kotlinx.serialization.*
import kotlinx.serialization.json.*
+import java.math.BigDecimal
+
fun main() {
- // caution: creating null with JsonUnquotedLiteral will cause an exception!
- JsonUnquotedLiteral("null")
+ val piObjectJson = """
+ {
+ "pi_literal": 3.141592653589793238462643383279
+ }
+ """.trimIndent()
+
+ val piObject: JsonObject = Json.decodeFromString(piObjectJson)
+
+ val piJsonLiteral = piObject["pi_literal"]!!.jsonPrimitive.content
+
+ val pi = BigDecimal(piJsonLiteral)
+
+ println(pi)
}
diff --git a/guide/example/example-json-21.kt b/guide/example/example-json-21.kt
index 3f1b2477..86a4b734 100644
--- a/guide/example/example-json-21.kt
+++ b/guide/example/example-json-21.kt
@@ -4,29 +4,7 @@ package example.exampleJson21
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-import kotlinx.serialization.builtins.*
-
-@Serializable
-data class Project(
- val name: String,
- @Serializable(with = UserListSerializer::class)
- val users: List<User>
-)
-
-@Serializable
-data class User(val name: String)
-
-object UserListSerializer : JsonTransformingSerializer<List<User>>(ListSerializer(User.serializer())) {
- // If response is not an array, then it is a single object that should be wrapped into the array
- override fun transformDeserialize(element: JsonElement): JsonElement =
- if (element !is JsonArray) JsonArray(listOf(element)) else element
-}
-
fun main() {
- println(Json.decodeFromString<Project>("""
- {"name":"kotlinx.serialization","users":{"name":"kotlin"}}
- """))
- println(Json.decodeFromString<Project>("""
- {"name":"kotlinx.serialization","users":[{"name":"kotlin"},{"name":"jetbrains"}]}
- """))
+ // caution: creating null with JsonUnquotedLiteral will cause an exception!
+ JsonUnquotedLiteral("null")
}
diff --git a/guide/example/example-json-22.kt b/guide/example/example-json-22.kt
index 58b7b261..84bd0d8a 100644
--- a/guide/example/example-json-22.kt
+++ b/guide/example/example-json-22.kt
@@ -17,14 +17,16 @@ data class Project(
data class User(val name: String)
object UserListSerializer : JsonTransformingSerializer<List<User>>(ListSerializer(User.serializer())) {
-
- override fun transformSerialize(element: JsonElement): JsonElement {
- require(element is JsonArray) // this serializer is used only with lists
- return element.singleOrNull() ?: element
- }
+ // If response is not an array, then it is a single object that should be wrapped into the array
+ override fun transformDeserialize(element: JsonElement): JsonElement =
+ if (element !is JsonArray) JsonArray(listOf(element)) else element
}
fun main() {
- val data = Project("kotlinx.serialization", listOf(User("kotlin")))
- println(Json.encodeToString(data))
+ println(Json.decodeFromString<Project>("""
+ {"name":"kotlinx.serialization","users":{"name":"kotlin"}}
+ """))
+ println(Json.decodeFromString<Project>("""
+ {"name":"kotlinx.serialization","users":[{"name":"kotlin"},{"name":"jetbrains"}]}
+ """))
}
diff --git a/guide/example/example-json-23.kt b/guide/example/example-json-23.kt
index 3b553e25..bb23f527 100644
--- a/guide/example/example-json-23.kt
+++ b/guide/example/example-json-23.kt
@@ -4,19 +4,27 @@ package example.exampleJson23
import kotlinx.serialization.*
import kotlinx.serialization.json.*
+import kotlinx.serialization.builtins.*
+
+@Serializable
+data class Project(
+ val name: String,
+ @Serializable(with = UserListSerializer::class)
+ val users: List<User>
+)
+
@Serializable
-class Project(val name: String, val language: String)
+data class User(val name: String)
+
+object UserListSerializer : JsonTransformingSerializer<List<User>>(ListSerializer(User.serializer())) {
-object ProjectSerializer : JsonTransformingSerializer<Project>(Project.serializer()) {
- override fun transformSerialize(element: JsonElement): JsonElement =
- // Filter out top-level key value pair with the key "language" and the value "Kotlin"
- JsonObject(element.jsonObject.filterNot {
- (k, v) -> k == "language" && v.jsonPrimitive.content == "Kotlin"
- })
+ override fun transformSerialize(element: JsonElement): JsonElement {
+ require(element is JsonArray) // this serializer is used only with lists
+ return element.singleOrNull() ?: element
+ }
}
fun main() {
- val data = Project("kotlinx.serialization", "Kotlin")
- println(Json.encodeToString(data)) // using plugin-generated serializer
- println(Json.encodeToString(ProjectSerializer, data)) // using custom serializer
+ val data = Project("kotlinx.serialization", listOf(User("kotlin")))
+ println(Json.encodeToString(data))
}
diff --git a/guide/example/example-json-24.kt b/guide/example/example-json-24.kt
index 19fbbea6..def90f20 100644
--- a/guide/example/example-json-24.kt
+++ b/guide/example/example-json-24.kt
@@ -4,33 +4,19 @@ package example.exampleJson24
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-import kotlinx.serialization.builtins.*
-
-@Serializable
-abstract class Project {
- abstract val name: String
-}
-
@Serializable
-data class BasicProject(override val name: String): Project()
-
-
-@Serializable
-data class OwnedProject(override val name: String, val owner: String) : Project()
-
-object ProjectSerializer : JsonContentPolymorphicSerializer<Project>(Project::class) {
- override fun selectDeserializer(element: JsonElement) = when {
- "owner" in element.jsonObject -> OwnedProject.serializer()
- else -> BasicProject.serializer()
- }
+class Project(val name: String, val language: String)
+
+object ProjectSerializer : JsonTransformingSerializer<Project>(Project.serializer()) {
+ override fun transformSerialize(element: JsonElement): JsonElement =
+ // Filter out top-level key value pair with the key "language" and the value "Kotlin"
+ JsonObject(element.jsonObject.filterNot {
+ (k, v) -> k == "language" && v.jsonPrimitive.content == "Kotlin"
+ })
}
fun main() {
- val data = listOf(
- OwnedProject("kotlinx.serialization", "kotlin"),
- BasicProject("example")
- )
- val string = Json.encodeToString(ListSerializer(ProjectSerializer), data)
- println(string)
- println(Json.decodeFromString(ListSerializer(ProjectSerializer), string))
+ val data = Project("kotlinx.serialization", "Kotlin")
+ println(Json.encodeToString(data)) // using plugin-generated serializer
+ println(Json.encodeToString(ProjectSerializer, data)) // using custom serializer
}
diff --git a/guide/example/example-json-25.kt b/guide/example/example-json-25.kt
index 94c9deee..6f6d67a0 100644
--- a/guide/example/example-json-25.kt
+++ b/guide/example/example-json-25.kt
@@ -4,56 +4,33 @@ package example.exampleJson25
import kotlinx.serialization.*
import kotlinx.serialization.json.*
-import kotlinx.serialization.descriptors.*
-import kotlinx.serialization.encoding.*
+import kotlinx.serialization.builtins.*
-@Serializable(with = ResponseSerializer::class)
-sealed class Response<out T> {
- data class Ok<out T>(val data: T) : Response<T>()
- data class Error(val message: String) : Response<Nothing>()
+@Serializable
+abstract class Project {
+ abstract val name: String
}
-class ResponseSerializer<T>(private val dataSerializer: KSerializer<T>) : KSerializer<Response<T>> {
- override val descriptor: SerialDescriptor = buildSerialDescriptor("Response", PolymorphicKind.SEALED) {
- element("Ok", buildClassSerialDescriptor("Ok") {
- element<String>("message")
- })
- element("Error", dataSerializer.descriptor)
- }
+@Serializable
+data class BasicProject(override val name: String): Project()
- override fun deserialize(decoder: Decoder): Response<T> {
- // Decoder -> JsonDecoder
- require(decoder is JsonDecoder) // this class can be decoded only by Json
- // JsonDecoder -> JsonElement
- val element = decoder.decodeJsonElement()
- // JsonElement -> value
- if (element is JsonObject && "error" in element)
- return Response.Error(element["error"]!!.jsonPrimitive.content)
- return Response.Ok(decoder.json.decodeFromJsonElement(dataSerializer, element))
- }
- override fun serialize(encoder: Encoder, value: Response<T>) {
- // Encoder -> JsonEncoder
- require(encoder is JsonEncoder) // This class can be encoded only by Json
- // value -> JsonElement
- val element = when (value) {
- is Response.Ok -> encoder.json.encodeToJsonElement(dataSerializer, value.data)
- is Response.Error -> buildJsonObject { put("error", value.message) }
- }
- // JsonElement -> JsonEncoder
- encoder.encodeJsonElement(element)
+@Serializable
+data class OwnedProject(override val name: String, val owner: String) : Project()
+
+object ProjectSerializer : JsonContentPolymorphicSerializer<Project>(Project::class) {
+ override fun selectDeserializer(element: JsonElement) = when {
+ "owner" in element.jsonObject -> OwnedProject.serializer()
+ else -> BasicProject.serializer()
}
}
-@Serializable
-data class Project(val name: String)
-
fun main() {
- val responses = listOf(
- Response.Ok(Project("kotlinx.serialization")),
- Response.Error("Not found")
+ val data = listOf(
+ OwnedProject("kotlinx.serialization", "kotlin"),
+ BasicProject("example")
)
- val string = Json.encodeToString(responses)
+ val string = Json.encodeToString(ListSerializer(ProjectSerializer), data)
println(string)
- println(Json.decodeFromString<List<Response<Project>>>(string))
+ println(Json.decodeFromString(ListSerializer(ProjectSerializer), string))
}
diff --git a/guide/example/example-json-26.kt b/guide/example/example-json-26.kt
index 9e4b5857..32b2fb65 100644
--- a/guide/example/example-json-26.kt
+++ b/guide/example/example-json-26.kt
@@ -7,31 +7,53 @@ import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
-data class UnknownProject(val name: String, val details: JsonObject)
+@Serializable(with = ResponseSerializer::class)
+sealed class Response<out T> {
+ data class Ok<out T>(val data: T) : Response<T>()
+ data class Error(val message: String) : Response<Nothing>()
+}
-object UnknownProjectSerializer : KSerializer<UnknownProject> {
- override val descriptor: SerialDescriptor = buildClassSerialDescriptor("UnknownProject") {
- element<String>("name")
- element<JsonElement>("details")
+class ResponseSerializer<T>(private val dataSerializer: KSerializer<T>) : KSerializer<Response<T>> {
+ override val descriptor: SerialDescriptor = buildSerialDescriptor("Response", PolymorphicKind.SEALED) {
+ element("Ok", buildClassSerialDescriptor("Ok") {
+ element<String>("message")
+ })
+ element("Error", dataSerializer.descriptor)
}
- override fun deserialize(decoder: Decoder): UnknownProject {
- // Cast to JSON-specific interface
- val jsonInput = decoder as? JsonDecoder ?: error("Can be deserialized only by JSON")
- // Read the whole content as JSON
- val json = jsonInput.decodeJsonElement().jsonObject
- // Extract and remove name property
- val name = json.getValue("name").jsonPrimitive.content
- val details = json.toMutableMap()
- details.remove("name")
- return UnknownProject(name, JsonObject(details))
+ override fun deserialize(decoder: Decoder): Response<T> {
+ // Decoder -> JsonDecoder
+ require(decoder is JsonDecoder) // this class can be decoded only by Json
+ // JsonDecoder -> JsonElement
+ val element = decoder.decodeJsonElement()
+ // JsonElement -> value
+ if (element is JsonObject && "error" in element)
+ return Response.Error(element["error"]!!.jsonPrimitive.content)
+ return Response.Ok(decoder.json.decodeFromJsonElement(dataSerializer, element))
}
- override fun serialize(encoder: Encoder, value: UnknownProject) {
- error("Serialization is not supported")
+ override fun serialize(encoder: Encoder, value: Response<T>) {
+ // Encoder -> JsonEncoder
+ require(encoder is JsonEncoder) // This class can be encoded only by Json
+ // value -> JsonElement
+ val element = when (value) {
+ is Response.Ok -> encoder.json.encodeToJsonElement(dataSerializer, value.data)
+ is Response.Error -> buildJsonObject { put("error", value.message) }
+ }
+ // JsonElement -> JsonEncoder
+ encoder.encodeJsonElement(element)
}
}
+@Serializable
+data class Project(val name: String)
+
fun main() {
- println(Json.decodeFromString(UnknownProjectSerializer, """{"type":"unknown","name":"example","maintainer":"Unknown","license":"Apache 2.0"}"""))
+ val responses = listOf(
+ Response.Ok(Project("kotlinx.serialization")),
+ Response.Error("Not found")
+ )
+ val string = Json.encodeToString(responses)
+ println(string)
+ println(Json.decodeFromString<List<Response<Project>>>(string))
}
diff --git a/guide/example/example-json-27.kt b/guide/example/example-json-27.kt
new file mode 100644
index 00000000..219de6ef
--- /dev/null
+++ b/guide/example/example-json-27.kt
@@ -0,0 +1,37 @@
+// This file was automatically generated from json.md by Knit tool. Do not edit.
+package example.exampleJson27
+
+import kotlinx.serialization.*
+import kotlinx.serialization.json.*
+
+import kotlinx.serialization.descriptors.*
+import kotlinx.serialization.encoding.*
+
+data class UnknownProject(val name: String, val details: JsonObject)
+
+object UnknownProjectSerializer : KSerializer<UnknownProject> {
+ override val descriptor: SerialDescriptor = buildClassSerialDescriptor("UnknownProject") {
+ element<String>("name")
+ element<JsonElement>("details")
+ }
+
+ override fun deserialize(decoder: Decoder): UnknownProject {
+ // Cast to JSON-specific interface
+ val jsonInput = decoder as? JsonDecoder ?: error("Can be deserialized only by JSON")
+ // Read the whole content as JSON
+ val json = jsonInput.decodeJsonElement().jsonObject
+ // Extract and remove name property
+ val name = json.getValue("name").jsonPrimitive.content
+ val details = json.toMutableMap()
+ details.remove("name")
+ return UnknownProject(name, JsonObject(details))
+ }
+
+ override fun serialize(encoder: Encoder, value: UnknownProject) {
+ error("Serialization is not supported")
+ }
+}
+
+fun main() {
+ println(Json.decodeFromString(UnknownProjectSerializer, """{"type":"unknown","name":"example","maintainer":"Unknown","license":"Apache 2.0"}"""))
+}
diff --git a/guide/test/JsonTest.kt b/guide/test/JsonTest.kt
index 8a081f01..115ef778 100644
--- a/guide/test/JsonTest.kt
+++ b/guide/test/JsonTest.kt
@@ -90,45 +90,42 @@ class JsonTest {
@Test
fun testExampleJson12() {
captureOutput("ExampleJson12") { example.exampleJson12.main() }.verifyOutputLines(
- "{\"project_name\":\"kotlinx.serialization\",\"project_owner\":\"Kotlin\"}"
+ "CasesList(cases=[VALUE_A, VALUE_B])"
)
}
@Test
fun testExampleJson13() {
captureOutput("ExampleJson13") { example.exampleJson13.main() }.verifyOutputLines(
- "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}"
+ "{\"project_name\":\"kotlinx.serialization\",\"project_owner\":\"Kotlin\"}"
)
}
@Test
fun testExampleJson14() {
captureOutput("ExampleJson14") { example.exampleJson14.main() }.verifyOutputLines(
- "9042"
+ "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}"
)
}
@Test
fun testExampleJson15() {
captureOutput("ExampleJson15") { example.exampleJson15.main() }.verifyOutputLines(
- "{\"name\":\"kotlinx.serialization\",\"owner\":{\"name\":\"kotlin\"},\"forks\":[{\"votes\":42},{\"votes\":9000}]}"
+ "9042"
)
}
@Test
fun testExampleJson16() {
captureOutput("ExampleJson16") { example.exampleJson16.main() }.verifyOutputLines(
- "Project(name=kotlinx.serialization, language=Kotlin)"
+ "{\"name\":\"kotlinx.serialization\",\"owner\":{\"name\":\"kotlin\"},\"forks\":[{\"votes\":42},{\"votes\":9000}]}"
)
}
@Test
fun testExampleJson17() {
captureOutput("ExampleJson17") { example.exampleJson17.main() }.verifyOutputLines(
- "{",
- " \"pi_double\": 3.141592653589793,",
- " \"pi_string\": \"3.141592653589793238462643383279\"",
- "}"
+ "Project(name=kotlinx.serialization, language=Kotlin)"
)
}
@@ -136,7 +133,6 @@ class JsonTest {
fun testExampleJson18() {
captureOutput("ExampleJson18") { example.exampleJson18.main() }.verifyOutputLines(
"{",
- " \"pi_literal\": 3.141592653589793238462643383279,",
" \"pi_double\": 3.141592653589793,",
" \"pi_string\": \"3.141592653589793238462643383279\"",
"}"
@@ -146,59 +142,70 @@ class JsonTest {
@Test
fun testExampleJson19() {
captureOutput("ExampleJson19") { example.exampleJson19.main() }.verifyOutputLines(
- "3.141592653589793238462643383279"
+ "{",
+ " \"pi_literal\": 3.141592653589793238462643383279,",
+ " \"pi_double\": 3.141592653589793,",
+ " \"pi_string\": \"3.141592653589793238462643383279\"",
+ "}"
)
}
@Test
fun testExampleJson20() {
- captureOutput("ExampleJson20") { example.exampleJson20.main() }.verifyOutputLinesStart(
- "Exception in thread \"main\" kotlinx.serialization.json.internal.JsonEncodingException: Creating a literal unquoted value of 'null' is forbidden. If you want to create JSON null literal, use JsonNull object, otherwise, use JsonPrimitive"
+ captureOutput("ExampleJson20") { example.exampleJson20.main() }.verifyOutputLines(
+ "3.141592653589793238462643383279"
)
}
@Test
fun testExampleJson21() {
- captureOutput("ExampleJson21") { example.exampleJson21.main() }.verifyOutputLines(
- "Project(name=kotlinx.serialization, users=[User(name=kotlin)])",
- "Project(name=kotlinx.serialization, users=[User(name=kotlin), User(name=jetbrains)])"
+ captureOutput("ExampleJson21") { example.exampleJson21.main() }.verifyOutputLinesStart(
+ "Exception in thread \"main\" kotlinx.serialization.json.internal.JsonEncodingException: Creating a literal unquoted value of 'null' is forbidden. If you want to create JSON null literal, use JsonNull object, otherwise, use JsonPrimitive"
)
}
@Test
fun testExampleJson22() {
captureOutput("ExampleJson22") { example.exampleJson22.main() }.verifyOutputLines(
- "{\"name\":\"kotlinx.serialization\",\"users\":{\"name\":\"kotlin\"}}"
+ "Project(name=kotlinx.serialization, users=[User(name=kotlin)])",
+ "Project(name=kotlinx.serialization, users=[User(name=kotlin), User(name=jetbrains)])"
)
}
@Test
fun testExampleJson23() {
captureOutput("ExampleJson23") { example.exampleJson23.main() }.verifyOutputLines(
- "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}",
- "{\"name\":\"kotlinx.serialization\"}"
+ "{\"name\":\"kotlinx.serialization\",\"users\":{\"name\":\"kotlin\"}}"
)
}
@Test
fun testExampleJson24() {
captureOutput("ExampleJson24") { example.exampleJson24.main() }.verifyOutputLines(
- "[{\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"},{\"name\":\"example\"}]",
- "[OwnedProject(name=kotlinx.serialization, owner=kotlin), BasicProject(name=example)]"
+ "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}",
+ "{\"name\":\"kotlinx.serialization\"}"
)
}
@Test
fun testExampleJson25() {
captureOutput("ExampleJson25") { example.exampleJson25.main() }.verifyOutputLines(
- "[{\"name\":\"kotlinx.serialization\"},{\"error\":\"Not found\"}]",
- "[Ok(data=Project(name=kotlinx.serialization)), Error(message=Not found)]"
+ "[{\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"},{\"name\":\"example\"}]",
+ "[OwnedProject(name=kotlinx.serialization, owner=kotlin), BasicProject(name=example)]"
)
}
@Test
fun testExampleJson26() {
captureOutput("ExampleJson26") { example.exampleJson26.main() }.verifyOutputLines(
+ "[{\"name\":\"kotlinx.serialization\"},{\"error\":\"Not found\"}]",
+ "[Ok(data=Project(name=kotlinx.serialization)), Error(message=Not found)]"
+ )
+ }
+
+ @Test
+ fun testExampleJson27() {
+ captureOutput("ExampleJson27") { example.exampleJson27.main() }.verifyOutputLines(
"UnknownProject(name=example, details={\"type\":\"unknown\",\"maintainer\":\"Unknown\",\"license\":\"Apache 2.0\"})"
)
}
diff --git a/integration-test/gradle.properties b/integration-test/gradle.properties
index 73390ad5..749d4310 100644
--- a/integration-test/gradle.properties
+++ b/integration-test/gradle.properties
@@ -2,8 +2,8 @@
# Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#
-mainKotlinVersion=1.8.21
-mainLibVersion=1.5.2-SNAPSHOT
+mainKotlinVersion=1.9.0
+mainLibVersion=1.6.0-SNAPSHOT
kotlin.code.style=official
kotlin.js.compiler=ir
diff --git a/integration-test/kotlin-js-store/yarn.lock b/integration-test/kotlin-js-store/yarn.lock
index e236232a..08c49839 100644
--- a/integration-test/kotlin-js-store/yarn.lock
+++ b/integration-test/kotlin-js-store/yarn.lock
@@ -2,151 +2,6 @@
# yarn lockfile v1
-"@babel/code-frame@^7.10.4":
- version "7.21.4"
- resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39"
- integrity sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==
- dependencies:
- "@babel/highlight" "^7.18.6"
-
-"@babel/helper-validator-identifier@^7.18.6":
- version "7.19.1"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
- integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==
-
-"@babel/highlight@^7.18.6":
- version "7.18.6"
- resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf"
- integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==
- dependencies:
- "@babel/helper-validator-identifier" "^7.18.6"
- chalk "^2.0.0"
- js-tokens "^4.0.0"
-
-"@jridgewell/gen-mapping@^0.3.0":
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
- integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==
- dependencies:
- "@jridgewell/set-array" "^1.0.1"
- "@jridgewell/sourcemap-codec" "^1.4.10"
- "@jridgewell/trace-mapping" "^0.3.9"
-
-"@jridgewell/resolve-uri@3.1.0":
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
- integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
-
-"@jridgewell/set-array@^1.0.1":
- version "1.1.2"
- resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
- integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
-
-"@jridgewell/source-map@^0.3.2":
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.3.tgz#8108265659d4c33e72ffe14e33d6cc5eb59f2fda"
- integrity sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==
- dependencies:
- "@jridgewell/gen-mapping" "^0.3.0"
- "@jridgewell/trace-mapping" "^0.3.9"
-
-"@jridgewell/sourcemap-codec@1.4.14":
- version "1.4.14"
- resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
- integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
-
-"@jridgewell/sourcemap-codec@^1.4.10":
- version "1.4.15"
- resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
- integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
-
-"@jridgewell/trace-mapping@^0.3.9":
- version "0.3.18"
- resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6"
- integrity sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==
- dependencies:
- "@jridgewell/resolve-uri" "3.1.0"
- "@jridgewell/sourcemap-codec" "1.4.14"
-
-"@rollup/plugin-commonjs@^21.0.1":
- version "21.1.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553"
- integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- commondir "^1.0.1"
- estree-walker "^2.0.1"
- glob "^7.1.6"
- is-reference "^1.2.1"
- magic-string "^0.25.7"
- resolve "^1.17.0"
-
-"@rollup/plugin-node-resolve@^13.1.3":
- version "13.3.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz#da1c5c5ce8316cef96a2f823d111c1e4e498801c"
- integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- "@types/resolve" "1.17.1"
- deepmerge "^4.2.2"
- is-builtin-module "^3.1.0"
- is-module "^1.0.0"
- resolve "^1.19.0"
-
-"@rollup/plugin-typescript@^8.3.0":
- version "8.5.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz#7ea11599a15b0a30fa7ea69ce3b791d41b862515"
- integrity sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- resolve "^1.17.0"
-
-"@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0":
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
- integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
- dependencies:
- "@types/estree" "0.0.39"
- estree-walker "^1.0.1"
- picomatch "^2.2.2"
-
-"@types/estree@*":
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194"
- integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==
-
-"@types/estree@0.0.39":
- version "0.0.39"
- resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
- integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
-
-"@types/node@*":
- version "20.1.1"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-20.1.1.tgz#afc492e8dbe7f672dd3a13674823522b467a45ad"
- integrity sha512-uKBEevTNb+l6/aCQaKVnUModfEMjAl98lw2Si9P5y4hLu9tm6AlX2ZIoXZX6Wh9lJueYPrGPKk5WMCNHg/u6/A==
-
-"@types/node@^12.12.14":
- version "12.20.55"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
- integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
-
-"@types/resolve@1.17.1":
- version "1.17.1"
- resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
- integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==
- dependencies:
- "@types/node" "*"
-
-"@ungap/promise-all-settled@1.1.2":
- version "1.1.2"
- resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
- integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==
-
-acorn@^8.5.0:
- version "8.8.2"
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
- integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
-
ansi-colors@4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
@@ -157,13 +12,6 @@ ansi-regex@^5.0.1:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
-ansi-styles@^3.2.1:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
- integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
- dependencies:
- color-convert "^1.9.0"
-
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
@@ -184,11 +32,6 @@ argparse@^2.0.1:
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
-atob@^2.1.2:
- version "2.1.2"
- resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
- integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
-
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
@@ -231,25 +74,11 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
-builtin-modules@^3.3.0:
- version "3.3.0"
- resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
- integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==
-
camelcase@^6.0.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
-chalk@^2.0.0:
- version "2.4.2"
- resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
- integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
- dependencies:
- ansi-styles "^3.2.1"
- escape-string-regexp "^1.0.5"
- supports-color "^5.3.0"
-
chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
@@ -282,13 +111,6 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
-color-convert@^1.9.0:
- version "1.9.3"
- resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
- integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
- dependencies:
- color-name "1.1.3"
-
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
@@ -296,26 +118,11 @@ color-convert@^2.0.1:
dependencies:
color-name "~1.1.4"
-color-name@1.1.3:
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
- integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==
-
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
-commander@^2.20.0:
- version "2.20.3"
- resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
- integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
-
-commondir@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
- integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==
-
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -333,16 +140,6 @@ decamelize@^4.0.0:
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837"
integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==
-decode-uri-component@^0.2.0:
- version "0.2.2"
- resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
- integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==
-
-deepmerge@^4.2.2:
- version "4.3.1"
- resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a"
- integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==
-
diff@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
@@ -363,21 +160,6 @@ escape-string-regexp@4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
-escape-string-regexp@^1.0.5:
- version "1.0.5"
- resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
- integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==
-
-estree-walker@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
- integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==
-
-estree-walker@^2.0.1:
- version "2.0.2"
- resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
- integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
-
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
@@ -398,7 +180,7 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
-format-util@1.0.5, format-util@^1.0.5:
+format-util@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==
@@ -413,11 +195,6 @@ fsevents@~2.3.2:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
-function-bind@^1.1.1:
- version "1.1.1"
- resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
- integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
-
get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
@@ -442,35 +219,11 @@ glob@7.2.0:
once "^1.3.0"
path-is-absolute "^1.0.0"
-glob@^7.1.3, glob@^7.1.6:
- version "7.2.3"
- resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
- integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
- dependencies:
- fs.realpath "^1.0.0"
- inflight "^1.0.4"
- inherits "2"
- minimatch "^3.1.1"
- once "^1.3.0"
- path-is-absolute "^1.0.0"
-
-has-flag@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
- integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==
-
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
-has@^1.0.3:
- version "1.0.3"
- resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
- integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
- dependencies:
- function-bind "^1.1.1"
-
he@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
@@ -496,25 +249,6 @@ is-binary-path@~2.1.0:
dependencies:
binary-extensions "^2.0.0"
-is-builtin-module@^3.1.0:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169"
- integrity sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==
- dependencies:
- builtin-modules "^3.3.0"
-
-is-core-module@^2.11.0:
- version "2.12.0"
- resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.0.tgz#36ad62f6f73c8253fd6472517a12483cf03e7ec4"
- integrity sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==
- dependencies:
- has "^1.0.3"
-
-is-docker@^2.0.0:
- version "2.2.1"
- resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
- integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
-
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
@@ -532,11 +266,6 @@ is-glob@^4.0.1, is-glob@~4.0.1:
dependencies:
is-extglob "^2.1.1"
-is-module@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
- integrity sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==
-
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
@@ -547,39 +276,11 @@ is-plain-obj@^2.1.0:
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
-is-reference@^1.2.1:
- version "1.2.1"
- resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7"
- integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==
- dependencies:
- "@types/estree" "*"
-
is-unicode-supported@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
-is-wsl@^2.2.0:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
- integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
- dependencies:
- is-docker "^2.0.0"
-
-jest-worker@^26.2.1:
- version "26.6.2"
- resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
- integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==
- dependencies:
- "@types/node" "*"
- merge-stream "^2.0.0"
- supports-color "^7.0.0"
-
-js-tokens@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
- integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
-
js-yaml@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
@@ -602,18 +303,6 @@ log-symbols@4.1.0:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"
-magic-string@^0.25.7:
- version "0.25.9"
- resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
- integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
- dependencies:
- sourcemap-codec "^1.4.8"
-
-merge-stream@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
- integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
-
minimatch@5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b"
@@ -621,19 +310,18 @@ minimatch@5.0.1:
dependencies:
brace-expansion "^2.0.1"
-minimatch@^3.0.4, minimatch@^3.1.1:
+minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"
-mocha@10.0.0:
- version "10.0.0"
- resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.0.0.tgz#205447d8993ec755335c4b13deba3d3a13c4def9"
- integrity sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==
+mocha@10.2.0:
+ version "10.2.0"
+ resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8"
+ integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==
dependencies:
- "@ungap/promise-all-settled" "1.1.2"
ansi-colors "4.1.1"
browser-stdout "1.3.1"
chokidar "3.5.3"
@@ -707,12 +395,7 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
-path-parse@^1.0.7:
- version "1.0.7"
- resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
- integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
-
-picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2:
+picomatch@^2.0.4, picomatch@^2.2.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
@@ -736,47 +419,6 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
-resolve@^1.17.0, resolve@^1.19.0:
- version "1.22.2"
- resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.2.tgz#0ed0943d4e301867955766c9f3e1ae6d01c6845f"
- integrity sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==
- dependencies:
- is-core-module "^2.11.0"
- path-parse "^1.0.7"
- supports-preserve-symlinks-flag "^1.0.0"
-
-rimraf@^3.0.0:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
- integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
- dependencies:
- glob "^7.1.3"
-
-rollup-plugin-sourcemaps@^0.6.3:
- version "0.6.3"
- resolved "https://registry.yarnpkg.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed"
- integrity sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw==
- dependencies:
- "@rollup/pluginutils" "^3.0.9"
- source-map-resolve "^0.6.0"
-
-rollup-plugin-terser@^7.0.2:
- version "7.0.2"
- resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
- integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==
- dependencies:
- "@babel/code-frame" "^7.10.4"
- jest-worker "^26.2.1"
- serialize-javascript "^4.0.0"
- terser "^5.0.0"
-
-rollup@^2.68.0:
- version "2.79.1"
- resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
- integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==
- optionalDependencies:
- fsevents "~2.3.2"
-
safe-buffer@^5.1.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
@@ -789,22 +431,7 @@ serialize-javascript@6.0.0:
dependencies:
randombytes "^2.1.0"
-serialize-javascript@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa"
- integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==
- dependencies:
- randombytes "^2.1.0"
-
-source-map-resolve@^0.6.0:
- version "0.6.0"
- resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2"
- integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==
- dependencies:
- atob "^2.1.2"
- decode-uri-component "^0.2.0"
-
-source-map-support@0.5.21, source-map-support@~0.5.20:
+source-map-support@0.5.21:
version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
@@ -817,11 +444,6 @@ source-map@^0.6.0:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
-sourcemap-codec@^1.4.8:
- version "1.4.8"
- resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
- integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
-
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
@@ -850,35 +472,13 @@ supports-color@8.1.1:
dependencies:
has-flag "^4.0.0"
-supports-color@^5.3.0:
- version "5.5.0"
- resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
- integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
- dependencies:
- has-flag "^3.0.0"
-
-supports-color@^7.0.0, supports-color@^7.1.0:
+supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"
-supports-preserve-symlinks-flag@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
- integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
-
-terser@^5.0.0:
- version "5.17.3"
- resolved "https://registry.yarnpkg.com/terser/-/terser-5.17.3.tgz#7f908f16b3cdf3f6c0f8338e6c1c674837f90d25"
- integrity sha512-AudpAZKmZHkG9jueayypz4duuCFJMMNGRMwaPvQKWfxKedh8Z2x3OCoDqIIi1xx5+iwx1u6Au8XQcc9Lke65Yg==
- dependencies:
- "@jridgewell/source-map" "^0.3.2"
- acorn "^8.5.0"
- commander "^2.20.0"
- source-map-support "~0.5.20"
-
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
@@ -886,20 +486,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
-tslib@^2.3.1:
- version "2.5.0"
- resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
- integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
-
-typescript@4.7.4:
- version "4.7.4"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
- integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
-
-typescript@^3.7.2:
- version "3.9.10"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
- integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
+typescript@5.0.4:
+ version "5.0.4"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
+ integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
workerpool@6.2.1:
version "6.2.1"
diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock
index 04ba3290..2ecec42c 100644
--- a/kotlin-js-store/yarn.lock
+++ b/kotlin-js-store/yarn.lock
@@ -2,151 +2,6 @@
# yarn lockfile v1
-"@babel/code-frame@^7.10.4":
- version "7.21.4"
- resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39"
- integrity sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==
- dependencies:
- "@babel/highlight" "^7.18.6"
-
-"@babel/helper-validator-identifier@^7.18.6":
- version "7.19.1"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
- integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==
-
-"@babel/highlight@^7.18.6":
- version "7.18.6"
- resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf"
- integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==
- dependencies:
- "@babel/helper-validator-identifier" "^7.18.6"
- chalk "^2.0.0"
- js-tokens "^4.0.0"
-
-"@jridgewell/gen-mapping@^0.3.0":
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
- integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==
- dependencies:
- "@jridgewell/set-array" "^1.0.1"
- "@jridgewell/sourcemap-codec" "^1.4.10"
- "@jridgewell/trace-mapping" "^0.3.9"
-
-"@jridgewell/resolve-uri@3.1.0":
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
- integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
-
-"@jridgewell/set-array@^1.0.1":
- version "1.1.2"
- resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
- integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
-
-"@jridgewell/source-map@^0.3.2":
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.3.tgz#8108265659d4c33e72ffe14e33d6cc5eb59f2fda"
- integrity sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==
- dependencies:
- "@jridgewell/gen-mapping" "^0.3.0"
- "@jridgewell/trace-mapping" "^0.3.9"
-
-"@jridgewell/sourcemap-codec@1.4.14":
- version "1.4.14"
- resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
- integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
-
-"@jridgewell/sourcemap-codec@^1.4.10":
- version "1.4.15"
- resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
- integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
-
-"@jridgewell/trace-mapping@^0.3.9":
- version "0.3.18"
- resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6"
- integrity sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==
- dependencies:
- "@jridgewell/resolve-uri" "3.1.0"
- "@jridgewell/sourcemap-codec" "1.4.14"
-
-"@rollup/plugin-commonjs@^21.0.1":
- version "21.1.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553"
- integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- commondir "^1.0.1"
- estree-walker "^2.0.1"
- glob "^7.1.6"
- is-reference "^1.2.1"
- magic-string "^0.25.7"
- resolve "^1.17.0"
-
-"@rollup/plugin-node-resolve@^13.1.3":
- version "13.3.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz#da1c5c5ce8316cef96a2f823d111c1e4e498801c"
- integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- "@types/resolve" "1.17.1"
- deepmerge "^4.2.2"
- is-builtin-module "^3.1.0"
- is-module "^1.0.0"
- resolve "^1.19.0"
-
-"@rollup/plugin-typescript@^8.3.0":
- version "8.5.0"
- resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz#7ea11599a15b0a30fa7ea69ce3b791d41b862515"
- integrity sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==
- dependencies:
- "@rollup/pluginutils" "^3.1.0"
- resolve "^1.17.0"
-
-"@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0":
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
- integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
- dependencies:
- "@types/estree" "0.0.39"
- estree-walker "^1.0.1"
- picomatch "^2.2.2"
-
-"@types/estree@*":
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194"
- integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==
-
-"@types/estree@0.0.39":
- version "0.0.39"
- resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
- integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
-
-"@types/node@*":
- version "20.1.1"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-20.1.1.tgz#afc492e8dbe7f672dd3a13674823522b467a45ad"
- integrity sha512-uKBEevTNb+l6/aCQaKVnUModfEMjAl98lw2Si9P5y4hLu9tm6AlX2ZIoXZX6Wh9lJueYPrGPKk5WMCNHg/u6/A==
-
-"@types/node@^12.12.14":
- version "12.20.55"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
- integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
-
-"@types/resolve@1.17.1":
- version "1.17.1"
- resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
- integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==
- dependencies:
- "@types/node" "*"
-
-"@ungap/promise-all-settled@1.1.2":
- version "1.1.2"
- resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
- integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==
-
-acorn@^8.5.0:
- version "8.8.2"
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
- integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
-
ansi-colors@4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
@@ -157,13 +12,6 @@ ansi-regex@^5.0.1:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
-ansi-styles@^3.2.1:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
- integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
- dependencies:
- color-convert "^1.9.0"
-
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
@@ -184,11 +32,6 @@ argparse@^2.0.1:
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
-atob@^2.1.2:
- version "2.1.2"
- resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
- integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
-
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
@@ -231,25 +74,11 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
-builtin-modules@^3.3.0:
- version "3.3.0"
- resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
- integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==
-
camelcase@^6.0.0:
version "6.2.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.1.tgz#250fd350cfd555d0d2160b1d51510eaf8326e86e"
integrity sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==
-chalk@^2.0.0:
- version "2.4.2"
- resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
- integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
- dependencies:
- ansi-styles "^3.2.1"
- escape-string-regexp "^1.0.5"
- supports-color "^5.3.0"
-
chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
@@ -282,13 +111,6 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
-color-convert@^1.9.0:
- version "1.9.3"
- resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
- integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
- dependencies:
- color-name "1.1.3"
-
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
@@ -296,26 +118,11 @@ color-convert@^2.0.1:
dependencies:
color-name "~1.1.4"
-color-name@1.1.3:
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
- integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==
-
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
-commander@^2.20.0:
- version "2.20.3"
- resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
- integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
-
-commondir@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
- integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==
-
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -333,16 +140,6 @@ decamelize@^4.0.0:
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837"
integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==
-decode-uri-component@^0.2.0:
- version "0.2.2"
- resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
- integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==
-
-deepmerge@^4.2.2:
- version "4.3.1"
- resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a"
- integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==
-
diff@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
@@ -363,21 +160,6 @@ escape-string-regexp@4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
-escape-string-regexp@^1.0.5:
- version "1.0.5"
- resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
- integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==
-
-estree-walker@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
- integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==
-
-estree-walker@^2.0.1:
- version "2.0.2"
- resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
- integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
-
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
@@ -398,7 +180,7 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
-format-util@1.0.5, format-util@^1.0.5:
+format-util@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==
@@ -413,11 +195,6 @@ fsevents@~2.3.2:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
-function-bind@^1.1.1:
- version "1.1.1"
- resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
- integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
-
get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
@@ -442,35 +219,11 @@ glob@7.2.0:
once "^1.3.0"
path-is-absolute "^1.0.0"
-glob@^7.1.3, glob@^7.1.6:
- version "7.2.3"
- resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
- integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
- dependencies:
- fs.realpath "^1.0.0"
- inflight "^1.0.4"
- inherits "2"
- minimatch "^3.1.1"
- once "^1.3.0"
- path-is-absolute "^1.0.0"
-
-has-flag@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
- integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==
-
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
-has@^1.0.3:
- version "1.0.3"
- resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
- integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
- dependencies:
- function-bind "^1.1.1"
-
he@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
@@ -496,25 +249,6 @@ is-binary-path@~2.1.0:
dependencies:
binary-extensions "^2.0.0"
-is-builtin-module@^3.1.0:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169"
- integrity sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==
- dependencies:
- builtin-modules "^3.3.0"
-
-is-core-module@^2.11.0:
- version "2.12.0"
- resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.0.tgz#36ad62f6f73c8253fd6472517a12483cf03e7ec4"
- integrity sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==
- dependencies:
- has "^1.0.3"
-
-is-docker@^2.0.0:
- version "2.2.1"
- resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
- integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
-
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
@@ -532,11 +266,6 @@ is-glob@^4.0.1, is-glob@~4.0.1:
dependencies:
is-extglob "^2.1.1"
-is-module@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
- integrity sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==
-
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
@@ -547,39 +276,11 @@ is-plain-obj@^2.1.0:
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
-is-reference@^1.2.1:
- version "1.2.1"
- resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7"
- integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==
- dependencies:
- "@types/estree" "*"
-
is-unicode-supported@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
-is-wsl@^2.2.0:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
- integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
- dependencies:
- is-docker "^2.0.0"
-
-jest-worker@^26.2.1:
- version "26.6.2"
- resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
- integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==
- dependencies:
- "@types/node" "*"
- merge-stream "^2.0.0"
- supports-color "^7.0.0"
-
-js-tokens@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
- integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
-
js-yaml@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
@@ -602,18 +303,6 @@ log-symbols@4.1.0:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"
-magic-string@^0.25.7:
- version "0.25.9"
- resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
- integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
- dependencies:
- sourcemap-codec "^1.4.8"
-
-merge-stream@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
- integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
-
minimatch@5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b"
@@ -628,19 +317,11 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
-minimatch@^3.1.1:
- version "3.1.2"
- resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
- integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
- dependencies:
- brace-expansion "^1.1.7"
-
-mocha@10.0.0:
- version "10.0.0"
- resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.0.0.tgz#205447d8993ec755335c4b13deba3d3a13c4def9"
- integrity sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==
+mocha@10.2.0:
+ version "10.2.0"
+ resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8"
+ integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==
dependencies:
- "@ungap/promise-all-settled" "1.1.2"
ansi-colors "4.1.1"
browser-stdout "1.3.1"
chokidar "3.5.3"
@@ -714,12 +395,7 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
-path-parse@^1.0.7:
- version "1.0.7"
- resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
- integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
-
-picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2:
+picomatch@^2.0.4, picomatch@^2.2.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
@@ -743,47 +419,6 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
-resolve@^1.17.0, resolve@^1.19.0:
- version "1.22.2"
- resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.2.tgz#0ed0943d4e301867955766c9f3e1ae6d01c6845f"
- integrity sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==
- dependencies:
- is-core-module "^2.11.0"
- path-parse "^1.0.7"
- supports-preserve-symlinks-flag "^1.0.0"
-
-rimraf@^3.0.0:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
- integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
- dependencies:
- glob "^7.1.3"
-
-rollup-plugin-sourcemaps@^0.6.3:
- version "0.6.3"
- resolved "https://registry.yarnpkg.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed"
- integrity sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw==
- dependencies:
- "@rollup/pluginutils" "^3.0.9"
- source-map-resolve "^0.6.0"
-
-rollup-plugin-terser@^7.0.2:
- version "7.0.2"
- resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
- integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==
- dependencies:
- "@babel/code-frame" "^7.10.4"
- jest-worker "^26.2.1"
- serialize-javascript "^4.0.0"
- terser "^5.0.0"
-
-rollup@^2.68.0:
- version "2.79.1"
- resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
- integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==
- optionalDependencies:
- fsevents "~2.3.2"
-
safe-buffer@^5.1.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
@@ -796,22 +431,7 @@ serialize-javascript@6.0.0:
dependencies:
randombytes "^2.1.0"
-serialize-javascript@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa"
- integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==
- dependencies:
- randombytes "^2.1.0"
-
-source-map-resolve@^0.6.0:
- version "0.6.0"
- resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2"
- integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==
- dependencies:
- atob "^2.1.2"
- decode-uri-component "^0.2.0"
-
-source-map-support@0.5.21, source-map-support@~0.5.20:
+source-map-support@0.5.21:
version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
@@ -824,11 +444,6 @@ source-map@^0.6.0:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
-sourcemap-codec@^1.4.8:
- version "1.4.8"
- resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
- integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
-
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
@@ -857,35 +472,13 @@ supports-color@8.1.1:
dependencies:
has-flag "^4.0.0"
-supports-color@^5.3.0:
- version "5.5.0"
- resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
- integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
- dependencies:
- has-flag "^3.0.0"
-
-supports-color@^7.0.0, supports-color@^7.1.0:
+supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"
-supports-preserve-symlinks-flag@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
- integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
-
-terser@^5.0.0:
- version "5.17.3"
- resolved "https://registry.yarnpkg.com/terser/-/terser-5.17.3.tgz#7f908f16b3cdf3f6c0f8338e6c1c674837f90d25"
- integrity sha512-AudpAZKmZHkG9jueayypz4duuCFJMMNGRMwaPvQKWfxKedh8Z2x3OCoDqIIi1xx5+iwx1u6Au8XQcc9Lke65Yg==
- dependencies:
- "@jridgewell/source-map" "^0.3.2"
- acorn "^8.5.0"
- commander "^2.20.0"
- source-map-support "~0.5.20"
-
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
@@ -893,20 +486,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
-tslib@^2.3.1:
- version "2.5.0"
- resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
- integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
-
-typescript@4.7.4:
- version "4.7.4"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
- integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
-
-typescript@^3.7.2:
- version "3.9.10"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
- integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
+typescript@5.0.4:
+ version "5.0.4"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
+ integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
workerpool@6.2.1:
version "6.2.1"
diff --git a/settings.gradle b/settings.gradle
index 01d4ea62..ed5256ee 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -2,6 +2,10 @@
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
+plugins {
+ id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
+}
+
rootProject.name = 'kotlinx-serialization'
include ':kotlinx-serialization-core'