(#) Unstable receivers will always be recomposed
!!! WARNING: Unstable receivers will always be recomposed
This is a warning.
Id
: `ComposeUnstableReceiver`
Summary
: Unstable receivers will always be recomposed
Severity
: Warning
Category
: Productivity
Platform
: Any
Vendor
: slack
Identifier
: com.slack.lint.compose:compose-lints
Feedback
: https://github.com/slackhq/compose-lints/issues
Min
: Lint 8.7+
Compiled
: Lint 8.7+
Artifact
: [com.slack.lint.compose:compose-lint-checks](com_slack_lint_compose_compose-lint-checks.md.html)
Since
: 1.3.0
Affects
: Kotlin and Java files and test sources
Editing
: This check runs on the fly in the IDE editor
Implementation
: [Source Code](https://github.com/slackhq/compose-lints/tree/main/compose-lint-checks/src/main/java/slack/lint/compose/UnstableReceiverDetector.kt)
Tests
: [Source Code](https://github.com/slackhq/compose-lints/tree/main/compose-lint-checks/src/test/java/slack/lint/compose/UnstableReceiverDetectorTest.kt)
Copyright Year
: 2023
Instance composable functions on non-stable classes will always be
recomposed. If possible, make the receiver type stable or refactor this
function if that isn't possible. See
https://slackhq.github.io/compose-lints/rules/#unstable-receivers for
more information.
(##) Example
Here is an example of lint warnings produced by this check:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
src/ExampleInterface.kt:4:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
@Composable fun Content()
-------
src/ExampleInterface.kt:8:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
@Composable fun Content() {}
-------
src/ExampleInterface.kt:12:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
fun Example.OtherContent() {}
-------
src/ExampleInterface.kt:15:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
val Example.OtherContentProperty get() {}
-------
src/ExampleInterface.kt:19:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
@Composable fun present(): T
-------
src/ExampleInterface.kt:23:Warning: Instance composable functions on
non-stable classes will always be recomposed. If possible, make the
receiver type stable or refactor this function if that isn't possible.
See https://slackhq.github.io/compose-lints/rules/#unstable-receivers
for more information. [ComposeUnstableReceiver]
@Composable override fun present(): String { return "hi" }
-------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is the source file referenced above:
`src/ExampleInterface.kt`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
import androidx.compose.runtime.Composable
interface ExampleInterface {
@Composable fun Content()
}
class Example {
@Composable fun Content() {}
}
@Composable
fun Example.OtherContent() {}
@get:Composable
val Example.OtherContentProperty get() {}
// Supertypes
interface Presenter