Sylvain Patenaude
10/27/2021, 9:08 PM@SharedImmutable is applicable only to top level declarations
and also this one in enums:
@SharedImmutable is applicable only to val with backing field or to property with delegation
Example of data class:
data class SomeDataClass(
@SharedImmutable val someInt: Int,
@SharedImmutable val someString: String,
@SharedImmutable val someBool: Boolean
)
Example of enum class:
enum class SomeEnumClass(
/** The [Int] representation of this enum value. */
@SharedImmutable val value: Int
) {
@SharedImmutable ValueA(0),
@SharedImmutable ValueB(1);
companion object {
internal fun fromInt(value: Int) = values().firstOrNull() { it.value == value } ?: ValueA
}
}
Thread in Slack Conversation