https://kotlinlang.org logo
Title
z

Zoltan Demant

03/10/2023, 3:47 PM
Why are so many function return values marked as
@Stable
in compose when they are primitives? Arent they marked as stable by default already?
@Stable
fun Color.toArgb(): Int {
    return (convert(ColorSpaces.Srgb).value shr 32).toInt()
}
@Stable
is explicitly declared everywhere in the Compose public interface, for documentation and ABI stability purposes. if you're not exporting a stable binary interface, that doesn't matter to you, but it does matter to the Compose libraries themselves
z

Zoltan Demant

03/10/2023, 3:55 PM
Got it, thank you! 👍🏽
a

Albert Chang

03/11/2023, 8:04 AM
That guideline only covers stable types, which isn't the case here.
@Stable
annotation on a function has a different meaning and it is documented:
When applied to a function or a property, the
Stable
annotation indicates that the function will return the same result if the same parameters are passed in. This is only meaningful if the parameters and results are themselves
Stable
,
Immutable
, or primitive.