Unconditional

Marker for methods whose identity is their call order, so callers must not vary that order.

Two rules, both enforced by KComponentUnconditionalMisuseDetector:

  • They must be called unconditionally: not inside if, when, for, while or forEach.

  • They may only be called from another @Unconditional method, which is what keeps the first rule from being escaped one frame up.

ComponentScope.diffOf is the case this exists for. It appends to a per-render list and reads the previous render's value back by that position, so a call that runs on some renders and not others silently pairs a value with the wrong predecessor.

Hooks used to work this way and no longer do: the compiler plugin gives each hook call site a structural identity, so Hook does not carry this annotation and hooks may be called conditionally. Do not reach for @Unconditional on anything hook-shaped.