1 /*
2  * Copyright 2025 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.annotation
18 
19 /**
20  * RememberInComposition is used by an associated lint check to enforce that a marked constructor,
21  * function, or property getter is not called directly within composition. This should be used to
22  * mark APIs that:
23  * - Return stateful / mutable objects that should be reused across compositions
24  * - Return objects whose identity is important to maintain across compositions, for example
25  *   lightweight objects used as 'keys' for other APIs
26  * - Return objects that are expensive to instantiate, and should be remembered for performance
27  *   reasons
28  *
29  * Note that the lint check will recommend that users either remember this call, or move it outside
30  * composition. As a result this should not be used to mark APIs that are intended to be used inside
31  * a side effect, as these should not be called inside a remember block.
32  */
33 @MustBeDocumented
34 @Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER)
35 @Retention(AnnotationRetention.BINARY)
36 public annotation class RememberInComposition
37