IntentionallyFunctionTypeAlias

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

Acknowledges that the annotated type alias deliberately exposes a bare function type.

The library-api-watchdog compiler plugin warns about publicly visible type aliases that abbreviate function types, because the alias is erased from the compiled API: users bind to the bare function shape, and the type can't grow members or constraints later without breaking them, unlike a fun interface. Apply this annotation to suppress the warning when exposing the function type is intended (for example, for lambdas that only travel through inline functions).

See the check documentation for rationale and examples.

Parameters

reason

why the alias deliberately exposes a function type.

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