blob: f84d7b97974a66b0594fa04944585729400ac60f [file] [log] [blame]
Clara Fok93e18122024-04-23 10:28:10 -07001# Keep `Companion` object fields of serializable classes.
2# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
3-if @kotlinx.serialization.Serializable class **
4-keepclassmembers class <1> {
5 static <1>$Companion Companion;
6}
7
8# Keep `serializer()` on companion objects (both default and named) of serializable classes.
9-if @kotlinx.serialization.Serializable class ** {
10 static **$* *;
11}
12-keepclassmembers class <2>$<3> {
13 kotlinx.serialization.KSerializer serializer(...);
14}
15
16# Keep `INSTANCE.serializer()` of serializable objects.
17-if @kotlinx.serialization.Serializable class ** {
18 public static ** INSTANCE;
19}
20-keepclassmembers class <1> {
21 public static <1> INSTANCE;
22 kotlinx.serialization.KSerializer serializer(...);
23}
24
25# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
26-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
27
28# Don't print notes about potential mistakes or omissions in the configuration for kotlinx-serialization classes
29# See also https://github.com/Kotlin/kotlinx.serialization/issues/1900
30-dontnote kotlinx.serialization.**
31
32# Serialization core uses `java.lang.ClassValue` for caching inside these specified classes.
33# If there is no `java.lang.ClassValue` (for example, in Android), then R8/ProGuard will print a warning.
34# However, since in this case they will not be used, we can disable these warnings
35-dontwarn kotlinx.serialization.internal.ClassValueReferences