1 /*
2  * Copyright 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.compose.runtime
18 
19 /**
20  * The [Composable] declares that it doesn't expect a particular applier. See [ComposableTarget] for
21  * more details on what appliers a [Composable] function expects.
22  *
23  * In a [Composable] function, all the open composable appliers with the same applier index must
24  * have the same name.. [CompositionLocalProvider], for example, can use [ComposableOpenTarget] to
25  * declare that its content parameter must have the same applier as it receives, since it calls the
26  * content parameter directly, but it could be any applier. [ComposableOpenTarget], in this way,
27  * works like an open type parameter for the type of applier used by the implied composer parameter.
28  *
29  * Th [ComposableOpenTarget] is unlikely to be required explicitly as it is inferred automatically
30  * by the Compose compiler plugin. See [ComposableTarget] for more details on how attributes are
31  * inferred.
32  *
33  * @param index The index of the open applier parameter. All open appliers with the same
34  *   non-negative index in the same declaration must have the same name. All negative indexes are
35  *   considered anonymous and can match any applier. If the [index] is only used once in a
36  *   declaration it can also match any applier but it is recommended to use a negative index instead
37  *   or just leave the annotation off as a missing annotation is equivalent to an anonymous applier.
38  */
39 @Retention(AnnotationRetention.BINARY)
40 @Target(
41     AnnotationTarget.FUNCTION,
42     AnnotationTarget.PROPERTY_GETTER,
43     AnnotationTarget.TYPE,
44     AnnotationTarget.TYPE_PARAMETER,
45 )
46 annotation class ComposableOpenTarget(val index: Int)
47