IntentionallyExhaustive

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class IntentionallyExhaustive(val reason: ExemptionReason = ExemptionReason.OTHER, val description: String = "")(source)

Acknowledges that the annotated enum or sealed hierarchy is deliberately exhaustive.

The library-api-watchdog compiler plugin warns about publicly visible enums and sealed hierarchies, because users can match on them exhaustively (when without an else branch), which turns adding an entry or a subtype into a breaking change. Apply this annotation to suppress the warning when the set of entries/subtypes is an intended, stable part of the API contract.

See the check documentation for rationale and examples.

Parameters

reason

why the hierarchy is deliberately exhaustive.

description

free-form explanation of the exemption. May be empty only when reason explains the exemption on its own (ExemptionReason.FOR_BACKWARDS_COMPATIBILITY, ExemptionReason.API_DESIGN).

Properties

Link copied to clipboard
Link copied to clipboard