chRyNaN / serialization-parcelable

Android Parcelable support for the Kotlinx Serialization library.
Apache License 2.0
70 stars 3 forks source link

Decoding nullable types from Bundle #3

Closed tadfisher closed 1 year ago

tadfisher commented 1 year ago

Describe the bug

The Parcelable.decodeFromBundle() functions impose an upper bound of <T : Any> on the value type, which doesn't mirror the decodeFromByteArray and decodeFromParcel functions.

I'm optimistic that the : Any bound could simply be removed, as it's the serializer's job to encode/decode null and not-null marks.

chRyNaN commented 1 year ago

@tadfisher Thanks for bringing up this issue. It is a bit complicated because sometimes a KClass is needed in those functions which has a generic type parameter scoped to Any. However, I believe I addressed this issue in release 0.5.1 (9): https://github.com/chRyNaN/serialization-parcelable/releases/tag/0.5.1 and specifically commit: https://github.com/chRyNaN/serialization-parcelable/commit/ce2ff4c17d5ab08f34baaaae5e7dc81aa4026bd2