Presence of (transient) delegated field in the serialized class breaks deserialization (#5103)

Do not include delegated field into generated constructor even though it
might have backing field.

Test that shows issue was added. Properties that are explicitly marked
as delegated are now excluded.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2091
This commit is contained in:
AngryGami
2023-04-26 12:28:57 +02:00
committed by GitHub
parent 63a5a74613
commit bfeff81867
4 changed files with 122 additions and 1 deletions
@@ -82,7 +82,7 @@ class SerializableIrGenerator(
it is IrProperty && it.backingField != null -> {
if (it in serialDescs) {
current = it
} else if (it.backingField?.initializer != null) {
} else if (it.backingField?.initializer != null && !it.isDelegated) {
// skip transient lateinit or deferred properties (with null initializer)
val expression = initializerAdapter(it.backingField!!.initializer!!)