2ae2f09fee
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
27 lines
663 B
Kotlin
Vendored
27 lines
663 B
Kotlin
Vendored
// WITH_STDLIB
|
|
|
|
import kotlinx.serialization.*
|
|
import kotlinx.serialization.json.*
|
|
|
|
@Serializable
|
|
class SomeClass(val ctor: Int) {
|
|
var body: String = ""
|
|
|
|
// Not serializable: no backing field
|
|
val getter: Int get() = 42
|
|
}
|
|
|
|
fun test(targetString: String): String {
|
|
val c = SomeClass(1).apply { body = "x" }
|
|
val s = Json.encodeToString(SomeClass.serializer(), c)
|
|
if (s != targetString) return s
|
|
val i = Json.decodeFromString(SomeClass.serializer(), s)
|
|
if (i.ctor != c.ctor) return "Incorrect ctor"
|
|
if (i.body != c.body) return "Incorrect body"
|
|
return "OK"
|
|
}
|
|
|
|
fun box(): String {
|
|
return test("""{"ctor":1,"body":"x"}""")
|
|
}
|