How is this data class inferred as unstable? Which...
# compose
k
How is this data class inferred as unstable? Which contract it doesn't comply with?
Copy code
data class User(val id: Int) {
    private var name = "a"
}

unstable class User {
  stable val id: Int
  stable var name: String
  <runtime stability> = Unstable
}
l
can't have vars in the class
k
It's a private var though, based on the contract, only the public properties are considered. And in this case the equals will forever be the same because the constructor property is a val
• The result of
equals
for two instances will forever be the same for the same two instances.
• If a public property of the type changes, Composition will be notified.
• All public property types are also stable.
z
You can file a bug, but I think the inference is kind of meant to be “best effort”, to cover most common cases that are easy to prove correct. I’m guessing it doesn’t catch this because it would have to do a lot more complicated analysis to prove that your private var is never read by any public properties or methods.