IntentionallyInlinedLogic

annotation class IntentionallyInlinedLogic(val reason: ExemptionReason = ExemptionReason.OTHER, val description: String = "")(source)

Acknowledges that the annotated inline function or the annotated property's inline accessors deliberately carry logic in their body.

The library-api-watchdog compiler plugin warns about publicly visible inline functions and inline property accessors whose body does more than delegate to a non-inline function, because the compiler copies an inline body into every user binary: logic placed there - and its bugs - stays frozen in users compiled against an old library version until they recompile. Keep public inline functions thin wrappers that resolve what only the call site knows (a reified type argument, an inlined lambda) and hand the actual work to a non-inline function, marked @PublishedApi internal when it should stay out of the public API. Apply this annotation to suppress the warning when inlining the logic is intended (for example, when a lambda must run inline for non-local returns, or when a hot path must not pay for an extra call). On a property it covers both accessors.

See the check documentation for rationale and examples.

Parameters

reason

why the logic is deliberately inlined.

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