I upgraded to kotlin 1.5.31 in the last few days a...
# multiplatform
s
I upgraded to kotlin 1.5.31 in the last few days and I'm getting this error when compiling in iOS:
Copy code
@SharedImmutable is applicable only to top level declarations
and also this one in enums:
Copy code
@SharedImmutable is applicable only to val with backing field or to property with delegation
Example of data class:
Copy code
data class SomeDataClass(
    @SharedImmutable val someInt: Int,
    @SharedImmutable val someString: String,
    @SharedImmutable val someBool: Boolean
)
Example of enum class:
Copy code
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