andylamax
10/31/2021, 7:40 AMobject Test {
@get:Composable
val primary: Color get() = TODO()
}
and
object Test {
val primary: Color
@Composeable
get() = TODO()
}
Compose seem to be happy with the later and not with former. I though these where same. Anyone?knthmn
10/31/2021, 9:48 AM@Composable
, it is only applicable on
AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY_GETTER
andylamax
10/31/2021, 10:12 AMknthmn
11/01/2021, 7:43 AM@Target(AnnotationTarget.FIELD)
annotation class FieldAnnotation
@Target(AnnotationTarget.PROPERTY_GETTER)
annotation class GetterAnnotation
@Target(AnnotationTarget.PROPERTY)
annotation class PropertyAnnotation
class Test {
@FieldAnnotation val x1 = 0
val x2 @FieldAnnotation get() = 0 // compilation error
@GetterAnnotation val x3 = 0 // compilation error
val x4 @GetterAnnotation get() = 0
@PropertyAnnotation val x5 = 0
val x6 @PropertyAnnotation get() = 0 // compilation error
}
andylamax
11/01/2021, 8:30 AMobject Test {
@get:Composable // Has @get:
val primary: Color get() = TODO()
}
with
object Test {
@Composable // No @get:
val primary: Color get() = TODO()
}
The later indeed applies to the backing field. What does the former do?@Target(AnnotationTarget.FIELD)
annotation class FieldAnnotation
@Target(AnnotationTarget.PROPERTY_GETTER)
annotation class GetterAnnotation
@Target(AnnotationTarget.PROPERTY)
annotation class PropertyAnnotation
class Test {
@get:GetterAnnotation val x3 = 0 // Getter annotation, applied on field with a 'get' directive
val x4 get() = 0
}
knthmn
11/01/2021, 3:20 PMandylamax
11/01/2021, 6:37 PMRein T
11/09/2021, 9:35 AM@get:
annotates a java getter.
can it be that Compose scans kotlin code?andylamax
11/10/2021, 3:56 AM@get:
annotates the java getter, what does
val p @Annotation get() = ...
annotate??Rein T
11/10/2021, 10:26 AM@get:Size
to a get()
in one of my project and it works just as good.
What I was thinking is that your problem is linked to how Composable scans the kotlin code and not applicable to @AnyAnnotation
andylamax
11/10/2021, 9:31 PMRein T
11/11/2021, 8:32 AM