Support kotlinx.collections.immutable in kotlin-parcelize plugin

#KT-57685 Fixed

Co-authored-by: Ilya Gulya <ilyagulya@gmail.com>
This commit is contained in:
Ilya Gulya
2023-10-02 23:29:43 +00:00
committed by Space Team
parent e8853fd40b
commit f6b2c642c2
20 changed files with 416 additions and 54 deletions
@@ -15,6 +15,27 @@ package org.jetbrains.kotlin.parcelize
* reflection, as well as all objects, enums, and function types (since they are implicitly serializable).
*/
object BuiltinParcelableTypes {
val IMMUTABLE_LIST_FQNAMES = setOf(
kotlinxImmutable("PersistentList"),
kotlinxImmutable("ImmutableList"),
)
val IMMUTABLE_SET_FQNAMES = setOf(
kotlinxImmutable("PersistentSet"),
kotlinxImmutable("ImmutableSet"),
)
val IMMUTABLE_MAP_FQNAMES = setOf(
kotlinxImmutable("PersistentMap"),
kotlinxImmutable("ImmutableMap"),
)
val IMMUTABLE_COLLECTIONS_FQNAMES = setOf(
*IMMUTABLE_LIST_FQNAMES.toTypedArray(),
*IMMUTABLE_SET_FQNAMES.toTypedArray(),
*IMMUTABLE_MAP_FQNAMES.toTypedArray()
)
val PARCELABLE_SUPERTYPE_FQNAMES = setOf(
"android.os.Parcelable",
"android.os.IBinder",
@@ -97,5 +118,6 @@ object BuiltinParcelableTypes {
"kotlin.collections.MutableMap",
"kotlin.collections.MutableSet",
"kotlin.collections.Set",
*IMMUTABLE_COLLECTIONS_FQNAMES.toTypedArray(),
)
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.parcelize
/**
* Required because :kotlin-compiler-embeddable performs package relocation
* If there's a "kotlinx.collections.immutable" string literal in bytecode
* it becomes "org.jetbrains.kotlin.kotlinx.collections.immutable" thus
* breaking target project class name matching
*/
fun kotlinxImmutable(name: String? = null): String {
return listOfNotNull("kotlinx", "collections", "immutable", name).joinToString(".")
}