RequiresOptIn

annotation class RequiresOptIn(message: String, level: RequiresOptIn.Level)

Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in.

Call sites of any declaration annotated with that marker should opt in to the API either by using OptIn, or by being annotated with that marker themselves, effectively causing further propagation of the opt-in requirement.

This class requires opt-in itself and can only be used with the compiler argument -Xopt-in=kotlin.RequiresOptIn.

Since Kotlin

1.3

Constructors

RequiresOptIn
Link copied to clipboard
fun RequiresOptIn(message: String = "", level: RequiresOptIn.Level = Level.ERROR)

Types

Level
Link copied to clipboard
enum Level : Enum<RequiresOptIn.Level>

Severity of the diagnostic that should be reported on usages which did not explicitly opted into the API either by using OptIn or by being annotated with the corresponding marker annotation.

Properties

level
Link copied to clipboard
val level: RequiresOptIn.Level

specifies how usages of API without an explicit opt-in are reported in code.

message
Link copied to clipboard
val message: String

message to be reported on usages of API without an explicit opt-in, or empty string for the default message. The default message is: "This declaration is experimental and its usage should be marked with 'Marker' or '@OptIn(Marker::class)'", where Marker is the opt-in requirement marker.