AssumeOptInAlsoOptsInTo
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
}
Content copied to clipboard
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
Content copied to clipboard