IntentionallyMutableCollection

Acknowledges that the annotated declaration deliberately exposes a mutable collection type in the public API.

The library-api-watchdog compiler plugin warns about public signatures - return types, property types, and parameter types, including their type arguments - that mention mutable collection types (MutableList, MutableMap, ..., their implementations, and arrays, which are mutable collections too), as well as mutable bounds on type parameters. Sharing a mutable collection across the API boundary makes it unclear whether user-side and library-side mutations affect each other. Apply this annotation to suppress the warning when sharing the mutable collection is an intended part of the API contract. On a function, a property, or a constructor it covers the whole signature. On a single parameter or type parameter it covers just that parameter. On a type usage (List<@IntentionallyMutableCollection MutableList<Int>>) it covers the annotated type and everything nested in it.

See the check documentation for rationale and examples.

Parameters

reason

why the declaration deliberately exposes a mutable collection.

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