W3cubDocs

/Kotlin

RequiresOptIn

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class RequiresOptIn

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.

Types

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

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.

enum class Level

Constructors

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

<init>

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

RequiresOptIn(
    message: String = "", 
    level: Level = Level.ERROR)

Properties

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

level

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

val level: Level
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

message

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.

val message: String

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-requires-opt-in/index.html