AssumeOptInAlsoOptsInTo

annotation class AssumeOptInAlsoOptsInTo(val tagAnnotations: KClass<out Annotation>)

Indicates that a RequiresOptIn annotation assumes all usages of the API marked with the annotation, also opt in all RequiresOptIn annotations that are tagged with the tagAnnotations.

This annotation is used to relax checks when an experimental API is used in an IVI internal annotated class. For example:

@ExperimentalApi
class ExperimentalClass

@InternalApi
class InternalClass {
val foo: ExperimentalClass
}

The above example would normally require InternalClass to be annotated with ExperimentalApi, however with the use of AssumeOptInAlsoOptsInTo, we can relax that check. For this we need to define a tag annotation which is annotated with AnnotationReferenceTag, and annotate ExperimentalApi with this tag annotation. Next we need to annotate InternalApi with AssumeOptInAlsoOptsInTo and reference the tag annotation in tagAnnotations:

@AnnotationReferenceTag
annotation class ExperimentalApiTag

@RequiresOptIn
@ExperimentalApiTag
annotation class ExperimentalApi

@RequiresOptIn
@AssumeOptInAlsoOptsInTo(ExperimentalApiTag::class)
annotation class InternalApi

Constructors

Link copied to clipboard
fun AssumeOptInAlsoOptsInTo(vararg tagAnnotations: KClass<out Annotation>)

Properties

Link copied to clipboard
val tagAnnotations: Array<out KClass<out Annotation>>