The variable is instanciated through by rememberSaveable() (note that it does the same through remember(). Restoring its state IS important, as it affects the state that it will have after recomposition.
I think that it is easy to reproduce without my entire repos, but if you want there is a test that fails if I remove this assignation: TestAuthentication#testKeepSessionDialogNotReopens()
Thank you for this feedback about rule S6615.
My first intuition is that the rule is raising correctly. It’s true that changing the value of a local delegated property such as canShowSignedInDialog may trigger side effects. Currently the rule does not take these side effects into account.
The variable is instanciated through by rememberSaveable() (note that it does the same through remember() . Restoring its state IS important, as it affects the state that it will have after recomposition.
Assigning false to the local property will also trigger a recomposition. In that sense, the following pattern seems fragile:
var canShowStaySignedInDialog by rememberSaveable { mutableStateOf(false) }
//...
if (canShowStaySignedInDialog) {
canShowStaySignedInDialog = false
}
I might have been too fast in my judgement. The bug I’m referencing is related to the non-inline lambda scope and now I realized you don’t use lambda, so I agree with what @Pierre-Loup_Tristant answered here.
So, in your case the issue will still be reported in 2.3.
However, while we can discuss what is the best practice in Compose in your case, what is not, I don’t think such issue should be raised here as technically “assigned value is used”.
Since, the root cause seems to be in the compiler diagnostics. You can double-check the behavior by enabling extended diagnostics and report this issue to the Kotlin maintainers (https://youtrack.jetbrains.com/projects/KT). I think they’ll be the best people to judge whether this is a bug or the intended behavior due to this comment from the Kotlin issue tracker: