Files
kotlin-fork/plugins/kotlinx-serialization/testData/firMembers/classWithGenericParameters.kt
T
Sergey.Shanshin 2ae2f09fee [FIR] Fixed phase for FirCompanionGenerationProcessor to COMPANION_GENERATION
Phase COMPILER_REQUIRED_ANNOTATIONS causes errors in the kotlinx serialization tests:

org.jetbrains.kotlin.fir.symbols.FirLazyResolveContractViolationException: `lazyResolveToPhase(COMPILER_REQUIRED_ANNOTATIONS)` cannot be called from a transformer with a phase COMPILER_REQUIRED_ANNOTATIONS.
`lazyResolveToPhase` can be called only from a transformer with a phase which is strictly greater than a requested phase;
 i.e., `lazyResolveToPhase(A)` may be only called from a lazy transformer with a phase B, where A < B. This is a contract of lazy resolve
2024-02-12 15:54:11 +00:00

24 lines
693 B
Kotlin
Vendored

// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.builtins.*
@Serializable
class GenericBox<T, V>(
val i: Int,
val t: T,
val vs: List<V>
)
fun box(): String {
val box = GenericBox(42, "foo", listOf(true, false))
val serial = GenericBox.serializer(String.serializer(), Boolean.serializer())
val target = """{"i":42,"t":"foo","vs":[true,false]}"""
val s = Json.encodeToString(serial, box)
if (target != s) return "Incorrect serialization: $s"
val decoded = Json.decodeFromString(serial, s)
if (box.t != decoded.t || box.vs != decoded.vs) return "Incorrect deserialization"
return "OK"
}