Skip to content

Commit

Permalink
[Parcelize] Make sure that kotlin.uuid.Uuid uses parcelize generation…
Browse files Browse the repository at this point in the history
… and not Serializable

Merge-request: KOTLIN-MR-1340
Merged-by: Rafał Galczak <[email protected]>
  • Loading branch information
gala377 authored and Space Cloud committed Jan 29, 2025
1 parent 015f16e commit bfbfac6
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object BuiltinParcelableTypes {
"kotlin.ranges.CharRange",
"kotlin.ranges.IntRange",
"kotlin.ranges.LongRange",
"kotlin.uuid.Uuid",
)

val PARCELABLE_BASE_TYPE_FQNAMES = setOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
public final class Test$Creator : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()

public final Test createFromParcel(android.os.Parcel parcel) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkNotNullParameter, (Ljava/lang/Object;Ljava/lang/String;)V)
NEW (Test)
DUP
GETSTATIC (kotlin/uuid/Uuid, Companion, Lkotlin/uuid/Uuid$Companion;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readLong, ()J)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readLong, ()J)
INVOKEVIRTUAL (kotlin/uuid/Uuid$Companion, fromLongs, (JJ)Lkotlin/uuid/Uuid;)
INVOKESPECIAL (Test, <init>, (Lkotlin/uuid/Uuid;)V)
ARETURN
LABEL (L1)
}

public java.lang.Object createFromParcel(android.os.Parcel source) {
LABEL (L0)
ALOAD (0)
ALOAD (1)
INVOKEVIRTUAL (Test$Creator, createFromParcel, (Landroid/os/Parcel;)LTest;)
ARETURN
LABEL (L1)
}

public final Test[] newArray(int size)

public java.lang.Object[] newArray(int size)
}

public final class Test : java/lang/Object, android/os/Parcelable {
public final static android.os.Parcelable$Creator CREATOR

private final kotlin.uuid.Uuid uuidData

static void <clinit>()

public void <init>(kotlin.uuid.Uuid uuidData)

public final kotlin.uuid.Uuid component1()

public final Test copy(kotlin.uuid.Uuid uuidData)

public static Test copy$default(Test p0, kotlin.uuid.Uuid p1, int p2, java.lang.Object p3)

public final int describeContents()

public boolean equals(java.lang.Object other)

public final kotlin.uuid.Uuid getUuidData()

public int hashCode()

public java.lang.String toString()

public final void writeToParcel(android.os.Parcel dest, int flags) {
LABEL (L0)
ALOAD (1)
LDC (dest)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkNotNullParameter, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (0)
GETFIELD (Test, uuidData, Lkotlin/uuid/Uuid;)
ASTORE (3)
ALOAD (3)
INVOKEVIRTUAL (kotlin/uuid/Uuid, getMostSignificantBits, ()J)
ALOAD (3)
INVOKEVIRTUAL (kotlin/uuid/Uuid, getLeastSignificantBits, ()J)
LSTORE (4)
LSTORE (6)
LABEL (L1)
ICONST_0
ISTORE (8)
LABEL (L2)
ALOAD (1)
LLOAD (6)
INVOKEVIRTUAL (android/os/Parcel, writeLong, (J)V)
ALOAD (1)
LLOAD (4)
INVOKEVIRTUAL (android/os/Parcel, writeLong, (J)V)
LABEL (L3)
LINENUMBER (13)
RETURN
LABEL (L4)
}
}
89 changes: 89 additions & 0 deletions plugins/parcelize/parcelize-compiler/testData/codegen/uuid.asm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
public final class Test$Creator : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()

public final Test createFromParcel(android.os.Parcel parcel) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkNotNullParameter, (Ljava/lang/Object;Ljava/lang/String;)V)
NEW (Test)
DUP
GETSTATIC (kotlin/uuid/Uuid, Companion, Lkotlin/uuid/Uuid$Companion;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readLong, ()J)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readLong, ()J)
INVOKEVIRTUAL (kotlin/uuid/Uuid$Companion, fromLongs, (JJ)Lkotlin/uuid/Uuid;)
INVOKESPECIAL (Test, <init>, (Lkotlin/uuid/Uuid;)V)
ARETURN
LABEL (L1)
}

public java.lang.Object createFromParcel(android.os.Parcel source) {
LABEL (L0)
ALOAD (0)
ALOAD (1)
INVOKEVIRTUAL (Test$Creator, createFromParcel, (Landroid/os/Parcel;)LTest;)
ARETURN
LABEL (L1)
}

public final Test[] newArray(int size)

public java.lang.Object[] newArray(int size)
}

public final class Test : java/lang/Object, android/os/Parcelable {
public final static android.os.Parcelable$Creator CREATOR

private final kotlin.uuid.Uuid uuidData

static void <clinit>()

public void <init>(kotlin.uuid.Uuid uuidData)

public final kotlin.uuid.Uuid component1()

public final Test copy(kotlin.uuid.Uuid uuidData)

public static Test copy$default(Test p0, kotlin.uuid.Uuid p1, int p2, java.lang.Object p3)

public int describeContents()

public boolean equals(java.lang.Object other)

public final kotlin.uuid.Uuid getUuidData()

public int hashCode()

public java.lang.String toString()

public void writeToParcel(android.os.Parcel out, int flags) {
LABEL (L0)
ALOAD (1)
LDC (out)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkNotNullParameter, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (0)
GETFIELD (Test, uuidData, Lkotlin/uuid/Uuid;)
ASTORE (3)
ALOAD (3)
INVOKEVIRTUAL (kotlin/uuid/Uuid, getMostSignificantBits, ()J)
ALOAD (3)
INVOKEVIRTUAL (kotlin/uuid/Uuid, getLeastSignificantBits, ()J)
LSTORE (4)
LSTORE (6)
LABEL (L1)
ICONST_0
ISTORE (8)
LABEL (L2)
ALOAD (1)
LLOAD (6)
INVOKEVIRTUAL (android/os/Parcel, writeLong, (J)V)
ALOAD (1)
LLOAD (4)
INVOKEVIRTUAL (android/os/Parcel, writeLong, (J)V)
LABEL (L3)
RETURN
LABEL (L4)
}
}
13 changes: 13 additions & 0 deletions plugins/parcelize/parcelize-compiler/testData/codegen/uuid.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// CURIOUS_ABOUT: writeToParcel, createFromParcel
// WITH_STDLIB

@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)

import kotlinx.parcelize.*
import android.os.Parcelable
import kotlin.uuid.Uuid

@Parcelize
data class Test(
val uuidData: Uuid,
) : Parcelable

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bfbfac6

Please sign in to comment.