If I have an inline (now `value`) class, can I mar...
# compose
d
If I have an inline (now
value
) class, can I mark it as
@Immutable
? Will this property transfer to the wrapped class and be understood accordingly by the Compose runtime later on?
j
I could be mistaken, but I think we already/automatically treat value classes as immutable. Maybe only if the underlying value type is immutable though. While it is strongly desirable for `@Immutable`objects to only reference other `@Immutable`classes, there is no such restriction currently enforced, so the property will not be applied transitively.
d
yeah, I mean that if I know that my collection will be treated as immutable here, could I go from this
Copy code
@Immutable
data class UserList(val users: Map<UserId, User>)
to this
Copy code
@Immutable
value class UserList(val users: Map<UserId, User>)
? (or substitute Map for any effectively immutable custom
data class
which I know won't be mutated, only copy-ed)