Skip to content

Commit 1b0accd

Browse files
authored
Fixed keeping INSTANCE field and serializer function for serializable objects in R8 full mode (Kotlin#2865)
Details https://issuetracker.google.com/issues/379996140 Fixes Kotlin#2861
1 parent 1758faa commit 1b0accd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

rules/r8.pro

+13
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,16 @@
1010

1111
-if @kotlinx.serialization.Serializable class **
1212
-keep, allowshrinking, allowoptimization, allowobfuscation, allowaccessmodification class <1>
13+
14+
15+
# Rule to save INSTANCE field and serializer function for Kotlin serializable objects.
16+
#
17+
# R8 full mode works differently if the instance is not explicitly accessed in the code.
18+
#
19+
# see https://github.com/Kotlin/kotlinx.serialization/issues/2861
20+
# see https://issuetracker.google.com/issues/379996140
21+
22+
-keepclassmembers @kotlinx.serialization.Serializable class ** {
23+
public static ** INSTANCE;
24+
kotlinx.serialization.KSerializer serializer(...);
25+
}

0 commit comments

Comments
 (0)