Parcelable: Handle nullability in Parcelize Parcelable serializer (KT-20032)
This commit is contained in:
committed by
Yan Zhulanow
parent
88138fc420
commit
a03c03c427
+1
-1
@@ -183,7 +183,7 @@ interface ParcelSerializer {
|
||||
else -> null
|
||||
}
|
||||
|
||||
creatorAsmType?.let { EfficientParcelableParcelSerializer(asmType, creatorAsmType) }
|
||||
creatorAsmType?.let { wrapToNullAwareIfNeeded(type, EfficientParcelableParcelSerializer(asmType, creatorAsmType)) }
|
||||
?: GenericParcelableParcelSerializer(asmType, context.containerClassType)
|
||||
}
|
||||
else {
|
||||
|
||||
Vendored
+7
-3
@@ -7,17 +7,21 @@ import kotlinx.android.parcel.*
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class Foo(val a: String) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class Test(
|
||||
val str1: String,
|
||||
val str2: String?,
|
||||
val int1: Int,
|
||||
val int2: Int?
|
||||
val int2: Int?,
|
||||
val foo: Foo?
|
||||
) : Parcelable
|
||||
|
||||
fun box() = parcelTest { parcel ->
|
||||
val first = Test("John", "Smith", 20, 30)
|
||||
val second = Test("A", null, 20, null)
|
||||
val first = Test("John", "Smith", 20, 30, Foo("a"))
|
||||
val second = Test("A", null, 20, null, null)
|
||||
|
||||
first.writeToParcel(parcel, 0)
|
||||
second.writeToParcel(parcel, 0)
|
||||
|
||||
Reference in New Issue
Block a user